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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 const int kDefaultStartBitrate = 300; | 162 const int kDefaultStartBitrate = 300; |
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(int num_cpu_cores, | 172 VideoReceiveStream::VideoReceiveStream( |
172 PacketRouter* packet_router, | 173 RtpStreamReceiverControllerInterface* receiver_controller, |
173 VideoReceiveStream::Config config, | 174 int num_cpu_cores, |
174 ProcessThread* process_thread, | 175 PacketRouter* packet_router, |
175 CallStats* call_stats) | 176 VideoReceiveStream::Config config, |
| 177 ProcessThread* process_thread, |
| 178 CallStats* call_stats) |
176 : transport_adapter_(config.rtcp_send_transport), | 179 : transport_adapter_(config.rtcp_send_transport), |
177 config_(std::move(config)), | 180 config_(std::move(config)), |
178 num_cpu_cores_(num_cpu_cores), | 181 num_cpu_cores_(num_cpu_cores), |
179 process_thread_(process_thread), | 182 process_thread_(process_thread), |
180 clock_(Clock::GetRealTimeClock()), | 183 clock_(Clock::GetRealTimeClock()), |
181 decode_thread_(&DecodeThreadFunction, | 184 decode_thread_(&DecodeThreadFunction, |
182 this, | 185 this, |
183 "DecodingThread", | 186 "DecodingThread", |
184 rtc::kHighestPriority), | 187 rtc::kHighestPriority), |
185 call_stats_(call_stats), | 188 call_stats_(call_stats), |
(...skipping 29 matching lines...) Expand all Loading... |
215 decoder_payload_types.insert(decoder.payload_type); | 218 decoder_payload_types.insert(decoder.payload_type); |
216 } | 219 } |
217 | 220 |
218 video_receiver_.SetRenderDelay(config.render_delay_ms); | 221 video_receiver_.SetRenderDelay(config.render_delay_ms); |
219 | 222 |
220 jitter_estimator_.reset(new VCMJitterEstimator(clock_)); | 223 jitter_estimator_.reset(new VCMJitterEstimator(clock_)); |
221 frame_buffer_.reset(new video_coding::FrameBuffer( | 224 frame_buffer_.reset(new video_coding::FrameBuffer( |
222 clock_, jitter_estimator_.get(), timing_.get(), &stats_proxy_)); | 225 clock_, jitter_estimator_.get(), timing_.get(), &stats_proxy_)); |
223 | 226 |
224 process_thread_->RegisterModule(&rtp_stream_sync_, RTC_FROM_HERE); | 227 process_thread_->RegisterModule(&rtp_stream_sync_, RTC_FROM_HERE); |
| 228 |
| 229 // Register with RtpStreamReceiverController. |
| 230 media_receiver_ = receiver_controller->CreateReceiver( |
| 231 config_.rtp.remote_ssrc, &rtp_video_stream_receiver_); |
| 232 if (config.rtp.rtx_ssrc) { |
| 233 rtx_receiver_ = receiver_controller->CreateReceiver( |
| 234 config_.rtp.rtx_ssrc, &rtp_video_stream_receiver_); |
| 235 } |
225 } | 236 } |
226 | 237 |
227 VideoReceiveStream::~VideoReceiveStream() { | 238 VideoReceiveStream::~VideoReceiveStream() { |
228 RTC_DCHECK_RUN_ON(&worker_thread_checker_); | 239 RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
229 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 240 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); |
230 Stop(); | 241 Stop(); |
231 | 242 |
232 process_thread_->DeRegisterModule(&rtp_stream_sync_); | 243 process_thread_->DeRegisterModule(&rtp_stream_sync_); |
233 } | 244 } |
234 | 245 |
235 void VideoReceiveStream::SignalNetworkState(NetworkState state) { | 246 void VideoReceiveStream::SignalNetworkState(NetworkState state) { |
236 RTC_DCHECK_RUN_ON(&worker_thread_checker_); | 247 RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
237 rtp_video_stream_receiver_.SignalNetworkState(state); | 248 rtp_video_stream_receiver_.SignalNetworkState(state); |
238 } | 249 } |
239 | 250 |
240 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { | 251 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
241 return rtp_video_stream_receiver_.DeliverRtcp(packet, length); | 252 return rtp_video_stream_receiver_.DeliverRtcp(packet, length); |
242 } | 253 } |
243 | 254 |
244 void VideoReceiveStream::OnRtpPacket(const RtpPacketReceived& packet) { | |
245 rtp_video_stream_receiver_.OnRtpPacket(packet); | |
246 } | |
247 | |
248 void VideoReceiveStream::SetSync(Syncable* audio_syncable) { | 255 void VideoReceiveStream::SetSync(Syncable* audio_syncable) { |
249 RTC_DCHECK_RUN_ON(&worker_thread_checker_); | 256 RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
250 rtp_stream_sync_.ConfigureSync(audio_syncable); | 257 rtp_stream_sync_.ConfigureSync(audio_syncable); |
251 } | 258 } |
252 | 259 |
253 void VideoReceiveStream::Start() { | 260 void VideoReceiveStream::Start() { |
254 RTC_DCHECK_RUN_ON(&worker_thread_checker_); | 261 RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
255 if (decode_thread_.IsRunning()) | 262 if (decode_thread_.IsRunning()) |
256 return; | 263 return; |
257 | 264 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 if (stream_is_active && !receiving_keyframe) { | 512 if (stream_is_active && !receiving_keyframe) { |
506 LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs | 513 LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs |
507 << " ms, requesting keyframe."; | 514 << " ms, requesting keyframe."; |
508 RequestKeyFrame(); | 515 RequestKeyFrame(); |
509 } | 516 } |
510 } | 517 } |
511 return true; | 518 return true; |
512 } | 519 } |
513 } // namespace internal | 520 } // namespace internal |
514 } // namespace webrtc | 521 } // namespace webrtc |
OLD | NEW |