OLD | NEW |
---|---|
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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 GenerateSsrcs(*current_streams, num_ssrcs, &ssrcs); | 439 GenerateSsrcs(*current_streams, num_ssrcs, &ssrcs); |
440 if (include_rtx_streams) { | 440 if (include_rtx_streams) { |
441 content_description->AddLegacyStream(ssrcs[0], ssrcs[1]); | 441 content_description->AddLegacyStream(ssrcs[0], ssrcs[1]); |
442 content_description->set_multistream(true); | 442 content_description->set_multistream(true); |
443 } else { | 443 } else { |
444 content_description->AddLegacyStream(ssrcs[0]); | 444 content_description->AddLegacyStream(ssrcs[0]); |
445 } | 445 } |
446 return true; | 446 return true; |
447 } | 447 } |
448 | 448 |
449 const bool include_flexfec_stream = | |
450 ContainsFlexfecCodec(content_description->codecs()); | |
451 | |
449 MediaSessionOptions::Streams::const_iterator stream_it; | 452 MediaSessionOptions::Streams::const_iterator stream_it; |
450 for (stream_it = streams.begin(); | 453 for (stream_it = streams.begin(); |
451 stream_it != streams.end(); ++stream_it) { | 454 stream_it != streams.end(); ++stream_it) { |
452 if (stream_it->type != media_type) | 455 if (stream_it->type != media_type) |
453 continue; // Wrong media type. | 456 continue; // Wrong media type. |
454 | 457 |
455 const StreamParams* param = | 458 const StreamParams* param = |
456 GetStreamByIds(*current_streams, "", stream_it->id); | 459 GetStreamByIds(*current_streams, "", stream_it->id); |
457 // groupid is empty for StreamParams generated using | 460 // groupid is empty for StreamParams generated using |
458 // MediaSessionDescriptionFactory. | 461 // MediaSessionDescriptionFactory. |
(...skipping 15 matching lines...) Expand all Loading... | |
474 if (include_rtx_streams) { | 477 if (include_rtx_streams) { |
475 // Generate an RTX ssrc for every ssrc in the group. | 478 // Generate an RTX ssrc for every ssrc in the group. |
476 std::vector<uint32_t> rtx_ssrcs; | 479 std::vector<uint32_t> rtx_ssrcs; |
477 GenerateSsrcs(*current_streams, static_cast<int>(ssrcs.size()), | 480 GenerateSsrcs(*current_streams, static_cast<int>(ssrcs.size()), |
478 &rtx_ssrcs); | 481 &rtx_ssrcs); |
479 for (size_t i = 0; i < ssrcs.size(); ++i) { | 482 for (size_t i = 0; i < ssrcs.size(); ++i) { |
480 stream_param.AddFidSsrc(ssrcs[i], rtx_ssrcs[i]); | 483 stream_param.AddFidSsrc(ssrcs[i], rtx_ssrcs[i]); |
481 } | 484 } |
482 content_description->set_multistream(true); | 485 content_description->set_multistream(true); |
483 } | 486 } |
487 // Generate extra ssrc for include_flexfec_stream case. | |
488 if (include_flexfec_stream) { | |
489 // TODO(brandtr): Update when we support multistream protection. | |
perkj_webrtc
2016/11/17 20:41:12
No support for Simulcast?
brandtr
2016/11/21 09:16:30
No :( This is not too hard to add though, so it ma
| |
490 if (ssrcs.size() == 1) { | |
491 std::vector<uint32_t> flexfec_ssrcs; | |
492 GenerateSsrcs(*current_streams, 1, &flexfec_ssrcs); | |
493 stream_param.AddFecFrSsrc(ssrcs[0], flexfec_ssrcs[0]); | |
494 content_description->set_multistream(true); | |
495 } else if (!ssrcs.empty()) { | |
496 LOG(LS_WARNING) | |
497 << "Our FlexFEC implementation only supports protecting " | |
498 << "a single media streams. This session has multiple " | |
499 << "media streams however, so no FlexFEC SSRC will be generated."; | |
500 } | |
501 } | |
484 stream_param.cname = options.rtcp_cname; | 502 stream_param.cname = options.rtcp_cname; |
485 stream_param.sync_label = stream_it->sync_label; | 503 stream_param.sync_label = stream_it->sync_label; |
486 content_description->AddStream(stream_param); | 504 content_description->AddStream(stream_param); |
487 | 505 |
488 // Store the new StreamParams in current_streams. | 506 // Store the new StreamParams in current_streams. |
489 // This is necessary so that we can use the CNAME for other media types. | 507 // This is necessary so that we can use the CNAME for other media types. |
490 current_streams->push_back(stream_param); | 508 current_streams->push_back(stream_param); |
491 } else { | 509 } else { |
492 content_description->AddStream(*param); | 510 content_description->AddStream(*param); |
493 } | 511 } |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
679 } | 697 } |
680 } | 698 } |
681 return false; | 699 return false; |
682 } | 700 } |
683 | 701 |
684 template <class C> | 702 template <class C> |
685 static bool IsRtxCodec(const C& codec) { | 703 static bool IsRtxCodec(const C& codec) { |
686 return stricmp(codec.name.c_str(), kRtxCodecName) == 0; | 704 return stricmp(codec.name.c_str(), kRtxCodecName) == 0; |
687 } | 705 } |
688 | 706 |
707 template <class C> | |
708 static bool ContainsFlexfecCodec(const std::vector<C>& codecs) { | |
709 typename std::vector<C>::const_iterator it; | |
710 for (it = codecs.begin(); it != codecs.end(); ++it) { | |
perkj_webrtc
2016/11/17 20:41:12
const auto& codec : codecs ?
brandtr
2016/11/21 09:16:30
Done.
| |
711 if (IsFlexfecCodec(*it)) { | |
712 return true; | |
713 } | |
714 } | |
715 return false; | |
716 } | |
717 | |
718 template <class C> | |
719 static bool IsFlexfecCodec(const C& codec) { | |
720 return stricmp(codec.name.c_str(), kFlexfecCodecName) == 0; | |
721 } | |
722 | |
689 static TransportOptions GetTransportOptions(const MediaSessionOptions& options, | 723 static TransportOptions GetTransportOptions(const MediaSessionOptions& options, |
690 const std::string& content_name) { | 724 const std::string& content_name) { |
691 TransportOptions transport_options; | 725 TransportOptions transport_options; |
692 auto it = options.transport_options.find(content_name); | 726 auto it = options.transport_options.find(content_name); |
693 if (it != options.transport_options.end()) { | 727 if (it != options.transport_options.end()) { |
694 transport_options = it->second; | 728 transport_options = it->second; |
695 } | 729 } |
696 transport_options.enable_ice_renomination = options.enable_ice_renomination; | 730 transport_options.enable_ice_renomination = options.enable_ice_renomination; |
697 return transport_options; | 731 return transport_options; |
698 } | 732 } |
(...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2158 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); | 2192 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
2159 } | 2193 } |
2160 | 2194 |
2161 DataContentDescription* GetFirstDataContentDescription( | 2195 DataContentDescription* GetFirstDataContentDescription( |
2162 SessionDescription* sdesc) { | 2196 SessionDescription* sdesc) { |
2163 return static_cast<DataContentDescription*>( | 2197 return static_cast<DataContentDescription*>( |
2164 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 2198 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
2165 } | 2199 } |
2166 | 2200 |
2167 } // namespace cricket | 2201 } // namespace cricket |
OLD | NEW |