OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
11 #include "webrtc/video/video_receive_stream.h" | 11 #include "webrtc/video/video_receive_stream.h" |
12 | 12 |
13 #include <stdlib.h> | 13 #include <stdlib.h> |
14 | 14 |
15 #include <set> | 15 #include <set> |
16 #include <string> | 16 #include <string> |
17 #include <utility> | 17 #include <utility> |
18 | 18 |
19 #include "webrtc/base/checks.h" | 19 #include "webrtc/base/checks.h" |
20 #include "webrtc/base/location.h" | 20 #include "webrtc/base/location.h" |
21 #include "webrtc/base/logging.h" | 21 #include "webrtc/base/logging.h" |
22 #include "webrtc/base/optional.h" | 22 #include "webrtc/base/optional.h" |
23 #include "webrtc/base/trace_event.h" | 23 #include "webrtc/base/trace_event.h" |
| 24 #include "webrtc/call/rtp_stream_receiver_controller_interface.h" |
24 #include "webrtc/common_types.h" | 25 #include "webrtc/common_types.h" |
25 #include "webrtc/common_video/h264/profile_level_id.h" | 26 #include "webrtc/common_video/h264/profile_level_id.h" |
26 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 27 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
27 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" | 28 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" |
28 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 29 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
29 #include "webrtc/modules/utility/include/process_thread.h" | 30 #include "webrtc/modules/utility/include/process_thread.h" |
30 #include "webrtc/modules/video_coding/frame_object.h" | 31 #include "webrtc/modules/video_coding/frame_object.h" |
31 #include "webrtc/modules/video_coding/include/video_coding.h" | 32 #include "webrtc/modules/video_coding/include/video_coding.h" |
32 #include "webrtc/modules/video_coding/jitter_estimator.h" | 33 #include "webrtc/modules/video_coding/jitter_estimator.h" |
33 #include "webrtc/modules/video_coding/timing.h" | 34 #include "webrtc/modules/video_coding/timing.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 codec.startBitrate = codec.minBitrate = codec.maxBitrate = | 163 codec.startBitrate = codec.minBitrate = codec.maxBitrate = |
163 kDefaultStartBitrate; | 164 kDefaultStartBitrate; |
164 | 165 |
165 return codec; | 166 return codec; |
166 } | 167 } |
167 } // namespace | 168 } // namespace |
168 | 169 |
169 namespace internal { | 170 namespace internal { |
170 | 171 |
171 VideoReceiveStream::VideoReceiveStream( | 172 VideoReceiveStream::VideoReceiveStream( |
| 173 RtpStreamReceiverControllerInterface* receiver_controller, |
172 int num_cpu_cores, | 174 int num_cpu_cores, |
173 PacketRouter* packet_router, | 175 PacketRouter* packet_router, |
174 VideoReceiveStream::Config config, | 176 VideoReceiveStream::Config config, |
175 ProcessThread* process_thread, | 177 ProcessThread* process_thread, |
176 CallStats* call_stats) | 178 CallStats* call_stats) |
177 : transport_adapter_(config.rtcp_send_transport), | 179 : transport_adapter_(config.rtcp_send_transport), |
178 config_(std::move(config)), | 180 config_(std::move(config)), |
179 num_cpu_cores_(num_cpu_cores), | 181 num_cpu_cores_(num_cpu_cores), |
180 process_thread_(process_thread), | 182 process_thread_(process_thread), |
181 clock_(Clock::GetRealTimeClock()), | 183 clock_(Clock::GetRealTimeClock()), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 216 } |
215 | 217 |
216 video_receiver_.SetRenderDelay(config.render_delay_ms); | 218 video_receiver_.SetRenderDelay(config.render_delay_ms); |
217 | 219 |
218 jitter_estimator_.reset(new VCMJitterEstimator(clock_)); | 220 jitter_estimator_.reset(new VCMJitterEstimator(clock_)); |
219 frame_buffer_.reset(new video_coding::FrameBuffer( | 221 frame_buffer_.reset(new video_coding::FrameBuffer( |
220 clock_, jitter_estimator_.get(), timing_.get(), &stats_proxy_)); | 222 clock_, jitter_estimator_.get(), timing_.get(), &stats_proxy_)); |
221 | 223 |
222 process_thread_->RegisterModule(&video_receiver_, RTC_FROM_HERE); | 224 process_thread_->RegisterModule(&video_receiver_, RTC_FROM_HERE); |
223 process_thread_->RegisterModule(&rtp_stream_sync_, RTC_FROM_HERE); | 225 process_thread_->RegisterModule(&rtp_stream_sync_, RTC_FROM_HERE); |
| 226 |
| 227 // Register with RtpStreamReceiverController. |
| 228 media_receiver_ = receiver_controller->CreateReceiver( |
| 229 config_.rtp.remote_ssrc, &rtp_video_stream_receiver_); |
| 230 if (config.rtp.rtx_ssrc) { |
| 231 rtx_receiver_ = receiver_controller->CreateReceiver( |
| 232 config_.rtp.rtx_ssrc, &rtp_video_stream_receiver_); |
| 233 } |
224 } | 234 } |
225 | 235 |
226 VideoReceiveStream::~VideoReceiveStream() { | 236 VideoReceiveStream::~VideoReceiveStream() { |
227 RTC_DCHECK_RUN_ON(&worker_thread_checker_); | 237 RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
228 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 238 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); |
229 Stop(); | 239 Stop(); |
230 | 240 |
231 process_thread_->DeRegisterModule(&rtp_stream_sync_); | 241 process_thread_->DeRegisterModule(&rtp_stream_sync_); |
232 process_thread_->DeRegisterModule(&video_receiver_); | 242 process_thread_->DeRegisterModule(&video_receiver_); |
233 } | 243 } |
234 | 244 |
235 void VideoReceiveStream::SignalNetworkState(NetworkState state) { | 245 void VideoReceiveStream::SignalNetworkState(NetworkState state) { |
236 RTC_DCHECK_RUN_ON(&worker_thread_checker_); | 246 RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
237 rtp_video_stream_receiver_.SignalNetworkState(state); | 247 rtp_video_stream_receiver_.SignalNetworkState(state); |
238 } | 248 } |
239 | 249 |
240 | 250 |
241 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { | 251 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
242 return rtp_video_stream_receiver_.DeliverRtcp(packet, length); | 252 return rtp_video_stream_receiver_.DeliverRtcp(packet, length); |
243 } | 253 } |
244 | 254 |
245 void VideoReceiveStream::OnRtpPacket(const RtpPacketReceived& packet) { | |
246 rtp_video_stream_receiver_.OnRtpPacket(packet); | |
247 } | |
248 | |
249 void VideoReceiveStream::SetSync(Syncable* audio_syncable) { | 255 void VideoReceiveStream::SetSync(Syncable* audio_syncable) { |
250 RTC_DCHECK_RUN_ON(&worker_thread_checker_); | 256 RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
251 rtp_stream_sync_.ConfigureSync(audio_syncable); | 257 rtp_stream_sync_.ConfigureSync(audio_syncable); |
252 } | 258 } |
253 | 259 |
254 void VideoReceiveStream::Start() { | 260 void VideoReceiveStream::Start() { |
255 RTC_DCHECK_RUN_ON(&worker_thread_checker_); | 261 RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
256 if (decode_thread_.IsRunning()) | 262 if (decode_thread_.IsRunning()) |
257 return; | 263 return; |
258 | 264 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 if (stream_is_active && !receiving_keyframe) { | 505 if (stream_is_active && !receiving_keyframe) { |
500 LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs | 506 LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs |
501 << " ms, requesting keyframe."; | 507 << " ms, requesting keyframe."; |
502 RequestKeyFrame(); | 508 RequestKeyFrame(); |
503 } | 509 } |
504 } | 510 } |
505 return true; | 511 return true; |
506 } | 512 } |
507 } // namespace internal | 513 } // namespace internal |
508 } // namespace webrtc | 514 } // namespace webrtc |
OLD | NEW |