Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Side by Side Diff: webrtc/video_engine/vie_channel.cc

Issue 1315413002: Wire up currently-received video codec to stats. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: feedback Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video_engine/vie_channel.h ('k') | webrtc/video_receive_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 module_process_thread_(module_process_thread), 98 module_process_thread_(module_process_thread),
99 crit_(CriticalSectionWrapper::CreateCriticalSection()), 99 crit_(CriticalSectionWrapper::CreateCriticalSection()),
100 send_payload_router_(new PayloadRouter()), 100 send_payload_router_(new PayloadRouter()),
101 vcm_protection_callback_(new ViEChannelProtectionCallback(this)), 101 vcm_protection_callback_(new ViEChannelProtectionCallback(this)),
102 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(), 102 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(),
103 nullptr, 103 nullptr,
104 nullptr)), 104 nullptr)),
105 vie_receiver_(channel_id, vcm_, remote_bitrate_estimator, this), 105 vie_receiver_(channel_id, vcm_, remote_bitrate_estimator, this),
106 vie_sync_(vcm_), 106 vie_sync_(vcm_),
107 stats_observer_(new ChannelStatsObserver(this)), 107 stats_observer_(new ChannelStatsObserver(this)),
108 vcm_receive_stats_callback_(NULL), 108 receive_stats_callback_(nullptr),
109 incoming_video_stream_(nullptr), 109 incoming_video_stream_(nullptr),
110 codec_observer_(NULL),
111 intra_frame_observer_(intra_frame_observer), 110 intra_frame_observer_(intra_frame_observer),
112 rtt_stats_(rtt_stats), 111 rtt_stats_(rtt_stats),
113 paced_sender_(paced_sender), 112 paced_sender_(paced_sender),
114 packet_router_(packet_router), 113 packet_router_(packet_router),
115 bandwidth_observer_(bandwidth_observer), 114 bandwidth_observer_(bandwidth_observer),
116 send_time_observer_(send_time_observer), 115 send_time_observer_(send_time_observer),
117 decoder_reset_(true),
118 nack_history_size_sender_(kSendSidePacketHistorySize), 116 nack_history_size_sender_(kSendSidePacketHistorySize),
119 max_nack_reordering_threshold_(kMaxPacketAgeToNack), 117 max_nack_reordering_threshold_(kMaxPacketAgeToNack),
120 pre_render_callback_(NULL), 118 pre_render_callback_(NULL),
121 report_block_stats_sender_(new ReportBlockStats()), 119 report_block_stats_sender_(new ReportBlockStats()),
122 time_of_first_rtt_ms_(-1), 120 time_of_first_rtt_ms_(-1),
123 rtt_sum_ms_(0), 121 rtt_sum_ms_(0),
124 num_rtts_(0), 122 num_rtts_(0),
125 rtp_rtcp_modules_( 123 rtp_rtcp_modules_(
126 CreateRtpRtcpModules(ViEModuleId(engine_id_, channel_id_), 124 CreateRtpRtcpModules(ViEModuleId(engine_id_, channel_id_),
127 !sender, 125 !sender,
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 video_codec.codecType != kVideoCodecULPFEC) { 428 video_codec.codecType != kVideoCodecULPFEC) {
431 // Register codec type with VCM, but do not register RED or ULPFEC. 429 // Register codec type with VCM, but do not register RED or ULPFEC.
432 if (vcm_->RegisterReceiveCodec(&video_codec, number_of_cores_, false) != 430 if (vcm_->RegisterReceiveCodec(&video_codec, number_of_cores_, false) !=
433 VCM_OK) { 431 VCM_OK) {
434 return -1; 432 return -1;
435 } 433 }
436 } 434 }
437 return 0; 435 return 0;
438 } 436 }
439 437
440 int32_t ViEChannel::RegisterCodecObserver(ViEDecoderObserver* observer) {
441 CriticalSectionScoped cs(crit_.get());
442 if (observer) {
443 if (codec_observer_) {
444 LOG_F(LS_ERROR) << "Observer already registered.";
445 return -1;
446 }
447 codec_observer_ = observer;
448 } else {
449 codec_observer_ = NULL;
450 }
451 return 0;
452 }
453
454 int32_t ViEChannel::RegisterExternalDecoder(const uint8_t pl_type, 438 int32_t ViEChannel::RegisterExternalDecoder(const uint8_t pl_type,
455 VideoDecoder* decoder, 439 VideoDecoder* decoder,
456 bool buffered_rendering, 440 bool buffered_rendering,
457 int32_t render_delay) { 441 int32_t render_delay) {
458 DCHECK(!sender_); 442 DCHECK(!sender_);
459 int32_t result; 443 int32_t result;
460 result = vcm_->RegisterExternalDecoder(decoder, pl_type, buffered_rendering); 444 result = vcm_->RegisterExternalDecoder(decoder, pl_type, buffered_rendering);
461 if (result != VCM_OK) { 445 if (result != VCM_OK) {
462 return result; 446 return result;
463 } 447 }
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 return stats_observer_.get(); 1019 return stats_observer_.get();
1036 } 1020 }
1037 1021
1038 // Do not acquire the lock of |vcm_| in this function. Decode callback won't 1022 // Do not acquire the lock of |vcm_| in this function. Decode callback won't
1039 // necessarily be called from the decoding thread. The decoding thread may have 1023 // necessarily be called from the decoding thread. The decoding thread may have
1040 // held the lock when calling VideoDecoder::Decode, Reset, or Release. Acquiring 1024 // held the lock when calling VideoDecoder::Decode, Reset, or Release. Acquiring
1041 // the same lock in the path of decode callback can deadlock. 1025 // the same lock in the path of decode callback can deadlock.
1042 int32_t ViEChannel::FrameToRender(VideoFrame& video_frame) { // NOLINT 1026 int32_t ViEChannel::FrameToRender(VideoFrame& video_frame) { // NOLINT
1043 CriticalSectionScoped cs(crit_.get()); 1027 CriticalSectionScoped cs(crit_.get());
1044 1028
1045 if (decoder_reset_) {
1046 // Trigger a callback to the user if the incoming codec has changed.
1047 if (codec_observer_) {
1048 // The codec set by RegisterReceiveCodec might not be the size we're
1049 // actually decoding.
1050 receive_codec_.width = static_cast<uint16_t>(video_frame.width());
1051 receive_codec_.height = static_cast<uint16_t>(video_frame.height());
1052 codec_observer_->IncomingCodecChanged(channel_id_, receive_codec_);
1053 }
1054 decoder_reset_ = false;
1055 }
1056
1057 if (pre_render_callback_ != NULL) 1029 if (pre_render_callback_ != NULL)
1058 pre_render_callback_->FrameCallback(&video_frame); 1030 pre_render_callback_->FrameCallback(&video_frame);
1059 1031
1060 incoming_video_stream_->RenderFrame(channel_id_, video_frame); 1032 incoming_video_stream_->RenderFrame(channel_id_, video_frame);
1061 return 0; 1033 return 0;
1062 } 1034 }
1063 1035
1064 int32_t ViEChannel::ReceivedDecodedReferenceFrame( 1036 int32_t ViEChannel::ReceivedDecodedReferenceFrame(
1065 const uint64_t picture_id) { 1037 const uint64_t picture_id) {
1066 return rtp_rtcp_modules_[0]->SendRTCPReferencePictureSelection(picture_id); 1038 return rtp_rtcp_modules_[0]->SendRTCPReferencePictureSelection(picture_id);
1067 } 1039 }
1068 1040
1069 void ViEChannel::IncomingCodecChanged(const VideoCodec& codec) { 1041 void ViEChannel::OnIncomingPayloadType(int payload_type) {
1070 CriticalSectionScoped cs(crit_.get()); 1042 CriticalSectionScoped cs(crit_.get());
1071 receive_codec_ = codec; 1043 if (receive_stats_callback_)
1044 receive_stats_callback_->OnIncomingPayloadType(payload_type);
1072 } 1045 }
1073 1046
1074 void ViEChannel::OnReceiveRatesUpdated(uint32_t bit_rate, uint32_t frame_rate) { 1047 void ViEChannel::OnReceiveRatesUpdated(uint32_t bit_rate, uint32_t frame_rate) {
1075 CriticalSectionScoped cs(crit_.get()); 1048 CriticalSectionScoped cs(crit_.get());
1076 if (codec_observer_) 1049 if (receive_stats_callback_)
1077 codec_observer_->IncomingRate(channel_id_, frame_rate, bit_rate); 1050 receive_stats_callback_->OnIncomingRate(frame_rate, bit_rate);
1078 } 1051 }
1079 1052
1080 void ViEChannel::OnDiscardedPacketsUpdated(int discarded_packets) { 1053 void ViEChannel::OnDiscardedPacketsUpdated(int discarded_packets) {
1081 CriticalSectionScoped cs(crit_.get()); 1054 CriticalSectionScoped cs(crit_.get());
1082 if (vcm_receive_stats_callback_ != NULL) 1055 if (receive_stats_callback_)
1083 vcm_receive_stats_callback_->OnDiscardedPacketsUpdated(discarded_packets); 1056 receive_stats_callback_->OnDiscardedPacketsUpdated(discarded_packets);
1084 } 1057 }
1085 1058
1086 void ViEChannel::OnFrameCountsUpdated(const FrameCounts& frame_counts) { 1059 void ViEChannel::OnFrameCountsUpdated(const FrameCounts& frame_counts) {
1087 CriticalSectionScoped cs(crit_.get()); 1060 CriticalSectionScoped cs(crit_.get());
1088 receive_frame_counts_ = frame_counts; 1061 receive_frame_counts_ = frame_counts;
1089 if (vcm_receive_stats_callback_ != NULL) 1062 if (receive_stats_callback_)
1090 vcm_receive_stats_callback_->OnFrameCountsUpdated(frame_counts); 1063 receive_stats_callback_->OnFrameCountsUpdated(frame_counts);
1091 } 1064 }
1092 1065
1093 void ViEChannel::OnDecoderTiming(int decode_ms, 1066 void ViEChannel::OnDecoderTiming(int decode_ms,
1094 int max_decode_ms, 1067 int max_decode_ms,
1095 int current_delay_ms, 1068 int current_delay_ms,
1096 int target_delay_ms, 1069 int target_delay_ms,
1097 int jitter_buffer_ms, 1070 int jitter_buffer_ms,
1098 int min_playout_delay_ms, 1071 int min_playout_delay_ms,
1099 int render_delay_ms) { 1072 int render_delay_ms) {
1100 CriticalSectionScoped cs(crit_.get()); 1073 CriticalSectionScoped cs(crit_.get());
1101 if (!codec_observer_) 1074 if (!receive_stats_callback_)
1102 return; 1075 return;
1103 codec_observer_->DecoderTiming(decode_ms, 1076 receive_stats_callback_->OnDecoderTiming(
1104 max_decode_ms, 1077 decode_ms, max_decode_ms, current_delay_ms, target_delay_ms,
1105 current_delay_ms, 1078 jitter_buffer_ms, min_playout_delay_ms, render_delay_ms);
1106 target_delay_ms,
1107 jitter_buffer_ms,
1108 min_playout_delay_ms,
1109 render_delay_ms);
1110 } 1079 }
1111 1080
1112 int32_t ViEChannel::RequestKeyFrame() { 1081 int32_t ViEChannel::RequestKeyFrame() {
1113 return rtp_rtcp_modules_[0]->RequestKeyFrame(); 1082 return rtp_rtcp_modules_[0]->RequestKeyFrame();
1114 } 1083 }
1115 1084
1116 int32_t ViEChannel::SliceLossIndicationRequest( 1085 int32_t ViEChannel::SliceLossIndicationRequest(
1117 const uint64_t picture_id) { 1086 const uint64_t picture_id) {
1118 return rtp_rtcp_modules_[0]->SendRTCPSliceLossIndication( 1087 return rtp_rtcp_modules_[0]->SendRTCPSliceLossIndication(
1119 static_cast<uint8_t>(picture_id)); 1088 static_cast<uint8_t>(picture_id));
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 I420FrameCallback* pre_render_callback) { 1223 I420FrameCallback* pre_render_callback) {
1255 CriticalSectionScoped cs(crit_.get()); 1224 CriticalSectionScoped cs(crit_.get());
1256 pre_render_callback_ = pre_render_callback; 1225 pre_render_callback_ = pre_render_callback;
1257 } 1226 }
1258 1227
1259 void ViEChannel::RegisterPreDecodeImageCallback( 1228 void ViEChannel::RegisterPreDecodeImageCallback(
1260 EncodedImageCallback* pre_decode_callback) { 1229 EncodedImageCallback* pre_decode_callback) {
1261 vcm_->RegisterPreDecodeImageCallback(pre_decode_callback); 1230 vcm_->RegisterPreDecodeImageCallback(pre_decode_callback);
1262 } 1231 }
1263 1232
1233 // TODO(pbos): Remove OnInitializeDecoder which is called from the RTP module,
1234 // any decoder resetting should be handled internally within the VCM.
1264 int32_t ViEChannel::OnInitializeDecoder( 1235 int32_t ViEChannel::OnInitializeDecoder(
1265 const int32_t id, 1236 const int32_t id,
1266 const int8_t payload_type, 1237 const int8_t payload_type,
1267 const char payload_name[RTP_PAYLOAD_NAME_SIZE], 1238 const char payload_name[RTP_PAYLOAD_NAME_SIZE],
1268 const int frequency, 1239 const int frequency,
1269 const uint8_t channels, 1240 const uint8_t channels,
1270 const uint32_t rate) { 1241 const uint32_t rate) {
1271 LOG(LS_INFO) << "OnInitializeDecoder " << static_cast<int>(payload_type) 1242 LOG(LS_INFO) << "OnInitializeDecoder " << static_cast<int>(payload_type)
1272 << " " << payload_name; 1243 << " " << payload_name;
1273 vcm_->ResetDecoder(); 1244 vcm_->ResetDecoder();
1274 1245
1275 CriticalSectionScoped cs(crit_.get());
1276 decoder_reset_ = true;
1277 return 0; 1246 return 0;
1278 } 1247 }
1279 1248
1280 void ViEChannel::OnIncomingSSRCChanged(const int32_t id, const uint32_t ssrc) { 1249 void ViEChannel::OnIncomingSSRCChanged(const int32_t id, const uint32_t ssrc) {
1281 DCHECK_EQ(channel_id_, ChannelId(id)); 1250 DCHECK_EQ(channel_id_, ChannelId(id));
1282 rtp_rtcp_modules_[0]->SetRemoteSSRC(ssrc); 1251 rtp_rtcp_modules_[0]->SetRemoteSSRC(ssrc);
1283 } 1252 }
1284 1253
1285 void ViEChannel::OnIncomingCSRCChanged(const int32_t id, 1254 void ViEChannel::OnIncomingCSRCChanged(const int32_t id,
1286 const uint32_t CSRC, 1255 const uint32_t CSRC,
1287 const bool added) { 1256 const bool added) {
1288 DCHECK_EQ(channel_id_, ChannelId(id)); 1257 DCHECK_EQ(channel_id_, ChannelId(id));
1289 CriticalSectionScoped cs(crit_.get()); 1258 CriticalSectionScoped cs(crit_.get());
1290 } 1259 }
1291 1260
1292 void ViEChannel::RegisterSendFrameCountObserver( 1261 void ViEChannel::RegisterSendFrameCountObserver(
1293 FrameCountObserver* observer) { 1262 FrameCountObserver* observer) {
1294 send_frame_count_observer_.Set(observer); 1263 send_frame_count_observer_.Set(observer);
1295 } 1264 }
1296 1265
1297 void ViEChannel::RegisterReceiveStatisticsProxy( 1266 void ViEChannel::RegisterReceiveStatisticsProxy(
1298 ReceiveStatisticsProxy* receive_statistics_proxy) { 1267 ReceiveStatisticsProxy* receive_statistics_proxy) {
1299 CriticalSectionScoped cs(crit_.get()); 1268 CriticalSectionScoped cs(crit_.get());
1300 vcm_receive_stats_callback_ = receive_statistics_proxy; 1269 receive_stats_callback_ = receive_statistics_proxy;
1301 } 1270 }
1302 1271
1303 void ViEChannel::SetIncomingVideoStream( 1272 void ViEChannel::SetIncomingVideoStream(
1304 IncomingVideoStream* incoming_video_stream) { 1273 IncomingVideoStream* incoming_video_stream) {
1305 CriticalSectionScoped cs(crit_.get()); 1274 CriticalSectionScoped cs(crit_.get());
1306 incoming_video_stream_ = incoming_video_stream; 1275 incoming_video_stream_ = incoming_video_stream;
1307 } 1276 }
1308 } // namespace webrtc 1277 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video_engine/vie_channel.h ('k') | webrtc/video_receive_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698