nisse | ea3a798 | 2017-05-15 02:42:11 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef COMMON_VIDEO_INCLUDE_VIDEO_FRAME_H_ |
| 12 | #define COMMON_VIDEO_INCLUDE_VIDEO_FRAME_H_ |
nisse | ea3a798 | 2017-05-15 02:42:11 -0700 | [diff] [blame] | 13 | |
| 14 | // TODO(nisse): This header file should eventually be deleted. The |
| 15 | // EncodedImage class stays in this file until we have figured out how |
| 16 | // to refactor and clean up related interfaces, at which point it |
| 17 | // should be moved to somewhere under api/. |
| 18 | |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 19 | #include "common_types.h" // NOLINT(build/include) |
| 20 | #include "typedefs.h" // NOLINT(build/include) |
nisse | ea3a798 | 2017-05-15 02:42:11 -0700 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | // TODO(pbos): Rename EncodedFrame and reformat this class' members. |
| 25 | class EncodedImage { |
| 26 | public: |
| 27 | static const size_t kBufferPaddingBytesH264; |
| 28 | |
| 29 | // Some decoders require encoded image buffers to be padded with a small |
| 30 | // number of additional bytes (due to over-reading byte readers). |
| 31 | static size_t GetBufferPaddingBytes(VideoCodecType codec_type); |
| 32 | |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 33 | EncodedImage(); |
| 34 | EncodedImage(uint8_t* buffer, size_t length, size_t size); |
nisse | ea3a798 | 2017-05-15 02:42:11 -0700 | [diff] [blame] | 35 | |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 36 | void SetEncodeTime(int64_t encode_start_ms, int64_t encode_finish_ms) const; |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 37 | |
nisse | ea3a798 | 2017-05-15 02:42:11 -0700 | [diff] [blame] | 38 | // TODO(kthelgason): get rid of this struct as it only has a single member |
| 39 | // remaining. |
| 40 | struct AdaptReason { |
| 41 | AdaptReason() : bw_resolutions_disabled(-1) {} |
| 42 | int bw_resolutions_disabled; // Number of resolutions that are not sent |
| 43 | // due to bandwidth for this frame. |
| 44 | // Or -1 if information is not provided. |
| 45 | }; |
| 46 | uint32_t _encodedWidth = 0; |
| 47 | uint32_t _encodedHeight = 0; |
| 48 | uint32_t _timeStamp = 0; |
| 49 | // NTP time of the capture time in local timebase in milliseconds. |
| 50 | int64_t ntp_time_ms_ = 0; |
| 51 | int64_t capture_time_ms_ = 0; |
| 52 | FrameType _frameType = kVideoFrameDelta; |
| 53 | uint8_t* _buffer; |
| 54 | size_t _length; |
| 55 | size_t _size; |
| 56 | VideoRotation rotation_ = kVideoRotation_0; |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 57 | mutable VideoContentType content_type_ = VideoContentType::UNSPECIFIED; |
nisse | ea3a798 | 2017-05-15 02:42:11 -0700 | [diff] [blame] | 58 | bool _completeFrame = false; |
| 59 | AdaptReason adapt_reason_; |
| 60 | int qp_ = -1; // Quantizer value. |
| 61 | |
| 62 | // When an application indicates non-zero values here, it is taken as an |
| 63 | // indication that all future frames will be constrained with those limits |
| 64 | // until the application indicates a change again. |
| 65 | PlayoutDelay playout_delay_ = {-1, -1}; |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 66 | |
| 67 | // Timing information should be updatable on const instances. |
| 68 | mutable struct Timing { |
sprang | ba050a6 | 2017-08-18 02:51:12 -0700 | [diff] [blame] | 69 | uint8_t flags = TimingFrameFlags::kInvalid; |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 70 | int64_t encode_start_ms = 0; |
| 71 | int64_t encode_finish_ms = 0; |
| 72 | int64_t packetization_finish_ms = 0; |
| 73 | int64_t pacer_exit_ms = 0; |
| 74 | int64_t network_timestamp_ms = 0; |
| 75 | int64_t network2_timestamp_ms = 0; |
| 76 | int64_t receive_start_ms = 0; |
| 77 | int64_t receive_finish_ms = 0; |
| 78 | } timing_; |
nisse | ea3a798 | 2017-05-15 02:42:11 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | } // namespace webrtc |
| 82 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 83 | #endif // COMMON_VIDEO_INCLUDE_VIDEO_FRAME_H_ |