blob: 96f9d00d06e77780e9e6b5ac7b9f3125d63396f1 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 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_MODULES_VIDEO_CODING_ENCODED_FRAME_H_
12#define WEBRTC_MODULES_VIDEO_CODING_ENCODED_FRAME_H_
13
stefan@webrtc.orgc5300432012-10-08 07:06:53 +000014#include <vector>
15
pbos@webrtc.orga4407322013-07-16 12:32:05 +000016#include "webrtc/common_types.h"
kjellander6f8ce062015-11-16 13:52:24 -080017#include "webrtc/common_video/include/video_image.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010018#include "webrtc/modules/include/module_common_types.h"
Henrik Kjellander2557b862015-11-18 22:00:21 +010019#include "webrtc/modules/video_coding/include/video_codec_interface.h"
20#include "webrtc/modules/video_coding/include/video_coding_defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000021
philipel9d3ab612015-12-21 04:12:39 -080022namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000023
philipel9d3ab612015-12-21 04:12:39 -080024class VCMEncodedFrame : protected EncodedImage {
25 public:
26 VCMEncodedFrame();
27 explicit VCMEncodedFrame(const webrtc::EncodedImage& rhs);
28 VCMEncodedFrame(const VCMEncodedFrame& rhs);
niklase@google.com470e71d2011-07-07 08:21:25 +000029
philipel9d3ab612015-12-21 04:12:39 -080030 ~VCMEncodedFrame();
31 /**
32 * Delete VideoFrame and resets members to zero
33 */
34 void Free();
35 /**
36 * Set render time in milliseconds
37 */
38 void SetRenderTime(const int64_t renderTimeMs) {
39 _renderTimeMs = renderTimeMs;
40 }
niklase@google.com470e71d2011-07-07 08:21:25 +000041
philipel9d3ab612015-12-21 04:12:39 -080042 /**
43 * Set the encoded frame size
44 */
45 void SetEncodedSize(uint32_t width, uint32_t height) {
46 _encodedWidth = width;
47 _encodedHeight = height;
48 }
49 /**
50 * Get the encoded image
51 */
52 const webrtc::EncodedImage& EncodedImage() const {
53 return static_cast<const webrtc::EncodedImage&>(*this);
54 }
55 /**
56 * Get pointer to frame buffer
57 */
58 const uint8_t* Buffer() const { return _buffer; }
59 /**
60 * Get frame length
61 */
62 size_t Length() const { return _length; }
63 /**
64 * Get frame timestamp (90kHz)
65 */
66 uint32_t TimeStamp() const { return _timeStamp; }
67 /**
68 * Get render time in milliseconds
69 */
70 int64_t RenderTimeMs() const { return _renderTimeMs; }
71 /**
72 * Get frame type
73 */
74 webrtc::FrameType FrameType() const { return _frameType; }
75 /**
76 * Get frame rotation
77 */
perkj414dda12016-07-04 01:45:23 -070078 VideoRotation rotation() const { return rotation_; }
philipel9d3ab612015-12-21 04:12:39 -080079 /**
ilnik00d802b2017-04-11 10:34:31 -070080 * Get video content type
81 */
82 VideoContentType contentType() const { return content_type_; }
83 /**
84 * True if this frame is complete, false otherwise
85 */
philipel9d3ab612015-12-21 04:12:39 -080086 bool Complete() const { return _completeFrame; }
87 /**
88 * True if there's a frame missing before this frame
89 */
90 bool MissingFrame() const { return _missingFrame; }
91 /**
92 * Payload type of the encoded payload
93 */
94 uint8_t PayloadType() const { return _payloadType; }
95 /**
96 * Get codec specific info.
97 * The returned pointer is only valid as long as the VCMEncodedFrame
98 * is valid. Also, VCMEncodedFrame owns the pointer and will delete
99 * the object.
100 */
101 const CodecSpecificInfo* CodecSpecific() const { return &_codecSpecificInfo; }
niklase@google.com470e71d2011-07-07 08:21:25 +0000102
philipel9d3ab612015-12-21 04:12:39 -0800103 protected:
104 /**
105 * Verifies that current allocated buffer size is larger than or equal to the
106 * input size.
107 * If the current buffer size is smaller, a new allocation is made and the old
108 * buffer data
109 * is copied to the new buffer.
110 * Buffer size is updated to minimumSize.
111 */
112 void VerifyAndAllocate(size_t minimumSize);
niklase@google.com470e71d2011-07-07 08:21:25 +0000113
philipel9d3ab612015-12-21 04:12:39 -0800114 void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +0000115
philipel9d3ab612015-12-21 04:12:39 -0800116 void CopyCodecSpecific(const RTPVideoHeader* header);
henrik.lundin@webrtc.org473bac82011-08-17 09:47:33 +0000117
philipel9d3ab612015-12-21 04:12:39 -0800118 int64_t _renderTimeMs;
119 uint8_t _payloadType;
120 bool _missingFrame;
121 CodecSpecificInfo _codecSpecificInfo;
122 webrtc::VideoCodecType _codec;
guoweis@webrtc.org54d072e2015-03-17 21:54:50 +0000123
philipel9d3ab612015-12-21 04:12:39 -0800124 // Video rotation is only set along with the last packet for each frame
125 // (same as marker bit). This |_rotation_set| is only for debugging purpose
126 // to ensure we don't set it twice for a frame.
127 bool _rotation_set;
niklase@google.com470e71d2011-07-07 08:21:25 +0000128};
129
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000130} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000131
philipel9d3ab612015-12-21 04:12:39 -0800132#endif // WEBRTC_MODULES_VIDEO_CODING_ENCODED_FRAME_H_