blob: 2860d599b54ab4a7360d90d7ae7d11278c6498aa [file] [log] [blame]
nisseea3a7982017-05-15 02:42:11 -07001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef COMMON_VIDEO_INCLUDE_VIDEO_FRAME_H_
12#define COMMON_VIDEO_INCLUDE_VIDEO_FRAME_H_
nisseea3a7982017-05-15 02:42:11 -070013
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 Bonadei71207422017-09-15 13:58:09 +020019#include "common_types.h" // NOLINT(build/include)
20#include "typedefs.h" // NOLINT(build/include)
nisseea3a7982017-05-15 02:42:11 -070021
22namespace webrtc {
23
24// TODO(pbos): Rename EncodedFrame and reformat this class' members.
25class 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
mflodman351424e2017-08-10 02:43:14 -070033 EncodedImage();
34 EncodedImage(uint8_t* buffer, size_t length, size_t size);
nisseea3a7982017-05-15 02:42:11 -070035
mflodman351424e2017-08-10 02:43:14 -070036 void SetEncodeTime(int64_t encode_start_ms, int64_t encode_finish_ms) const;
ilnik04f4d122017-06-19 07:18:55 -070037
nisseea3a7982017-05-15 02:42:11 -070038 // 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;
ilnik6d5b4d62017-08-30 03:32:14 -070057 mutable VideoContentType content_type_ = VideoContentType::UNSPECIFIED;
nisseea3a7982017-05-15 02:42:11 -070058 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};
ilnik04f4d122017-06-19 07:18:55 -070066
67 // Timing information should be updatable on const instances.
68 mutable struct Timing {
sprangba050a62017-08-18 02:51:12 -070069 uint8_t flags = TimingFrameFlags::kInvalid;
ilnik04f4d122017-06-19 07:18:55 -070070 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_;
nisseea3a7982017-05-15 02:42:11 -070079};
80
81} // namespace webrtc
82
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020083#endif // COMMON_VIDEO_INCLUDE_VIDEO_FRAME_H_