session_description.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /*
  2. * Copyright 2004 The WebRTC Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef PC_SESSION_DESCRIPTION_H_
  11. #define PC_SESSION_DESCRIPTION_H_
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include <iosfwd>
  15. #include <memory>
  16. #include <string>
  17. #include <utility>
  18. #include <vector>
  19. #include "absl/memory/memory.h"
  20. #include "api/crypto_params.h"
  21. #include "api/media_types.h"
  22. #include "api/rtp_parameters.h"
  23. #include "api/rtp_transceiver_interface.h"
  24. #include "media/base/media_channel.h"
  25. #include "media/base/stream_params.h"
  26. #include "p2p/base/transport_description.h"
  27. #include "p2p/base/transport_info.h"
  28. #include "pc/media_protocol_names.h"
  29. #include "pc/simulcast_description.h"
  30. #include "rtc_base/deprecation.h"
  31. #include "rtc_base/socket_address.h"
  32. #include "rtc_base/system/rtc_export.h"
  33. namespace cricket {
  34. typedef std::vector<AudioCodec> AudioCodecs;
  35. typedef std::vector<VideoCodec> VideoCodecs;
  36. typedef std::vector<RtpDataCodec> RtpDataCodecs;
  37. typedef std::vector<CryptoParams> CryptoParamsVec;
  38. typedef std::vector<webrtc::RtpExtension> RtpHeaderExtensions;
  39. // RTC4585 RTP/AVPF
  40. extern const char kMediaProtocolAvpf[];
  41. // RFC5124 RTP/SAVPF
  42. extern const char kMediaProtocolSavpf[];
  43. extern const char kMediaProtocolDtlsSavpf[];
  44. // Options to control how session descriptions are generated.
  45. const int kAutoBandwidth = -1;
  46. class AudioContentDescription;
  47. class VideoContentDescription;
  48. class RtpDataContentDescription;
  49. class SctpDataContentDescription;
  50. // Describes a session description media section. There are subclasses for each
  51. // media type (audio, video, data) that will have additional information.
  52. class MediaContentDescription {
  53. public:
  54. MediaContentDescription() = default;
  55. virtual ~MediaContentDescription() = default;
  56. virtual MediaType type() const = 0;
  57. // Try to cast this media description to an AudioContentDescription. Returns
  58. // nullptr if the cast fails.
  59. virtual AudioContentDescription* as_audio() { return nullptr; }
  60. virtual const AudioContentDescription* as_audio() const { return nullptr; }
  61. // Try to cast this media description to a VideoContentDescription. Returns
  62. // nullptr if the cast fails.
  63. virtual VideoContentDescription* as_video() { return nullptr; }
  64. virtual const VideoContentDescription* as_video() const { return nullptr; }
  65. virtual RtpDataContentDescription* as_rtp_data() { return nullptr; }
  66. virtual const RtpDataContentDescription* as_rtp_data() const {
  67. return nullptr;
  68. }
  69. virtual SctpDataContentDescription* as_sctp() { return nullptr; }
  70. virtual const SctpDataContentDescription* as_sctp() const { return nullptr; }
  71. virtual bool has_codecs() const = 0;
  72. // Copy operator that returns an unique_ptr.
  73. // Not a virtual function.
  74. // If a type-specific variant of Clone() is desired, override it, or
  75. // simply use std::make_unique<typename>(*this) instead of Clone().
  76. std::unique_ptr<MediaContentDescription> Clone() const {
  77. return absl::WrapUnique(CloneInternal());
  78. }
  79. // |protocol| is the expected media transport protocol, such as RTP/AVPF,
  80. // RTP/SAVPF or SCTP/DTLS.
  81. virtual std::string protocol() const { return protocol_; }
  82. virtual void set_protocol(const std::string& protocol) {
  83. protocol_ = protocol;
  84. }
  85. virtual webrtc::RtpTransceiverDirection direction() const {
  86. return direction_;
  87. }
  88. virtual void set_direction(webrtc::RtpTransceiverDirection direction) {
  89. direction_ = direction;
  90. }
  91. virtual bool rtcp_mux() const { return rtcp_mux_; }
  92. virtual void set_rtcp_mux(bool mux) { rtcp_mux_ = mux; }
  93. virtual bool rtcp_reduced_size() const { return rtcp_reduced_size_; }
  94. virtual void set_rtcp_reduced_size(bool reduced_size) {
  95. rtcp_reduced_size_ = reduced_size;
  96. }
  97. // Indicates support for the remote network estimate packet type. This
  98. // functionality is experimental and subject to change without notice.
  99. virtual bool remote_estimate() const { return remote_estimate_; }
  100. virtual void set_remote_estimate(bool remote_estimate) {
  101. remote_estimate_ = remote_estimate;
  102. }
  103. virtual int bandwidth() const { return bandwidth_; }
  104. virtual void set_bandwidth(int bandwidth) { bandwidth_ = bandwidth; }
  105. virtual const std::vector<CryptoParams>& cryptos() const { return cryptos_; }
  106. virtual void AddCrypto(const CryptoParams& params) {
  107. cryptos_.push_back(params);
  108. }
  109. virtual void set_cryptos(const std::vector<CryptoParams>& cryptos) {
  110. cryptos_ = cryptos;
  111. }
  112. virtual const RtpHeaderExtensions& rtp_header_extensions() const {
  113. return rtp_header_extensions_;
  114. }
  115. virtual void set_rtp_header_extensions(
  116. const RtpHeaderExtensions& extensions) {
  117. rtp_header_extensions_ = extensions;
  118. rtp_header_extensions_set_ = true;
  119. }
  120. virtual void AddRtpHeaderExtension(const webrtc::RtpExtension& ext) {
  121. rtp_header_extensions_.push_back(ext);
  122. rtp_header_extensions_set_ = true;
  123. }
  124. virtual void AddRtpHeaderExtension(const cricket::RtpHeaderExtension& ext) {
  125. webrtc::RtpExtension webrtc_extension;
  126. webrtc_extension.uri = ext.uri;
  127. webrtc_extension.id = ext.id;
  128. rtp_header_extensions_.push_back(webrtc_extension);
  129. rtp_header_extensions_set_ = true;
  130. }
  131. virtual void ClearRtpHeaderExtensions() {
  132. rtp_header_extensions_.clear();
  133. rtp_header_extensions_set_ = true;
  134. }
  135. // We can't always tell if an empty list of header extensions is
  136. // because the other side doesn't support them, or just isn't hooked up to
  137. // signal them. For now we assume an empty list means no signaling, but
  138. // provide the ClearRtpHeaderExtensions method to allow "no support" to be
  139. // clearly indicated (i.e. when derived from other information).
  140. virtual bool rtp_header_extensions_set() const {
  141. return rtp_header_extensions_set_;
  142. }
  143. virtual const StreamParamsVec& streams() const { return send_streams_; }
  144. // TODO(pthatcher): Remove this by giving mediamessage.cc access
  145. // to MediaContentDescription
  146. virtual StreamParamsVec& mutable_streams() { return send_streams_; }
  147. virtual void AddStream(const StreamParams& stream) {
  148. send_streams_.push_back(stream);
  149. }
  150. // Legacy streams have an ssrc, but nothing else.
  151. void AddLegacyStream(uint32_t ssrc) {
  152. AddStream(StreamParams::CreateLegacy(ssrc));
  153. }
  154. void AddLegacyStream(uint32_t ssrc, uint32_t fid_ssrc) {
  155. StreamParams sp = StreamParams::CreateLegacy(ssrc);
  156. sp.AddFidSsrc(ssrc, fid_ssrc);
  157. AddStream(sp);
  158. }
  159. // Sets the CNAME of all StreamParams if it have not been set.
  160. virtual void SetCnameIfEmpty(const std::string& cname) {
  161. for (cricket::StreamParamsVec::iterator it = send_streams_.begin();
  162. it != send_streams_.end(); ++it) {
  163. if (it->cname.empty())
  164. it->cname = cname;
  165. }
  166. }
  167. virtual uint32_t first_ssrc() const {
  168. if (send_streams_.empty()) {
  169. return 0;
  170. }
  171. return send_streams_[0].first_ssrc();
  172. }
  173. virtual bool has_ssrcs() const {
  174. if (send_streams_.empty()) {
  175. return false;
  176. }
  177. return send_streams_[0].has_ssrcs();
  178. }
  179. virtual void set_conference_mode(bool enable) { conference_mode_ = enable; }
  180. virtual bool conference_mode() const { return conference_mode_; }
  181. // https://tools.ietf.org/html/rfc4566#section-5.7
  182. // May be present at the media or session level of SDP. If present at both
  183. // levels, the media-level attribute overwrites the session-level one.
  184. virtual void set_connection_address(const rtc::SocketAddress& address) {
  185. connection_address_ = address;
  186. }
  187. virtual const rtc::SocketAddress& connection_address() const {
  188. return connection_address_;
  189. }
  190. // Determines if it's allowed to mix one- and two-byte rtp header extensions
  191. // within the same rtp stream.
  192. enum ExtmapAllowMixed { kNo, kSession, kMedia };
  193. virtual void set_extmap_allow_mixed_enum(
  194. ExtmapAllowMixed new_extmap_allow_mixed) {
  195. if (new_extmap_allow_mixed == kMedia &&
  196. extmap_allow_mixed_enum_ == kSession) {
  197. // Do not downgrade from session level to media level.
  198. return;
  199. }
  200. extmap_allow_mixed_enum_ = new_extmap_allow_mixed;
  201. }
  202. virtual ExtmapAllowMixed extmap_allow_mixed_enum() const {
  203. return extmap_allow_mixed_enum_;
  204. }
  205. virtual bool extmap_allow_mixed() const {
  206. return extmap_allow_mixed_enum_ != kNo;
  207. }
  208. // Simulcast functionality.
  209. virtual bool HasSimulcast() const { return !simulcast_.empty(); }
  210. virtual SimulcastDescription& simulcast_description() { return simulcast_; }
  211. virtual const SimulcastDescription& simulcast_description() const {
  212. return simulcast_;
  213. }
  214. virtual void set_simulcast_description(
  215. const SimulcastDescription& simulcast) {
  216. simulcast_ = simulcast;
  217. }
  218. virtual const std::vector<RidDescription>& receive_rids() const {
  219. return receive_rids_;
  220. }
  221. virtual void set_receive_rids(const std::vector<RidDescription>& rids) {
  222. receive_rids_ = rids;
  223. }
  224. virtual const absl::optional<std::string>& alt_protocol() const {
  225. return alt_protocol_;
  226. }
  227. virtual void set_alt_protocol(const absl::optional<std::string>& protocol) {
  228. alt_protocol_ = protocol;
  229. }
  230. protected:
  231. bool rtcp_mux_ = false;
  232. bool rtcp_reduced_size_ = false;
  233. bool remote_estimate_ = false;
  234. int bandwidth_ = kAutoBandwidth;
  235. std::string protocol_;
  236. std::vector<CryptoParams> cryptos_;
  237. std::vector<webrtc::RtpExtension> rtp_header_extensions_;
  238. bool rtp_header_extensions_set_ = false;
  239. StreamParamsVec send_streams_;
  240. bool conference_mode_ = false;
  241. webrtc::RtpTransceiverDirection direction_ =
  242. webrtc::RtpTransceiverDirection::kSendRecv;
  243. rtc::SocketAddress connection_address_;
  244. // Mixed one- and two-byte header not included in offer on media level or
  245. // session level, but we will respond that we support it. The plan is to add
  246. // it to our offer on session level. See todo in SessionDescription.
  247. ExtmapAllowMixed extmap_allow_mixed_enum_ = kNo;
  248. SimulcastDescription simulcast_;
  249. std::vector<RidDescription> receive_rids_;
  250. absl::optional<std::string> alt_protocol_;
  251. private:
  252. // Copy function that returns a raw pointer. Caller will assert ownership.
  253. // Should only be called by the Clone() function. Must be implemented
  254. // by each final subclass.
  255. virtual MediaContentDescription* CloneInternal() const = 0;
  256. };
  257. template <class C>
  258. class MediaContentDescriptionImpl : public MediaContentDescription {
  259. public:
  260. void set_protocol(const std::string& protocol) override {
  261. RTC_DCHECK(IsRtpProtocol(protocol));
  262. protocol_ = protocol;
  263. }
  264. typedef C CodecType;
  265. // Codecs should be in preference order (most preferred codec first).
  266. virtual const std::vector<C>& codecs() const { return codecs_; }
  267. virtual void set_codecs(const std::vector<C>& codecs) { codecs_ = codecs; }
  268. bool has_codecs() const override { return !codecs_.empty(); }
  269. virtual bool HasCodec(int id) {
  270. bool found = false;
  271. for (typename std::vector<C>::iterator iter = codecs_.begin();
  272. iter != codecs_.end(); ++iter) {
  273. if (iter->id == id) {
  274. found = true;
  275. break;
  276. }
  277. }
  278. return found;
  279. }
  280. virtual void AddCodec(const C& codec) { codecs_.push_back(codec); }
  281. virtual void AddOrReplaceCodec(const C& codec) {
  282. for (typename std::vector<C>::iterator iter = codecs_.begin();
  283. iter != codecs_.end(); ++iter) {
  284. if (iter->id == codec.id) {
  285. *iter = codec;
  286. return;
  287. }
  288. }
  289. AddCodec(codec);
  290. }
  291. virtual void AddCodecs(const std::vector<C>& codecs) {
  292. typename std::vector<C>::const_iterator codec;
  293. for (codec = codecs.begin(); codec != codecs.end(); ++codec) {
  294. AddCodec(*codec);
  295. }
  296. }
  297. private:
  298. std::vector<C> codecs_;
  299. };
  300. class AudioContentDescription : public MediaContentDescriptionImpl<AudioCodec> {
  301. public:
  302. AudioContentDescription() {}
  303. virtual MediaType type() const { return MEDIA_TYPE_AUDIO; }
  304. virtual AudioContentDescription* as_audio() { return this; }
  305. virtual const AudioContentDescription* as_audio() const { return this; }
  306. private:
  307. virtual AudioContentDescription* CloneInternal() const {
  308. return new AudioContentDescription(*this);
  309. }
  310. };
  311. class VideoContentDescription : public MediaContentDescriptionImpl<VideoCodec> {
  312. public:
  313. virtual MediaType type() const { return MEDIA_TYPE_VIDEO; }
  314. virtual VideoContentDescription* as_video() { return this; }
  315. virtual const VideoContentDescription* as_video() const { return this; }
  316. private:
  317. virtual VideoContentDescription* CloneInternal() const {
  318. return new VideoContentDescription(*this);
  319. }
  320. };
  321. class RtpDataContentDescription
  322. : public MediaContentDescriptionImpl<RtpDataCodec> {
  323. public:
  324. RtpDataContentDescription() {}
  325. MediaType type() const override { return MEDIA_TYPE_DATA; }
  326. RtpDataContentDescription* as_rtp_data() override { return this; }
  327. const RtpDataContentDescription* as_rtp_data() const override { return this; }
  328. private:
  329. RtpDataContentDescription* CloneInternal() const override {
  330. return new RtpDataContentDescription(*this);
  331. }
  332. };
  333. class SctpDataContentDescription : public MediaContentDescription {
  334. public:
  335. SctpDataContentDescription() {}
  336. SctpDataContentDescription(const SctpDataContentDescription& o)
  337. : MediaContentDescription(o),
  338. use_sctpmap_(o.use_sctpmap_),
  339. port_(o.port_),
  340. max_message_size_(o.max_message_size_) {}
  341. MediaType type() const override { return MEDIA_TYPE_DATA; }
  342. SctpDataContentDescription* as_sctp() override { return this; }
  343. const SctpDataContentDescription* as_sctp() const override { return this; }
  344. bool has_codecs() const override { return false; }
  345. void set_protocol(const std::string& protocol) override {
  346. RTC_DCHECK(IsSctpProtocol(protocol));
  347. protocol_ = protocol;
  348. }
  349. bool use_sctpmap() const { return use_sctpmap_; }
  350. void set_use_sctpmap(bool enable) { use_sctpmap_ = enable; }
  351. int port() const { return port_; }
  352. void set_port(int port) { port_ = port; }
  353. int max_message_size() const { return max_message_size_; }
  354. void set_max_message_size(int max_message_size) {
  355. max_message_size_ = max_message_size;
  356. }
  357. private:
  358. SctpDataContentDescription* CloneInternal() const override {
  359. return new SctpDataContentDescription(*this);
  360. }
  361. bool use_sctpmap_ = true; // Note: "true" is no longer conformant.
  362. // Defaults should be constants imported from SCTP. Quick hack.
  363. int port_ = 5000;
  364. // draft-ietf-mmusic-sdp-sctp-23: Max message size default is 64K
  365. int max_message_size_ = 64 * 1024;
  366. };
  367. // Protocol used for encoding media. This is the "top level" protocol that may
  368. // be wrapped by zero or many transport protocols (UDP, ICE, etc.).
  369. enum class MediaProtocolType {
  370. kRtp, // Section will use the RTP protocol (e.g., for audio or video).
  371. // https://tools.ietf.org/html/rfc3550
  372. kSctp // Section will use the SCTP protocol (e.g., for a data channel).
  373. // https://tools.ietf.org/html/rfc4960
  374. };
  375. // Represents a session description section. Most information about the section
  376. // is stored in the description, which is a subclass of MediaContentDescription.
  377. // Owns the description.
  378. class RTC_EXPORT ContentInfo {
  379. public:
  380. explicit ContentInfo(MediaProtocolType type) : type(type) {}
  381. ~ContentInfo();
  382. // Copy
  383. ContentInfo(const ContentInfo& o);
  384. ContentInfo& operator=(const ContentInfo& o);
  385. ContentInfo(ContentInfo&& o) = default;
  386. ContentInfo& operator=(ContentInfo&& o) = default;
  387. // Alias for |name|.
  388. std::string mid() const { return name; }
  389. void set_mid(const std::string& mid) { this->name = mid; }
  390. // Alias for |description|.
  391. MediaContentDescription* media_description();
  392. const MediaContentDescription* media_description() const;
  393. void set_media_description(std::unique_ptr<MediaContentDescription> desc) {
  394. description_ = std::move(desc);
  395. }
  396. // TODO(bugs.webrtc.org/8620): Rename this to mid.
  397. std::string name;
  398. MediaProtocolType type;
  399. bool rejected = false;
  400. bool bundle_only = false;
  401. private:
  402. friend class SessionDescription;
  403. std::unique_ptr<MediaContentDescription> description_;
  404. };
  405. typedef std::vector<std::string> ContentNames;
  406. // This class provides a mechanism to aggregate different media contents into a
  407. // group. This group can also be shared with the peers in a pre-defined format.
  408. // GroupInfo should be populated only with the |content_name| of the
  409. // MediaDescription.
  410. class ContentGroup {
  411. public:
  412. explicit ContentGroup(const std::string& semantics);
  413. ContentGroup(const ContentGroup&);
  414. ContentGroup(ContentGroup&&);
  415. ContentGroup& operator=(const ContentGroup&);
  416. ContentGroup& operator=(ContentGroup&&);
  417. ~ContentGroup();
  418. const std::string& semantics() const { return semantics_; }
  419. const ContentNames& content_names() const { return content_names_; }
  420. const std::string* FirstContentName() const;
  421. bool HasContentName(const std::string& content_name) const;
  422. void AddContentName(const std::string& content_name);
  423. bool RemoveContentName(const std::string& content_name);
  424. private:
  425. std::string semantics_;
  426. ContentNames content_names_;
  427. };
  428. typedef std::vector<ContentInfo> ContentInfos;
  429. typedef std::vector<ContentGroup> ContentGroups;
  430. const ContentInfo* FindContentInfoByName(const ContentInfos& contents,
  431. const std::string& name);
  432. const ContentInfo* FindContentInfoByType(const ContentInfos& contents,
  433. const std::string& type);
  434. // Determines how the MSID will be signaled in the SDP. These can be used as
  435. // flags to indicate both or none.
  436. enum MsidSignaling {
  437. // Signal MSID with one a=msid line in the media section.
  438. kMsidSignalingMediaSection = 0x1,
  439. // Signal MSID with a=ssrc: msid lines in the media section.
  440. kMsidSignalingSsrcAttribute = 0x2
  441. };
  442. // Describes a collection of contents, each with its own name and
  443. // type. Analogous to a <jingle> or <session> stanza. Assumes that
  444. // contents are unique be name, but doesn't enforce that.
  445. class SessionDescription {
  446. public:
  447. SessionDescription();
  448. ~SessionDescription();
  449. std::unique_ptr<SessionDescription> Clone() const;
  450. // Content accessors.
  451. const ContentInfos& contents() const { return contents_; }
  452. ContentInfos& contents() { return contents_; }
  453. const ContentInfo* GetContentByName(const std::string& name) const;
  454. ContentInfo* GetContentByName(const std::string& name);
  455. const MediaContentDescription* GetContentDescriptionByName(
  456. const std::string& name) const;
  457. MediaContentDescription* GetContentDescriptionByName(const std::string& name);
  458. const ContentInfo* FirstContentByType(MediaProtocolType type) const;
  459. const ContentInfo* FirstContent() const;
  460. // Content mutators.
  461. // Adds a content to this description. Takes ownership of ContentDescription*.
  462. void AddContent(const std::string& name,
  463. MediaProtocolType type,
  464. std::unique_ptr<MediaContentDescription> description);
  465. void AddContent(const std::string& name,
  466. MediaProtocolType type,
  467. bool rejected,
  468. std::unique_ptr<MediaContentDescription> description);
  469. void AddContent(const std::string& name,
  470. MediaProtocolType type,
  471. bool rejected,
  472. bool bundle_only,
  473. std::unique_ptr<MediaContentDescription> description);
  474. void AddContent(ContentInfo&& content);
  475. bool RemoveContentByName(const std::string& name);
  476. // Transport accessors.
  477. const TransportInfos& transport_infos() const { return transport_infos_; }
  478. TransportInfos& transport_infos() { return transport_infos_; }
  479. const TransportInfo* GetTransportInfoByName(const std::string& name) const;
  480. TransportInfo* GetTransportInfoByName(const std::string& name);
  481. const TransportDescription* GetTransportDescriptionByName(
  482. const std::string& name) const {
  483. const TransportInfo* tinfo = GetTransportInfoByName(name);
  484. return tinfo ? &tinfo->description : NULL;
  485. }
  486. // Transport mutators.
  487. void set_transport_infos(const TransportInfos& transport_infos) {
  488. transport_infos_ = transport_infos;
  489. }
  490. // Adds a TransportInfo to this description.
  491. void AddTransportInfo(const TransportInfo& transport_info);
  492. bool RemoveTransportInfoByName(const std::string& name);
  493. // Group accessors.
  494. const ContentGroups& groups() const { return content_groups_; }
  495. const ContentGroup* GetGroupByName(const std::string& name) const;
  496. bool HasGroup(const std::string& name) const;
  497. // Group mutators.
  498. void AddGroup(const ContentGroup& group) { content_groups_.push_back(group); }
  499. // Remove the first group with the same semantics specified by |name|.
  500. void RemoveGroupByName(const std::string& name);
  501. // Global attributes.
  502. void set_msid_supported(bool supported) { msid_supported_ = supported; }
  503. bool msid_supported() const { return msid_supported_; }
  504. // Determines how the MSIDs were/will be signaled. Flag value composed of
  505. // MsidSignaling bits (see enum above).
  506. void set_msid_signaling(int msid_signaling) {
  507. msid_signaling_ = msid_signaling;
  508. }
  509. int msid_signaling() const { return msid_signaling_; }
  510. // Determines if it's allowed to mix one- and two-byte rtp header extensions
  511. // within the same rtp stream.
  512. void set_extmap_allow_mixed(bool supported) {
  513. extmap_allow_mixed_ = supported;
  514. MediaContentDescription::ExtmapAllowMixed media_level_setting =
  515. supported ? MediaContentDescription::kSession
  516. : MediaContentDescription::kNo;
  517. for (auto& content : contents_) {
  518. // Do not set to kNo if the current setting is kMedia.
  519. if (supported || content.media_description()->extmap_allow_mixed_enum() !=
  520. MediaContentDescription::kMedia) {
  521. content.media_description()->set_extmap_allow_mixed_enum(
  522. media_level_setting);
  523. }
  524. }
  525. }
  526. bool extmap_allow_mixed() const { return extmap_allow_mixed_; }
  527. private:
  528. SessionDescription(const SessionDescription&);
  529. ContentInfos contents_;
  530. TransportInfos transport_infos_;
  531. ContentGroups content_groups_;
  532. bool msid_supported_ = true;
  533. // Default to what Plan B would do.
  534. // TODO(bugs.webrtc.org/8530): Change default to kMsidSignalingMediaSection.
  535. int msid_signaling_ = kMsidSignalingSsrcAttribute;
  536. // TODO(webrtc:9985): Activate mixed one- and two-byte header extension in
  537. // offer at session level. It's currently not included in offer by default
  538. // because clients prior to https://bugs.webrtc.org/9712 cannot parse this
  539. // correctly. If it's included in offer to us we will respond that we support
  540. // it.
  541. bool extmap_allow_mixed_ = false;
  542. };
  543. // Indicates whether a session description was sent by the local client or
  544. // received from the remote client.
  545. enum ContentSource { CS_LOCAL, CS_REMOTE };
  546. } // namespace cricket
  547. #endif // PC_SESSION_DESCRIPTION_H_