| 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 | 17 |
| 18 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
| 19 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
| 20 #include "webrtc/call/congestion_controller.h" | 20 #include "webrtc/call/congestion_controller.h" |
| 21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
| 22 #include "webrtc/modules/utility/include/process_thread.h" | 22 #include "webrtc/modules/utility/include/process_thread.h" |
| 23 #include "webrtc/system_wrappers/include/clock.h" | 23 #include "webrtc/system_wrappers/include/clock.h" |
| 24 #include "webrtc/video/call_stats.h" | 24 #include "webrtc/video/call_stats.h" |
| 25 #include "webrtc/video/receive_statistics_proxy.h" | 25 #include "webrtc/video/receive_statistics_proxy.h" |
| 26 #include "webrtc/video_receive_stream.h" | 26 #include "webrtc/video_receive_stream.h" |
| 27 | 27 |
| 28 namespace webrtc { | 28 namespace webrtc { |
| 29 | 29 |
| 30 static bool UseSendSideBwe(const std::vector<RtpExtension>& extensions) { | 30 static bool UseSendSideBwe(const VideoReceiveStream::Config& config) { |
| 31 for (const auto& extension : extensions) { | 31 if (!config.rtp.transport_cc) |
| 32 return false; |
| 33 for (const auto& extension : config.rtp.extensions) { |
| 32 if (extension.name == RtpExtension::kTransportSequenceNumber) | 34 if (extension.name == RtpExtension::kTransportSequenceNumber) |
| 33 return true; | 35 return true; |
| 34 } | 36 } |
| 35 return false; | 37 return false; |
| 36 } | 38 } |
| 37 | 39 |
| 38 std::string VideoReceiveStream::Decoder::ToString() const { | 40 std::string VideoReceiveStream::Decoder::ToString() const { |
| 39 std::stringstream ss; | 41 std::stringstream ss; |
| 40 ss << "{decoder: " << (decoder != nullptr ? "(VideoDecoder)" : "nullptr"); | 42 ss << "{decoder: " << (decoder != nullptr ? "(VideoDecoder)" : "nullptr"); |
| 41 ss << ", payload_type: " << payload_type; | 43 ss << ", payload_type: " << payload_type; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 webrtc::VoiceEngine* voice_engine, | 148 webrtc::VoiceEngine* voice_engine, |
| 147 ProcessThread* process_thread, | 149 ProcessThread* process_thread, |
| 148 CallStats* call_stats) | 150 CallStats* call_stats) |
| 149 : transport_adapter_(config.rtcp_send_transport), | 151 : transport_adapter_(config.rtcp_send_transport), |
| 150 encoded_frame_proxy_(config.pre_decode_callback), | 152 encoded_frame_proxy_(config.pre_decode_callback), |
| 151 config_(config), | 153 config_(config), |
| 152 process_thread_(process_thread), | 154 process_thread_(process_thread), |
| 153 clock_(Clock::GetRealTimeClock()), | 155 clock_(Clock::GetRealTimeClock()), |
| 154 congestion_controller_(congestion_controller), | 156 congestion_controller_(congestion_controller), |
| 155 call_stats_(call_stats), | 157 call_stats_(call_stats), |
| 156 vcm_(VideoCodingModule::Create(clock_, nullptr, nullptr)) { | 158 vcm_(VideoCodingModule::Create(clock_, nullptr, nullptr)), |
| 159 incoming_video_stream_( |
| 160 0, |
| 161 config.renderer ? config.renderer->SmoothsRenderedFrames() : false), |
| 162 stats_proxy_(config_.rtp.remote_ssrc, clock_), |
| 163 vie_channel_(num_cpu_cores, |
| 164 &transport_adapter_, |
| 165 process_thread, |
| 166 nullptr, |
| 167 vcm_.get(), |
| 168 nullptr, |
| 169 nullptr, |
| 170 nullptr, |
| 171 congestion_controller_->GetRemoteBitrateEstimator( |
| 172 UseSendSideBwe(config_)), |
| 173 call_stats_->rtcp_rtt_stats(), |
| 174 congestion_controller_->pacer(), |
| 175 congestion_controller_->packet_router(), |
| 176 1, |
| 177 false) { |
| 157 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); | 178 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); |
| 158 | 179 |
| 159 bool send_side_bwe = | 180 RTC_CHECK(vie_channel_.Init() == 0); |
| 160 config.rtp.transport_cc && UseSendSideBwe(config_.rtp.extensions); | |
| 161 | |
| 162 RemoteBitrateEstimator* bitrate_estimator = | |
| 163 congestion_controller_->GetRemoteBitrateEstimator(send_side_bwe); | |
| 164 | |
| 165 vie_channel_.reset(new ViEChannel( | |
| 166 num_cpu_cores, &transport_adapter_, process_thread, nullptr, vcm_.get(), | |
| 167 nullptr, nullptr, nullptr, bitrate_estimator, | |
| 168 call_stats_->rtcp_rtt_stats(), congestion_controller_->pacer(), | |
| 169 congestion_controller_->packet_router(), 1, false)); | |
| 170 | |
| 171 RTC_CHECK(vie_channel_->Init() == 0); | |
| 172 | 181 |
| 173 // Register the channel to receive stats updates. | 182 // Register the channel to receive stats updates. |
| 174 call_stats_->RegisterStatsObserver(vie_channel_->GetStatsObserver()); | 183 call_stats_->RegisterStatsObserver(vie_channel_.GetStatsObserver()); |
| 175 | 184 |
| 176 // TODO(pbos): This is not fine grained enough... | 185 // TODO(pbos): This is not fine grained enough... |
| 177 vie_channel_->SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, | 186 vie_channel_.SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, |
| 178 -1, -1); | 187 -1, -1); |
| 179 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) | 188 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) |
| 180 << "A stream should not be configured with RTCP disabled. This value is " | 189 << "A stream should not be configured with RTCP disabled. This value is " |
| 181 "reserved for internal usage."; | 190 "reserved for internal usage."; |
| 182 vie_channel_->SetRTCPMode(config_.rtp.rtcp_mode); | 191 vie_channel_.SetRTCPMode(config_.rtp.rtcp_mode); |
| 183 | 192 |
| 184 RTC_DCHECK(config_.rtp.remote_ssrc != 0); | 193 RTC_DCHECK(config_.rtp.remote_ssrc != 0); |
| 185 // TODO(pbos): What's an appropriate local_ssrc for receive-only streams? | 194 // TODO(pbos): What's an appropriate local_ssrc for receive-only streams? |
| 186 RTC_DCHECK(config_.rtp.local_ssrc != 0); | 195 RTC_DCHECK(config_.rtp.local_ssrc != 0); |
| 187 RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc); | 196 RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc); |
| 188 | 197 |
| 189 vie_channel_->SetSSRC(config_.rtp.local_ssrc, kViEStreamTypeNormal, 0); | 198 vie_channel_.SetSSRC(config_.rtp.local_ssrc, kViEStreamTypeNormal, 0); |
| 190 // TODO(pbos): Support multiple RTX, per video payload. | 199 // TODO(pbos): Support multiple RTX, per video payload. |
| 191 Config::Rtp::RtxMap::const_iterator it = config_.rtp.rtx.begin(); | 200 Config::Rtp::RtxMap::const_iterator it = config_.rtp.rtx.begin(); |
| 192 for (; it != config_.rtp.rtx.end(); ++it) { | 201 for (; it != config_.rtp.rtx.end(); ++it) { |
| 193 RTC_DCHECK(it->second.ssrc != 0); | 202 RTC_DCHECK(it->second.ssrc != 0); |
| 194 RTC_DCHECK(it->second.payload_type != 0); | 203 RTC_DCHECK(it->second.payload_type != 0); |
| 195 | 204 |
| 196 vie_channel_->SetRemoteSSRCType(kViEStreamTypeRtx, it->second.ssrc); | 205 vie_channel_.SetRemoteSSRCType(kViEStreamTypeRtx, it->second.ssrc); |
| 197 vie_channel_->SetRtxReceivePayloadType(it->second.payload_type, it->first); | 206 vie_channel_.SetRtxReceivePayloadType(it->second.payload_type, it->first); |
| 198 } | 207 } |
| 199 // TODO(holmer): When Chrome no longer depends on this being false by default, | 208 // TODO(holmer): When Chrome no longer depends on this being false by default, |
| 200 // always use the mapping and remove this whole codepath. | 209 // always use the mapping and remove this whole codepath. |
| 201 vie_channel_->SetUseRtxPayloadMappingOnRestore( | 210 vie_channel_.SetUseRtxPayloadMappingOnRestore( |
| 202 config_.rtp.use_rtx_payload_mapping_on_restore); | 211 config_.rtp.use_rtx_payload_mapping_on_restore); |
| 203 | 212 |
| 204 congestion_controller_->SetChannelRembStatus(false, config_.rtp.remb, | 213 congestion_controller_->SetChannelRembStatus(false, config_.rtp.remb, |
| 205 vie_channel_->rtp_rtcp()); | 214 vie_channel_.rtp_rtcp()); |
| 206 | 215 |
| 207 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { | 216 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { |
| 208 const std::string& extension = config_.rtp.extensions[i].name; | 217 const std::string& extension = config_.rtp.extensions[i].name; |
| 209 int id = config_.rtp.extensions[i].id; | 218 int id = config_.rtp.extensions[i].id; |
| 210 // One-byte-extension local identifiers are in the range 1-14 inclusive. | 219 // One-byte-extension local identifiers are in the range 1-14 inclusive. |
| 211 RTC_DCHECK_GE(id, 1); | 220 RTC_DCHECK_GE(id, 1); |
| 212 RTC_DCHECK_LE(id, 14); | 221 RTC_DCHECK_LE(id, 14); |
| 213 if (extension == RtpExtension::kTOffset) { | 222 if (extension == RtpExtension::kTOffset) { |
| 214 RTC_CHECK_EQ(0, vie_channel_->SetReceiveTimestampOffsetStatus(true, id)); | 223 RTC_CHECK_EQ(0, vie_channel_.SetReceiveTimestampOffsetStatus(true, id)); |
| 215 } else if (extension == RtpExtension::kAbsSendTime) { | 224 } else if (extension == RtpExtension::kAbsSendTime) { |
| 216 RTC_CHECK_EQ(0, vie_channel_->SetReceiveAbsoluteSendTimeStatus(true, id)); | 225 RTC_CHECK_EQ(0, vie_channel_.SetReceiveAbsoluteSendTimeStatus(true, id)); |
| 217 } else if (extension == RtpExtension::kVideoRotation) { | 226 } else if (extension == RtpExtension::kVideoRotation) { |
| 218 RTC_CHECK_EQ(0, vie_channel_->SetReceiveVideoRotationStatus(true, id)); | 227 RTC_CHECK_EQ(0, vie_channel_.SetReceiveVideoRotationStatus(true, id)); |
| 219 } else if (extension == RtpExtension::kTransportSequenceNumber) { | 228 } else if (extension == RtpExtension::kTransportSequenceNumber) { |
| 220 RTC_CHECK_EQ(0, | 229 RTC_CHECK_EQ(0, |
| 221 vie_channel_->SetReceiveTransportSequenceNumber(true, id)); | 230 vie_channel_.SetReceiveTransportSequenceNumber(true, id)); |
| 222 } else { | 231 } else { |
| 223 RTC_NOTREACHED() << "Unsupported RTP extension."; | 232 RTC_NOTREACHED() << "Unsupported RTP extension."; |
| 224 } | 233 } |
| 225 } | 234 } |
| 226 | 235 |
| 227 if (config_.rtp.fec.ulpfec_payload_type != -1) { | 236 if (config_.rtp.fec.ulpfec_payload_type != -1) { |
| 228 // ULPFEC without RED doesn't make sense. | 237 // ULPFEC without RED doesn't make sense. |
| 229 RTC_DCHECK(config_.rtp.fec.red_payload_type != -1); | 238 RTC_DCHECK(config_.rtp.fec.red_payload_type != -1); |
| 230 VideoCodec codec; | 239 VideoCodec codec; |
| 231 memset(&codec, 0, sizeof(codec)); | 240 memset(&codec, 0, sizeof(codec)); |
| 232 codec.codecType = kVideoCodecULPFEC; | 241 codec.codecType = kVideoCodecULPFEC; |
| 233 strncpy(codec.plName, "ulpfec", sizeof(codec.plName)); | 242 strncpy(codec.plName, "ulpfec", sizeof(codec.plName)); |
| 234 codec.plType = config_.rtp.fec.ulpfec_payload_type; | 243 codec.plType = config_.rtp.fec.ulpfec_payload_type; |
| 235 RTC_CHECK_EQ(0, vie_channel_->SetReceiveCodec(codec)); | 244 RTC_CHECK_EQ(0, vie_channel_.SetReceiveCodec(codec)); |
| 236 } | 245 } |
| 237 if (config_.rtp.fec.red_payload_type != -1) { | 246 if (config_.rtp.fec.red_payload_type != -1) { |
| 238 VideoCodec codec; | 247 VideoCodec codec; |
| 239 memset(&codec, 0, sizeof(codec)); | 248 memset(&codec, 0, sizeof(codec)); |
| 240 codec.codecType = kVideoCodecRED; | 249 codec.codecType = kVideoCodecRED; |
| 241 strncpy(codec.plName, "red", sizeof(codec.plName)); | 250 strncpy(codec.plName, "red", sizeof(codec.plName)); |
| 242 codec.plType = config_.rtp.fec.red_payload_type; | 251 codec.plType = config_.rtp.fec.red_payload_type; |
| 243 RTC_CHECK_EQ(0, vie_channel_->SetReceiveCodec(codec)); | 252 RTC_CHECK_EQ(0, vie_channel_.SetReceiveCodec(codec)); |
| 244 if (config_.rtp.fec.red_rtx_payload_type != -1) { | 253 if (config_.rtp.fec.red_rtx_payload_type != -1) { |
| 245 vie_channel_->SetRtxReceivePayloadType( | 254 vie_channel_.SetRtxReceivePayloadType( |
| 246 config_.rtp.fec.red_rtx_payload_type, | 255 config_.rtp.fec.red_rtx_payload_type, |
| 247 config_.rtp.fec.red_payload_type); | 256 config_.rtp.fec.red_payload_type); |
| 248 } | 257 } |
| 249 } | 258 } |
| 250 | 259 |
| 251 if (config.rtp.rtcp_xr.receiver_reference_time_report) | 260 if (config.rtp.rtcp_xr.receiver_reference_time_report) |
| 252 vie_channel_->SetRtcpXrRrtrStatus(true); | 261 vie_channel_.SetRtcpXrRrtrStatus(true); |
| 253 | 262 |
| 254 stats_proxy_.reset( | 263 vie_channel_.RegisterReceiveStatisticsProxy(&stats_proxy_); |
| 255 new ReceiveStatisticsProxy(config_.rtp.remote_ssrc, clock_)); | 264 vie_channel_.RegisterReceiveChannelRtcpStatisticsCallback(&stats_proxy_); |
| 256 | 265 vie_channel_.RegisterReceiveChannelRtpStatisticsCallback(&stats_proxy_); |
| 257 vie_channel_->RegisterReceiveStatisticsProxy(stats_proxy_.get()); | 266 vie_channel_.RegisterRtcpPacketTypeCounterObserver(&stats_proxy_); |
| 258 vie_channel_->RegisterReceiveChannelRtcpStatisticsCallback( | |
| 259 stats_proxy_.get()); | |
| 260 vie_channel_->RegisterReceiveChannelRtpStatisticsCallback(stats_proxy_.get()); | |
| 261 vie_channel_->RegisterRtcpPacketTypeCounterObserver(stats_proxy_.get()); | |
| 262 | 267 |
| 263 RTC_DCHECK(!config_.decoders.empty()); | 268 RTC_DCHECK(!config_.decoders.empty()); |
| 264 std::set<int> decoder_payload_types; | 269 std::set<int> decoder_payload_types; |
| 265 for (size_t i = 0; i < config_.decoders.size(); ++i) { | 270 for (size_t i = 0; i < config_.decoders.size(); ++i) { |
| 266 const Decoder& decoder = config_.decoders[i]; | 271 const Decoder& decoder = config_.decoders[i]; |
| 267 RTC_CHECK(decoder.decoder); | 272 RTC_CHECK(decoder.decoder); |
| 268 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == | 273 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == |
| 269 decoder_payload_types.end()) | 274 decoder_payload_types.end()) |
| 270 << "Duplicate payload type (" << decoder.payload_type | 275 << "Duplicate payload type (" << decoder.payload_type |
| 271 << ") for different decoders."; | 276 << ") for different decoders."; |
| 272 decoder_payload_types.insert(decoder.payload_type); | 277 decoder_payload_types.insert(decoder.payload_type); |
| 273 vie_channel_->RegisterExternalDecoder(decoder.payload_type, | 278 vie_channel_.RegisterExternalDecoder(decoder.payload_type, |
| 274 decoder.decoder); | 279 decoder.decoder); |
| 275 | 280 |
| 276 VideoCodec codec = CreateDecoderVideoCodec(decoder); | 281 VideoCodec codec = CreateDecoderVideoCodec(decoder); |
| 277 | 282 |
| 278 RTC_CHECK_EQ(0, vie_channel_->SetReceiveCodec(codec)); | 283 RTC_CHECK_EQ(0, vie_channel_.SetReceiveCodec(codec)); |
| 279 } | 284 } |
| 280 | 285 |
| 281 incoming_video_stream_.reset(new IncomingVideoStream( | 286 incoming_video_stream_.SetExpectedRenderDelay(config.render_delay_ms); |
| 282 0, config.renderer ? config.renderer->SmoothsRenderedFrames() : false)); | 287 vie_channel_.SetExpectedRenderDelay(config.render_delay_ms); |
| 283 incoming_video_stream_->SetExpectedRenderDelay(config.render_delay_ms); | 288 incoming_video_stream_.SetExternalCallback(this); |
| 284 vie_channel_->SetExpectedRenderDelay(config.render_delay_ms); | 289 vie_channel_.SetIncomingVideoStream(&incoming_video_stream_); |
| 285 incoming_video_stream_->SetExternalCallback(this); | |
| 286 vie_channel_->SetIncomingVideoStream(incoming_video_stream_.get()); | |
| 287 | 290 |
| 288 vie_channel_->RegisterPreDecodeImageCallback(this); | 291 vie_channel_.RegisterPreDecodeImageCallback(this); |
| 289 vie_channel_->RegisterPreRenderCallback(this); | 292 vie_channel_.RegisterPreRenderCallback(this); |
| 290 | 293 |
| 291 process_thread_->RegisterModule(vcm_.get()); | 294 process_thread_->RegisterModule(vcm_.get()); |
| 292 } | 295 } |
| 293 | 296 |
| 294 VideoReceiveStream::~VideoReceiveStream() { | 297 VideoReceiveStream::~VideoReceiveStream() { |
| 295 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 298 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); |
| 296 incoming_video_stream_->Stop(); | 299 incoming_video_stream_.Stop(); |
| 297 process_thread_->DeRegisterModule(vcm_.get()); | 300 process_thread_->DeRegisterModule(vcm_.get()); |
| 298 vie_channel_->RegisterPreRenderCallback(nullptr); | 301 vie_channel_.RegisterPreRenderCallback(nullptr); |
| 299 vie_channel_->RegisterPreDecodeImageCallback(nullptr); | 302 vie_channel_.RegisterPreDecodeImageCallback(nullptr); |
| 300 | 303 |
| 301 call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver()); | 304 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver()); |
| 302 congestion_controller_->SetChannelRembStatus(false, false, | 305 congestion_controller_->SetChannelRembStatus(false, false, |
| 303 vie_channel_->rtp_rtcp()); | 306 vie_channel_.rtp_rtcp()); |
| 304 | 307 |
| 305 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC(); | 308 uint32_t remote_ssrc = vie_channel_.GetRemoteSSRC(); |
| 306 bool send_side_bwe = UseSendSideBwe(config_.rtp.extensions); | 309 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) |
| 307 congestion_controller_->GetRemoteBitrateEstimator(send_side_bwe)-> | 310 ->RemoveStream(remote_ssrc); |
| 308 RemoveStream(remote_ssrc); | |
| 309 } | 311 } |
| 310 | 312 |
| 311 void VideoReceiveStream::Start() { | 313 void VideoReceiveStream::Start() { |
| 312 transport_adapter_.Enable(); | 314 transport_adapter_.Enable(); |
| 313 incoming_video_stream_->Start(); | 315 incoming_video_stream_.Start(); |
| 314 vie_channel_->StartReceive(); | 316 vie_channel_.StartReceive(); |
| 315 } | 317 } |
| 316 | 318 |
| 317 void VideoReceiveStream::Stop() { | 319 void VideoReceiveStream::Stop() { |
| 318 incoming_video_stream_->Stop(); | 320 incoming_video_stream_.Stop(); |
| 319 vie_channel_->StopReceive(); | 321 vie_channel_.StopReceive(); |
| 320 transport_adapter_.Disable(); | 322 transport_adapter_.Disable(); |
| 321 } | 323 } |
| 322 | 324 |
| 323 void VideoReceiveStream::SetSyncChannel(VoiceEngine* voice_engine, | 325 void VideoReceiveStream::SetSyncChannel(VoiceEngine* voice_engine, |
| 324 int audio_channel_id) { | 326 int audio_channel_id) { |
| 325 if (voice_engine != nullptr && audio_channel_id != -1) { | 327 if (voice_engine != nullptr && audio_channel_id != -1) { |
| 326 VoEVideoSync* voe_sync_interface = VoEVideoSync::GetInterface(voice_engine); | 328 VoEVideoSync* voe_sync_interface = VoEVideoSync::GetInterface(voice_engine); |
| 327 vie_channel_->SetVoiceChannel(audio_channel_id, voe_sync_interface); | 329 vie_channel_.SetVoiceChannel(audio_channel_id, voe_sync_interface); |
| 328 voe_sync_interface->Release(); | 330 voe_sync_interface->Release(); |
| 329 } else { | 331 } else { |
| 330 vie_channel_->SetVoiceChannel(-1, nullptr); | 332 vie_channel_.SetVoiceChannel(-1, nullptr); |
| 331 } | 333 } |
| 332 } | 334 } |
| 333 | 335 |
| 334 VideoReceiveStream::Stats VideoReceiveStream::GetStats() const { | 336 VideoReceiveStream::Stats VideoReceiveStream::GetStats() const { |
| 335 return stats_proxy_->GetStats(); | 337 return stats_proxy_.GetStats(); |
| 336 } | 338 } |
| 337 | 339 |
| 338 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { | 340 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
| 339 return vie_channel_->ReceivedRTCPPacket(packet, length) == 0; | 341 return vie_channel_.ReceivedRTCPPacket(packet, length) == 0; |
| 340 } | 342 } |
| 341 | 343 |
| 342 bool VideoReceiveStream::DeliverRtp(const uint8_t* packet, | 344 bool VideoReceiveStream::DeliverRtp(const uint8_t* packet, |
| 343 size_t length, | 345 size_t length, |
| 344 const PacketTime& packet_time) { | 346 const PacketTime& packet_time) { |
| 345 return vie_channel_->ReceivedRTPPacket(packet, length, packet_time) == 0; | 347 return vie_channel_.ReceivedRTPPacket(packet, length, packet_time) == 0; |
| 346 } | 348 } |
| 347 | 349 |
| 348 void VideoReceiveStream::FrameCallback(VideoFrame* video_frame) { | 350 void VideoReceiveStream::FrameCallback(VideoFrame* video_frame) { |
| 349 stats_proxy_->OnDecodedFrame(); | 351 stats_proxy_.OnDecodedFrame(); |
| 350 | 352 |
| 351 // Post processing is not supported if the frame is backed by a texture. | 353 // Post processing is not supported if the frame is backed by a texture. |
| 352 if (video_frame->native_handle() == NULL) { | 354 if (video_frame->native_handle() == NULL) { |
| 353 if (config_.pre_render_callback) | 355 if (config_.pre_render_callback) |
| 354 config_.pre_render_callback->FrameCallback(video_frame); | 356 config_.pre_render_callback->FrameCallback(video_frame); |
| 355 } | 357 } |
| 356 } | 358 } |
| 357 | 359 |
| 358 int VideoReceiveStream::RenderFrame(const uint32_t /*stream_id*/, | 360 int VideoReceiveStream::RenderFrame(const uint32_t /*stream_id*/, |
| 359 const VideoFrame& video_frame) { | 361 const VideoFrame& video_frame) { |
| 360 // TODO(pbos): Wire up config_.render->IsTextureSupported() and convert if not | 362 // TODO(pbos): Wire up config_.render->IsTextureSupported() and convert if not |
| 361 // supported. Or provide methods for converting a texture frame in | 363 // supported. Or provide methods for converting a texture frame in |
| 362 // VideoFrame. | 364 // VideoFrame. |
| 363 | 365 |
| 364 if (config_.renderer != nullptr) | 366 if (config_.renderer != nullptr) |
| 365 config_.renderer->RenderFrame( | 367 config_.renderer->RenderFrame( |
| 366 video_frame, | 368 video_frame, |
| 367 video_frame.render_time_ms() - clock_->TimeInMilliseconds()); | 369 video_frame.render_time_ms() - clock_->TimeInMilliseconds()); |
| 368 | 370 |
| 369 stats_proxy_->OnRenderedFrame(video_frame.width(), video_frame.height()); | 371 stats_proxy_.OnRenderedFrame(video_frame.width(), video_frame.height()); |
| 370 | 372 |
| 371 return 0; | 373 return 0; |
| 372 } | 374 } |
| 373 | 375 |
| 374 // TODO(asapersson): Consider moving callback from video_encoder.h or | 376 // TODO(asapersson): Consider moving callback from video_encoder.h or |
| 375 // creating a different callback. | 377 // creating a different callback. |
| 376 int32_t VideoReceiveStream::Encoded( | 378 int32_t VideoReceiveStream::Encoded( |
| 377 const EncodedImage& encoded_image, | 379 const EncodedImage& encoded_image, |
| 378 const CodecSpecificInfo* codec_specific_info, | 380 const CodecSpecificInfo* codec_specific_info, |
| 379 const RTPFragmentationHeader* fragmentation) { | 381 const RTPFragmentationHeader* fragmentation) { |
| 380 stats_proxy_->OnPreDecode(encoded_image, codec_specific_info); | 382 stats_proxy_.OnPreDecode(encoded_image, codec_specific_info); |
| 381 if (config_.pre_decode_callback) { | 383 if (config_.pre_decode_callback) { |
| 382 // TODO(asapersson): Remove EncodedFrameCallbackAdapter. | 384 // TODO(asapersson): Remove EncodedFrameCallbackAdapter. |
| 383 encoded_frame_proxy_.Encoded( | 385 encoded_frame_proxy_.Encoded( |
| 384 encoded_image, codec_specific_info, fragmentation); | 386 encoded_image, codec_specific_info, fragmentation); |
| 385 } | 387 } |
| 386 return 0; | 388 return 0; |
| 387 } | 389 } |
| 388 | 390 |
| 389 void VideoReceiveStream::SignalNetworkState(NetworkState state) { | 391 void VideoReceiveStream::SignalNetworkState(NetworkState state) { |
| 390 vie_channel_->SetRTCPMode(state == kNetworkUp ? config_.rtp.rtcp_mode | 392 vie_channel_.SetRTCPMode(state == kNetworkUp ? config_.rtp.rtcp_mode |
| 391 : RtcpMode::kOff); | 393 : RtcpMode::kOff); |
| 392 } | 394 } |
| 393 | 395 |
| 394 } // namespace internal | 396 } // namespace internal |
| 395 } // namespace webrtc | 397 } // namespace webrtc |
| OLD | NEW |