Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: webrtc/pc/mediasession.h

Issue 3001083002: Revert of Adding support for Unified Plan offer/answer negotiation. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/pc/mediasession.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 RtpTransceiverDirection Reversed() const { 96 RtpTransceiverDirection Reversed() const {
97 return RtpTransceiverDirection(recv, send); 97 return RtpTransceiverDirection(recv, send);
98 } 98 }
99 }; 99 };
100 100
101 RtpTransceiverDirection 101 RtpTransceiverDirection
102 NegotiateRtpTransceiverDirection(RtpTransceiverDirection offer, 102 NegotiateRtpTransceiverDirection(RtpTransceiverDirection offer,
103 RtpTransceiverDirection wants); 103 RtpTransceiverDirection wants);
104 104
105 // Options for an RtpSender contained with an media description/"m=" section. 105 struct MediaSessionOptions {
106 struct SenderOptions { 106 MediaSessionOptions()
107 std::string track_id; 107 : recv_audio(true),
108 std::string stream_id; 108 recv_video(false),
109 int num_sim_layers; 109 data_channel_type(DCT_NONE),
110 }; 110 is_muc(false),
111 vad_enabled(true), // When disabled, removes all CN codecs from SDP.
112 rtcp_mux_enabled(true),
113 bundle_enabled(false),
114 video_bandwidth(kAutoBandwidth),
115 data_bandwidth(kDataMaxBandwidth),
116 rtcp_cname(kDefaultRtcpCname) {}
111 117
112 // Options for an individual media description/"m=" section. 118 bool has_audio() const {
113 struct MediaDescriptionOptions { 119 return recv_audio || HasSendMediaStream(MEDIA_TYPE_AUDIO);
114 MediaDescriptionOptions(MediaType type, 120 }
115 const std::string& mid, 121 bool has_video() const {
116 RtpTransceiverDirection direction, 122 return recv_video || HasSendMediaStream(MEDIA_TYPE_VIDEO);
117 bool stopped) 123 }
118 : type(type), mid(mid), direction(direction), stopped(stopped) {} 124 bool has_data() const { return data_channel_type != DCT_NONE; }
119 125
120 // TODO(deadbeef): When we don't support Plan B, there will only be one 126 // Add a stream with MediaType type and id.
121 // sender per media description and this can be simplified. 127 // All streams with the same sync_label will get the same CNAME.
122 void AddAudioSender(const std::string& track_id, 128 // All ids must be unique.
123 const std::string& stream_id); 129 void AddSendStream(MediaType type,
124 void AddVideoSender(const std::string& track_id, 130 const std::string& id,
125 const std::string& stream_id, 131 const std::string& sync_label);
132 void AddSendVideoStream(const std::string& id,
133 const std::string& sync_label,
126 int num_sim_layers); 134 int num_sim_layers);
135 void RemoveSendStream(MediaType type, const std::string& id);
127 136
128 // Internally just uses sender_options.
129 void AddRtpDataChannel(const std::string& track_id,
130 const std::string& stream_id);
131 137
132 MediaType type; 138 // Helper function.
133 std::string mid; 139 void AddSendStreamInternal(MediaType type,
134 RtpTransceiverDirection direction; 140 const std::string& id,
135 bool stopped; 141 const std::string& sync_label,
136 TransportOptions transport_options; 142 int num_sim_layers);
137 // Note: There's no equivalent "RtpReceiverOptions" because only send
138 // stream information goes in the local descriptions.
139 std::vector<SenderOptions> sender_options;
140 143
141 private: 144 bool HasSendMediaStream(MediaType type) const;
142 // Doesn't DCHECK on |type|.
143 void AddSenderInternal(const std::string& track_id,
144 const std::string& stream_id,
145 int num_sim_layers);
146 };
147 145
148 // Provides a mechanism for describing how m= sections should be generated. 146 // TODO(deadbeef): Put all the audio/video/data-specific options into a map
149 // The m= section with index X will use media_description_options[X]. There 147 // structure (content name -> options).
150 // must be an option for each existing section if creating an answer, or a 148 // MediaSessionDescriptionFactory assumes there will never be more than one
151 // subsequent offer. 149 // audio/video/data content, but this will change with unified plan.
152 struct MediaSessionOptions { 150 bool recv_audio;
153 MediaSessionOptions() {} 151 bool recv_video;
152 DataChannelType data_channel_type;
153 bool is_muc;
154 bool vad_enabled;
155 bool rtcp_mux_enabled;
156 bool bundle_enabled;
157 // bps. -1 == auto.
158 int video_bandwidth;
159 int data_bandwidth;
160 bool enable_ice_renomination = false;
161 // content name ("mid") => options.
162 std::map<std::string, TransportOptions> transport_options;
163 std::string rtcp_cname;
164 rtc::CryptoOptions crypto_options;
154 165
155 bool has_audio() const { return HasMediaDescription(MEDIA_TYPE_AUDIO); } 166 struct Stream {
156 bool has_video() const { return HasMediaDescription(MEDIA_TYPE_VIDEO); } 167 Stream(MediaType type,
157 bool has_data() const { return HasMediaDescription(MEDIA_TYPE_DATA); } 168 const std::string& id,
169 const std::string& sync_label,
170 int num_sim_layers)
171 : type(type), id(id), sync_label(sync_label),
172 num_sim_layers(num_sim_layers) {
173 }
174 MediaType type;
175 std::string id;
176 std::string sync_label;
177 int num_sim_layers;
178 };
158 179
159 bool HasMediaDescription(MediaType type) const; 180 typedef std::vector<Stream> Streams;
160 181 Streams streams;
161 DataChannelType data_channel_type = DCT_NONE;
162 bool is_muc = false;
163 bool vad_enabled = true; // When disabled, removes all CN codecs from SDP.
164 bool rtcp_mux_enabled = true;
165 bool bundle_enabled = false;
166 std::string rtcp_cname = kDefaultRtcpCname;
167 rtc::CryptoOptions crypto_options;
168 // List of media description options in the same order that the media
169 // descriptions will be generated.
170 std::vector<MediaDescriptionOptions> media_description_options;
171 }; 182 };
172 183
173 // "content" (as used in XEP-0166) descriptions for voice and video. 184 // "content" (as used in XEP-0166) descriptions for voice and video.
174 class MediaContentDescription : public ContentDescription { 185 class MediaContentDescription : public ContentDescription {
175 public: 186 public:
176 MediaContentDescription() {} 187 MediaContentDescription() {}
177 188
178 virtual MediaType type() const = 0; 189 virtual MediaType type() const = 0;
179 virtual bool has_codecs() const = 0; 190 virtual bool has_codecs() const = 0;
180 191
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // Legacy streams have an ssrc, but nothing else. 270 // Legacy streams have an ssrc, but nothing else.
260 void AddLegacyStream(uint32_t ssrc) { 271 void AddLegacyStream(uint32_t ssrc) {
261 streams_.push_back(StreamParams::CreateLegacy(ssrc)); 272 streams_.push_back(StreamParams::CreateLegacy(ssrc));
262 } 273 }
263 void AddLegacyStream(uint32_t ssrc, uint32_t fid_ssrc) { 274 void AddLegacyStream(uint32_t ssrc, uint32_t fid_ssrc) {
264 StreamParams sp = StreamParams::CreateLegacy(ssrc); 275 StreamParams sp = StreamParams::CreateLegacy(ssrc);
265 sp.AddFidSsrc(ssrc, fid_ssrc); 276 sp.AddFidSsrc(ssrc, fid_ssrc);
266 streams_.push_back(sp); 277 streams_.push_back(sp);
267 } 278 }
268 // Sets the CNAME of all StreamParams if it have not been set. 279 // Sets the CNAME of all StreamParams if it have not been set.
280 // This can be used to set the CNAME of legacy streams.
269 void SetCnameIfEmpty(const std::string& cname) { 281 void SetCnameIfEmpty(const std::string& cname) {
270 for (cricket::StreamParamsVec::iterator it = streams_.begin(); 282 for (cricket::StreamParamsVec::iterator it = streams_.begin();
271 it != streams_.end(); ++it) { 283 it != streams_.end(); ++it) {
272 if (it->cname.empty()) 284 if (it->cname.empty())
273 it->cname = cname; 285 it->cname = cname;
274 } 286 }
275 } 287 }
276 uint32_t first_ssrc() const { 288 uint32_t first_ssrc() const {
277 if (streams_.empty()) { 289 if (streams_.empty()) {
278 return 0; 290 return 0;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 void set_video_rtp_header_extensions(const RtpHeaderExtensions& extensions) { 462 void set_video_rtp_header_extensions(const RtpHeaderExtensions& extensions) {
451 video_rtp_extensions_ = extensions; 463 video_rtp_extensions_ = extensions;
452 } 464 }
453 const RtpHeaderExtensions& video_rtp_header_extensions() const { 465 const RtpHeaderExtensions& video_rtp_header_extensions() const {
454 return video_rtp_extensions_; 466 return video_rtp_extensions_;
455 } 467 }
456 const DataCodecs& data_codecs() const { return data_codecs_; } 468 const DataCodecs& data_codecs() const { return data_codecs_; }
457 void set_data_codecs(const DataCodecs& codecs) { data_codecs_ = codecs; } 469 void set_data_codecs(const DataCodecs& codecs) { data_codecs_ = codecs; }
458 SecurePolicy secure() const { return secure_; } 470 SecurePolicy secure() const { return secure_; }
459 void set_secure(SecurePolicy s) { secure_ = s; } 471 void set_secure(SecurePolicy s) { secure_ = s; }
472 // Decides if a StreamParams shall be added to the audio and video media
473 // content in SessionDescription when CreateOffer and CreateAnswer is called
474 // even if |options| don't include a Stream. This is needed to support legacy
475 // applications. |add_legacy_| is true per default.
476 void set_add_legacy_streams(bool add_legacy) { add_legacy_ = add_legacy; }
460 477
461 void set_enable_encrypted_rtp_header_extensions(bool enable) { 478 void set_enable_encrypted_rtp_header_extensions(bool enable) {
462 enable_encrypted_rtp_header_extensions_ = enable; 479 enable_encrypted_rtp_header_extensions_ = enable;
463 } 480 }
464 481
465 SessionDescription* CreateOffer( 482 SessionDescription* CreateOffer(
466 const MediaSessionOptions& options, 483 const MediaSessionOptions& options,
467 const SessionDescription* current_description) const; 484 const SessionDescription* current_description) const;
468 SessionDescription* CreateAnswer( 485 SessionDescription* CreateAnswer(
469 const SessionDescription* offer, 486 const SessionDescription* offer,
470 const MediaSessionOptions& options, 487 const MediaSessionOptions& options,
471 const SessionDescription* current_description) const; 488 const SessionDescription* current_description) const;
472 489
473 private: 490 private:
474 const AudioCodecs& GetAudioCodecsForOffer( 491 const AudioCodecs& GetAudioCodecsForOffer(
475 const RtpTransceiverDirection& direction) const; 492 const RtpTransceiverDirection& direction) const;
476 const AudioCodecs& GetAudioCodecsForAnswer( 493 const AudioCodecs& GetAudioCodecsForAnswer(
477 const RtpTransceiverDirection& offer, 494 const RtpTransceiverDirection& offer,
478 const RtpTransceiverDirection& answer) const; 495 const RtpTransceiverDirection& answer) const;
479 void GetCodecsForOffer(const SessionDescription* current_description, 496 void GetCodecsToOffer(const SessionDescription* current_description,
480 AudioCodecs* audio_codecs, 497 const AudioCodecs& supported_audio_codecs,
481 VideoCodecs* video_codecs, 498 const VideoCodecs& supported_video_codecs,
482 DataCodecs* data_codecs) const; 499 const DataCodecs& supported_data_codecs,
483 void GetCodecsForAnswer(const SessionDescription* current_description, 500 AudioCodecs* audio_codecs,
484 const SessionDescription* remote_offer, 501 VideoCodecs* video_codecs,
485 AudioCodecs* audio_codecs, 502 DataCodecs* data_codecs) const;
486 VideoCodecs* video_codecs,
487 DataCodecs* data_codecs) const;
488 void GetRtpHdrExtsToOffer(const SessionDescription* current_description, 503 void GetRtpHdrExtsToOffer(const SessionDescription* current_description,
489 RtpHeaderExtensions* audio_extensions, 504 RtpHeaderExtensions* audio_extensions,
490 RtpHeaderExtensions* video_extensions) const; 505 RtpHeaderExtensions* video_extensions) const;
491 bool AddTransportOffer( 506 bool AddTransportOffer(
492 const std::string& content_name, 507 const std::string& content_name,
493 const TransportOptions& transport_options, 508 const TransportOptions& transport_options,
494 const SessionDescription* current_desc, 509 const SessionDescription* current_desc,
495 SessionDescription* offer) const; 510 SessionDescription* offer) const;
496 511
497 TransportDescription* CreateTransportAnswer( 512 TransportDescription* CreateTransportAnswer(
498 const std::string& content_name, 513 const std::string& content_name,
499 const SessionDescription* offer_desc, 514 const SessionDescription* offer_desc,
500 const TransportOptions& transport_options, 515 const TransportOptions& transport_options,
501 const SessionDescription* current_desc, 516 const SessionDescription* current_desc,
502 bool require_transport_attributes) const; 517 bool require_transport_attributes) const;
503 518
504 bool AddTransportAnswer( 519 bool AddTransportAnswer(
505 const std::string& content_name, 520 const std::string& content_name,
506 const TransportDescription& transport_desc, 521 const TransportDescription& transport_desc,
507 SessionDescription* answer_desc) const; 522 SessionDescription* answer_desc) const;
508 523
509 // Helpers for adding media contents to the SessionDescription. Returns true 524 // Helpers for adding media contents to the SessionDescription. Returns true
510 // it succeeds or the media content is not needed, or false if there is any 525 // it succeeds or the media content is not needed, or false if there is any
511 // error. 526 // error.
512 527
513 bool AddAudioContentForOffer( 528 bool AddAudioContentForOffer(
514 const MediaDescriptionOptions& media_description_options, 529 const MediaSessionOptions& options,
515 const MediaSessionOptions& session_options,
516 const ContentInfo* current_content,
517 const SessionDescription* current_description, 530 const SessionDescription* current_description,
518 const RtpHeaderExtensions& audio_rtp_extensions, 531 const RtpHeaderExtensions& audio_rtp_extensions,
519 const AudioCodecs& audio_codecs, 532 const AudioCodecs& audio_codecs,
520 StreamParamsVec* current_streams, 533 StreamParamsVec* current_streams,
521 SessionDescription* desc) const; 534 SessionDescription* desc) const;
522 535
523 bool AddVideoContentForOffer( 536 bool AddVideoContentForOffer(
524 const MediaDescriptionOptions& media_description_options, 537 const MediaSessionOptions& options,
525 const MediaSessionOptions& session_options,
526 const ContentInfo* current_content,
527 const SessionDescription* current_description, 538 const SessionDescription* current_description,
528 const RtpHeaderExtensions& video_rtp_extensions, 539 const RtpHeaderExtensions& video_rtp_extensions,
529 const VideoCodecs& video_codecs, 540 const VideoCodecs& video_codecs,
530 StreamParamsVec* current_streams, 541 StreamParamsVec* current_streams,
531 SessionDescription* desc) const; 542 SessionDescription* desc) const;
532 543
533 bool AddDataContentForOffer( 544 bool AddDataContentForOffer(
534 const MediaDescriptionOptions& media_description_options, 545 const MediaSessionOptions& options,
535 const MediaSessionOptions& session_options,
536 const ContentInfo* current_content,
537 const SessionDescription* current_description, 546 const SessionDescription* current_description,
538 const DataCodecs& data_codecs, 547 DataCodecs* data_codecs,
539 StreamParamsVec* current_streams, 548 StreamParamsVec* current_streams,
540 SessionDescription* desc) const; 549 SessionDescription* desc) const;
541 550
542 bool AddAudioContentForAnswer( 551 bool AddAudioContentForAnswer(const SessionDescription* offer,
543 const MediaDescriptionOptions& media_description_options, 552 const MediaSessionOptions& options,
544 const MediaSessionOptions& session_options, 553 const SessionDescription* current_description,
545 const ContentInfo* offer_content, 554 const TransportInfo* bundle_transport,
546 const SessionDescription* offer_description, 555 StreamParamsVec* current_streams,
547 const ContentInfo* current_content, 556 SessionDescription* answer) const;
548 const SessionDescription* current_description,
549 const TransportInfo* bundle_transport,
550 const AudioCodecs& audio_codecs,
551 StreamParamsVec* current_streams,
552 SessionDescription* answer) const;
553 557
554 bool AddVideoContentForAnswer( 558 bool AddVideoContentForAnswer(const SessionDescription* offer,
555 const MediaDescriptionOptions& media_description_options, 559 const MediaSessionOptions& options,
556 const MediaSessionOptions& session_options, 560 const SessionDescription* current_description,
557 const ContentInfo* offer_content, 561 const TransportInfo* bundle_transport,
558 const SessionDescription* offer_description, 562 StreamParamsVec* current_streams,
559 const ContentInfo* current_content, 563 SessionDescription* answer) const;
560 const SessionDescription* current_description,
561 const TransportInfo* bundle_transport,
562 const VideoCodecs& video_codecs,
563 StreamParamsVec* current_streams,
564 SessionDescription* answer) const;
565 564
566 bool AddDataContentForAnswer( 565 bool AddDataContentForAnswer(const SessionDescription* offer,
567 const MediaDescriptionOptions& media_description_options, 566 const MediaSessionOptions& options,
568 const MediaSessionOptions& session_options, 567 const SessionDescription* current_description,
569 const ContentInfo* offer_content, 568 const TransportInfo* bundle_transport,
570 const SessionDescription* offer_description, 569 StreamParamsVec* current_streams,
571 const ContentInfo* current_content, 570 SessionDescription* answer) const;
572 const SessionDescription* current_description,
573 const TransportInfo* bundle_transport,
574 const DataCodecs& data_codecs,
575 StreamParamsVec* current_streams,
576 SessionDescription* answer) const;
577
578 void ComputeAudioCodecsIntersectionAndUnion();
579 571
580 AudioCodecs audio_send_codecs_; 572 AudioCodecs audio_send_codecs_;
581 AudioCodecs audio_recv_codecs_; 573 AudioCodecs audio_recv_codecs_;
582 // Intersection of send and recv.
583 AudioCodecs audio_sendrecv_codecs_; 574 AudioCodecs audio_sendrecv_codecs_;
584 // Union of send and recv.
585 AudioCodecs all_audio_codecs_;
586 RtpHeaderExtensions audio_rtp_extensions_; 575 RtpHeaderExtensions audio_rtp_extensions_;
587 VideoCodecs video_codecs_; 576 VideoCodecs video_codecs_;
588 RtpHeaderExtensions video_rtp_extensions_; 577 RtpHeaderExtensions video_rtp_extensions_;
589 DataCodecs data_codecs_; 578 DataCodecs data_codecs_;
579 SecurePolicy secure_;
580 bool add_legacy_;
590 bool enable_encrypted_rtp_header_extensions_ = false; 581 bool enable_encrypted_rtp_header_extensions_ = false;
591 // TODO(zhihuang): Rename secure_ to sdec_policy_; rename the related getter
592 // and setter.
593 SecurePolicy secure_ = SEC_DISABLED;
594 std::string lang_; 582 std::string lang_;
595 const TransportDescriptionFactory* transport_desc_factory_; 583 const TransportDescriptionFactory* transport_desc_factory_;
596 }; 584 };
597 585
598 // Convenience functions. 586 // Convenience functions.
599 bool IsMediaContent(const ContentInfo* content); 587 bool IsMediaContent(const ContentInfo* content);
600 bool IsAudioContent(const ContentInfo* content); 588 bool IsAudioContent(const ContentInfo* content);
601 bool IsVideoContent(const ContentInfo* content); 589 bool IsVideoContent(const ContentInfo* content);
602 bool IsDataContent(const ContentInfo* content); 590 bool IsDataContent(const ContentInfo* content);
603 const ContentInfo* GetFirstMediaContent(const ContentInfos& contents, 591 const ContentInfo* GetFirstMediaContent(const ContentInfos& contents,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 void GetSupportedVideoSdesCryptoSuiteNames( 631 void GetSupportedVideoSdesCryptoSuiteNames(
644 const rtc::CryptoOptions& crypto_options, 632 const rtc::CryptoOptions& crypto_options,
645 std::vector<std::string>* crypto_suite_names); 633 std::vector<std::string>* crypto_suite_names);
646 void GetSupportedDataSdesCryptoSuiteNames( 634 void GetSupportedDataSdesCryptoSuiteNames(
647 const rtc::CryptoOptions& crypto_options, 635 const rtc::CryptoOptions& crypto_options,
648 std::vector<std::string>* crypto_suite_names); 636 std::vector<std::string>* crypto_suite_names);
649 637
650 } // namespace cricket 638 } // namespace cricket
651 639
652 #endif // WEBRTC_PC_MEDIASESSION_H_ 640 #endif // WEBRTC_PC_MEDIASESSION_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/pc/mediasession.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698