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 // Types and classes used in media session descriptions. 12*d9f75844SAndroid Build Coastguard Worker 13*d9f75844SAndroid Build Coastguard Worker #ifndef PC_MEDIA_SESSION_H_ 14*d9f75844SAndroid Build Coastguard Worker #define PC_MEDIA_SESSION_H_ 15*d9f75844SAndroid Build Coastguard Worker 16*d9f75844SAndroid Build Coastguard Worker #include <map> 17*d9f75844SAndroid Build Coastguard Worker #include <memory> 18*d9f75844SAndroid Build Coastguard Worker #include <string> 19*d9f75844SAndroid Build Coastguard Worker #include <vector> 20*d9f75844SAndroid Build Coastguard Worker 21*d9f75844SAndroid Build Coastguard Worker #include "api/crypto/crypto_options.h" 22*d9f75844SAndroid Build Coastguard Worker #include "api/field_trials_view.h" 23*d9f75844SAndroid Build Coastguard Worker #include "api/media_types.h" 24*d9f75844SAndroid Build Coastguard Worker #include "api/rtp_parameters.h" 25*d9f75844SAndroid Build Coastguard Worker #include "api/rtp_transceiver_direction.h" 26*d9f75844SAndroid Build Coastguard Worker #include "media/base/media_constants.h" 27*d9f75844SAndroid Build Coastguard Worker #include "media/base/rid_description.h" 28*d9f75844SAndroid Build Coastguard Worker #include "media/base/stream_params.h" 29*d9f75844SAndroid Build Coastguard Worker #include "p2p/base/ice_credentials_iterator.h" 30*d9f75844SAndroid Build Coastguard Worker #include "p2p/base/transport_description.h" 31*d9f75844SAndroid Build Coastguard Worker #include "p2p/base/transport_description_factory.h" 32*d9f75844SAndroid Build Coastguard Worker #include "p2p/base/transport_info.h" 33*d9f75844SAndroid Build Coastguard Worker #include "pc/jsep_transport.h" 34*d9f75844SAndroid Build Coastguard Worker #include "pc/media_protocol_names.h" 35*d9f75844SAndroid Build Coastguard Worker #include "pc/session_description.h" 36*d9f75844SAndroid Build Coastguard Worker #include "pc/simulcast_description.h" 37*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/memory/always_valid_pointer.h" 38*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/unique_id_generator.h" 39*d9f75844SAndroid Build Coastguard Worker 40*d9f75844SAndroid Build Coastguard Worker namespace webrtc { 41*d9f75844SAndroid Build Coastguard Worker 42*d9f75844SAndroid Build Coastguard Worker // Forward declaration due to circular dependecy. 43*d9f75844SAndroid Build Coastguard Worker class ConnectionContext; 44*d9f75844SAndroid Build Coastguard Worker 45*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc 46*d9f75844SAndroid Build Coastguard Worker 47*d9f75844SAndroid Build Coastguard Worker namespace cricket { 48*d9f75844SAndroid Build Coastguard Worker 49*d9f75844SAndroid Build Coastguard Worker class MediaEngineInterface; 50*d9f75844SAndroid Build Coastguard Worker 51*d9f75844SAndroid Build Coastguard Worker // Default RTCP CNAME for unit tests. 52*d9f75844SAndroid Build Coastguard Worker const char kDefaultRtcpCname[] = "DefaultRtcpCname"; 53*d9f75844SAndroid Build Coastguard Worker 54*d9f75844SAndroid Build Coastguard Worker // Options for an RtpSender contained with an media description/"m=" section. 55*d9f75844SAndroid Build Coastguard Worker // Note: Spec-compliant Simulcast and legacy simulcast are mutually exclusive. 56*d9f75844SAndroid Build Coastguard Worker struct SenderOptions { 57*d9f75844SAndroid Build Coastguard Worker std::string track_id; 58*d9f75844SAndroid Build Coastguard Worker std::vector<std::string> stream_ids; 59*d9f75844SAndroid Build Coastguard Worker // Use RIDs and Simulcast Layers to indicate spec-compliant Simulcast. 60*d9f75844SAndroid Build Coastguard Worker std::vector<RidDescription> rids; 61*d9f75844SAndroid Build Coastguard Worker SimulcastLayerList simulcast_layers; 62*d9f75844SAndroid Build Coastguard Worker // Use `num_sim_layers` to indicate legacy simulcast. 63*d9f75844SAndroid Build Coastguard Worker int num_sim_layers; 64*d9f75844SAndroid Build Coastguard Worker }; 65*d9f75844SAndroid Build Coastguard Worker 66*d9f75844SAndroid Build Coastguard Worker // Options for an individual media description/"m=" section. 67*d9f75844SAndroid Build Coastguard Worker struct MediaDescriptionOptions { MediaDescriptionOptionsMediaDescriptionOptions68*d9f75844SAndroid Build Coastguard Worker MediaDescriptionOptions(MediaType type, 69*d9f75844SAndroid Build Coastguard Worker const std::string& mid, 70*d9f75844SAndroid Build Coastguard Worker webrtc::RtpTransceiverDirection direction, 71*d9f75844SAndroid Build Coastguard Worker bool stopped) 72*d9f75844SAndroid Build Coastguard Worker : type(type), mid(mid), direction(direction), stopped(stopped) {} 73*d9f75844SAndroid Build Coastguard Worker 74*d9f75844SAndroid Build Coastguard Worker // TODO(deadbeef): When we don't support Plan B, there will only be one 75*d9f75844SAndroid Build Coastguard Worker // sender per media description and this can be simplified. 76*d9f75844SAndroid Build Coastguard Worker void AddAudioSender(const std::string& track_id, 77*d9f75844SAndroid Build Coastguard Worker const std::vector<std::string>& stream_ids); 78*d9f75844SAndroid Build Coastguard Worker void AddVideoSender(const std::string& track_id, 79*d9f75844SAndroid Build Coastguard Worker const std::vector<std::string>& stream_ids, 80*d9f75844SAndroid Build Coastguard Worker const std::vector<RidDescription>& rids, 81*d9f75844SAndroid Build Coastguard Worker const SimulcastLayerList& simulcast_layers, 82*d9f75844SAndroid Build Coastguard Worker int num_sim_layers); 83*d9f75844SAndroid Build Coastguard Worker 84*d9f75844SAndroid Build Coastguard Worker MediaType type; 85*d9f75844SAndroid Build Coastguard Worker std::string mid; 86*d9f75844SAndroid Build Coastguard Worker webrtc::RtpTransceiverDirection direction; 87*d9f75844SAndroid Build Coastguard Worker bool stopped; 88*d9f75844SAndroid Build Coastguard Worker TransportOptions transport_options; 89*d9f75844SAndroid Build Coastguard Worker // Note: There's no equivalent "RtpReceiverOptions" because only send 90*d9f75844SAndroid Build Coastguard Worker // stream information goes in the local descriptions. 91*d9f75844SAndroid Build Coastguard Worker std::vector<SenderOptions> sender_options; 92*d9f75844SAndroid Build Coastguard Worker std::vector<webrtc::RtpCodecCapability> codec_preferences; 93*d9f75844SAndroid Build Coastguard Worker std::vector<webrtc::RtpHeaderExtensionCapability> header_extensions; 94*d9f75844SAndroid Build Coastguard Worker 95*d9f75844SAndroid Build Coastguard Worker private: 96*d9f75844SAndroid Build Coastguard Worker // Doesn't DCHECK on `type`. 97*d9f75844SAndroid Build Coastguard Worker void AddSenderInternal(const std::string& track_id, 98*d9f75844SAndroid Build Coastguard Worker const std::vector<std::string>& stream_ids, 99*d9f75844SAndroid Build Coastguard Worker const std::vector<RidDescription>& rids, 100*d9f75844SAndroid Build Coastguard Worker const SimulcastLayerList& simulcast_layers, 101*d9f75844SAndroid Build Coastguard Worker int num_sim_layers); 102*d9f75844SAndroid Build Coastguard Worker }; 103*d9f75844SAndroid Build Coastguard Worker 104*d9f75844SAndroid Build Coastguard Worker // Provides a mechanism for describing how m= sections should be generated. 105*d9f75844SAndroid Build Coastguard Worker // The m= section with index X will use media_description_options[X]. There 106*d9f75844SAndroid Build Coastguard Worker // must be an option for each existing section if creating an answer, or a 107*d9f75844SAndroid Build Coastguard Worker // subsequent offer. 108*d9f75844SAndroid Build Coastguard Worker struct MediaSessionOptions { MediaSessionOptionsMediaSessionOptions109*d9f75844SAndroid Build Coastguard Worker MediaSessionOptions() {} 110*d9f75844SAndroid Build Coastguard Worker has_audioMediaSessionOptions111*d9f75844SAndroid Build Coastguard Worker bool has_audio() const { return HasMediaDescription(MEDIA_TYPE_AUDIO); } has_videoMediaSessionOptions112*d9f75844SAndroid Build Coastguard Worker bool has_video() const { return HasMediaDescription(MEDIA_TYPE_VIDEO); } has_dataMediaSessionOptions113*d9f75844SAndroid Build Coastguard Worker bool has_data() const { return HasMediaDescription(MEDIA_TYPE_DATA); } 114*d9f75844SAndroid Build Coastguard Worker 115*d9f75844SAndroid Build Coastguard Worker bool HasMediaDescription(MediaType type) const; 116*d9f75844SAndroid Build Coastguard Worker 117*d9f75844SAndroid Build Coastguard Worker bool vad_enabled = true; // When disabled, removes all CN codecs from SDP. 118*d9f75844SAndroid Build Coastguard Worker bool rtcp_mux_enabled = true; 119*d9f75844SAndroid Build Coastguard Worker bool bundle_enabled = false; 120*d9f75844SAndroid Build Coastguard Worker bool offer_extmap_allow_mixed = false; 121*d9f75844SAndroid Build Coastguard Worker bool raw_packetization_for_video = false; 122*d9f75844SAndroid Build Coastguard Worker std::string rtcp_cname = kDefaultRtcpCname; 123*d9f75844SAndroid Build Coastguard Worker webrtc::CryptoOptions crypto_options; 124*d9f75844SAndroid Build Coastguard Worker // List of media description options in the same order that the media 125*d9f75844SAndroid Build Coastguard Worker // descriptions will be generated. 126*d9f75844SAndroid Build Coastguard Worker std::vector<MediaDescriptionOptions> media_description_options; 127*d9f75844SAndroid Build Coastguard Worker std::vector<IceParameters> pooled_ice_credentials; 128*d9f75844SAndroid Build Coastguard Worker 129*d9f75844SAndroid Build Coastguard Worker // Use the draft-ietf-mmusic-sctp-sdp-03 obsolete syntax for SCTP 130*d9f75844SAndroid Build Coastguard Worker // datachannels. 131*d9f75844SAndroid Build Coastguard Worker // Default is true for backwards compatibility with clients that use 132*d9f75844SAndroid Build Coastguard Worker // this internal interface. 133*d9f75844SAndroid Build Coastguard Worker bool use_obsolete_sctp_sdp = true; 134*d9f75844SAndroid Build Coastguard Worker }; 135*d9f75844SAndroid Build Coastguard Worker 136*d9f75844SAndroid Build Coastguard Worker // Creates media session descriptions according to the supplied codecs and 137*d9f75844SAndroid Build Coastguard Worker // other fields, as well as the supplied per-call options. 138*d9f75844SAndroid Build Coastguard Worker // When creating answers, performs the appropriate negotiation 139*d9f75844SAndroid Build Coastguard Worker // of the various fields to determine the proper result. 140*d9f75844SAndroid Build Coastguard Worker class MediaSessionDescriptionFactory { 141*d9f75844SAndroid Build Coastguard Worker public: 142*d9f75844SAndroid Build Coastguard Worker // Simple constructor that does not set any configuration for the factory. 143*d9f75844SAndroid Build Coastguard Worker // When using this constructor, the methods below can be used to set the 144*d9f75844SAndroid Build Coastguard Worker // configuration. 145*d9f75844SAndroid Build Coastguard Worker // The TransportDescriptionFactory and the UniqueRandomIdGenerator are not 146*d9f75844SAndroid Build Coastguard Worker // owned by MediaSessionDescriptionFactory, so they must be kept alive by the 147*d9f75844SAndroid Build Coastguard Worker // user of this class. 148*d9f75844SAndroid Build Coastguard Worker MediaSessionDescriptionFactory(const TransportDescriptionFactory* factory, 149*d9f75844SAndroid Build Coastguard Worker rtc::UniqueRandomIdGenerator* ssrc_generator); 150*d9f75844SAndroid Build Coastguard Worker // This helper automatically sets up the factory to get its configuration 151*d9f75844SAndroid Build Coastguard Worker // from the specified MediaEngine 152*d9f75844SAndroid Build Coastguard Worker MediaSessionDescriptionFactory(cricket::MediaEngineInterface* media_engine, 153*d9f75844SAndroid Build Coastguard Worker bool rtx_enabled, 154*d9f75844SAndroid Build Coastguard Worker rtc::UniqueRandomIdGenerator* ssrc_generator, 155*d9f75844SAndroid Build Coastguard Worker const TransportDescriptionFactory* factory); 156*d9f75844SAndroid Build Coastguard Worker 157*d9f75844SAndroid Build Coastguard Worker const AudioCodecs& audio_sendrecv_codecs() const; 158*d9f75844SAndroid Build Coastguard Worker const AudioCodecs& audio_send_codecs() const; 159*d9f75844SAndroid Build Coastguard Worker const AudioCodecs& audio_recv_codecs() const; 160*d9f75844SAndroid Build Coastguard Worker void set_audio_codecs(const AudioCodecs& send_codecs, 161*d9f75844SAndroid Build Coastguard Worker const AudioCodecs& recv_codecs); 162*d9f75844SAndroid Build Coastguard Worker const VideoCodecs& video_sendrecv_codecs() const; 163*d9f75844SAndroid Build Coastguard Worker const VideoCodecs& video_send_codecs() const; 164*d9f75844SAndroid Build Coastguard Worker const VideoCodecs& video_recv_codecs() const; 165*d9f75844SAndroid Build Coastguard Worker void set_video_codecs(const VideoCodecs& send_codecs, 166*d9f75844SAndroid Build Coastguard Worker const VideoCodecs& recv_codecs); 167*d9f75844SAndroid Build Coastguard Worker RtpHeaderExtensions filtered_rtp_header_extensions( 168*d9f75844SAndroid Build Coastguard Worker RtpHeaderExtensions extensions) const; secure()169*d9f75844SAndroid Build Coastguard Worker SecurePolicy secure() const { return secure_; } set_secure(SecurePolicy s)170*d9f75844SAndroid Build Coastguard Worker void set_secure(SecurePolicy s) { secure_ = s; } 171*d9f75844SAndroid Build Coastguard Worker set_enable_encrypted_rtp_header_extensions(bool enable)172*d9f75844SAndroid Build Coastguard Worker void set_enable_encrypted_rtp_header_extensions(bool enable) { 173*d9f75844SAndroid Build Coastguard Worker enable_encrypted_rtp_header_extensions_ = enable; 174*d9f75844SAndroid Build Coastguard Worker } 175*d9f75844SAndroid Build Coastguard Worker set_is_unified_plan(bool is_unified_plan)176*d9f75844SAndroid Build Coastguard Worker void set_is_unified_plan(bool is_unified_plan) { 177*d9f75844SAndroid Build Coastguard Worker is_unified_plan_ = is_unified_plan; 178*d9f75844SAndroid Build Coastguard Worker } 179*d9f75844SAndroid Build Coastguard Worker 180*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<SessionDescription> CreateOffer( 181*d9f75844SAndroid Build Coastguard Worker const MediaSessionOptions& options, 182*d9f75844SAndroid Build Coastguard Worker const SessionDescription* current_description) const; 183*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<SessionDescription> CreateAnswer( 184*d9f75844SAndroid Build Coastguard Worker const SessionDescription* offer, 185*d9f75844SAndroid Build Coastguard Worker const MediaSessionOptions& options, 186*d9f75844SAndroid Build Coastguard Worker const SessionDescription* current_description) const; 187*d9f75844SAndroid Build Coastguard Worker 188*d9f75844SAndroid Build Coastguard Worker private: 189*d9f75844SAndroid Build Coastguard Worker struct AudioVideoRtpHeaderExtensions { 190*d9f75844SAndroid Build Coastguard Worker RtpHeaderExtensions audio; 191*d9f75844SAndroid Build Coastguard Worker RtpHeaderExtensions video; 192*d9f75844SAndroid Build Coastguard Worker }; 193*d9f75844SAndroid Build Coastguard Worker 194*d9f75844SAndroid Build Coastguard Worker const AudioCodecs& GetAudioCodecsForOffer( 195*d9f75844SAndroid Build Coastguard Worker const webrtc::RtpTransceiverDirection& direction) const; 196*d9f75844SAndroid Build Coastguard Worker const AudioCodecs& GetAudioCodecsForAnswer( 197*d9f75844SAndroid Build Coastguard Worker const webrtc::RtpTransceiverDirection& offer, 198*d9f75844SAndroid Build Coastguard Worker const webrtc::RtpTransceiverDirection& answer) const; 199*d9f75844SAndroid Build Coastguard Worker const VideoCodecs& GetVideoCodecsForOffer( 200*d9f75844SAndroid Build Coastguard Worker const webrtc::RtpTransceiverDirection& direction) const; 201*d9f75844SAndroid Build Coastguard Worker const VideoCodecs& GetVideoCodecsForAnswer( 202*d9f75844SAndroid Build Coastguard Worker const webrtc::RtpTransceiverDirection& offer, 203*d9f75844SAndroid Build Coastguard Worker const webrtc::RtpTransceiverDirection& answer) const; 204*d9f75844SAndroid Build Coastguard Worker void GetCodecsForOffer( 205*d9f75844SAndroid Build Coastguard Worker const std::vector<const ContentInfo*>& current_active_contents, 206*d9f75844SAndroid Build Coastguard Worker AudioCodecs* audio_codecs, 207*d9f75844SAndroid Build Coastguard Worker VideoCodecs* video_codecs) const; 208*d9f75844SAndroid Build Coastguard Worker void GetCodecsForAnswer( 209*d9f75844SAndroid Build Coastguard Worker const std::vector<const ContentInfo*>& current_active_contents, 210*d9f75844SAndroid Build Coastguard Worker const SessionDescription& remote_offer, 211*d9f75844SAndroid Build Coastguard Worker AudioCodecs* audio_codecs, 212*d9f75844SAndroid Build Coastguard Worker VideoCodecs* video_codecs) const; 213*d9f75844SAndroid Build Coastguard Worker AudioVideoRtpHeaderExtensions GetOfferedRtpHeaderExtensionsWithIds( 214*d9f75844SAndroid Build Coastguard Worker const std::vector<const ContentInfo*>& current_active_contents, 215*d9f75844SAndroid Build Coastguard Worker bool extmap_allow_mixed, 216*d9f75844SAndroid Build Coastguard Worker const std::vector<MediaDescriptionOptions>& media_description_options) 217*d9f75844SAndroid Build Coastguard Worker const; 218*d9f75844SAndroid Build Coastguard Worker bool AddTransportOffer(const std::string& content_name, 219*d9f75844SAndroid Build Coastguard Worker const TransportOptions& transport_options, 220*d9f75844SAndroid Build Coastguard Worker const SessionDescription* current_desc, 221*d9f75844SAndroid Build Coastguard Worker SessionDescription* offer, 222*d9f75844SAndroid Build Coastguard Worker IceCredentialsIterator* ice_credentials) const; 223*d9f75844SAndroid Build Coastguard Worker 224*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<TransportDescription> CreateTransportAnswer( 225*d9f75844SAndroid Build Coastguard Worker const std::string& content_name, 226*d9f75844SAndroid Build Coastguard Worker const SessionDescription* offer_desc, 227*d9f75844SAndroid Build Coastguard Worker const TransportOptions& transport_options, 228*d9f75844SAndroid Build Coastguard Worker const SessionDescription* current_desc, 229*d9f75844SAndroid Build Coastguard Worker bool require_transport_attributes, 230*d9f75844SAndroid Build Coastguard Worker IceCredentialsIterator* ice_credentials) const; 231*d9f75844SAndroid Build Coastguard Worker 232*d9f75844SAndroid Build Coastguard Worker bool AddTransportAnswer(const std::string& content_name, 233*d9f75844SAndroid Build Coastguard Worker const TransportDescription& transport_desc, 234*d9f75844SAndroid Build Coastguard Worker SessionDescription* answer_desc) const; 235*d9f75844SAndroid Build Coastguard Worker 236*d9f75844SAndroid Build Coastguard Worker // Helpers for adding media contents to the SessionDescription. Returns true 237*d9f75844SAndroid Build Coastguard Worker // it succeeds or the media content is not needed, or false if there is any 238*d9f75844SAndroid Build Coastguard Worker // error. 239*d9f75844SAndroid Build Coastguard Worker 240*d9f75844SAndroid Build Coastguard Worker bool AddAudioContentForOffer( 241*d9f75844SAndroid Build Coastguard Worker const MediaDescriptionOptions& media_description_options, 242*d9f75844SAndroid Build Coastguard Worker const MediaSessionOptions& session_options, 243*d9f75844SAndroid Build Coastguard Worker const ContentInfo* current_content, 244*d9f75844SAndroid Build Coastguard Worker const SessionDescription* current_description, 245*d9f75844SAndroid Build Coastguard Worker const RtpHeaderExtensions& audio_rtp_extensions, 246*d9f75844SAndroid Build Coastguard Worker const AudioCodecs& audio_codecs, 247*d9f75844SAndroid Build Coastguard Worker StreamParamsVec* current_streams, 248*d9f75844SAndroid Build Coastguard Worker SessionDescription* desc, 249*d9f75844SAndroid Build Coastguard Worker IceCredentialsIterator* ice_credentials) const; 250*d9f75844SAndroid Build Coastguard Worker 251*d9f75844SAndroid Build Coastguard Worker bool AddVideoContentForOffer( 252*d9f75844SAndroid Build Coastguard Worker const MediaDescriptionOptions& media_description_options, 253*d9f75844SAndroid Build Coastguard Worker const MediaSessionOptions& session_options, 254*d9f75844SAndroid Build Coastguard Worker const ContentInfo* current_content, 255*d9f75844SAndroid Build Coastguard Worker const SessionDescription* current_description, 256*d9f75844SAndroid Build Coastguard Worker const RtpHeaderExtensions& video_rtp_extensions, 257*d9f75844SAndroid Build Coastguard Worker const VideoCodecs& video_codecs, 258*d9f75844SAndroid Build Coastguard Worker StreamParamsVec* current_streams, 259*d9f75844SAndroid Build Coastguard Worker SessionDescription* desc, 260*d9f75844SAndroid Build Coastguard Worker IceCredentialsIterator* ice_credentials) const; 261*d9f75844SAndroid Build Coastguard Worker 262*d9f75844SAndroid Build Coastguard Worker bool AddDataContentForOffer( 263*d9f75844SAndroid Build Coastguard Worker const MediaDescriptionOptions& media_description_options, 264*d9f75844SAndroid Build Coastguard Worker const MediaSessionOptions& session_options, 265*d9f75844SAndroid Build Coastguard Worker const ContentInfo* current_content, 266*d9f75844SAndroid Build Coastguard Worker const SessionDescription* current_description, 267*d9f75844SAndroid Build Coastguard Worker StreamParamsVec* current_streams, 268*d9f75844SAndroid Build Coastguard Worker SessionDescription* desc, 269*d9f75844SAndroid Build Coastguard Worker IceCredentialsIterator* ice_credentials) const; 270*d9f75844SAndroid Build Coastguard Worker 271*d9f75844SAndroid Build Coastguard Worker bool AddUnsupportedContentForOffer( 272*d9f75844SAndroid Build Coastguard Worker const MediaDescriptionOptions& media_description_options, 273*d9f75844SAndroid Build Coastguard Worker const MediaSessionOptions& session_options, 274*d9f75844SAndroid Build Coastguard Worker const ContentInfo* current_content, 275*d9f75844SAndroid Build Coastguard Worker const SessionDescription* current_description, 276*d9f75844SAndroid Build Coastguard Worker SessionDescription* desc, 277*d9f75844SAndroid Build Coastguard Worker IceCredentialsIterator* ice_credentials) const; 278*d9f75844SAndroid Build Coastguard Worker 279*d9f75844SAndroid Build Coastguard Worker bool AddAudioContentForAnswer( 280*d9f75844SAndroid Build Coastguard Worker const MediaDescriptionOptions& media_description_options, 281*d9f75844SAndroid Build Coastguard Worker const MediaSessionOptions& session_options, 282*d9f75844SAndroid Build Coastguard Worker const ContentInfo* offer_content, 283*d9f75844SAndroid Build Coastguard Worker const SessionDescription* offer_description, 284*d9f75844SAndroid Build Coastguard Worker const ContentInfo* current_content, 285*d9f75844SAndroid Build Coastguard Worker const SessionDescription* current_description, 286*d9f75844SAndroid Build Coastguard Worker const TransportInfo* bundle_transport, 287*d9f75844SAndroid Build Coastguard Worker const AudioCodecs& audio_codecs, 288*d9f75844SAndroid Build Coastguard Worker const RtpHeaderExtensions& default_audio_rtp_header_extensions, 289*d9f75844SAndroid Build Coastguard Worker StreamParamsVec* current_streams, 290*d9f75844SAndroid Build Coastguard Worker SessionDescription* answer, 291*d9f75844SAndroid Build Coastguard Worker IceCredentialsIterator* ice_credentials) const; 292*d9f75844SAndroid Build Coastguard Worker 293*d9f75844SAndroid Build Coastguard Worker bool AddVideoContentForAnswer( 294*d9f75844SAndroid Build Coastguard Worker const MediaDescriptionOptions& media_description_options, 295*d9f75844SAndroid Build Coastguard Worker const MediaSessionOptions& session_options, 296*d9f75844SAndroid Build Coastguard Worker const ContentInfo* offer_content, 297*d9f75844SAndroid Build Coastguard Worker const SessionDescription* offer_description, 298*d9f75844SAndroid Build Coastguard Worker const ContentInfo* current_content, 299*d9f75844SAndroid Build Coastguard Worker const SessionDescription* current_description, 300*d9f75844SAndroid Build Coastguard Worker const TransportInfo* bundle_transport, 301*d9f75844SAndroid Build Coastguard Worker const VideoCodecs& video_codecs, 302*d9f75844SAndroid Build Coastguard Worker const RtpHeaderExtensions& default_video_rtp_header_extensions, 303*d9f75844SAndroid Build Coastguard Worker StreamParamsVec* current_streams, 304*d9f75844SAndroid Build Coastguard Worker SessionDescription* answer, 305*d9f75844SAndroid Build Coastguard Worker IceCredentialsIterator* ice_credentials) const; 306*d9f75844SAndroid Build Coastguard Worker 307*d9f75844SAndroid Build Coastguard Worker bool AddDataContentForAnswer( 308*d9f75844SAndroid Build Coastguard Worker const MediaDescriptionOptions& media_description_options, 309*d9f75844SAndroid Build Coastguard Worker const MediaSessionOptions& session_options, 310*d9f75844SAndroid Build Coastguard Worker const ContentInfo* offer_content, 311*d9f75844SAndroid Build Coastguard Worker const SessionDescription* offer_description, 312*d9f75844SAndroid Build Coastguard Worker const ContentInfo* current_content, 313*d9f75844SAndroid Build Coastguard Worker const SessionDescription* current_description, 314*d9f75844SAndroid Build Coastguard Worker const TransportInfo* bundle_transport, 315*d9f75844SAndroid Build Coastguard Worker StreamParamsVec* current_streams, 316*d9f75844SAndroid Build Coastguard Worker SessionDescription* answer, 317*d9f75844SAndroid Build Coastguard Worker IceCredentialsIterator* ice_credentials) const; 318*d9f75844SAndroid Build Coastguard Worker 319*d9f75844SAndroid Build Coastguard Worker bool AddUnsupportedContentForAnswer( 320*d9f75844SAndroid Build Coastguard Worker const MediaDescriptionOptions& media_description_options, 321*d9f75844SAndroid Build Coastguard Worker const MediaSessionOptions& session_options, 322*d9f75844SAndroid Build Coastguard Worker const ContentInfo* offer_content, 323*d9f75844SAndroid Build Coastguard Worker const SessionDescription* offer_description, 324*d9f75844SAndroid Build Coastguard Worker const ContentInfo* current_content, 325*d9f75844SAndroid Build Coastguard Worker const SessionDescription* current_description, 326*d9f75844SAndroid Build Coastguard Worker const TransportInfo* bundle_transport, 327*d9f75844SAndroid Build Coastguard Worker SessionDescription* answer, 328*d9f75844SAndroid Build Coastguard Worker IceCredentialsIterator* ice_credentials) const; 329*d9f75844SAndroid Build Coastguard Worker 330*d9f75844SAndroid Build Coastguard Worker void ComputeAudioCodecsIntersectionAndUnion(); 331*d9f75844SAndroid Build Coastguard Worker 332*d9f75844SAndroid Build Coastguard Worker void ComputeVideoCodecsIntersectionAndUnion(); 333*d9f75844SAndroid Build Coastguard Worker ssrc_generator()334*d9f75844SAndroid Build Coastguard Worker rtc::UniqueRandomIdGenerator* ssrc_generator() const { 335*d9f75844SAndroid Build Coastguard Worker return ssrc_generator_.get(); 336*d9f75844SAndroid Build Coastguard Worker } 337*d9f75844SAndroid Build Coastguard Worker 338*d9f75844SAndroid Build Coastguard Worker bool is_unified_plan_ = false; 339*d9f75844SAndroid Build Coastguard Worker AudioCodecs audio_send_codecs_; 340*d9f75844SAndroid Build Coastguard Worker AudioCodecs audio_recv_codecs_; 341*d9f75844SAndroid Build Coastguard Worker // Intersection of send and recv. 342*d9f75844SAndroid Build Coastguard Worker AudioCodecs audio_sendrecv_codecs_; 343*d9f75844SAndroid Build Coastguard Worker // Union of send and recv. 344*d9f75844SAndroid Build Coastguard Worker AudioCodecs all_audio_codecs_; 345*d9f75844SAndroid Build Coastguard Worker VideoCodecs video_send_codecs_; 346*d9f75844SAndroid Build Coastguard Worker VideoCodecs video_recv_codecs_; 347*d9f75844SAndroid Build Coastguard Worker // Intersection of send and recv. 348*d9f75844SAndroid Build Coastguard Worker VideoCodecs video_sendrecv_codecs_; 349*d9f75844SAndroid Build Coastguard Worker // Union of send and recv. 350*d9f75844SAndroid Build Coastguard Worker VideoCodecs all_video_codecs_; 351*d9f75844SAndroid Build Coastguard Worker // This object may or may not be owned by this class. 352*d9f75844SAndroid Build Coastguard Worker webrtc::AlwaysValidPointer<rtc::UniqueRandomIdGenerator> const 353*d9f75844SAndroid Build Coastguard Worker ssrc_generator_; 354*d9f75844SAndroid Build Coastguard Worker bool enable_encrypted_rtp_header_extensions_ = false; 355*d9f75844SAndroid Build Coastguard Worker // TODO(zhihuang): Rename secure_ to sdec_policy_; rename the related getter 356*d9f75844SAndroid Build Coastguard Worker // and setter. 357*d9f75844SAndroid Build Coastguard Worker SecurePolicy secure_ = SEC_DISABLED; 358*d9f75844SAndroid Build Coastguard Worker const TransportDescriptionFactory* transport_desc_factory_; 359*d9f75844SAndroid Build Coastguard Worker }; 360*d9f75844SAndroid Build Coastguard Worker 361*d9f75844SAndroid Build Coastguard Worker // Convenience functions. 362*d9f75844SAndroid Build Coastguard Worker bool IsMediaContent(const ContentInfo* content); 363*d9f75844SAndroid Build Coastguard Worker bool IsAudioContent(const ContentInfo* content); 364*d9f75844SAndroid Build Coastguard Worker bool IsVideoContent(const ContentInfo* content); 365*d9f75844SAndroid Build Coastguard Worker bool IsDataContent(const ContentInfo* content); 366*d9f75844SAndroid Build Coastguard Worker bool IsUnsupportedContent(const ContentInfo* content); 367*d9f75844SAndroid Build Coastguard Worker const ContentInfo* GetFirstMediaContent(const ContentInfos& contents, 368*d9f75844SAndroid Build Coastguard Worker MediaType media_type); 369*d9f75844SAndroid Build Coastguard Worker const ContentInfo* GetFirstAudioContent(const ContentInfos& contents); 370*d9f75844SAndroid Build Coastguard Worker const ContentInfo* GetFirstVideoContent(const ContentInfos& contents); 371*d9f75844SAndroid Build Coastguard Worker const ContentInfo* GetFirstDataContent(const ContentInfos& contents); 372*d9f75844SAndroid Build Coastguard Worker const ContentInfo* GetFirstMediaContent(const SessionDescription* sdesc, 373*d9f75844SAndroid Build Coastguard Worker MediaType media_type); 374*d9f75844SAndroid Build Coastguard Worker const ContentInfo* GetFirstAudioContent(const SessionDescription* sdesc); 375*d9f75844SAndroid Build Coastguard Worker const ContentInfo* GetFirstVideoContent(const SessionDescription* sdesc); 376*d9f75844SAndroid Build Coastguard Worker const ContentInfo* GetFirstDataContent(const SessionDescription* sdesc); 377*d9f75844SAndroid Build Coastguard Worker const AudioContentDescription* GetFirstAudioContentDescription( 378*d9f75844SAndroid Build Coastguard Worker const SessionDescription* sdesc); 379*d9f75844SAndroid Build Coastguard Worker const VideoContentDescription* GetFirstVideoContentDescription( 380*d9f75844SAndroid Build Coastguard Worker const SessionDescription* sdesc); 381*d9f75844SAndroid Build Coastguard Worker const SctpDataContentDescription* GetFirstSctpDataContentDescription( 382*d9f75844SAndroid Build Coastguard Worker const SessionDescription* sdesc); 383*d9f75844SAndroid Build Coastguard Worker // Non-const versions of the above functions. 384*d9f75844SAndroid Build Coastguard Worker // Useful when modifying an existing description. 385*d9f75844SAndroid Build Coastguard Worker ContentInfo* GetFirstMediaContent(ContentInfos* contents, MediaType media_type); 386*d9f75844SAndroid Build Coastguard Worker ContentInfo* GetFirstAudioContent(ContentInfos* contents); 387*d9f75844SAndroid Build Coastguard Worker ContentInfo* GetFirstVideoContent(ContentInfos* contents); 388*d9f75844SAndroid Build Coastguard Worker ContentInfo* GetFirstDataContent(ContentInfos* contents); 389*d9f75844SAndroid Build Coastguard Worker ContentInfo* GetFirstMediaContent(SessionDescription* sdesc, 390*d9f75844SAndroid Build Coastguard Worker MediaType media_type); 391*d9f75844SAndroid Build Coastguard Worker ContentInfo* GetFirstAudioContent(SessionDescription* sdesc); 392*d9f75844SAndroid Build Coastguard Worker ContentInfo* GetFirstVideoContent(SessionDescription* sdesc); 393*d9f75844SAndroid Build Coastguard Worker ContentInfo* GetFirstDataContent(SessionDescription* sdesc); 394*d9f75844SAndroid Build Coastguard Worker AudioContentDescription* GetFirstAudioContentDescription( 395*d9f75844SAndroid Build Coastguard Worker SessionDescription* sdesc); 396*d9f75844SAndroid Build Coastguard Worker VideoContentDescription* GetFirstVideoContentDescription( 397*d9f75844SAndroid Build Coastguard Worker SessionDescription* sdesc); 398*d9f75844SAndroid Build Coastguard Worker SctpDataContentDescription* GetFirstSctpDataContentDescription( 399*d9f75844SAndroid Build Coastguard Worker SessionDescription* sdesc); 400*d9f75844SAndroid Build Coastguard Worker 401*d9f75844SAndroid Build Coastguard Worker // Helper functions to return crypto suites used for SDES. 402*d9f75844SAndroid Build Coastguard Worker void GetSupportedAudioSdesCryptoSuites( 403*d9f75844SAndroid Build Coastguard Worker const webrtc::CryptoOptions& crypto_options, 404*d9f75844SAndroid Build Coastguard Worker std::vector<int>* crypto_suites); 405*d9f75844SAndroid Build Coastguard Worker void GetSupportedVideoSdesCryptoSuites( 406*d9f75844SAndroid Build Coastguard Worker const webrtc::CryptoOptions& crypto_options, 407*d9f75844SAndroid Build Coastguard Worker std::vector<int>* crypto_suites); 408*d9f75844SAndroid Build Coastguard Worker void GetSupportedDataSdesCryptoSuites( 409*d9f75844SAndroid Build Coastguard Worker const webrtc::CryptoOptions& crypto_options, 410*d9f75844SAndroid Build Coastguard Worker std::vector<int>* crypto_suites); 411*d9f75844SAndroid Build Coastguard Worker void GetSupportedAudioSdesCryptoSuiteNames( 412*d9f75844SAndroid Build Coastguard Worker const webrtc::CryptoOptions& crypto_options, 413*d9f75844SAndroid Build Coastguard Worker std::vector<std::string>* crypto_suite_names); 414*d9f75844SAndroid Build Coastguard Worker void GetSupportedVideoSdesCryptoSuiteNames( 415*d9f75844SAndroid Build Coastguard Worker const webrtc::CryptoOptions& crypto_options, 416*d9f75844SAndroid Build Coastguard Worker std::vector<std::string>* crypto_suite_names); 417*d9f75844SAndroid Build Coastguard Worker void GetSupportedDataSdesCryptoSuiteNames( 418*d9f75844SAndroid Build Coastguard Worker const webrtc::CryptoOptions& crypto_options, 419*d9f75844SAndroid Build Coastguard Worker std::vector<std::string>* crypto_suite_names); 420*d9f75844SAndroid Build Coastguard Worker 421*d9f75844SAndroid Build Coastguard Worker } // namespace cricket 422*d9f75844SAndroid Build Coastguard Worker 423*d9f75844SAndroid Build Coastguard Worker #endif // PC_MEDIA_SESSION_H_ 424