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. |
| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 return false; | 683 return false; |
666 } | 684 } |
667 media_desc->set_cryptos(common_cryptos); | 685 media_desc->set_cryptos(common_cryptos); |
668 } | 686 } |
669 } | 687 } |
670 return true; | 688 return true; |
671 } | 689 } |
672 | 690 |
673 template <class C> | 691 template <class C> |
674 static bool ContainsRtxCodec(const std::vector<C>& codecs) { | 692 static bool ContainsRtxCodec(const std::vector<C>& codecs) { |
675 typename std::vector<C>::const_iterator it; | 693 for (const auto& codec : codecs) { |
676 for (it = codecs.begin(); it != codecs.end(); ++it) { | 694 if (IsRtxCodec(codec)) { |
677 if (IsRtxCodec(*it)) { | |
678 return true; | 695 return true; |
679 } | 696 } |
680 } | 697 } |
681 return false; | 698 return false; |
682 } | 699 } |
683 | 700 |
684 template <class C> | 701 template <class C> |
685 static bool IsRtxCodec(const C& codec) { | 702 static bool IsRtxCodec(const C& codec) { |
686 return stricmp(codec.name.c_str(), kRtxCodecName) == 0; | 703 return stricmp(codec.name.c_str(), kRtxCodecName) == 0; |
687 } | 704 } |
688 | 705 |
| 706 template <class C> |
| 707 static bool ContainsFlexfecCodec(const std::vector<C>& codecs) { |
| 708 for (const auto& codec : codecs) { |
| 709 if (IsFlexfecCodec(codec)) { |
| 710 return true; |
| 711 } |
| 712 } |
| 713 return false; |
| 714 } |
| 715 |
| 716 template <class C> |
| 717 static bool IsFlexfecCodec(const C& codec) { |
| 718 return stricmp(codec.name.c_str(), kFlexfecCodecName) == 0; |
| 719 } |
| 720 |
689 static TransportOptions GetTransportOptions(const MediaSessionOptions& options, | 721 static TransportOptions GetTransportOptions(const MediaSessionOptions& options, |
690 const std::string& content_name) { | 722 const std::string& content_name) { |
691 TransportOptions transport_options; | 723 TransportOptions transport_options; |
692 auto it = options.transport_options.find(content_name); | 724 auto it = options.transport_options.find(content_name); |
693 if (it != options.transport_options.end()) { | 725 if (it != options.transport_options.end()) { |
694 transport_options = it->second; | 726 transport_options = it->second; |
695 } | 727 } |
696 transport_options.enable_ice_renomination = options.enable_ice_renomination; | 728 transport_options.enable_ice_renomination = options.enable_ice_renomination; |
697 return transport_options; | 729 return transport_options; |
698 } | 730 } |
(...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2158 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); | 2190 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
2159 } | 2191 } |
2160 | 2192 |
2161 DataContentDescription* GetFirstDataContentDescription( | 2193 DataContentDescription* GetFirstDataContentDescription( |
2162 SessionDescription* sdesc) { | 2194 SessionDescription* sdesc) { |
2163 return static_cast<DataContentDescription*>( | 2195 return static_cast<DataContentDescription*>( |
2164 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 2196 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
2165 } | 2197 } |
2166 | 2198 |
2167 } // namespace cricket | 2199 } // namespace cricket |
OLD | NEW |