| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 external_encoder_factory_(external_encoder_factory), | 648 external_encoder_factory_(external_encoder_factory), |
| 649 external_decoder_factory_(external_decoder_factory) { | 649 external_decoder_factory_(external_decoder_factory) { |
| 650 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 650 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 651 SetDefaultOptions(); | 651 SetDefaultOptions(); |
| 652 options_.SetAll(options); | 652 options_.SetAll(options); |
| 653 if (options_.cpu_overuse_detection) | 653 if (options_.cpu_overuse_detection) |
| 654 signal_cpu_adaptation_ = *options_.cpu_overuse_detection; | 654 signal_cpu_adaptation_ = *options_.cpu_overuse_detection; |
| 655 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; | 655 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; |
| 656 sending_ = false; | 656 sending_ = false; |
| 657 default_send_ssrc_ = 0; | 657 default_send_ssrc_ = 0; |
| 658 SetRecvCodecs(recv_codecs); | 658 RTC_DCHECK(ValidateCodecFormats(recv_codecs)); |
| 659 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs)); |
| 659 } | 660 } |
| 660 | 661 |
| 661 void WebRtcVideoChannel2::SetDefaultOptions() { | 662 void WebRtcVideoChannel2::SetDefaultOptions() { |
| 662 options_.cpu_overuse_detection = rtc::Optional<bool>(true); | 663 options_.cpu_overuse_detection = rtc::Optional<bool>(true); |
| 663 options_.dscp = rtc::Optional<bool>(false); | 664 options_.dscp = rtc::Optional<bool>(false); |
| 664 options_.suspend_below_min_bitrate = rtc::Optional<bool>(false); | 665 options_.suspend_below_min_bitrate = rtc::Optional<bool>(false); |
| 665 options_.screencast_min_bitrate = rtc::Optional<int>(0); | 666 options_.screencast_min_bitrate = rtc::Optional<int>(0); |
| 666 } | 667 } |
| 667 | 668 |
| 668 WebRtcVideoChannel2::~WebRtcVideoChannel2() { | 669 WebRtcVideoChannel2::~WebRtcVideoChannel2() { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 } | 738 } |
| 738 | 739 |
| 739 bool WebRtcVideoChannel2::GetChangedSendParameters( | 740 bool WebRtcVideoChannel2::GetChangedSendParameters( |
| 740 const VideoSendParameters& params, | 741 const VideoSendParameters& params, |
| 741 ChangedSendParameters* changed_params) const { | 742 ChangedSendParameters* changed_params) const { |
| 742 if (!ValidateCodecFormats(params.codecs) || | 743 if (!ValidateCodecFormats(params.codecs) || |
| 743 !ValidateRtpExtensions(params.extensions)) { | 744 !ValidateRtpExtensions(params.extensions)) { |
| 744 return false; | 745 return false; |
| 745 } | 746 } |
| 746 | 747 |
| 747 // ==== SEND CODEC ==== | 748 // Handle send codec. |
| 748 const std::vector<VideoCodecSettings> supported_codecs = | 749 const std::vector<VideoCodecSettings> supported_codecs = |
| 749 FilterSupportedCodecs(MapCodecs(params.codecs)); | 750 FilterSupportedCodecs(MapCodecs(params.codecs)); |
| 750 | 751 |
| 751 if (supported_codecs.empty()) { | 752 if (supported_codecs.empty()) { |
| 752 LOG(LS_ERROR) << "No video codecs supported."; | 753 LOG(LS_ERROR) << "No video codecs supported."; |
| 753 return false; | 754 return false; |
| 754 } | 755 } |
| 755 | 756 |
| 756 if (!send_codec_ || supported_codecs.front() != *send_codec_) { | 757 if (!send_codec_ || supported_codecs.front() != *send_codec_) { |
| 757 // Send codec has changed. | |
| 758 changed_params->codec = | 758 changed_params->codec = |
| 759 rtc::Optional<VideoCodecSettings>(supported_codecs.front()); | 759 rtc::Optional<VideoCodecSettings>(supported_codecs.front()); |
| 760 } | 760 } |
| 761 | 761 |
| 762 // ==== RTP HEADER EXTENSIONS ==== | 762 // Handle RTP header extensions. |
| 763 std::vector<webrtc::RtpExtension> filtered_extensions = FilterRtpExtensions( | 763 std::vector<webrtc::RtpExtension> filtered_extensions = FilterRtpExtensions( |
| 764 params.extensions, webrtc::RtpExtension::IsSupportedForVideo, true); | 764 params.extensions, webrtc::RtpExtension::IsSupportedForVideo, true); |
| 765 if (send_rtp_extensions_ != filtered_extensions) { | 765 if (send_rtp_extensions_ != filtered_extensions) { |
| 766 changed_params->rtp_header_extensions = | 766 changed_params->rtp_header_extensions = |
| 767 rtc::Optional<std::vector<webrtc::RtpExtension>>(filtered_extensions); | 767 rtc::Optional<std::vector<webrtc::RtpExtension>>(filtered_extensions); |
| 768 } | 768 } |
| 769 | 769 |
| 770 // ==== MAX BITRATE ==== | 770 // Handle max bitrate. |
| 771 if (params.max_bandwidth_bps != bitrate_config_.max_bitrate_bps && | 771 if (params.max_bandwidth_bps != bitrate_config_.max_bitrate_bps && |
| 772 params.max_bandwidth_bps >= 0) { | 772 params.max_bandwidth_bps >= 0) { |
| 773 // 0 uncaps max bitrate (-1). | 773 // 0 uncaps max bitrate (-1). |
| 774 changed_params->max_bandwidth_bps = rtc::Optional<int>( | 774 changed_params->max_bandwidth_bps = rtc::Optional<int>( |
| 775 params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps); | 775 params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps); |
| 776 } | 776 } |
| 777 | 777 |
| 778 // ==== OPTIONS ==== | 778 // Handle options. |
| 779 // TODO(pbos): Require VideoSendParameters to contain a full set of options | 779 // TODO(pbos): Require VideoSendParameters to contain a full set of options |
| 780 // and check if params.options != options_ instead of applying a delta. | 780 // and check if params.options != options_ instead of applying a delta. |
| 781 VideoOptions new_options = options_; | 781 VideoOptions new_options = options_; |
| 782 new_options.SetAll(params.options); | 782 new_options.SetAll(params.options); |
| 783 if (!(new_options == options_)) { | 783 if (!(new_options == options_)) { |
| 784 changed_params->options = rtc::Optional<VideoOptions>(new_options); | 784 changed_params->options = rtc::Optional<VideoOptions>(new_options); |
| 785 } | 785 } |
| 786 | 786 |
| 787 // Handle RTCP mode. |
| 787 if (params.rtcp.reduced_size != send_params_.rtcp.reduced_size) { | 788 if (params.rtcp.reduced_size != send_params_.rtcp.reduced_size) { |
| 788 changed_params->rtcp_mode = rtc::Optional<webrtc::RtcpMode>( | 789 changed_params->rtcp_mode = rtc::Optional<webrtc::RtcpMode>( |
| 789 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize | 790 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize |
| 790 : webrtc::RtcpMode::kCompound); | 791 : webrtc::RtcpMode::kCompound); |
| 791 } | 792 } |
| 792 | 793 |
| 793 return true; | 794 return true; |
| 794 } | 795 } |
| 795 | 796 |
| 796 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) { | 797 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 kv.second->SetFeedbackParameters(HasNack(send_codec_->codec), | 866 kv.second->SetFeedbackParameters(HasNack(send_codec_->codec), |
| 866 HasRemb(send_codec_->codec), | 867 HasRemb(send_codec_->codec), |
| 867 HasTransportCc(send_codec_->codec)); | 868 HasTransportCc(send_codec_->codec)); |
| 868 } | 869 } |
| 869 } | 870 } |
| 870 } | 871 } |
| 871 send_params_ = params; | 872 send_params_ = params; |
| 872 return true; | 873 return true; |
| 873 } | 874 } |
| 874 | 875 |
| 876 bool WebRtcVideoChannel2::GetChangedRecvParameters( |
| 877 const VideoRecvParameters& params, |
| 878 ChangedRecvParameters* changed_params) const { |
| 879 if (!ValidateCodecFormats(params.codecs) || |
| 880 !ValidateRtpExtensions(params.extensions)) { |
| 881 return false; |
| 882 } |
| 883 |
| 884 // Handle receive codecs. |
| 885 const std::vector<VideoCodecSettings> mapped_codecs = |
| 886 MapCodecs(params.codecs); |
| 887 if (mapped_codecs.empty()) { |
| 888 LOG(LS_ERROR) << "SetRecvParameters called without any video codecs."; |
| 889 return false; |
| 890 } |
| 891 |
| 892 std::vector<VideoCodecSettings> supported_codecs = |
| 893 FilterSupportedCodecs(mapped_codecs); |
| 894 |
| 895 if (mapped_codecs.size() != supported_codecs.size()) { |
| 896 LOG(LS_ERROR) << "SetRecvParameters called with unsupported video codecs."; |
| 897 return false; |
| 898 } |
| 899 |
| 900 if (ReceiveCodecsHaveChanged(recv_codecs_, supported_codecs)) { |
| 901 changed_params->codec_settings = |
| 902 rtc::Optional<std::vector<VideoCodecSettings>>(supported_codecs); |
| 903 } |
| 904 |
| 905 // Handle RTP header extensions. |
| 906 std::vector<webrtc::RtpExtension> filtered_extensions = FilterRtpExtensions( |
| 907 params.extensions, webrtc::RtpExtension::IsSupportedForVideo, false); |
| 908 if (filtered_extensions != recv_rtp_extensions_) { |
| 909 changed_params->rtp_header_extensions = |
| 910 rtc::Optional<std::vector<webrtc::RtpExtension>>(filtered_extensions); |
| 911 } |
| 912 |
| 913 // Handle RTCP mode. |
| 914 if (params.rtcp.reduced_size != recv_params_.rtcp.reduced_size) { |
| 915 changed_params->rtcp_mode = rtc::Optional<webrtc::RtcpMode>( |
| 916 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize |
| 917 : webrtc::RtcpMode::kCompound); |
| 918 } |
| 919 |
| 920 return true; |
| 921 } |
| 922 |
| 875 bool WebRtcVideoChannel2::SetRecvParameters(const VideoRecvParameters& params) { | 923 bool WebRtcVideoChannel2::SetRecvParameters(const VideoRecvParameters& params) { |
| 876 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvParameters"); | 924 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvParameters"); |
| 877 LOG(LS_INFO) << "SetRecvParameters: " << params.ToString(); | 925 LOG(LS_INFO) << "SetRecvParameters: " << params.ToString(); |
| 878 // TODO(pbos): Refactor this to only recreate the recv streams once | 926 ChangedRecvParameters changed_params; |
| 879 // instead of twice. | 927 if (!GetChangedRecvParameters(params, &changed_params)) { |
| 880 if (!SetRecvCodecs(params.codecs) || | |
| 881 !SetRecvRtpHeaderExtensions(params.extensions)) { | |
| 882 return false; | 928 return false; |
| 883 } | 929 } |
| 884 if (recv_params_.rtcp.reduced_size != params.rtcp.reduced_size) { | 930 if (changed_params.rtp_header_extensions) { |
| 931 recv_rtp_extensions_ = *changed_params.rtp_header_extensions; |
| 932 } |
| 933 if (changed_params.codec_settings) { |
| 934 LOG(LS_INFO) << "Changing recv codecs from " |
| 935 << CodecSettingsVectorToString(recv_codecs_) << " to " |
| 936 << CodecSettingsVectorToString(*changed_params.codec_settings); |
| 937 recv_codecs_ = *changed_params.codec_settings; |
| 938 } |
| 939 |
| 940 { |
| 885 rtc::CritScope stream_lock(&stream_crit_); | 941 rtc::CritScope stream_lock(&stream_crit_); |
| 886 for (auto& kv : receive_streams_) { | 942 for (auto& kv : receive_streams_) { |
| 887 kv.second->SetRecvParameters(params); | 943 kv.second->SetRecvParameters(changed_params); |
| 888 } | 944 } |
| 889 } | 945 } |
| 890 recv_params_ = params; | 946 recv_params_ = params; |
| 891 return true; | 947 return true; |
| 892 } | 948 } |
| 893 | 949 |
| 894 std::string WebRtcVideoChannel2::CodecSettingsVectorToString( | 950 std::string WebRtcVideoChannel2::CodecSettingsVectorToString( |
| 895 const std::vector<VideoCodecSettings>& codecs) { | 951 const std::vector<VideoCodecSettings>& codecs) { |
| 896 std::stringstream out; | 952 std::stringstream out; |
| 897 out << '{'; | 953 out << '{'; |
| 898 for (size_t i = 0; i < codecs.size(); ++i) { | 954 for (size_t i = 0; i < codecs.size(); ++i) { |
| 899 out << codecs[i].codec.ToString(); | 955 out << codecs[i].codec.ToString(); |
| 900 if (i != codecs.size() - 1) { | 956 if (i != codecs.size() - 1) { |
| 901 out << ", "; | 957 out << ", "; |
| 902 } | 958 } |
| 903 } | 959 } |
| 904 out << '}'; | 960 out << '}'; |
| 905 return out.str(); | 961 return out.str(); |
| 906 } | 962 } |
| 907 | 963 |
| 908 bool WebRtcVideoChannel2::SetRecvCodecs(const std::vector<VideoCodec>& codecs) { | |
| 909 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvCodecs"); | |
| 910 LOG(LS_INFO) << "SetRecvCodecs: " << CodecVectorToString(codecs); | |
| 911 if (!ValidateCodecFormats(codecs)) { | |
| 912 return false; | |
| 913 } | |
| 914 | |
| 915 const std::vector<VideoCodecSettings> mapped_codecs = MapCodecs(codecs); | |
| 916 if (mapped_codecs.empty()) { | |
| 917 LOG(LS_ERROR) << "SetRecvCodecs called without any video codecs."; | |
| 918 return false; | |
| 919 } | |
| 920 | |
| 921 std::vector<VideoCodecSettings> supported_codecs = | |
| 922 FilterSupportedCodecs(mapped_codecs); | |
| 923 | |
| 924 if (mapped_codecs.size() != supported_codecs.size()) { | |
| 925 LOG(LS_ERROR) << "SetRecvCodecs called with unsupported video codecs."; | |
| 926 return false; | |
| 927 } | |
| 928 | |
| 929 // Prevent reconfiguration when setting identical receive codecs. | |
| 930 if (!ReceiveCodecsHaveChanged(recv_codecs_, supported_codecs)) { | |
| 931 LOG(LS_INFO) | |
| 932 << "Ignoring call to SetRecvCodecs because codecs haven't changed."; | |
| 933 return true; | |
| 934 } | |
| 935 | |
| 936 LOG(LS_INFO) << "Changing recv codecs from " | |
| 937 << CodecSettingsVectorToString(recv_codecs_) << " to " | |
| 938 << CodecSettingsVectorToString(supported_codecs); | |
| 939 recv_codecs_ = supported_codecs; | |
| 940 | |
| 941 rtc::CritScope stream_lock(&stream_crit_); | |
| 942 for (std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = | |
| 943 receive_streams_.begin(); | |
| 944 it != receive_streams_.end(); ++it) { | |
| 945 it->second->SetRecvCodecs(recv_codecs_); | |
| 946 } | |
| 947 | |
| 948 return true; | |
| 949 } | |
| 950 | |
| 951 bool WebRtcVideoChannel2::GetSendCodec(VideoCodec* codec) { | 964 bool WebRtcVideoChannel2::GetSendCodec(VideoCodec* codec) { |
| 952 if (!send_codec_) { | 965 if (!send_codec_) { |
| 953 LOG(LS_VERBOSE) << "GetSendCodec: No send codec set."; | 966 LOG(LS_VERBOSE) << "GetSendCodec: No send codec set."; |
| 954 return false; | 967 return false; |
| 955 } | 968 } |
| 956 *codec = send_codec_->codec; | 969 *codec = send_codec_->codec; |
| 957 return true; | 970 return true; |
| 958 } | 971 } |
| 959 | 972 |
| 960 bool WebRtcVideoChannel2::SetSendStreamFormat(uint32_t ssrc, | 973 bool WebRtcVideoChannel2::SetSendStreamFormat(uint32_t ssrc, |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 rtc::CritScope stream_lock(&stream_crit_); | 1444 rtc::CritScope stream_lock(&stream_crit_); |
| 1432 if (send_streams_.find(ssrc) == send_streams_.end()) { | 1445 if (send_streams_.find(ssrc) == send_streams_.end()) { |
| 1433 LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc; | 1446 LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc; |
| 1434 return false; | 1447 return false; |
| 1435 } | 1448 } |
| 1436 | 1449 |
| 1437 send_streams_[ssrc]->MuteStream(mute); | 1450 send_streams_[ssrc]->MuteStream(mute); |
| 1438 return true; | 1451 return true; |
| 1439 } | 1452 } |
| 1440 | 1453 |
| 1441 bool WebRtcVideoChannel2::SetRecvRtpHeaderExtensions( | |
| 1442 const std::vector<RtpHeaderExtension>& extensions) { | |
| 1443 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvRtpHeaderExtensions"); | |
| 1444 if (!ValidateRtpExtensions(extensions)) { | |
| 1445 return false; | |
| 1446 } | |
| 1447 std::vector<webrtc::RtpExtension> filtered_extensions = FilterRtpExtensions( | |
| 1448 extensions, webrtc::RtpExtension::IsSupportedForVideo, false); | |
| 1449 if (recv_rtp_extensions_ == filtered_extensions) { | |
| 1450 LOG(LS_INFO) << "Ignoring call to SetRecvRtpHeaderExtensions because " | |
| 1451 "header extensions haven't changed."; | |
| 1452 return true; | |
| 1453 } | |
| 1454 recv_rtp_extensions_.swap(filtered_extensions); | |
| 1455 | |
| 1456 rtc::CritScope stream_lock(&stream_crit_); | |
| 1457 for (std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = | |
| 1458 receive_streams_.begin(); | |
| 1459 it != receive_streams_.end(); ++it) { | |
| 1460 it->second->SetRtpExtensions(recv_rtp_extensions_); | |
| 1461 } | |
| 1462 return true; | |
| 1463 } | |
| 1464 | |
| 1465 // TODO(pbos): Remove SetOptions in favor of SetSendParameters. | 1454 // TODO(pbos): Remove SetOptions in favor of SetSendParameters. |
| 1466 void WebRtcVideoChannel2::SetOptions(const VideoOptions& options) { | 1455 void WebRtcVideoChannel2::SetOptions(const VideoOptions& options) { |
| 1467 VideoSendParameters new_params = send_params_; | 1456 VideoSendParameters new_params = send_params_; |
| 1468 new_params.options.SetAll(options); | 1457 new_params.options.SetAll(options); |
| 1469 SetSendParameters(send_params_); | 1458 SetSendParameters(send_params_); |
| 1470 } | 1459 } |
| 1471 | 1460 |
| 1472 void WebRtcVideoChannel2::SetInterface(NetworkInterface* iface) { | 1461 void WebRtcVideoChannel2::SetInterface(NetworkInterface* iface) { |
| 1473 MediaChannel::SetInterface(iface); | 1462 MediaChannel::SetInterface(iface); |
| 1474 // Set the RTP recv/send buffer to a bigger size | 1463 // Set the RTP recv/send buffer to a bigger size |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2213 default_stream_(default_stream), | 2202 default_stream_(default_stream), |
| 2214 config_(config), | 2203 config_(config), |
| 2215 external_decoder_factory_(external_decoder_factory), | 2204 external_decoder_factory_(external_decoder_factory), |
| 2216 disable_prerenderer_smoothing_(disable_prerenderer_smoothing), | 2205 disable_prerenderer_smoothing_(disable_prerenderer_smoothing), |
| 2217 sink_(NULL), | 2206 sink_(NULL), |
| 2218 last_width_(-1), | 2207 last_width_(-1), |
| 2219 last_height_(-1), | 2208 last_height_(-1), |
| 2220 first_frame_timestamp_(-1), | 2209 first_frame_timestamp_(-1), |
| 2221 estimated_remote_start_ntp_time_ms_(0) { | 2210 estimated_remote_start_ntp_time_ms_(0) { |
| 2222 config_.renderer = this; | 2211 config_.renderer = this; |
| 2223 // SetRecvCodecs will also reset (start) the VideoReceiveStream. | 2212 std::vector<AllocatedDecoder> old_decoders; |
| 2224 LOG(LS_INFO) << "SetRecvCodecs (recv) because we are creating the receive " | 2213 ConfigureCodecs(recv_codecs, &old_decoders); |
| 2225 "stream for the first time: " | 2214 RecreateWebRtcStream(); |
| 2226 << CodecSettingsVectorToString(recv_codecs); | 2215 RTC_DCHECK(old_decoders.empty()); |
| 2227 SetRecvCodecs(recv_codecs); | |
| 2228 } | 2216 } |
| 2229 | 2217 |
| 2230 WebRtcVideoChannel2::WebRtcVideoReceiveStream::AllocatedDecoder:: | 2218 WebRtcVideoChannel2::WebRtcVideoReceiveStream::AllocatedDecoder:: |
| 2231 AllocatedDecoder(webrtc::VideoDecoder* decoder, | 2219 AllocatedDecoder(webrtc::VideoDecoder* decoder, |
| 2232 webrtc::VideoCodecType type, | 2220 webrtc::VideoCodecType type, |
| 2233 bool external) | 2221 bool external) |
| 2234 : decoder(decoder), | 2222 : decoder(decoder), |
| 2235 external_decoder(nullptr), | 2223 external_decoder(nullptr), |
| 2236 type(type), | 2224 type(type), |
| 2237 external(external) { | 2225 external(external) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2289 return AllocatedDecoder( | 2277 return AllocatedDecoder( |
| 2290 webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kH264), type, false); | 2278 webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kH264), type, false); |
| 2291 } | 2279 } |
| 2292 | 2280 |
| 2293 // This shouldn't happen, we should not be trying to create something we don't | 2281 // This shouldn't happen, we should not be trying to create something we don't |
| 2294 // support. | 2282 // support. |
| 2295 RTC_DCHECK(false); | 2283 RTC_DCHECK(false); |
| 2296 return AllocatedDecoder(NULL, webrtc::kVideoCodecUnknown, false); | 2284 return AllocatedDecoder(NULL, webrtc::kVideoCodecUnknown, false); |
| 2297 } | 2285 } |
| 2298 | 2286 |
| 2299 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRecvCodecs( | 2287 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ConfigureCodecs( |
| 2300 const std::vector<VideoCodecSettings>& recv_codecs) { | 2288 const std::vector<VideoCodecSettings>& recv_codecs, |
| 2301 std::vector<AllocatedDecoder> old_decoders = allocated_decoders_; | 2289 std::vector<AllocatedDecoder>* old_decoders) { |
| 2290 *old_decoders = allocated_decoders_; |
| 2302 allocated_decoders_.clear(); | 2291 allocated_decoders_.clear(); |
| 2303 config_.decoders.clear(); | 2292 config_.decoders.clear(); |
| 2304 for (size_t i = 0; i < recv_codecs.size(); ++i) { | 2293 for (size_t i = 0; i < recv_codecs.size(); ++i) { |
| 2305 AllocatedDecoder allocated_decoder = | 2294 AllocatedDecoder allocated_decoder = |
| 2306 CreateOrReuseVideoDecoder(&old_decoders, recv_codecs[i].codec); | 2295 CreateOrReuseVideoDecoder(old_decoders, recv_codecs[i].codec); |
| 2307 allocated_decoders_.push_back(allocated_decoder); | 2296 allocated_decoders_.push_back(allocated_decoder); |
| 2308 | 2297 |
| 2309 webrtc::VideoReceiveStream::Decoder decoder; | 2298 webrtc::VideoReceiveStream::Decoder decoder; |
| 2310 decoder.decoder = allocated_decoder.decoder; | 2299 decoder.decoder = allocated_decoder.decoder; |
| 2311 decoder.payload_type = recv_codecs[i].codec.id; | 2300 decoder.payload_type = recv_codecs[i].codec.id; |
| 2312 decoder.payload_name = recv_codecs[i].codec.name; | 2301 decoder.payload_name = recv_codecs[i].codec.name; |
| 2313 config_.decoders.push_back(decoder); | 2302 config_.decoders.push_back(decoder); |
| 2314 } | 2303 } |
| 2315 | 2304 |
| 2316 // TODO(pbos): Reconfigure RTX based on incoming recv_codecs. | 2305 // TODO(pbos): Reconfigure RTX based on incoming recv_codecs. |
| 2317 config_.rtp.fec = recv_codecs.front().fec; | 2306 config_.rtp.fec = recv_codecs.front().fec; |
| 2318 config_.rtp.nack.rtp_history_ms = | 2307 config_.rtp.nack.rtp_history_ms = |
| 2319 HasNack(recv_codecs.begin()->codec) ? kNackHistoryMs : 0; | 2308 HasNack(recv_codecs.begin()->codec) ? kNackHistoryMs : 0; |
| 2320 | |
| 2321 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRecvCodecs: " | |
| 2322 << CodecSettingsVectorToString(recv_codecs); | |
| 2323 RecreateWebRtcStream(); | |
| 2324 ClearDecoders(&old_decoders); | |
| 2325 } | 2309 } |
| 2326 | 2310 |
| 2327 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetLocalSsrc( | 2311 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetLocalSsrc( |
| 2328 uint32_t local_ssrc) { | 2312 uint32_t local_ssrc) { |
| 2329 // TODO(pbos): Consider turning this sanity check into a RTC_DCHECK. You | 2313 // TODO(pbos): Consider turning this sanity check into a RTC_DCHECK. You |
| 2330 // should not be able to create a sender with the same SSRC as a receiver, but | 2314 // should not be able to create a sender with the same SSRC as a receiver, but |
| 2331 // right now this can't be done due to unittests depending on receiving what | 2315 // right now this can't be done due to unittests depending on receiving what |
| 2332 // they are sending from the same MediaChannel. | 2316 // they are sending from the same MediaChannel. |
| 2333 if (local_ssrc == config_.rtp.remote_ssrc) { | 2317 if (local_ssrc == config_.rtp.remote_ssrc) { |
| 2334 LOG(LS_INFO) << "Ignoring call to SetLocalSsrc because parameters are " | 2318 LOG(LS_INFO) << "Ignoring call to SetLocalSsrc because parameters are " |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2361 config_.rtp.remb = remb_enabled; | 2345 config_.rtp.remb = remb_enabled; |
| 2362 config_.rtp.nack.rtp_history_ms = nack_history_ms; | 2346 config_.rtp.nack.rtp_history_ms = nack_history_ms; |
| 2363 config_.rtp.transport_cc = transport_cc_enabled; | 2347 config_.rtp.transport_cc = transport_cc_enabled; |
| 2364 LOG(LS_INFO) | 2348 LOG(LS_INFO) |
| 2365 << "RecreateWebRtcStream (recv) because of SetFeedbackParameters; nack=" | 2349 << "RecreateWebRtcStream (recv) because of SetFeedbackParameters; nack=" |
| 2366 << nack_enabled << ", remb=" << remb_enabled | 2350 << nack_enabled << ", remb=" << remb_enabled |
| 2367 << ", transport_cc=" << transport_cc_enabled; | 2351 << ", transport_cc=" << transport_cc_enabled; |
| 2368 RecreateWebRtcStream(); | 2352 RecreateWebRtcStream(); |
| 2369 } | 2353 } |
| 2370 | 2354 |
| 2371 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRtpExtensions( | |
| 2372 const std::vector<webrtc::RtpExtension>& extensions) { | |
| 2373 config_.rtp.extensions = extensions; | |
| 2374 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRtpExtensions"; | |
| 2375 RecreateWebRtcStream(); | |
| 2376 } | |
| 2377 | |
| 2378 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRecvParameters( | 2355 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRecvParameters( |
| 2379 const VideoRecvParameters& recv_params) { | 2356 const ChangedRecvParameters& params) { |
| 2380 config_.rtp.rtcp_mode = recv_params.rtcp.reduced_size | 2357 bool needs_recreation = false; |
| 2381 ? webrtc::RtcpMode::kReducedSize | 2358 std::vector<AllocatedDecoder> old_decoders; |
| 2382 : webrtc::RtcpMode::kCompound; | 2359 if (params.codec_settings) { |
| 2383 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRecvParameters"; | 2360 ConfigureCodecs(*params.codec_settings, &old_decoders); |
| 2384 RecreateWebRtcStream(); | 2361 needs_recreation = true; |
| 2362 } |
| 2363 if (params.rtp_header_extensions) { |
| 2364 config_.rtp.extensions = *params.rtp_header_extensions; |
| 2365 needs_recreation = true; |
| 2366 } |
| 2367 if (params.rtcp_mode) { |
| 2368 config_.rtp.rtcp_mode = *params.rtcp_mode; |
| 2369 needs_recreation = true; |
| 2370 } |
| 2371 if (needs_recreation) { |
| 2372 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRecvParameters"; |
| 2373 RecreateWebRtcStream(); |
| 2374 ClearDecoders(&old_decoders); |
| 2375 } |
| 2385 } | 2376 } |
| 2386 | 2377 |
| 2387 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { | 2378 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { |
| 2388 if (stream_ != NULL) { | 2379 if (stream_ != NULL) { |
| 2389 call_->DestroyVideoReceiveStream(stream_); | 2380 call_->DestroyVideoReceiveStream(stream_); |
| 2390 } | 2381 } |
| 2391 stream_ = call_->CreateVideoReceiveStream(config_); | 2382 stream_ = call_->CreateVideoReceiveStream(config_); |
| 2392 stream_->Start(); | 2383 stream_->Start(); |
| 2393 } | 2384 } |
| 2394 | 2385 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2614 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2605 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
| 2615 } | 2606 } |
| 2616 } | 2607 } |
| 2617 | 2608 |
| 2618 return video_codecs; | 2609 return video_codecs; |
| 2619 } | 2610 } |
| 2620 | 2611 |
| 2621 } // namespace cricket | 2612 } // namespace cricket |
| 2622 | 2613 |
| 2623 #endif // HAVE_WEBRTC_VIDEO | 2614 #endif // HAVE_WEBRTC_VIDEO |
| OLD | NEW |