blob: f311db2e68cf3199a67c646103dda4cb81bd6ab1 [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
22namespace webrtc
23{
24
25class VCMEncodedFrame : protected EncodedImage
26{
27public:
28 VCMEncodedFrame();
29 VCMEncodedFrame(const webrtc::EncodedImage& rhs);
30 VCMEncodedFrame(const VCMEncodedFrame& rhs);
31
32 ~VCMEncodedFrame();
33 /**
34 * Delete VideoFrame and resets members to zero
35 */
36 void Free();
37 /**
38 * Set render time in milliseconds
39 */
pbos@webrtc.org7b859cc2013-04-02 15:54:38 +000040 void SetRenderTime(const int64_t renderTimeMs) {_renderTimeMs = renderTimeMs;}
niklase@google.com470e71d2011-07-07 08:21:25 +000041
42 /**
43 * Set the encoded frame size
44 */
pbos@webrtc.org7b859cc2013-04-02 15:54:38 +000045 void SetEncodedSize(uint32_t width, uint32_t height)
niklase@google.com470e71d2011-07-07 08:21:25 +000046 { _encodedWidth = width; _encodedHeight = height; }
47 /**
48 * Get the encoded image
49 */
50 const webrtc::EncodedImage& EncodedImage() const
51 { return static_cast<const webrtc::EncodedImage&>(*this); }
52 /**
53 * Get pointer to frame buffer
54 */
pbos@webrtc.org7b859cc2013-04-02 15:54:38 +000055 const uint8_t* Buffer() const {return _buffer;}
niklase@google.com470e71d2011-07-07 08:21:25 +000056 /**
57 * Get frame length
58 */
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000059 size_t Length() const {return _length;}
niklase@google.com470e71d2011-07-07 08:21:25 +000060 /**
61 * Get frame timestamp (90kHz)
62 */
pbos@webrtc.org7b859cc2013-04-02 15:54:38 +000063 uint32_t TimeStamp() const {return _timeStamp;}
niklase@google.com470e71d2011-07-07 08:21:25 +000064 /**
65 * Get render time in milliseconds
66 */
pbos@webrtc.org7b859cc2013-04-02 15:54:38 +000067 int64_t RenderTimeMs() const {return _renderTimeMs;}
niklase@google.com470e71d2011-07-07 08:21:25 +000068 /**
69 * Get frame type
70 */
pbos22993e12015-10-19 02:39:06 -070071 webrtc::FrameType FrameType() const { return _frameType; }
niklase@google.com470e71d2011-07-07 08:21:25 +000072 /**
guoweis@webrtc.org54d072e2015-03-17 21:54:50 +000073 * Get frame rotation
74 */
75 VideoRotation rotation() const { return _rotation; }
76 /**
niklase@google.com470e71d2011-07-07 08:21:25 +000077 * True if this frame is complete, false otherwise
78 */
79 bool Complete() const { return _completeFrame; }
80 /**
81 * True if there's a frame missing before this frame
82 */
83 bool MissingFrame() const { return _missingFrame; }
84 /**
85 * Payload type of the encoded payload
86 */
pbos@webrtc.org7b859cc2013-04-02 15:54:38 +000087 uint8_t PayloadType() const { return _payloadType; }
niklase@google.com470e71d2011-07-07 08:21:25 +000088 /**
henrik.lundin@webrtc.org473bac82011-08-17 09:47:33 +000089 * Get codec specific info.
90 * The returned pointer is only valid as long as the VCMEncodedFrame
91 * is valid. Also, VCMEncodedFrame owns the pointer and will delete
92 * the object.
niklase@google.com470e71d2011-07-07 08:21:25 +000093 */
henrik.lundin@webrtc.org473bac82011-08-17 09:47:33 +000094 const CodecSpecificInfo* CodecSpecific() const {return &_codecSpecificInfo;}
niklase@google.com470e71d2011-07-07 08:21:25 +000095
stefan@webrtc.orgc3d89102011-09-08 06:50:28 +000096 const RTPFragmentationHeader* FragmentationHeader() const;
97
niklase@google.com470e71d2011-07-07 08:21:25 +000098protected:
99 /**
100 * Verifies that current allocated buffer size is larger than or equal to the input size.
101 * If the current buffer size is smaller, a new allocation is made and the old buffer data
102 * is copied to the new buffer.
103 * Buffer size is updated to minimumSize.
104 */
Magnus Jedvertab004042015-05-05 11:37:12 +0200105 void VerifyAndAllocate(size_t minimumSize);
niklase@google.com470e71d2011-07-07 08:21:25 +0000106
107 void Reset();
108
henrik.lundin@webrtc.org473bac82011-08-17 09:47:33 +0000109 void CopyCodecSpecific(const RTPVideoHeader* header);
110
pbos@webrtc.org7b859cc2013-04-02 15:54:38 +0000111 int64_t _renderTimeMs;
112 uint8_t _payloadType;
niklase@google.com470e71d2011-07-07 08:21:25 +0000113 bool _missingFrame;
henrik.lundin@webrtc.org473bac82011-08-17 09:47:33 +0000114 CodecSpecificInfo _codecSpecificInfo;
niklase@google.com470e71d2011-07-07 08:21:25 +0000115 webrtc::VideoCodecType _codec;
stefan@webrtc.orgc3d89102011-09-08 06:50:28 +0000116 RTPFragmentationHeader _fragmentation;
guoweis@webrtc.org54d072e2015-03-17 21:54:50 +0000117 VideoRotation _rotation;
118
119 // Video rotation is only set along with the last packet for each frame
120 // (same as marker bit). This |_rotation_set| is only for debugging purpose
121 // to ensure we don't set it twice for a frame.
122 bool _rotation_set;
niklase@google.com470e71d2011-07-07 08:21:25 +0000123};
124
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000125} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000126
127#endif // WEBRTC_MODULES_VIDEO_CODING_ENCODED_FRAME_H_