Chromium Code Reviews| 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 <string> | 15 #include <string> |
| 16 | 16 |
| 17 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
| 18 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 18 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
| 19 #include "webrtc/system_wrappers/interface/clock.h" | 19 #include "webrtc/system_wrappers/interface/clock.h" |
| 20 #include "webrtc/system_wrappers/interface/logging.h" | 20 #include "webrtc/system_wrappers/interface/logging.h" |
| 21 #include "webrtc/video/receive_statistics_proxy.h" | 21 #include "webrtc/video/receive_statistics_proxy.h" |
| 22 #include "webrtc/video_encoder.h" | |
| 23 #include "webrtc/video_receive_stream.h" | 22 #include "webrtc/video_receive_stream.h" |
| 24 | 23 |
| 25 namespace webrtc { | 24 namespace webrtc { |
| 26 std::string VideoReceiveStream::Decoder::ToString() const { | 25 std::string VideoReceiveStream::Decoder::ToString() const { |
| 27 std::stringstream ss; | 26 std::stringstream ss; |
| 28 ss << "{decoder: " << (decoder != nullptr ? "(VideoDecoder)" : "nullptr"); | 27 ss << "{decoder: " << (decoder != nullptr ? "(VideoDecoder)" : "nullptr"); |
| 29 ss << ", payload_type: " << payload_type; | 28 ss << ", payload_type: " << payload_type; |
| 30 ss << ", payload_name: " << payload_name; | 29 ss << ", payload_name: " << payload_name; |
| 31 ss << ", is_renderer: " << (is_renderer ? "yes" : "no"); | 30 ss << ", is_renderer: " << (is_renderer ? "yes" : "no"); |
| 32 ss << ", expected_delay_ms: " << expected_delay_ms; | 31 ss << ", expected_delay_ms: " << expected_delay_ms; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 VideoCodec codec = CreateDecoderVideoCodec(decoder); | 237 VideoCodec codec = CreateDecoderVideoCodec(decoder); |
| 239 | 238 |
| 240 RTC_CHECK_EQ(0, vie_channel_->SetReceiveCodec(codec)); | 239 RTC_CHECK_EQ(0, vie_channel_->SetReceiveCodec(codec)); |
| 241 } | 240 } |
| 242 | 241 |
| 243 incoming_video_stream_.reset(new IncomingVideoStream(0)); | 242 incoming_video_stream_.reset(new IncomingVideoStream(0)); |
| 244 incoming_video_stream_->SetExpectedRenderDelay(config.render_delay_ms); | 243 incoming_video_stream_->SetExpectedRenderDelay(config.render_delay_ms); |
| 245 incoming_video_stream_->SetExternalCallback(this); | 244 incoming_video_stream_->SetExternalCallback(this); |
| 246 vie_channel_->SetIncomingVideoStream(incoming_video_stream_.get()); | 245 vie_channel_->SetIncomingVideoStream(incoming_video_stream_.get()); |
| 247 | 246 |
| 248 if (config.pre_decode_callback) | 247 vie_channel_->RegisterPreDecodeImageCallback(this); |
| 249 vie_channel_->RegisterPreDecodeImageCallback(&encoded_frame_proxy_); | |
| 250 vie_channel_->RegisterPreRenderCallback(this); | 248 vie_channel_->RegisterPreRenderCallback(this); |
| 251 } | 249 } |
| 252 | 250 |
| 253 VideoReceiveStream::~VideoReceiveStream() { | 251 VideoReceiveStream::~VideoReceiveStream() { |
| 254 incoming_video_stream_->Stop(); | 252 incoming_video_stream_->Stop(); |
| 255 vie_channel_->RegisterPreRenderCallback(nullptr); | 253 vie_channel_->RegisterPreRenderCallback(nullptr); |
| 256 vie_channel_->RegisterPreDecodeImageCallback(nullptr); | 254 vie_channel_->RegisterPreDecodeImageCallback(nullptr); |
| 257 | 255 |
| 258 for (size_t i = 0; i < config_.decoders.size(); ++i) | 256 for (size_t i = 0; i < config_.decoders.size(); ++i) |
| 259 vie_channel_->DeRegisterExternalDecoder(config_.decoders[i].payload_type); | 257 vie_channel_->DeRegisterExternalDecoder(config_.decoders[i].payload_type); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 if (config_.renderer != nullptr) | 315 if (config_.renderer != nullptr) |
| 318 config_.renderer->RenderFrame( | 316 config_.renderer->RenderFrame( |
| 319 video_frame, | 317 video_frame, |
| 320 video_frame.render_time_ms() - clock_->TimeInMilliseconds()); | 318 video_frame.render_time_ms() - clock_->TimeInMilliseconds()); |
| 321 | 319 |
| 322 stats_proxy_->OnRenderedFrame(video_frame.width(), video_frame.height()); | 320 stats_proxy_->OnRenderedFrame(video_frame.width(), video_frame.height()); |
| 323 | 321 |
| 324 return 0; | 322 return 0; |
| 325 } | 323 } |
| 326 | 324 |
| 325 int32_t VideoReceiveStream::Encoded( | |
|
stefan-webrtc
2015/10/15 12:49:35
I find it a bit strange that we use an encode call
åsapersson
2015/10/16 09:33:59
Do this in a separate CL? Added comment.
stefan-webrtc
2015/10/16 09:40:10
Sounds good.
| |
| 326 const EncodedImage& encoded_image, | |
| 327 const CodecSpecificInfo* codec_specific_info, | |
| 328 const RTPFragmentationHeader* fragmentation) { | |
| 329 stats_proxy_->Encoded(encoded_image, codec_specific_info); | |
| 330 if (config_.pre_decode_callback) { | |
| 331 encoded_frame_proxy_.Encoded( | |
| 332 encoded_image, codec_specific_info, fragmentation); | |
| 333 } | |
| 334 return 0; | |
| 335 } | |
| 336 | |
| 327 void VideoReceiveStream::SignalNetworkState(NetworkState state) { | 337 void VideoReceiveStream::SignalNetworkState(NetworkState state) { |
| 328 if (state == kNetworkUp) | 338 if (state == kNetworkUp) |
| 329 SetRtcpMode(config_.rtp.rtcp_mode); | 339 SetRtcpMode(config_.rtp.rtcp_mode); |
| 330 if (state == kNetworkDown) | 340 if (state == kNetworkDown) |
| 331 vie_channel_->SetRTCPMode(kRtcpOff); | 341 vie_channel_->SetRTCPMode(kRtcpOff); |
| 332 } | 342 } |
| 333 | 343 |
| 334 void VideoReceiveStream::SetRtcpMode(newapi::RtcpMode mode) { | 344 void VideoReceiveStream::SetRtcpMode(newapi::RtcpMode mode) { |
| 335 switch (mode) { | 345 switch (mode) { |
| 336 case newapi::kRtcpCompound: | 346 case newapi::kRtcpCompound: |
| 337 vie_channel_->SetRTCPMode(kRtcpCompound); | 347 vie_channel_->SetRTCPMode(kRtcpCompound); |
| 338 break; | 348 break; |
| 339 case newapi::kRtcpReducedSize: | 349 case newapi::kRtcpReducedSize: |
| 340 vie_channel_->SetRTCPMode(kRtcpNonCompound); | 350 vie_channel_->SetRTCPMode(kRtcpNonCompound); |
| 341 break; | 351 break; |
| 342 } | 352 } |
| 343 } | 353 } |
| 344 } // namespace internal | 354 } // namespace internal |
| 345 } // namespace webrtc | 355 } // namespace webrtc |
| OLD | NEW |