session_description.h 22 KB

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