xref: /aosp_15_r20/external/webrtc/media/base/rid_description.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright 2018 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker  *
4*d9f75844SAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker  */
10*d9f75844SAndroid Build Coastguard Worker 
11*d9f75844SAndroid Build Coastguard Worker #ifndef MEDIA_BASE_RID_DESCRIPTION_H_
12*d9f75844SAndroid Build Coastguard Worker #define MEDIA_BASE_RID_DESCRIPTION_H_
13*d9f75844SAndroid Build Coastguard Worker 
14*d9f75844SAndroid Build Coastguard Worker #include <map>
15*d9f75844SAndroid Build Coastguard Worker #include <string>
16*d9f75844SAndroid Build Coastguard Worker #include <vector>
17*d9f75844SAndroid Build Coastguard Worker 
18*d9f75844SAndroid Build Coastguard Worker namespace cricket {
19*d9f75844SAndroid Build Coastguard Worker 
20*d9f75844SAndroid Build Coastguard Worker enum class RidDirection { kSend, kReceive };
21*d9f75844SAndroid Build Coastguard Worker 
22*d9f75844SAndroid Build Coastguard Worker // Description of a Restriction Id (RID) according to:
23*d9f75844SAndroid Build Coastguard Worker // https://tools.ietf.org/html/draft-ietf-mmusic-rid-15
24*d9f75844SAndroid Build Coastguard Worker // A Restriction Identifier serves two purposes:
25*d9f75844SAndroid Build Coastguard Worker //   1. Uniquely identifies an RTP stream inside an RTP session.
26*d9f75844SAndroid Build Coastguard Worker //      When combined with MIDs (https://tools.ietf.org/html/rfc5888),
27*d9f75844SAndroid Build Coastguard Worker //      RIDs uniquely identify an RTP stream within an RTP session.
28*d9f75844SAndroid Build Coastguard Worker //      The MID will identify the media section and the RID will identify
29*d9f75844SAndroid Build Coastguard Worker //      the stream within the section.
30*d9f75844SAndroid Build Coastguard Worker //      RID identifiers must be unique within the media section.
31*d9f75844SAndroid Build Coastguard Worker //   2. Allows indicating further restrictions to the stream.
32*d9f75844SAndroid Build Coastguard Worker //      These restrictions are added according to the direction specified.
33*d9f75844SAndroid Build Coastguard Worker //      The direction field identifies the direction of the RTP stream packets
34*d9f75844SAndroid Build Coastguard Worker //      to which the restrictions apply. The direction is independent of the
35*d9f75844SAndroid Build Coastguard Worker //      transceiver direction and can be one of {send, recv}.
36*d9f75844SAndroid Build Coastguard Worker //      The following are some examples of these restrictions:
37*d9f75844SAndroid Build Coastguard Worker //        a. max-width, max-height, max-fps, max-br, ...
38*d9f75844SAndroid Build Coastguard Worker //        b. further restricting the codec set (from what m= section specified)
39*d9f75844SAndroid Build Coastguard Worker //
40*d9f75844SAndroid Build Coastguard Worker // Note: Indicating dependencies between streams (using depend) will not be
41*d9f75844SAndroid Build Coastguard Worker // supported, since the WG is adopting a different approach to achieve this.
42*d9f75844SAndroid Build Coastguard Worker // As of 2018-12-04, the new SVC (Scalable Video Coder) approach is still not
43*d9f75844SAndroid Build Coastguard Worker // mature enough to be implemented as part of this work.
44*d9f75844SAndroid Build Coastguard Worker // See: https://w3c.github.io/webrtc-svc/ for more details.
45*d9f75844SAndroid Build Coastguard Worker struct RidDescription final {
46*d9f75844SAndroid Build Coastguard Worker   RidDescription();
47*d9f75844SAndroid Build Coastguard Worker   RidDescription(const std::string& rid, RidDirection direction);
48*d9f75844SAndroid Build Coastguard Worker   RidDescription(const RidDescription& other);
49*d9f75844SAndroid Build Coastguard Worker   ~RidDescription();
50*d9f75844SAndroid Build Coastguard Worker   RidDescription& operator=(const RidDescription& other);
51*d9f75844SAndroid Build Coastguard Worker 
52*d9f75844SAndroid Build Coastguard Worker   // This is currently required for unit tests of StreamParams which contains
53*d9f75844SAndroid Build Coastguard Worker   // RidDescription objects and checks for equality using operator==.
54*d9f75844SAndroid Build Coastguard Worker   bool operator==(const RidDescription& other) const;
55*d9f75844SAndroid Build Coastguard Worker   bool operator!=(const RidDescription& other) const {
56*d9f75844SAndroid Build Coastguard Worker     return !(*this == other);
57*d9f75844SAndroid Build Coastguard Worker   }
58*d9f75844SAndroid Build Coastguard Worker 
59*d9f75844SAndroid Build Coastguard Worker   // The RID identifier that uniquely identifies the stream within the session.
60*d9f75844SAndroid Build Coastguard Worker   std::string rid;
61*d9f75844SAndroid Build Coastguard Worker 
62*d9f75844SAndroid Build Coastguard Worker   // Specifies the direction for which the specified restrictions hold.
63*d9f75844SAndroid Build Coastguard Worker   // This direction is either send or receive and is independent of the
64*d9f75844SAndroid Build Coastguard Worker   // direction of the transceiver.
65*d9f75844SAndroid Build Coastguard Worker   // https://tools.ietf.org/html/draft-ietf-mmusic-rid-15#section-4 :
66*d9f75844SAndroid Build Coastguard Worker   // The "direction" field identifies the direction of the RTP Stream
67*d9f75844SAndroid Build Coastguard Worker   // packets to which the indicated restrictions are applied.  It may be
68*d9f75844SAndroid Build Coastguard Worker   // either "send" or "recv".  Note that these restriction directions are
69*d9f75844SAndroid Build Coastguard Worker   // expressed independently of any "inactive", "sendonly", "recvonly", or
70*d9f75844SAndroid Build Coastguard Worker   // "sendrecv" attributes associated with the media section.  It is, for
71*d9f75844SAndroid Build Coastguard Worker   // example, valid to indicate "recv" restrictions on a "sendonly"
72*d9f75844SAndroid Build Coastguard Worker   // stream; those restrictions would apply if, at a future point in time,
73*d9f75844SAndroid Build Coastguard Worker   // the stream were changed to "sendrecv" or "recvonly".
74*d9f75844SAndroid Build Coastguard Worker   RidDirection direction;
75*d9f75844SAndroid Build Coastguard Worker 
76*d9f75844SAndroid Build Coastguard Worker   // The list of codec payload types for this stream.
77*d9f75844SAndroid Build Coastguard Worker   // It should be a subset of the payloads supported for the media section.
78*d9f75844SAndroid Build Coastguard Worker   std::vector<int> payload_types;
79*d9f75844SAndroid Build Coastguard Worker 
80*d9f75844SAndroid Build Coastguard Worker   // Contains key-value pairs for restrictions.
81*d9f75844SAndroid Build Coastguard Worker   // The keys are not validated against a known set.
82*d9f75844SAndroid Build Coastguard Worker   // The meaning to infer for the values depends on each key.
83*d9f75844SAndroid Build Coastguard Worker   // Examples:
84*d9f75844SAndroid Build Coastguard Worker   // 1. An entry for max-width will have a value that is interpreted as an int.
85*d9f75844SAndroid Build Coastguard Worker   // 2. An entry for max-bpp (bits per pixel) will have a float value.
86*d9f75844SAndroid Build Coastguard Worker   // Interpretation (and validation of value) is left for the implementation.
87*d9f75844SAndroid Build Coastguard Worker   // I.E. the media engines should validate values for parameters they support.
88*d9f75844SAndroid Build Coastguard Worker   std::map<std::string, std::string> restrictions;
89*d9f75844SAndroid Build Coastguard Worker };
90*d9f75844SAndroid Build Coastguard Worker 
91*d9f75844SAndroid Build Coastguard Worker }  // namespace cricket
92*d9f75844SAndroid Build Coastguard Worker 
93*d9f75844SAndroid Build Coastguard Worker #endif  // MEDIA_BASE_RID_DESCRIPTION_H_
94