Index: webrtc/media/engine/webrtcvideoengine2.cc |
diff --git a/webrtc/media/engine/webrtcvideoengine2.cc b/webrtc/media/engine/webrtcvideoengine2.cc |
index 3cacc7da82ba3ee32cdfa69abf271635df9ec98b..6e0b69cffc3bdb518735a79bd003d34595ce680b 100644 |
--- a/webrtc/media/engine/webrtcvideoengine2.cc |
+++ b/webrtc/media/engine/webrtcvideoengine2.cc |
@@ -1342,6 +1342,7 @@ bool WebRtcVideoChannel2::GetStats(VideoMediaInfo* info) { |
info->Clear(); |
FillSenderStats(info, log_stats); |
FillReceiverStats(info, log_stats); |
+ FillSendAndReceiveCodecStats(info); |
webrtc::Call::Stats stats = call_->GetStats(); |
FillBandwidthEstimationStats(stats, info); |
if (stats.rtt_ms != -1) { |
@@ -1396,6 +1397,47 @@ void WebRtcVideoChannel2::FillBandwidthEstimationStats( |
video_media_info->bw_estimations.push_back(bwe_info); |
} |
+void WebRtcVideoChannel2::FillSendAndReceiveCodecStats( |
+ VideoMediaInfo* video_media_info) { |
+ // Codec parameters are fetched from streams and from a common list. The |
+ // payload type -> parameters maps ensure that there are no duplicates based |
+ // on direction and payload type. |
+ { |
+ // Stream-specific codec parameters |
+ rtc::CritScope stream_lock(&stream_crit_); |
+ for (const std::pair<uint32_t, WebRtcVideoSendStream*>& pair : |
+ send_streams_) { |
+ webrtc::RtpParameters stream_params = pair.second->GetRtpParameters(); |
+ for (const webrtc::RtpCodecParameters& codec_params : |
+ stream_params.codecs) { |
+ video_media_info->send_codecs.insert( |
+ std::make_pair(codec_params.payload_type, codec_params)); |
+ } |
+ } |
+ for (const std::pair<uint32_t, WebRtcVideoReceiveStream*>& pair : |
+ receive_streams_) { |
+ for (const webrtc::VideoReceiveStream::Decoder& decoder : |
+ pair.second->config().decoders) { |
+ VideoCodec codec(decoder.payload_type, decoder.payload_name); |
+ webrtc::RtpCodecParameters codec_params = codec.ToCodecParameters(); |
+ video_media_info->receive_codecs.insert( |
+ std::make_pair(codec_params.payload_type, codec_params)); |
+ } |
+ } |
+ } |
Taylor Brandstetter
2016/11/08 23:55:44
I think you can delete this block, since there sho
hbos
2016/11/11 11:20:05
Oh, that makes things simpler. Done.
|
+ // Common codec parameters |
+ for (const VideoCodec& codec : send_params_.codecs) { |
+ webrtc::RtpCodecParameters codec_params = codec.ToCodecParameters(); |
+ video_media_info->send_codecs.insert( |
+ std::make_pair(codec_params.payload_type, codec_params)); |
+ } |
+ for (const VideoCodec& codec : recv_params_.codecs) { |
+ webrtc::RtpCodecParameters codec_params = codec.ToCodecParameters(); |
+ video_media_info->receive_codecs.insert( |
+ std::make_pair(codec_params.payload_type, codec_params)); |
+ } |
+} |
+ |
void WebRtcVideoChannel2::OnPacketReceived( |
rtc::CopyOnWriteBuffer* packet, |
const rtc::PacketTime& packet_time) { |
@@ -2000,8 +2042,11 @@ VideoSenderInfo WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo( |
for (uint32_t ssrc : parameters_.config.rtp.ssrcs) |
info.add_ssrc(ssrc); |
- if (parameters_.codec_settings) |
+ if (parameters_.codec_settings) { |
info.codec_name = parameters_.codec_settings->codec.name; |
+ info.codec_payload_type = rtc::Optional<uint32_t>( |
+ static_cast<uint32_t>(parameters_.codec_settings->codec.id)); |
+ } |
if (stream_ == NULL) |
return info; |
@@ -2417,6 +2462,10 @@ WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetVideoReceiverInfo( |
info.add_ssrc(config_.rtp.remote_ssrc); |
webrtc::VideoReceiveStream::Stats stats = stream_->GetStats(); |
info.decoder_implementation_name = stats.decoder_implementation_name; |
+ if (stats.current_payload_type != -1) { |
+ info.codec_payload_type = rtc::Optional<uint32_t>( |
+ static_cast<uint32_t>(stats.current_payload_type)); |
+ } |
info.bytes_rcvd = stats.rtp_stats.transmitted.payload_bytes + |
stats.rtp_stats.transmitted.header_bytes + |
stats.rtp_stats.transmitted.padding_bytes; |