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