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

Side by Side Diff: webrtc/modules/video_coding/generic_decoder.cc

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

Powered by Google App Engine
This is Rietveld 408576698