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 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 receive_streams_.erase(prev_stream); | 1177 receive_streams_.erase(prev_stream); |
1178 } | 1178 } |
1179 | 1179 |
1180 if (!ValidateReceiveSsrcAvailability(sp)) | 1180 if (!ValidateReceiveSsrcAvailability(sp)) |
1181 return false; | 1181 return false; |
1182 | 1182 |
1183 for (uint32_t used_ssrc : sp.ssrcs) | 1183 for (uint32_t used_ssrc : sp.ssrcs) |
1184 receive_ssrcs_.insert(used_ssrc); | 1184 receive_ssrcs_.insert(used_ssrc); |
1185 | 1185 |
1186 webrtc::VideoReceiveStream::Config config(this); | 1186 webrtc::VideoReceiveStream::Config config(this); |
1187 webrtc::FlexfecConfig flexfec_config; | 1187 webrtc::FlexfecReceiveStream::Config flexfec_config(this); |
1188 ConfigureReceiverRtp(&config, &flexfec_config, sp); | 1188 ConfigureReceiverRtp(&config, &flexfec_config, sp); |
1189 | 1189 |
1190 config.disable_prerenderer_smoothing = | 1190 config.disable_prerenderer_smoothing = |
1191 video_config_.disable_prerenderer_smoothing; | 1191 video_config_.disable_prerenderer_smoothing; |
1192 config.sync_group = sp.sync_label; | 1192 config.sync_group = sp.sync_label; |
1193 | 1193 |
1194 receive_streams_[ssrc] = new WebRtcVideoReceiveStream( | 1194 receive_streams_[ssrc] = new WebRtcVideoReceiveStream( |
1195 call_, sp, std::move(config), external_decoder_factory_, default_stream, | 1195 call_, sp, std::move(config), external_decoder_factory_, default_stream, |
1196 recv_codecs_, flexfec_config); | 1196 recv_codecs_, flexfec_config); |
1197 | 1197 |
1198 return true; | 1198 return true; |
1199 } | 1199 } |
1200 | 1200 |
1201 void WebRtcVideoChannel2::ConfigureReceiverRtp( | 1201 void WebRtcVideoChannel2::ConfigureReceiverRtp( |
1202 webrtc::VideoReceiveStream::Config* config, | 1202 webrtc::VideoReceiveStream::Config* config, |
1203 webrtc::FlexfecConfig* flexfec_config, | 1203 webrtc::FlexfecReceiveStream::Config* flexfec_config, |
1204 const StreamParams& sp) const { | 1204 const StreamParams& sp) const { |
1205 uint32_t ssrc = sp.first_ssrc(); | 1205 uint32_t ssrc = sp.first_ssrc(); |
1206 | 1206 |
1207 config->rtp.remote_ssrc = ssrc; | 1207 config->rtp.remote_ssrc = ssrc; |
1208 config->rtp.local_ssrc = rtcp_receiver_report_ssrc_; | 1208 config->rtp.local_ssrc = rtcp_receiver_report_ssrc_; |
1209 | 1209 |
1210 // TODO(pbos): This protection is against setting the same local ssrc as | 1210 // TODO(pbos): This protection is against setting the same local ssrc as |
1211 // remote which is not permitted by the lower-level API. RTCP requires a | 1211 // remote which is not permitted by the lower-level API. RTCP requires a |
1212 // corresponding sender SSRC. Figure out what to do when we don't have | 1212 // corresponding sender SSRC. Figure out what to do when we don't have |
1213 // (receive-only) or know a good local SSRC. | 1213 // (receive-only) or know a good local SSRC. |
(...skipping 12 matching lines...) Expand all Loading... |
1226 // receiver_params_. | 1226 // receiver_params_. |
1227 config->rtp.rtcp_mode = send_params_.rtcp.reduced_size | 1227 config->rtp.rtcp_mode = send_params_.rtcp.reduced_size |
1228 ? webrtc::RtcpMode::kReducedSize | 1228 ? webrtc::RtcpMode::kReducedSize |
1229 : webrtc::RtcpMode::kCompound; | 1229 : webrtc::RtcpMode::kCompound; |
1230 | 1230 |
1231 config->rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; | 1231 config->rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; |
1232 config->rtp.transport_cc = | 1232 config->rtp.transport_cc = |
1233 send_codec_ ? HasTransportCc(send_codec_->codec) : false; | 1233 send_codec_ ? HasTransportCc(send_codec_->codec) : false; |
1234 | 1234 |
1235 // TODO(brandtr): Generalize when we add support for multistream protection. | 1235 // TODO(brandtr): Generalize when we add support for multistream protection. |
1236 uint32_t flexfec_ssrc; | 1236 if (sp.GetFecFrSsrc(ssrc, &flexfec_config->remote_ssrc)) { |
1237 if (sp.GetFecFrSsrc(ssrc, &flexfec_ssrc)) { | |
1238 flexfec_config->flexfec_ssrc = flexfec_ssrc; | |
1239 flexfec_config->protected_media_ssrcs = {ssrc}; | 1237 flexfec_config->protected_media_ssrcs = {ssrc}; |
| 1238 flexfec_config->local_ssrc = config->rtp.local_ssrc; |
| 1239 flexfec_config->rtcp_mode = config->rtp.rtcp_mode; |
| 1240 flexfec_config->transport_cc = config->rtp.transport_cc; |
| 1241 flexfec_config->rtp_header_extensions = config->rtp.extensions; |
1240 } | 1242 } |
1241 | 1243 |
1242 for (size_t i = 0; i < recv_codecs_.size(); ++i) { | 1244 for (size_t i = 0; i < recv_codecs_.size(); ++i) { |
1243 uint32_t rtx_ssrc; | 1245 uint32_t rtx_ssrc; |
1244 if (recv_codecs_[i].rtx_payload_type != -1 && | 1246 if (recv_codecs_[i].rtx_payload_type != -1 && |
1245 sp.GetFidSsrc(ssrc, &rtx_ssrc)) { | 1247 sp.GetFidSsrc(ssrc, &rtx_ssrc)) { |
1246 webrtc::VideoReceiveStream::Config::Rtp::Rtx& rtx = | 1248 webrtc::VideoReceiveStream::Config::Rtp::Rtx& rtx = |
1247 config->rtp.rtx[recv_codecs_[i].codec.id]; | 1249 config->rtp.rtx[recv_codecs_[i].codec.id]; |
1248 rtx.ssrc = rtx_ssrc; | 1250 rtx.ssrc = rtx_ssrc; |
1249 rtx.payload_type = recv_codecs_[i].rtx_payload_type; | 1251 rtx.payload_type = recv_codecs_[i].rtx_payload_type; |
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2153 UpdateSendState(); | 2155 UpdateSendState(); |
2154 } | 2156 } |
2155 | 2157 |
2156 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( | 2158 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( |
2157 webrtc::Call* call, | 2159 webrtc::Call* call, |
2158 const StreamParams& sp, | 2160 const StreamParams& sp, |
2159 webrtc::VideoReceiveStream::Config config, | 2161 webrtc::VideoReceiveStream::Config config, |
2160 WebRtcVideoDecoderFactory* external_decoder_factory, | 2162 WebRtcVideoDecoderFactory* external_decoder_factory, |
2161 bool default_stream, | 2163 bool default_stream, |
2162 const std::vector<VideoCodecSettings>& recv_codecs, | 2164 const std::vector<VideoCodecSettings>& recv_codecs, |
2163 const webrtc::FlexfecConfig& flexfec_config) | 2165 const webrtc::FlexfecReceiveStream::Config& flexfec_config) |
2164 : call_(call), | 2166 : call_(call), |
2165 stream_params_(sp), | 2167 stream_params_(sp), |
2166 stream_(NULL), | 2168 stream_(NULL), |
2167 default_stream_(default_stream), | 2169 default_stream_(default_stream), |
2168 config_(std::move(config)), | 2170 config_(std::move(config)), |
2169 flexfec_config_(flexfec_config), | 2171 flexfec_config_(flexfec_config), |
2170 flexfec_stream_(nullptr), | 2172 flexfec_stream_(nullptr), |
2171 external_decoder_factory_(external_decoder_factory), | 2173 external_decoder_factory_(external_decoder_factory), |
2172 sink_(NULL), | 2174 sink_(NULL), |
2173 first_frame_timestamp_(-1), | 2175 first_frame_timestamp_(-1), |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2262 webrtc::VideoReceiveStream::Decoder decoder; | 2264 webrtc::VideoReceiveStream::Decoder decoder; |
2263 decoder.decoder = allocated_decoder.decoder; | 2265 decoder.decoder = allocated_decoder.decoder; |
2264 decoder.payload_type = recv_codecs[i].codec.id; | 2266 decoder.payload_type = recv_codecs[i].codec.id; |
2265 decoder.payload_name = recv_codecs[i].codec.name; | 2267 decoder.payload_name = recv_codecs[i].codec.name; |
2266 decoder.codec_params = recv_codecs[i].codec.params; | 2268 decoder.codec_params = recv_codecs[i].codec.params; |
2267 config_.decoders.push_back(decoder); | 2269 config_.decoders.push_back(decoder); |
2268 } | 2270 } |
2269 | 2271 |
2270 // TODO(pbos): Reconfigure RTX based on incoming recv_codecs. | 2272 // TODO(pbos): Reconfigure RTX based on incoming recv_codecs. |
2271 config_.rtp.ulpfec = recv_codecs.front().ulpfec; | 2273 config_.rtp.ulpfec = recv_codecs.front().ulpfec; |
2272 flexfec_config_.flexfec_payload_type = | 2274 flexfec_config_.payload_type = recv_codecs.front().flexfec_payload_type; |
2273 recv_codecs.front().flexfec_payload_type; | |
2274 | 2275 |
2275 config_.rtp.nack.rtp_history_ms = | 2276 config_.rtp.nack.rtp_history_ms = |
2276 HasNack(recv_codecs.begin()->codec) ? kNackHistoryMs : 0; | 2277 HasNack(recv_codecs.begin()->codec) ? kNackHistoryMs : 0; |
2277 } | 2278 } |
2278 | 2279 |
2279 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetLocalSsrc( | 2280 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetLocalSsrc( |
2280 uint32_t local_ssrc) { | 2281 uint32_t local_ssrc) { |
2281 // TODO(pbos): Consider turning this sanity check into a RTC_DCHECK. You | 2282 // TODO(pbos): Consider turning this sanity check into a RTC_DCHECK. You |
2282 // should not be able to create a sender with the same SSRC as a receiver, but | 2283 // should not be able to create a sender with the same SSRC as a receiver, but |
2283 // right now this can't be done due to unittests depending on receiving what | 2284 // right now this can't be done due to unittests depending on receiving what |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2346 if (flexfec_stream_) { | 2347 if (flexfec_stream_) { |
2347 call_->DestroyFlexfecReceiveStream(flexfec_stream_); | 2348 call_->DestroyFlexfecReceiveStream(flexfec_stream_); |
2348 flexfec_stream_ = nullptr; | 2349 flexfec_stream_ = nullptr; |
2349 } | 2350 } |
2350 if (stream_) { | 2351 if (stream_) { |
2351 call_->DestroyVideoReceiveStream(stream_); | 2352 call_->DestroyVideoReceiveStream(stream_); |
2352 } | 2353 } |
2353 stream_ = call_->CreateVideoReceiveStream(config_.Copy()); | 2354 stream_ = call_->CreateVideoReceiveStream(config_.Copy()); |
2354 stream_->Start(); | 2355 stream_->Start(); |
2355 if (IsFlexfecFieldTrialEnabled() && flexfec_config_.IsCompleteAndEnabled()) { | 2356 if (IsFlexfecFieldTrialEnabled() && flexfec_config_.IsCompleteAndEnabled()) { |
2356 webrtc::FlexfecReceiveStream::Config config; | 2357 flexfec_stream_ = call_->CreateFlexfecReceiveStream(flexfec_config_); |
2357 // Payload types and SSRCs come from the FlexFEC specific part of the SDP. | |
2358 config.payload_type = flexfec_config_.flexfec_payload_type; | |
2359 config.remote_ssrc = flexfec_config_.flexfec_ssrc; | |
2360 config.protected_media_ssrcs = flexfec_config_.protected_media_ssrcs; | |
2361 // RTCP messages and RTP header extensions apply to the entire track | |
2362 // in the SDP. | |
2363 config.transport_cc = config_.rtp.transport_cc; | |
2364 config.rtp_header_extensions = config_.rtp.extensions; | |
2365 flexfec_stream_ = call_->CreateFlexfecReceiveStream(config); | |
2366 flexfec_stream_->Start(); | 2358 flexfec_stream_->Start(); |
2367 } | 2359 } |
2368 } | 2360 } |
2369 | 2361 |
2370 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders( | 2362 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders( |
2371 std::vector<AllocatedDecoder>* allocated_decoders) { | 2363 std::vector<AllocatedDecoder>* allocated_decoders) { |
2372 for (size_t i = 0; i < allocated_decoders->size(); ++i) { | 2364 for (size_t i = 0; i < allocated_decoders->size(); ++i) { |
2373 if ((*allocated_decoders)[i].external) { | 2365 if ((*allocated_decoders)[i].external) { |
2374 external_decoder_factory_->DestroyVideoDecoder( | 2366 external_decoder_factory_->DestroyVideoDecoder( |
2375 (*allocated_decoders)[i].external_decoder); | 2367 (*allocated_decoders)[i].external_decoder); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2587 rtx_mapping[video_codecs[i].codec.id] != | 2579 rtx_mapping[video_codecs[i].codec.id] != |
2588 ulpfec_config.red_payload_type) { | 2580 ulpfec_config.red_payload_type) { |
2589 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2581 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2590 } | 2582 } |
2591 } | 2583 } |
2592 | 2584 |
2593 return video_codecs; | 2585 return video_codecs; |
2594 } | 2586 } |
2595 | 2587 |
2596 } // namespace cricket | 2588 } // namespace cricket |
OLD | NEW |