OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 std::stringstream out; | 631 std::stringstream out; |
632 const std::vector<VideoCodec>& codecs = | 632 const std::vector<VideoCodec>& codecs = |
633 external_encoder_factory->supported_codecs(); | 633 external_encoder_factory->supported_codecs(); |
634 for (size_t i = 0; i < codecs.size(); ++i) { | 634 for (size_t i = 0; i < codecs.size(); ++i) { |
635 VideoCodec codec = codecs[i]; | 635 VideoCodec codec = codecs[i]; |
636 out << codec.name; | 636 out << codec.name; |
637 if (i != codecs.size() - 1) { | 637 if (i != codecs.size() - 1) { |
638 out << ", "; | 638 out << ", "; |
639 } | 639 } |
640 // Don't add internally-supported codecs twice. | 640 // Don't add internally-supported codecs twice. |
641 if (IsCodecSupported(supported_codecs, codec)) | 641 if (FindMatchingCodec(supported_codecs, codec)) |
642 continue; | 642 continue; |
643 | 643 |
644 // External video encoders are given payloads 120-127. This also means that | 644 // External video encoders are given payloads 120-127. This also means that |
645 // we only support up to 8 external payload types. | 645 // we only support up to 8 external payload types. |
646 // TODO(deadbeef): mediasession.cc already has code to dynamically | 646 // TODO(deadbeef): mediasession.cc already has code to dynamically |
647 // determine a payload type. We should be able to just leave the payload | 647 // determine a payload type. We should be able to just leave the payload |
648 // type empty and let mediasession determine it. However, currently RTX | 648 // type empty and let mediasession determine it. However, currently RTX |
649 // codecs are associated to codecs by payload type, meaning we DO need | 649 // codecs are associated to codecs by payload type, meaning we DO need |
650 // to allocate unique payload types here. So to make this change we would | 650 // to allocate unique payload types here. So to make this change we would |
651 // need to make RTX codecs associated by name instead. | 651 // need to make RTX codecs associated by name instead. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 delete kv.second; | 692 delete kv.second; |
693 } | 693 } |
694 | 694 |
695 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings> | 695 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings> |
696 WebRtcVideoChannel2::SelectSendVideoCodec( | 696 WebRtcVideoChannel2::SelectSendVideoCodec( |
697 const std::vector<VideoCodecSettings>& remote_mapped_codecs) const { | 697 const std::vector<VideoCodecSettings>& remote_mapped_codecs) const { |
698 const std::vector<VideoCodec> local_supported_codecs = | 698 const std::vector<VideoCodec> local_supported_codecs = |
699 GetSupportedCodecs(external_encoder_factory_); | 699 GetSupportedCodecs(external_encoder_factory_); |
700 // Select the first remote codec that is supported locally. | 700 // Select the first remote codec that is supported locally. |
701 for (const VideoCodecSettings& remote_mapped_codec : remote_mapped_codecs) { | 701 for (const VideoCodecSettings& remote_mapped_codec : remote_mapped_codecs) { |
702 if (IsCodecSupported(local_supported_codecs, remote_mapped_codec.codec)) | 702 // For H264, we will limit the encode level to the remote offered level |
| 703 // regardless if level asymmetry is allowed or not. This is strictly not |
| 704 // following the spec in https://tools.ietf.org/html/rfc6184#section-8.2.2 |
| 705 // since we should limit the encode level to the lower of local and remote |
| 706 // level when level asymmetry is not allowed. |
| 707 if (FindMatchingCodec(local_supported_codecs, remote_mapped_codec.codec)) |
703 return rtc::Optional<VideoCodecSettings>(remote_mapped_codec); | 708 return rtc::Optional<VideoCodecSettings>(remote_mapped_codec); |
704 } | 709 } |
705 // No remote codec was supported. | 710 // No remote codec was supported. |
706 return rtc::Optional<VideoCodecSettings>(); | 711 return rtc::Optional<VideoCodecSettings>(); |
707 } | 712 } |
708 | 713 |
709 bool WebRtcVideoChannel2::ReceiveCodecsHaveChanged( | 714 bool WebRtcVideoChannel2::ReceiveCodecsHaveChanged( |
710 std::vector<VideoCodecSettings> before, | 715 std::vector<VideoCodecSettings> before, |
711 std::vector<VideoCodecSettings> after) { | 716 std::vector<VideoCodecSettings> after) { |
712 if (before.size() != after.size()) { | 717 if (before.size() != after.size()) { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 MapCodecs(params.codecs); | 953 MapCodecs(params.codecs); |
949 if (mapped_codecs.empty()) { | 954 if (mapped_codecs.empty()) { |
950 LOG(LS_ERROR) << "SetRecvParameters called without any video codecs."; | 955 LOG(LS_ERROR) << "SetRecvParameters called without any video codecs."; |
951 return false; | 956 return false; |
952 } | 957 } |
953 | 958 |
954 // Verify that every mapped codec is supported locally. | 959 // Verify that every mapped codec is supported locally. |
955 const std::vector<VideoCodec> local_supported_codecs = | 960 const std::vector<VideoCodec> local_supported_codecs = |
956 GetSupportedCodecs(external_encoder_factory_); | 961 GetSupportedCodecs(external_encoder_factory_); |
957 for (const VideoCodecSettings& mapped_codec : mapped_codecs) { | 962 for (const VideoCodecSettings& mapped_codec : mapped_codecs) { |
958 if (!IsCodecSupported(local_supported_codecs, mapped_codec.codec)) { | 963 if (!FindMatchingCodec(local_supported_codecs, mapped_codec.codec)) { |
959 LOG(LS_ERROR) << "SetRecvParameters called with unsupported video codec: " | 964 LOG(LS_ERROR) << "SetRecvParameters called with unsupported video codec: " |
960 << mapped_codec.codec.ToString(); | 965 << mapped_codec.codec.ToString(); |
961 return false; | 966 return false; |
962 } | 967 } |
963 } | 968 } |
964 | 969 |
965 if (ReceiveCodecsHaveChanged(recv_codecs_, mapped_codecs)) { | 970 if (ReceiveCodecsHaveChanged(recv_codecs_, mapped_codecs)) { |
966 changed_params->codec_settings = | 971 changed_params->codec_settings = |
967 rtc::Optional<std::vector<VideoCodecSettings>>(mapped_codecs); | 972 rtc::Optional<std::vector<VideoCodecSettings>>(mapped_codecs); |
968 } | 973 } |
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2547 rtx_mapping[video_codecs[i].codec.id] != | 2552 rtx_mapping[video_codecs[i].codec.id] != |
2548 ulpfec_config.red_payload_type) { | 2553 ulpfec_config.red_payload_type) { |
2549 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2554 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2550 } | 2555 } |
2551 } | 2556 } |
2552 | 2557 |
2553 return video_codecs; | 2558 return video_codecs; |
2554 } | 2559 } |
2555 | 2560 |
2556 } // namespace cricket | 2561 } // namespace cricket |
OLD | NEW |