Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 #ifndef WEBRTC_API_VIDEO_VIDEO_TIMING_H_ | 11 #ifndef WEBRTC_API_VIDEO_VIDEO_TIMING_H_ |
| 12 #define WEBRTC_API_VIDEO_VIDEO_TIMING_H_ | 12 #define WEBRTC_API_VIDEO_VIDEO_TIMING_H_ |
| 13 | 13 |
| 14 #include <stdint.h> | 14 #include <stdint.h> |
| 15 | 15 |
| 16 #include <limits> | |
| 16 #include <string> | 17 #include <string> |
| 17 | 18 |
| 18 #include "webrtc/rtc_base/checks.h" | 19 #include "webrtc/rtc_base/checks.h" |
| 19 #include "webrtc/rtc_base/safe_conversions.h" | 20 #include "webrtc/rtc_base/safe_conversions.h" |
| 20 | 21 |
| 21 namespace webrtc { | 22 namespace webrtc { |
| 22 | 23 |
| 24 enum TimingFrameFlags : uint8_t { | |
| 25 kDefault = 0, // No flags set (used by old protocol) | |
| 26 kTriggeredByTimer = 1 << 0, // Frame marked for tracing by periodic timer. | |
| 27 kTriggeredBySize = 1 << 1, // Frame marked for tracing due to size. | |
| 28 kInvalid = std::numeric_limits<uint8_t>::max() // Invalid, ignore! | |
| 29 }; | |
| 30 | |
| 23 // Video timing timestamps in ms counted from capture_time_ms of a frame. | 31 // Video timing timestamps in ms counted from capture_time_ms of a frame. |
| 24 // This structure represents data sent in video-timing RTP header extension. | 32 // This structure represents data sent in video-timing RTP header extension. |
| 25 struct VideoSendTiming { | 33 struct VideoSendTiming { |
| 26 static const uint8_t kEncodeStartDeltaIdx = 0; | 34 // Indices of the fields in the RTP header extension, counting from the first |
| 27 static const uint8_t kEncodeFinishDeltaIdx = 1; | 35 // byte after the one-byte header. |
| 28 static const uint8_t kPacketizationFinishDeltaIdx = 2; | 36 static constexpr uint8_t kEncodeStartDeltaIdx = 0; |
|
danilchap
2017/08/11 12:22:35
may be rename them from Idx to Offset
sprang_webrtc
2017/08/11 13:19:05
Done.
| |
| 29 static const uint8_t kPacerExitDeltaIdx = 3; | 37 static constexpr uint8_t kEncodeFinishDeltaIdx = 2; |
| 30 static const uint8_t kNetworkTimestampDeltaIdx = 4; | 38 static constexpr uint8_t kPacketizationFinishDeltaIdx = 4; |
| 31 static const uint8_t kNetwork2TimestampDeltaIdx = 5; | 39 static constexpr uint8_t kPacerExitDeltaIdx = 6; |
| 40 static constexpr uint8_t kNetworkTimestampDeltaIdx = 8; | |
| 41 static constexpr uint8_t kNetwork2TimestampDeltaIdx = 10; | |
| 42 static constexpr uint8_t kFLagsIdx = 12; | |
| 32 | 43 |
| 33 // Returns |time_ms - base_ms| capped at max 16-bit value. | 44 // Returns |time_ms - base_ms| capped at max 16-bit value. |
| 34 // Used to fill this data structure as per | 45 // Used to fill this data structure as per |
| 35 // https://webrtc.org/experiments/rtp-hdrext/video-timing/ extension stores | 46 // https://webrtc.org/experiments/rtp-hdrext/video-timing/ extension stores |
| 36 // 16-bit deltas of timestamps from packet capture time. | 47 // 16-bit deltas of timestamps from packet capture time. |
| 37 static uint16_t GetDeltaCappedMs(int64_t base_ms, int64_t time_ms) { | 48 static uint16_t GetDeltaCappedMs(int64_t base_ms, int64_t time_ms) { |
| 49 if (base_ms >= time_ms) | |
| 50 printf("Wat\n"); | |
|
danilchap
2017/08/11 12:22:35
may be add to next line:
RTC_DCHECK_GE(time_ms, ba
sprang_webrtc
2017/08/11 13:19:05
Oops, this was debug code I forgot to remove.
| |
| 38 RTC_DCHECK_GE(time_ms, base_ms); | 51 RTC_DCHECK_GE(time_ms, base_ms); |
| 39 return rtc::saturated_cast<uint16_t>(time_ms - base_ms); | 52 return rtc::saturated_cast<uint16_t>(time_ms - base_ms); |
| 40 } | 53 } |
| 41 | 54 |
| 42 uint16_t encode_start_delta_ms; | 55 uint16_t encode_start_delta_ms; |
| 43 uint16_t encode_finish_delta_ms; | 56 uint16_t encode_finish_delta_ms; |
| 44 uint16_t packetization_finish_delta_ms; | 57 uint16_t packetization_finish_delta_ms; |
| 45 uint16_t pacer_exit_delta_ms; | 58 uint16_t pacer_exit_delta_ms; |
| 46 uint16_t network_timstamp_delta_ms; | 59 uint16_t network_timstamp_delta_ms; |
| 47 uint16_t network2_timstamp_delta_ms; | 60 uint16_t network2_timstamp_delta_ms; |
| 48 bool is_timing_frame; | 61 uint8_t flags; |
|
danilchap
2017/08/11 12:22:35
may be TimingFrameFlags instead of uint8_t
sprang_webrtc
2017/08/11 13:19:05
No, this is intended a bit-field. kTriggeredByTime
| |
| 49 }; | 62 }; |
| 50 | 63 |
| 51 // Used to report precise timings of a 'timing frames'. Contains all important | 64 // Used to report precise timings of a 'timing frames'. Contains all important |
| 52 // timestamps for a lifetime of that specific frame. Reported as a string via | 65 // timestamps for a lifetime of that specific frame. Reported as a string via |
| 53 // GetStats(). Only frame which took the longest between two GetStats calls is | 66 // GetStats(). Only frame which took the longest between two GetStats calls is |
| 54 // reported. | 67 // reported. |
| 55 struct TimingFrameInfo { | 68 struct TimingFrameInfo { |
| 56 TimingFrameInfo(); | 69 TimingFrameInfo(); |
| 57 | 70 |
| 58 // Returns end-to-end delay of a frame, if sender and receiver timestamps are | 71 // Returns end-to-end delay of a frame, if sender and receiver timestamps are |
| 59 // synchronized, -1 otherwise. | 72 // synchronized, -1 otherwise. |
| 60 int64_t EndToEndDelay() const; | 73 int64_t EndToEndDelay() const; |
| 61 | 74 |
| 62 // Returns true if current frame took longer to process than |other| frame. | 75 // Returns true if current frame took longer to process than |other| frame. |
| 63 // If other frame's clocks are not synchronized, current frame is always | 76 // If other frame's clocks are not synchronized, current frame is always |
| 64 // preferred. | 77 // preferred. |
| 65 bool IsLongerThan(const TimingFrameInfo& other) const; | 78 bool IsLongerThan(const TimingFrameInfo& other) const; |
| 66 | 79 |
| 80 // Returns true if flags are set to indicate this frame was marked for tracing | |
| 81 // due to the size being outside some limit. | |
| 82 bool IsOutlier() const; | |
| 83 | |
| 84 // Returns true if the timing data is marked as invalid, in which case it | |
| 85 // should be ignored. | |
| 86 bool IsInvalid() const; | |
| 87 | |
| 67 std::string ToString() const; | 88 std::string ToString() const; |
| 68 | 89 |
| 69 uint32_t rtp_timestamp; // Identifier of a frame. | 90 uint32_t rtp_timestamp; // Identifier of a frame. |
| 70 // All timestamps below are in local monotonous clock of a receiver. | 91 // All timestamps below are in local monotonous clock of a receiver. |
| 71 // If sender clock is not yet estimated, sender timestamps | 92 // If sender clock is not yet estimated, sender timestamps |
| 72 // (capture_time_ms ... pacer_exit_ms) are negative values, still | 93 // (capture_time_ms ... pacer_exit_ms) are negative values, still |
| 73 // relatively correct. | 94 // relatively correct. |
| 74 int64_t capture_time_ms; // Captrue time of a frame. | 95 int64_t capture_time_ms; // Captrue time of a frame. |
| 75 int64_t encode_start_ms; // Encode start time. | 96 int64_t encode_start_ms; // Encode start time. |
| 76 int64_t encode_finish_ms; // Encode completion time. | 97 int64_t encode_finish_ms; // Encode completion time. |
| 77 int64_t packetization_finish_ms; // Time when frame was passed to pacer. | 98 int64_t packetization_finish_ms; // Time when frame was passed to pacer. |
| 78 int64_t pacer_exit_ms; // Time when last packet was pushed out of pacer. | 99 int64_t pacer_exit_ms; // Time when last packet was pushed out of pacer. |
| 79 // Two in-network RTP processor timestamps: meaning is application specific. | 100 // Two in-network RTP processor timestamps: meaning is application specific. |
| 80 int64_t network_timestamp_ms; | 101 int64_t network_timestamp_ms; |
| 81 int64_t network2_timestamp_ms; | 102 int64_t network2_timestamp_ms; |
| 82 int64_t receive_start_ms; // First received packet time. | 103 int64_t receive_start_ms; // First received packet time. |
| 83 int64_t receive_finish_ms; // Last received packet time. | 104 int64_t receive_finish_ms; // Last received packet time. |
| 84 int64_t decode_start_ms; // Decode start time. | 105 int64_t decode_start_ms; // Decode start time. |
| 85 int64_t decode_finish_ms; // Decode completion time. | 106 int64_t decode_finish_ms; // Decode completion time. |
| 86 int64_t render_time_ms; // Proposed render time to insure smooth playback. | 107 int64_t render_time_ms; // Proposed render time to insure smooth playback. |
| 108 | |
| 109 uint8_t flags; // Flags indicating validity and/or why tracing was triggered. | |
|
danilchap
2017/08/11 12:22:35
ditto
sprang_webrtc
2017/08/11 13:19:05
ditto :)
| |
| 87 }; | 110 }; |
| 88 | 111 |
| 89 } // namespace webrtc | 112 } // namespace webrtc |
| 90 | 113 |
| 91 #endif // WEBRTC_API_VIDEO_VIDEO_TIMING_H_ | 114 #endif // WEBRTC_API_VIDEO_VIDEO_TIMING_H_ |
| OLD | NEW |