Line data Source code
1 : /*
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 :
14 : #include <vector>
15 :
16 : #include "webrtc/common_types.h"
17 : #include "webrtc/common_video/include/video_image.h"
18 : #include "webrtc/modules/include/module_common_types.h"
19 : #include "webrtc/modules/video_coding/include/video_codec_interface.h"
20 : #include "webrtc/modules/video_coding/include/video_coding_defines.h"
21 :
22 : namespace webrtc {
23 :
24 : class VCMEncodedFrame : protected EncodedImage {
25 : public:
26 : VCMEncodedFrame();
27 : explicit VCMEncodedFrame(const webrtc::EncodedImage& rhs);
28 : VCMEncodedFrame(const VCMEncodedFrame& rhs);
29 :
30 : ~VCMEncodedFrame();
31 : /**
32 : * Delete VideoFrame and resets members to zero
33 : */
34 : void Free();
35 : /**
36 : * Set render time in milliseconds
37 : */
38 0 : void SetRenderTime(const int64_t renderTimeMs) {
39 0 : _renderTimeMs = renderTimeMs;
40 0 : }
41 :
42 : /**
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 0 : const webrtc::EncodedImage& EncodedImage() const {
53 0 : return static_cast<const webrtc::EncodedImage&>(*this);
54 : }
55 : /**
56 : * Get pointer to frame buffer
57 : */
58 0 : const uint8_t* Buffer() const { return _buffer; }
59 : /**
60 : * Get frame length
61 : */
62 0 : size_t Length() const { return _length; }
63 : /**
64 : * Get frame timestamp (90kHz)
65 : */
66 0 : uint32_t TimeStamp() const { return _timeStamp; }
67 : /**
68 : * Get render time in milliseconds
69 : */
70 0 : int64_t RenderTimeMs() const { return _renderTimeMs; }
71 : /**
72 : * Get frame type
73 : */
74 0 : webrtc::FrameType FrameType() const { return _frameType; }
75 : /**
76 : * Get frame rotation
77 : */
78 0 : VideoRotation rotation() const { return rotation_; }
79 : /**
80 : * True if this frame is complete, false otherwise
81 : */
82 0 : bool Complete() const { return _completeFrame; }
83 : /**
84 : * True if there's a frame missing before this frame
85 : */
86 0 : bool MissingFrame() const { return _missingFrame; }
87 : /**
88 : * Payload type of the encoded payload
89 : */
90 0 : uint8_t PayloadType() const { return _payloadType; }
91 : /**
92 : * Get codec specific info.
93 : * The returned pointer is only valid as long as the VCMEncodedFrame
94 : * is valid. Also, VCMEncodedFrame owns the pointer and will delete
95 : * the object.
96 : */
97 0 : const CodecSpecificInfo* CodecSpecific() const { return &_codecSpecificInfo; }
98 :
99 : protected:
100 : /**
101 : * Verifies that current allocated buffer size is larger than or equal to the
102 : * input size.
103 : * If the current buffer size is smaller, a new allocation is made and the old
104 : * buffer data
105 : * is copied to the new buffer.
106 : * Buffer size is updated to minimumSize.
107 : */
108 : void VerifyAndAllocate(size_t minimumSize);
109 :
110 : void Reset();
111 :
112 : void CopyCodecSpecific(const RTPVideoHeader* header);
113 :
114 : int64_t _renderTimeMs;
115 : uint8_t _payloadType;
116 : bool _missingFrame;
117 : CodecSpecificInfo _codecSpecificInfo;
118 : webrtc::VideoCodecType _codec;
119 :
120 : // Video rotation is only set along with the last packet for each frame
121 : // (same as marker bit). This |_rotation_set| is only for debugging purpose
122 : // to ensure we don't set it twice for a frame.
123 : bool _rotation_set;
124 : };
125 :
126 : } // namespace webrtc
127 :
128 : #endif // WEBRTC_MODULES_VIDEO_CODING_ENCODED_FRAME_H_
|