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