ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_API_VIDEO_VIDEO_TIMING_H_ |
| 12 | #define WEBRTC_API_VIDEO_VIDEO_TIMING_H_ |
| 13 | |
| 14 | #include <stdint.h> |
| 15 | #include <limits> |
| 16 | #include "webrtc/base/checks.h" |
| 17 | #include "webrtc/base/safe_conversions.h" |
| 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | // Video timing timstamps in ms counted from capture_time_ms of a frame. |
| 22 | struct VideoTiming { |
| 23 | static const uint8_t kEncodeStartDeltaIdx = 0; |
| 24 | static const uint8_t kEncodeFinishDeltaIdx = 1; |
| 25 | static const uint8_t kPacketizationFinishDeltaIdx = 2; |
| 26 | static const uint8_t kPacerExitDeltaIdx = 3; |
| 27 | static const uint8_t kNetworkTimestampDeltaIdx = 4; |
| 28 | static const uint8_t kNetwork2TimestampDeltaIdx = 5; |
| 29 | |
| 30 | // Returns |time_ms - base_ms| capped at max 16-bit value. |
| 31 | // Used to fill this data structure as per |
| 32 | // https://webrtc.org/experiments/rtp-hdrext/video-timing/ extension stores |
| 33 | // 16-bit deltas of timestamps from packet capture time. |
| 34 | static uint16_t GetDeltaCappedMs(int64_t base_ms, int64_t time_ms) { |
| 35 | RTC_DCHECK_GE(time_ms, base_ms); |
| 36 | return rtc::saturated_cast<uint16_t>(time_ms - base_ms); |
| 37 | } |
| 38 | |
| 39 | uint16_t encode_start_delta_ms; |
| 40 | uint16_t encode_finish_delta_ms; |
| 41 | uint16_t packetization_finish_delta_ms; |
| 42 | uint16_t pacer_exit_delta_ms; |
| 43 | uint16_t network_timstamp_delta_ms; |
| 44 | uint16_t network2_timstamp_delta_ms; |
| 45 | bool is_timing_frame; |
| 46 | }; |
| 47 | |
| 48 | } // namespace webrtc |
| 49 | |
| 50 | #endif // WEBRTC_API_VIDEO_VIDEO_TIMING_H_ |