 Chromium Code Reviews
 Chromium Code Reviews Issue 2946413002:
  Report timing frames info in GetStats.  (Closed)
    
  
    Issue 2946413002:
  Report timing frames info in GetStats.  (Closed) 
  | OLD | NEW | 
|---|---|
| 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 | 
| 11 #include <algorithm> | |
| 12 | |
| 11 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" | 
| 12 #include "webrtc/base/logging.h" | 14 #include "webrtc/base/logging.h" | 
| 13 #include "webrtc/base/timeutils.h" | 15 #include "webrtc/base/timeutils.h" | 
| 14 #include "webrtc/base/trace_event.h" | 16 #include "webrtc/base/trace_event.h" | 
| 15 #include "webrtc/modules/video_coding/include/video_coding.h" | 17 #include "webrtc/modules/video_coding/include/video_coding.h" | 
| 16 #include "webrtc/modules/video_coding/generic_decoder.h" | 18 #include "webrtc/modules/video_coding/generic_decoder.h" | 
| 17 #include "webrtc/modules/video_coding/internal_defines.h" | 19 #include "webrtc/modules/video_coding/internal_defines.h" | 
| 18 #include "webrtc/system_wrappers/include/clock.h" | 20 #include "webrtc/system_wrappers/include/clock.h" | 
| 19 | 21 | 
| 20 namespace webrtc { | 22 namespace webrtc { | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 const int64_t now_ms = _clock->TimeInMilliseconds(); | 85 const int64_t now_ms = _clock->TimeInMilliseconds(); | 
| 84 if (!decode_time_ms) { | 86 if (!decode_time_ms) { | 
| 85 decode_time_ms = | 87 decode_time_ms = | 
| 86 rtc::Optional<int32_t>(now_ms - frameInfo->decodeStartTimeMs); | 88 rtc::Optional<int32_t>(now_ms - frameInfo->decodeStartTimeMs); | 
| 87 } | 89 } | 
| 88 _timing->StopDecodeTimer(decodedImage.timestamp(), *decode_time_ms, now_ms, | 90 _timing->StopDecodeTimer(decodedImage.timestamp(), *decode_time_ms, now_ms, | 
| 89 frameInfo->renderTimeMs); | 91 frameInfo->renderTimeMs); | 
| 90 | 92 | 
| 91 // Report timing information. | 93 // Report timing information. | 
| 92 if (frameInfo->timing.is_timing_frame) { | 94 if (frameInfo->timing.is_timing_frame) { | 
| 95 int64_t capture_time_ms = decodedImage.ntp_time_ms() - ntp_offset_; | |
| 
hbos
2017/06/27 14:08:31
What does |capture_time_ms| imply if |decodedImage
 
ilnik
2017/06/27 15:23:56
ntp_time_ms() is -1 if sender clock is not estimat
 | |
| 93 // Convert remote timestamps to local time from ntp timestamps. | 96 // Convert remote timestamps to local time from ntp timestamps. | 
| 94 frameInfo->timing.encode_start_ms -= ntp_offset_; | 97 frameInfo->timing.encode_start_ms -= ntp_offset_; | 
| 95 frameInfo->timing.encode_finish_ms -= ntp_offset_; | 98 frameInfo->timing.encode_finish_ms -= ntp_offset_; | 
| 96 frameInfo->timing.packetization_finish_ms -= ntp_offset_; | 99 frameInfo->timing.packetization_finish_ms -= ntp_offset_; | 
| 97 frameInfo->timing.pacer_exit_ms -= ntp_offset_; | 100 frameInfo->timing.pacer_exit_ms -= ntp_offset_; | 
| 98 frameInfo->timing.network_timestamp_ms -= ntp_offset_; | 101 frameInfo->timing.network_timestamp_ms -= ntp_offset_; | 
| 99 frameInfo->timing.network2_timestamp_ms -= ntp_offset_; | 102 frameInfo->timing.network2_timestamp_ms -= ntp_offset_; | 
| 100 // TODO(ilnik): Report timing information here. | 103 | 
| 101 // Capture time: decodedImage.ntp_time_ms() - ntp_offset | 104 int64_t sender_delta_ms = 0; | 
| 102 // Encode start: frameInfo->timing.encode_start_ms | 105 if (decodedImage.ntp_time_ms() < 0) { | 
| 103 // Encode finish: frameInfo->timing.encode_finish_ms | 106 // Sender clock is not estimated yet. Make sure that sender times are all | 
| 104 // Packetization done: frameInfo->timing.packetization_finish_ms | 107 // negative to indicate that. Yet they still should be relatively correct. | 
| 
hbos
2017/06/27 14:08:31
Can you document the meaning of negative values in
 
ilnik
2017/06/27 15:23:56
Done.
 | |
| 105 // Pacer exit: frameInfo->timing.pacer_exit_ms | 108 sender_delta_ms = | 
| 106 // Network timestamp: frameInfo->timing.network_timestamp_ms | 109 std::max({capture_time_ms, frameInfo->timing.encode_start_ms, | 
| 107 // Network2 timestamp: frameInfo->timing.network2_timestamp_ms | 110 frameInfo->timing.encode_finish_ms, | 
| 108 // Receive start: frameInfo->timing.receive_start_ms | 111 frameInfo->timing.packetization_finish_ms, | 
| 109 // Receive finish: frameInfo->timing.receive_finish_ms | 112 frameInfo->timing.pacer_exit_ms, | 
| 110 // Decode start: frameInfo->decodeStartTimeMs | 113 frameInfo->timing.network_timestamp_ms, | 
| 111 // Decode finish: now_ms | 114 frameInfo->timing.network2_timestamp_ms}) + | 
| 112 // Render time: frameInfo->renderTimeMs | 115 1; | 
| 116 } | |
| 117 | |
| 118 TimingFrameInfo timing_frame_info; | |
| 119 | |
| 120 timing_frame_info.capture_time_ms = capture_time_ms - sender_delta_ms; | |
| 121 timing_frame_info.encode_start_ms = | |
| 122 frameInfo->timing.encode_start_ms - sender_delta_ms; | |
| 123 timing_frame_info.encode_finish_ms = | |
| 124 frameInfo->timing.encode_finish_ms - sender_delta_ms; | |
| 125 timing_frame_info.packetization_finish_ms = | |
| 126 frameInfo->timing.packetization_finish_ms - sender_delta_ms; | |
| 127 timing_frame_info.pacer_exit_ms = | |
| 128 frameInfo->timing.pacer_exit_ms - sender_delta_ms; | |
| 129 timing_frame_info.network_timestamp_ms = | |
| 130 frameInfo->timing.network_timestamp_ms - sender_delta_ms; | |
| 131 timing_frame_info.network2_timestamp_ms = | |
| 132 frameInfo->timing.network2_timestamp_ms - sender_delta_ms; | |
| 133 timing_frame_info.receive_start_ms = frameInfo->timing.receive_start_ms; | |
| 134 timing_frame_info.receive_finish_ms = frameInfo->timing.receive_finish_ms; | |
| 135 timing_frame_info.decode_start_ms = frameInfo->decodeStartTimeMs; | |
| 136 timing_frame_info.decode_finish_ms = now_ms; | |
| 137 timing_frame_info.render_time_ms = frameInfo->renderTimeMs; | |
| 138 timing_frame_info.rtp_timestamp = decodedImage.timestamp(); | |
| 139 | |
| 140 _timing->SetTimingFrameInfo(timing_frame_info); | |
| 113 } | 141 } | 
| 114 | 142 | 
| 115 decodedImage.set_timestamp_us( | 143 decodedImage.set_timestamp_us( | 
| 116 frameInfo->renderTimeMs * rtc::kNumMicrosecsPerMillisec); | 144 frameInfo->renderTimeMs * rtc::kNumMicrosecsPerMillisec); | 
| 117 decodedImage.set_rotation(frameInfo->rotation); | 145 decodedImage.set_rotation(frameInfo->rotation); | 
| 118 _receiveCallback->FrameToRender(decodedImage, qp, frameInfo->content_type); | 146 _receiveCallback->FrameToRender(decodedImage, qp, frameInfo->content_type); | 
| 119 } | 147 } | 
| 120 | 148 | 
| 121 int32_t VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame( | 149 int32_t VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame( | 
| 122 const uint64_t pictureId) { | 150 const uint64_t pictureId) { | 
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 | 250 | 
| 223 bool VCMGenericDecoder::External() const { | 251 bool VCMGenericDecoder::External() const { | 
| 224 return _isExternal; | 252 return _isExternal; | 
| 225 } | 253 } | 
| 226 | 254 | 
| 227 bool VCMGenericDecoder::PrefersLateDecoding() const { | 255 bool VCMGenericDecoder::PrefersLateDecoding() const { | 
| 228 return _decoder->PrefersLateDecoding(); | 256 return _decoder->PrefersLateDecoding(); | 
| 229 } | 257 } | 
| 230 | 258 | 
| 231 } // namespace webrtc | 259 } // namespace webrtc | 
| OLD | NEW |