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 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
849 for (size_t i = 0; i < mapped_codecs.size(); ++i) { | 849 for (size_t i = 0; i < mapped_codecs.size(); ++i) { |
850 const VideoCodecSettings& codec = mapped_codecs[i]; | 850 const VideoCodecSettings& codec = mapped_codecs[i]; |
851 if (CodecIsInternallySupported(codec.codec.name) || | 851 if (CodecIsInternallySupported(codec.codec.name) || |
852 CodecIsExternallySupported(codec.codec.name)) { | 852 CodecIsExternallySupported(codec.codec.name)) { |
853 supported_codecs.push_back(codec); | 853 supported_codecs.push_back(codec); |
854 } | 854 } |
855 } | 855 } |
856 return supported_codecs; | 856 return supported_codecs; |
857 } | 857 } |
858 | 858 |
859 bool WebRtcVideoChannel2::CodecsHaveChanged( | |
860 std::vector<VideoCodecSettings> before, | |
861 std::vector<VideoCodecSettings> after) { | |
862 if (before.size() != after.size()) | |
863 return true; | |
pthatcher1
2015/08/18 20:24:32
{}s please
Taylor Brandstetter
2015/08/20 23:07:47
Done.
| |
864 // The receive codec order doesn't matter, so we sort the codecs before | |
865 // comparing. This is necessary because currently the | |
866 // only way to change the send codec is to munge SDP, which causes | |
867 // the receive codec list to change order, which causes the streams | |
868 // to be recreates which causes a "blink" of black video. In order | |
869 // to support munging the SDP in this way without recreating receive | |
870 // streams, we ignore the order of the received codecs so that | |
871 // changing the order doesn't cause this "blink". | |
872 auto comparison = | |
873 [](const VideoCodecSettings& codec1, const VideoCodecSettings& codec2) { | |
874 return codec1.codec.id > codec2.codec.id; | |
875 }; | |
876 std::sort(before.begin(), before.end(), comparison); | |
877 std::sort(after.begin(), after.end(), comparison); | |
878 for (size_t i = 0; i < before.size(); ++i) { | |
879 // For the same reason that we sort the codecs, we also ignore the | |
880 // preference. We don't want a preference change on the receive | |
881 // side to cause recreation of the stream. | |
882 before[i].codec.preference = 0; | |
883 after[i].codec.preference = 0; | |
884 if (before[i] != after[i]) { | |
885 return true; | |
886 } | |
887 } | |
888 return false; | |
889 } | |
890 | |
859 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) { | 891 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) { |
860 // TODO(pbos): Refactor this to only recreate the send streams once | 892 // TODO(pbos): Refactor this to only recreate the send streams once |
861 // instead of 4 times. | 893 // instead of 4 times. |
862 return (SetSendCodecs(params.codecs) && | 894 return (SetSendCodecs(params.codecs) && |
863 SetSendRtpHeaderExtensions(params.extensions) && | 895 SetSendRtpHeaderExtensions(params.extensions) && |
864 SetMaxSendBandwidth(params.max_bandwidth_bps) && | 896 SetMaxSendBandwidth(params.max_bandwidth_bps) && |
865 SetOptions(params.options)); | 897 SetOptions(params.options)); |
866 } | 898 } |
867 | 899 |
868 bool WebRtcVideoChannel2::SetRecvParameters(const VideoRecvParameters& params) { | 900 bool WebRtcVideoChannel2::SetRecvParameters(const VideoRecvParameters& params) { |
869 // TODO(pbos): Refactor this to only recreate the recv streams once | 901 // TODO(pbos): Refactor this to only recreate the recv streams once |
870 // instead of twice. | 902 // instead of twice. |
871 return (SetRecvCodecs(params.codecs) && | 903 return (SetRecvCodecs(params.codecs) && |
872 SetRecvRtpHeaderExtensions(params.extensions)); | 904 SetRecvRtpHeaderExtensions(params.extensions)); |
873 } | 905 } |
874 | 906 |
907 std::string WebRtcVideoChannel2::CodecSettingsVectorToString( | |
908 const std::vector<VideoCodecSettings>& codecs) { | |
909 std::stringstream out; | |
910 out << '{'; | |
911 for (size_t i = 0; i < codecs.size(); ++i) { | |
912 out << codecs[i].codec.ToString(); | |
913 if (i != codecs.size() - 1) { | |
914 out << ", "; | |
915 } | |
916 } | |
917 out << '}'; | |
918 return out.str(); | |
919 } | |
920 | |
875 bool WebRtcVideoChannel2::SetRecvCodecs(const std::vector<VideoCodec>& codecs) { | 921 bool WebRtcVideoChannel2::SetRecvCodecs(const std::vector<VideoCodec>& codecs) { |
876 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvCodecs"); | 922 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvCodecs"); |
877 LOG(LS_INFO) << "SetRecvCodecs: " << CodecVectorToString(codecs); | 923 LOG(LS_INFO) << "SetRecvCodecs: " << CodecVectorToString(codecs); |
878 if (!ValidateCodecFormats(codecs)) { | 924 if (!ValidateCodecFormats(codecs)) { |
879 return false; | 925 return false; |
880 } | 926 } |
881 | 927 |
882 const std::vector<VideoCodecSettings> mapped_codecs = MapCodecs(codecs); | 928 const std::vector<VideoCodecSettings> mapped_codecs = MapCodecs(codecs); |
883 if (mapped_codecs.empty()) { | 929 if (mapped_codecs.empty()) { |
884 LOG(LS_ERROR) << "SetRecvCodecs called without any video codecs."; | 930 LOG(LS_ERROR) << "SetRecvCodecs called without any video codecs."; |
885 return false; | 931 return false; |
886 } | 932 } |
887 | 933 |
888 const std::vector<VideoCodecSettings> supported_codecs = | 934 std::vector<VideoCodecSettings> supported_codecs = |
889 FilterSupportedCodecs(mapped_codecs); | 935 FilterSupportedCodecs(mapped_codecs); |
890 | 936 |
891 if (mapped_codecs.size() != supported_codecs.size()) { | 937 if (mapped_codecs.size() != supported_codecs.size()) { |
892 LOG(LS_ERROR) << "SetRecvCodecs called with unsupported video codecs."; | 938 LOG(LS_ERROR) << "SetRecvCodecs called with unsupported video codecs."; |
893 return false; | 939 return false; |
894 } | 940 } |
895 | 941 |
896 // Prevent reconfiguration when setting identical receive codecs. | 942 // Prevent reconfiguration when setting identical receive codecs. |
897 if (recv_codecs_.size() == supported_codecs.size()) { | 943 if (!CodecsHaveChanged(recv_codecs_, supported_codecs)) { |
898 bool reconfigured = false; | 944 LOG(LS_INFO) |
899 for (size_t i = 0; i < supported_codecs.size(); ++i) { | 945 << "Ignoring call to SetRecvCodecs because codecs haven't changed."; |
900 if (recv_codecs_[i] != supported_codecs[i]) { | 946 return true; |
901 reconfigured = true; | |
902 break; | |
903 } | |
904 } | |
905 if (!reconfigured) | |
906 return true; | |
907 } | 947 } |
908 | 948 |
949 LOG(LS_INFO) << "Changing recv codecs from " | |
950 << CodecSettingsVectorToString(recv_codecs_) << " to " | |
951 << CodecSettingsVectorToString(supported_codecs); | |
909 recv_codecs_ = supported_codecs; | 952 recv_codecs_ = supported_codecs; |
910 | 953 |
911 rtc::CritScope stream_lock(&stream_crit_); | 954 rtc::CritScope stream_lock(&stream_crit_); |
912 for (std::map<uint32, WebRtcVideoReceiveStream*>::iterator it = | 955 for (std::map<uint32, WebRtcVideoReceiveStream*>::iterator it = |
913 receive_streams_.begin(); | 956 receive_streams_.begin(); |
914 it != receive_streams_.end(); | 957 it != receive_streams_.end(); |
915 ++it) { | 958 ++it) { |
916 it->second->SetRecvCodecs(recv_codecs_); | 959 it->second->SetRecvCodecs(recv_codecs_); |
917 } | 960 } |
918 | 961 |
(...skipping 12 matching lines...) Expand all Loading... | |
931 | 974 |
932 if (supported_codecs.empty()) { | 975 if (supported_codecs.empty()) { |
933 LOG(LS_ERROR) << "No video codecs supported."; | 976 LOG(LS_ERROR) << "No video codecs supported."; |
934 return false; | 977 return false; |
935 } | 978 } |
936 | 979 |
937 LOG(LS_INFO) << "Using codec: " << supported_codecs.front().codec.ToString(); | 980 LOG(LS_INFO) << "Using codec: " << supported_codecs.front().codec.ToString(); |
938 | 981 |
939 VideoCodecSettings old_codec; | 982 VideoCodecSettings old_codec; |
940 if (send_codec_.Get(&old_codec) && supported_codecs.front() == old_codec) { | 983 if (send_codec_.Get(&old_codec) && supported_codecs.front() == old_codec) { |
984 LOG(LS_INFO) << "Ignore call to SetSendCodecs because first supported " | |
985 "codec hasn't changed."; | |
941 // Using same codec, avoid reconfiguring. | 986 // Using same codec, avoid reconfiguring. |
942 return true; | 987 return true; |
943 } | 988 } |
944 | 989 |
945 send_codec_.Set(supported_codecs.front()); | 990 send_codec_.Set(supported_codecs.front()); |
946 | 991 |
947 rtc::CritScope stream_lock(&stream_crit_); | 992 rtc::CritScope stream_lock(&stream_crit_); |
993 LOG(LS_INFO) << "Change the send codec because SetSendCodecs has a different " | |
994 "first supported codec."; | |
948 for (auto& kv : send_streams_) { | 995 for (auto& kv : send_streams_) { |
949 DCHECK(kv.second != nullptr); | 996 DCHECK(kv.second != nullptr); |
950 kv.second->SetCodec(supported_codecs.front()); | 997 kv.second->SetCodec(supported_codecs.front()); |
951 } | 998 } |
999 LOG(LS_INFO) << "SetNackAndRemb on all the receive streams because the send " | |
1000 "codec has changed."; | |
952 for (auto& kv : receive_streams_) { | 1001 for (auto& kv : receive_streams_) { |
953 DCHECK(kv.second != nullptr); | 1002 DCHECK(kv.second != nullptr); |
954 kv.second->SetNackAndRemb(HasNack(supported_codecs.front().codec), | 1003 kv.second->SetNackAndRemb(HasNack(supported_codecs.front().codec), |
955 HasRemb(supported_codecs.front().codec)); | 1004 HasRemb(supported_codecs.front().codec)); |
956 } | 1005 } |
957 | 1006 |
958 // TODO(holmer): Changing the codec parameters shouldn't necessarily mean that | 1007 // TODO(holmer): Changing the codec parameters shouldn't necessarily mean that |
959 // we change the min/max of bandwidth estimation. Reevaluate this. | 1008 // we change the min/max of bandwidth estimation. Reevaluate this. |
960 VideoCodec codec = supported_codecs.front().codec; | 1009 VideoCodec codec = supported_codecs.front().codec; |
961 int bitrate_kbps; | 1010 int bitrate_kbps; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1069 send_codec_, | 1118 send_codec_, |
1070 sp, | 1119 sp, |
1071 send_rtp_extensions_); | 1120 send_rtp_extensions_); |
1072 | 1121 |
1073 uint32 ssrc = sp.first_ssrc(); | 1122 uint32 ssrc = sp.first_ssrc(); |
1074 DCHECK(ssrc != 0); | 1123 DCHECK(ssrc != 0); |
1075 send_streams_[ssrc] = stream; | 1124 send_streams_[ssrc] = stream; |
1076 | 1125 |
1077 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) { | 1126 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) { |
1078 rtcp_receiver_report_ssrc_ = ssrc; | 1127 rtcp_receiver_report_ssrc_ = ssrc; |
1128 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added " | |
1129 "a send stream."; | |
1079 for (auto& kv : receive_streams_) | 1130 for (auto& kv : receive_streams_) |
1080 kv.second->SetLocalSsrc(ssrc); | 1131 kv.second->SetLocalSsrc(ssrc); |
1081 } | 1132 } |
1082 if (default_send_ssrc_ == 0) { | 1133 if (default_send_ssrc_ == 0) { |
1083 default_send_ssrc_ = ssrc; | 1134 default_send_ssrc_ = ssrc; |
1084 } | 1135 } |
1085 if (sending_) { | 1136 if (sending_) { |
1086 stream->Start(); | 1137 stream->Start(); |
1087 } | 1138 } |
1088 | 1139 |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1458 bool WebRtcVideoChannel2::SetRecvRtpHeaderExtensions( | 1509 bool WebRtcVideoChannel2::SetRecvRtpHeaderExtensions( |
1459 const std::vector<RtpHeaderExtension>& extensions) { | 1510 const std::vector<RtpHeaderExtension>& extensions) { |
1460 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvRtpHeaderExtensions"); | 1511 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvRtpHeaderExtensions"); |
1461 LOG(LS_INFO) << "SetRecvRtpHeaderExtensions: " | 1512 LOG(LS_INFO) << "SetRecvRtpHeaderExtensions: " |
1462 << RtpExtensionsToString(extensions); | 1513 << RtpExtensionsToString(extensions); |
1463 if (!ValidateRtpHeaderExtensionIds(extensions)) | 1514 if (!ValidateRtpHeaderExtensionIds(extensions)) |
1464 return false; | 1515 return false; |
1465 | 1516 |
1466 std::vector<webrtc::RtpExtension> filtered_extensions = | 1517 std::vector<webrtc::RtpExtension> filtered_extensions = |
1467 FilterRtpExtensions(extensions); | 1518 FilterRtpExtensions(extensions); |
1468 if (!RtpExtensionsHaveChanged(recv_rtp_extensions_, filtered_extensions)) | 1519 if (!RtpExtensionsHaveChanged(recv_rtp_extensions_, filtered_extensions)) { |
1520 LOG(LS_INFO) << "Ignoring call to SetRecvRtpHeaderExtensions because " | |
1521 "header extensions haven't changed."; | |
1469 return true; | 1522 return true; |
1523 } | |
1470 | 1524 |
1471 recv_rtp_extensions_ = filtered_extensions; | 1525 recv_rtp_extensions_ = filtered_extensions; |
1472 | 1526 |
1473 rtc::CritScope stream_lock(&stream_crit_); | 1527 rtc::CritScope stream_lock(&stream_crit_); |
1474 for (std::map<uint32, WebRtcVideoReceiveStream*>::iterator it = | 1528 for (std::map<uint32, WebRtcVideoReceiveStream*>::iterator it = |
1475 receive_streams_.begin(); | 1529 receive_streams_.begin(); |
1476 it != receive_streams_.end(); | 1530 it != receive_streams_.end(); |
1477 ++it) { | 1531 ++it) { |
1478 it->second->SetRtpExtensions(recv_rtp_extensions_); | 1532 it->second->SetRtpExtensions(recv_rtp_extensions_); |
1479 } | 1533 } |
1480 return true; | 1534 return true; |
1481 } | 1535 } |
1482 | 1536 |
1483 bool WebRtcVideoChannel2::SetSendRtpHeaderExtensions( | 1537 bool WebRtcVideoChannel2::SetSendRtpHeaderExtensions( |
1484 const std::vector<RtpHeaderExtension>& extensions) { | 1538 const std::vector<RtpHeaderExtension>& extensions) { |
1485 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetSendRtpHeaderExtensions"); | 1539 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetSendRtpHeaderExtensions"); |
1486 LOG(LS_INFO) << "SetSendRtpHeaderExtensions: " | 1540 LOG(LS_INFO) << "SetSendRtpHeaderExtensions: " |
1487 << RtpExtensionsToString(extensions); | 1541 << RtpExtensionsToString(extensions); |
1488 if (!ValidateRtpHeaderExtensionIds(extensions)) | 1542 if (!ValidateRtpHeaderExtensionIds(extensions)) |
1489 return false; | 1543 return false; |
1490 | 1544 |
1491 std::vector<webrtc::RtpExtension> filtered_extensions = | 1545 std::vector<webrtc::RtpExtension> filtered_extensions = |
1492 FilterRtpExtensions(extensions); | 1546 FilterRtpExtensions(extensions); |
1493 if (!RtpExtensionsHaveChanged(send_rtp_extensions_, filtered_extensions)) | 1547 if (!RtpExtensionsHaveChanged(send_rtp_extensions_, filtered_extensions)) { |
1548 LOG(LS_INFO) << "Ignoring call to SetSendRtpHeaderExtensions because " | |
1549 "header extensions haven't changed."; | |
1494 return true; | 1550 return true; |
1551 } | |
1495 | 1552 |
1496 send_rtp_extensions_ = filtered_extensions; | 1553 send_rtp_extensions_ = filtered_extensions; |
1497 | 1554 |
1498 const webrtc::RtpExtension* cvo_extension = FindHeaderExtension( | 1555 const webrtc::RtpExtension* cvo_extension = FindHeaderExtension( |
1499 send_rtp_extensions_, kRtpVideoRotationHeaderExtension); | 1556 send_rtp_extensions_, kRtpVideoRotationHeaderExtension); |
1500 | 1557 |
1501 rtc::CritScope stream_lock(&stream_crit_); | 1558 rtc::CritScope stream_lock(&stream_crit_); |
1502 for (std::map<uint32, WebRtcVideoSendStream*>::iterator it = | 1559 for (std::map<uint32, WebRtcVideoSendStream*>::iterator it = |
1503 send_streams_.begin(); | 1560 send_streams_.begin(); |
1504 it != send_streams_.end(); | 1561 it != send_streams_.end(); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1873 return; | 1930 return; |
1874 | 1931 |
1875 capturer_->SetApplyRotation(apply_rotation); | 1932 capturer_->SetApplyRotation(apply_rotation); |
1876 } | 1933 } |
1877 | 1934 |
1878 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions( | 1935 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions( |
1879 const VideoOptions& options) { | 1936 const VideoOptions& options) { |
1880 rtc::CritScope cs(&lock_); | 1937 rtc::CritScope cs(&lock_); |
1881 VideoCodecSettings codec_settings; | 1938 VideoCodecSettings codec_settings; |
1882 if (parameters_.codec_settings.Get(&codec_settings)) { | 1939 if (parameters_.codec_settings.Get(&codec_settings)) { |
1940 LOG(LS_INFO) << "SetCodecAndOptions because of SetOptions; options=" | |
1941 << options.ToString(); | |
1883 SetCodecAndOptions(codec_settings, options); | 1942 SetCodecAndOptions(codec_settings, options); |
1884 } else { | 1943 } else { |
1885 parameters_.options = options; | 1944 parameters_.options = options; |
1886 } | 1945 } |
1887 } | 1946 } |
1888 | 1947 |
1889 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetCodec( | 1948 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetCodec( |
1890 const VideoCodecSettings& codec_settings) { | 1949 const VideoCodecSettings& codec_settings) { |
1891 rtc::CritScope cs(&lock_); | 1950 rtc::CritScope cs(&lock_); |
1951 LOG(LS_INFO) << "SetCodecAndOptions because of SetCodec."; | |
1892 SetCodecAndOptions(codec_settings, parameters_.options); | 1952 SetCodecAndOptions(codec_settings, parameters_.options); |
1893 } | 1953 } |
1894 | 1954 |
1895 webrtc::VideoCodecType CodecTypeFromName(const std::string& name) { | 1955 webrtc::VideoCodecType CodecTypeFromName(const std::string& name) { |
1896 if (CodecNamesEq(name, kVp8CodecName)) { | 1956 if (CodecNamesEq(name, kVp8CodecName)) { |
1897 return webrtc::kVideoCodecVP8; | 1957 return webrtc::kVideoCodecVP8; |
1898 } else if (CodecNamesEq(name, kVp9CodecName)) { | 1958 } else if (CodecNamesEq(name, kVp9CodecName)) { |
1899 return webrtc::kVideoCodecVP9; | 1959 return webrtc::kVideoCodecVP9; |
1900 } else if (CodecNamesEq(name, kH264CodecName)) { | 1960 } else if (CodecNamesEq(name, kH264CodecName)) { |
1901 return webrtc::kVideoCodecH264; | 1961 return webrtc::kVideoCodecH264; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1978 | 2038 |
1979 parameters_.config.rtp.nack.rtp_history_ms = | 2039 parameters_.config.rtp.nack.rtp_history_ms = |
1980 HasNack(codec_settings.codec) ? kNackHistoryMs : 0; | 2040 HasNack(codec_settings.codec) ? kNackHistoryMs : 0; |
1981 | 2041 |
1982 options.suspend_below_min_bitrate.Get( | 2042 options.suspend_below_min_bitrate.Get( |
1983 ¶meters_.config.suspend_below_min_bitrate); | 2043 ¶meters_.config.suspend_below_min_bitrate); |
1984 | 2044 |
1985 parameters_.codec_settings.Set(codec_settings); | 2045 parameters_.codec_settings.Set(codec_settings); |
1986 parameters_.options = options; | 2046 parameters_.options = options; |
1987 | 2047 |
2048 LOG(LS_INFO) | |
2049 << "RecreateWebRtcStream (send) because of SetCodecAndOptions; options=" | |
2050 << options.ToString(); | |
1988 RecreateWebRtcStream(); | 2051 RecreateWebRtcStream(); |
1989 if (allocated_encoder_.encoder != new_encoder.encoder) { | 2052 if (allocated_encoder_.encoder != new_encoder.encoder) { |
1990 DestroyVideoEncoder(&allocated_encoder_); | 2053 DestroyVideoEncoder(&allocated_encoder_); |
1991 allocated_encoder_ = new_encoder; | 2054 allocated_encoder_ = new_encoder; |
1992 } | 2055 } |
1993 } | 2056 } |
1994 | 2057 |
1995 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetRtpExtensions( | 2058 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetRtpExtensions( |
1996 const std::vector<webrtc::RtpExtension>& rtp_extensions) { | 2059 const std::vector<webrtc::RtpExtension>& rtp_extensions) { |
1997 rtc::CritScope cs(&lock_); | 2060 rtc::CritScope cs(&lock_); |
1998 parameters_.config.rtp.extensions = rtp_extensions; | 2061 parameters_.config.rtp.extensions = rtp_extensions; |
1999 if (stream_ != nullptr) | 2062 if (stream_ != nullptr) { |
2063 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetRtpExtensions"; | |
2000 RecreateWebRtcStream(); | 2064 RecreateWebRtcStream(); |
2065 } | |
2001 } | 2066 } |
2002 | 2067 |
2003 webrtc::VideoEncoderConfig | 2068 webrtc::VideoEncoderConfig |
2004 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( | 2069 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( |
2005 const Dimensions& dimensions, | 2070 const Dimensions& dimensions, |
2006 const VideoCodec& codec) const { | 2071 const VideoCodec& codec) const { |
2007 webrtc::VideoEncoderConfig encoder_config; | 2072 webrtc::VideoEncoderConfig encoder_config; |
2008 if (dimensions.is_screencast) { | 2073 if (dimensions.is_screencast) { |
2009 int screencast_min_bitrate_kbps; | 2074 int screencast_min_bitrate_kbps; |
2010 parameters_.options.screencast_min_bitrate.Get( | 2075 parameters_.options.screencast_min_bitrate.Get( |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2270 default_stream_(default_stream), | 2335 default_stream_(default_stream), |
2271 config_(config), | 2336 config_(config), |
2272 external_decoder_factory_(external_decoder_factory), | 2337 external_decoder_factory_(external_decoder_factory), |
2273 renderer_(NULL), | 2338 renderer_(NULL), |
2274 last_width_(-1), | 2339 last_width_(-1), |
2275 last_height_(-1), | 2340 last_height_(-1), |
2276 first_frame_timestamp_(-1), | 2341 first_frame_timestamp_(-1), |
2277 estimated_remote_start_ntp_time_ms_(0) { | 2342 estimated_remote_start_ntp_time_ms_(0) { |
2278 config_.renderer = this; | 2343 config_.renderer = this; |
2279 // SetRecvCodecs will also reset (start) the VideoReceiveStream. | 2344 // SetRecvCodecs will also reset (start) the VideoReceiveStream. |
2345 LOG(LS_INFO) << "SetRecvCodecs (recv) because we are creating the receive " | |
2346 "stream for the first time: " | |
2347 << CodecSettingsVectorToString(recv_codecs); | |
2280 SetRecvCodecs(recv_codecs); | 2348 SetRecvCodecs(recv_codecs); |
2281 } | 2349 } |
2282 | 2350 |
2283 WebRtcVideoChannel2::WebRtcVideoReceiveStream::AllocatedDecoder:: | 2351 WebRtcVideoChannel2::WebRtcVideoReceiveStream::AllocatedDecoder:: |
2284 AllocatedDecoder(webrtc::VideoDecoder* decoder, | 2352 AllocatedDecoder(webrtc::VideoDecoder* decoder, |
2285 webrtc::VideoCodecType type, | 2353 webrtc::VideoCodecType type, |
2286 bool external) | 2354 bool external) |
2287 : decoder(decoder), | 2355 : decoder(decoder), |
2288 external_decoder(nullptr), | 2356 external_decoder(nullptr), |
2289 type(type), | 2357 type(type), |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2365 decoder.payload_name = recv_codecs[i].codec.name; | 2433 decoder.payload_name = recv_codecs[i].codec.name; |
2366 config_.decoders.push_back(decoder); | 2434 config_.decoders.push_back(decoder); |
2367 } | 2435 } |
2368 | 2436 |
2369 // TODO(pbos): Reconfigure RTX based on incoming recv_codecs. | 2437 // TODO(pbos): Reconfigure RTX based on incoming recv_codecs. |
2370 config_.rtp.fec = recv_codecs.front().fec; | 2438 config_.rtp.fec = recv_codecs.front().fec; |
2371 config_.rtp.nack.rtp_history_ms = | 2439 config_.rtp.nack.rtp_history_ms = |
2372 HasNack(recv_codecs.begin()->codec) ? kNackHistoryMs : 0; | 2440 HasNack(recv_codecs.begin()->codec) ? kNackHistoryMs : 0; |
2373 | 2441 |
2374 ClearDecoders(&old_decoders); | 2442 ClearDecoders(&old_decoders); |
2443 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRecvCodecs: " | |
2444 << CodecSettingsVectorToString(recv_codecs); | |
2375 RecreateWebRtcStream(); | 2445 RecreateWebRtcStream(); |
2376 } | 2446 } |
2377 | 2447 |
2378 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetLocalSsrc( | 2448 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetLocalSsrc( |
2379 uint32_t local_ssrc) { | 2449 uint32_t local_ssrc) { |
2380 // TODO(pbos): Consider turning this sanity check into a DCHECK. You should | 2450 // TODO(pbos): Consider turning this sanity check into a DCHECK. You should |
2381 // not be able to create a sender with the same SSRC as a receiver, but right | 2451 // not be able to create a sender with the same SSRC as a receiver, but right |
2382 // now this can't be done due to unittests depending on receiving what they | 2452 // now this can't be done due to unittests depending on receiving what they |
2383 // are sending from the same MediaChannel. | 2453 // are sending from the same MediaChannel. |
2384 if (local_ssrc == config_.rtp.remote_ssrc) | 2454 if (local_ssrc == config_.rtp.remote_ssrc) { |
2455 LOG(LS_INFO) << "Ignoring call to SetLocalSsrc because parameters are " | |
2456 "unchanged; local_ssrc=" << local_ssrc; | |
2385 return; | 2457 return; |
2458 } | |
2386 | 2459 |
2387 config_.rtp.local_ssrc = local_ssrc; | 2460 config_.rtp.local_ssrc = local_ssrc; |
2461 LOG(LS_INFO) | |
2462 << "RecreateWebRtcStream (recv) because of SetLocalSsrc; local_ssrc=" | |
2463 << local_ssrc; | |
2388 RecreateWebRtcStream(); | 2464 RecreateWebRtcStream(); |
2389 } | 2465 } |
2390 | 2466 |
2391 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetNackAndRemb( | 2467 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetNackAndRemb( |
2392 bool nack_enabled, bool remb_enabled) { | 2468 bool nack_enabled, bool remb_enabled) { |
2393 int nack_history_ms = nack_enabled ? kNackHistoryMs : 0; | 2469 int nack_history_ms = nack_enabled ? kNackHistoryMs : 0; |
2394 if (config_.rtp.nack.rtp_history_ms == nack_history_ms && | 2470 if (config_.rtp.nack.rtp_history_ms == nack_history_ms && |
2395 config_.rtp.remb == remb_enabled) { | 2471 config_.rtp.remb == remb_enabled) { |
2472 LOG(LS_INFO) << "Ignoring call to SetNackAndRemb because parameters are " | |
2473 "unchanged; nack=" << nack_enabled | |
2474 << ", remb=" << remb_enabled; | |
2396 return; | 2475 return; |
2397 } | 2476 } |
2398 config_.rtp.remb = remb_enabled; | 2477 config_.rtp.remb = remb_enabled; |
2399 config_.rtp.nack.rtp_history_ms = nack_history_ms; | 2478 config_.rtp.nack.rtp_history_ms = nack_history_ms; |
2479 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetNackAndRemb; nack=" | |
2480 << nack_enabled << ", remb=" << remb_enabled; | |
2400 RecreateWebRtcStream(); | 2481 RecreateWebRtcStream(); |
2401 } | 2482 } |
2402 | 2483 |
2403 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRtpExtensions( | 2484 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRtpExtensions( |
2404 const std::vector<webrtc::RtpExtension>& extensions) { | 2485 const std::vector<webrtc::RtpExtension>& extensions) { |
2405 config_.rtp.extensions = extensions; | 2486 config_.rtp.extensions = extensions; |
2487 LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRtpExtensions"; | |
2406 RecreateWebRtcStream(); | 2488 RecreateWebRtcStream(); |
2407 } | 2489 } |
2408 | 2490 |
2409 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { | 2491 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { |
2410 if (stream_ != NULL) { | 2492 if (stream_ != NULL) { |
2411 call_->DestroyVideoReceiveStream(stream_); | 2493 call_->DestroyVideoReceiveStream(stream_); |
2412 } | 2494 } |
2413 stream_ = call_->CreateVideoReceiveStream(config_); | 2495 stream_ = call_->CreateVideoReceiveStream(config_); |
2414 stream_->Start(); | 2496 stream_->Start(); |
2415 } | 2497 } |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2639 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2721 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2640 } | 2722 } |
2641 } | 2723 } |
2642 | 2724 |
2643 return video_codecs; | 2725 return video_codecs; |
2644 } | 2726 } |
2645 | 2727 |
2646 } // namespace cricket | 2728 } // namespace cricket |
2647 | 2729 |
2648 #endif // HAVE_WEBRTC_VIDEO | 2730 #endif // HAVE_WEBRTC_VIDEO |
OLD | NEW |