OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_VIDEO_CODING_ENCODED_FRAME_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_ENCODED_FRAME_H_ |
12 #define WEBRTC_MODULES_VIDEO_CODING_ENCODED_FRAME_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_ENCODED_FRAME_H_ |
13 | 13 |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "webrtc/common_types.h" | 16 #include "webrtc/common_types.h" |
17 #include "webrtc/common_video/include/video_image.h" | 17 #include "webrtc/common_video/include/video_image.h" |
18 #include "webrtc/modules/include/module_common_types.h" | 18 #include "webrtc/modules/include/module_common_types.h" |
19 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 19 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
20 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 20 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
21 | 21 |
22 namespace webrtc | 22 namespace webrtc { |
23 { | |
24 | 23 |
25 class VCMEncodedFrame : protected EncodedImage | 24 class VCMEncodedFrame : protected EncodedImage { |
26 { | 25 public: |
27 public: | 26 VCMEncodedFrame(); |
28 VCMEncodedFrame(); | 27 explicit VCMEncodedFrame(const webrtc::EncodedImage& rhs); |
29 VCMEncodedFrame(const webrtc::EncodedImage& rhs); | 28 VCMEncodedFrame(const VCMEncodedFrame& rhs); |
30 VCMEncodedFrame(const VCMEncodedFrame& rhs); | |
31 | 29 |
32 ~VCMEncodedFrame(); | 30 ~VCMEncodedFrame(); |
33 /** | 31 /** |
34 * Delete VideoFrame and resets members to zero | 32 * Delete VideoFrame and resets members to zero |
35 */ | 33 */ |
36 void Free(); | 34 void Free(); |
37 /** | 35 /** |
38 * Set render time in milliseconds | 36 * Set render time in milliseconds |
39 */ | 37 */ |
40 void SetRenderTime(const int64_t renderTimeMs) {_renderTimeMs = renderTimeMs
;} | 38 void SetRenderTime(const int64_t renderTimeMs) { |
| 39 _renderTimeMs = renderTimeMs; |
| 40 } |
41 | 41 |
42 /** | 42 /** |
43 * Set the encoded frame size | 43 * Set the encoded frame size |
44 */ | 44 */ |
45 void SetEncodedSize(uint32_t width, uint32_t height) | 45 void SetEncodedSize(uint32_t width, uint32_t height) { |
46 { _encodedWidth = width; _encodedHeight = height; } | 46 _encodedWidth = width; |
47 /** | 47 _encodedHeight = height; |
48 * Get the encoded image | 48 } |
49 */ | 49 /** |
50 const webrtc::EncodedImage& EncodedImage() const | 50 * Get the encoded image |
51 { return static_cast<const webrtc::EncodedImage&>(*this);
} | 51 */ |
52 /** | 52 const webrtc::EncodedImage& EncodedImage() const { |
53 * Get pointer to frame buffer | 53 return static_cast<const webrtc::EncodedImage&>(*this); |
54 */ | 54 } |
55 const uint8_t* Buffer() const {return _buffer;} | 55 /** |
56 /** | 56 * Get pointer to frame buffer |
57 * Get frame length | 57 */ |
58 */ | 58 const uint8_t* Buffer() const { return _buffer; } |
59 size_t Length() const {return _length;} | 59 /** |
60 /** | 60 * Get frame length |
61 * Get frame timestamp (90kHz) | 61 */ |
62 */ | 62 size_t Length() const { return _length; } |
63 uint32_t TimeStamp() const {return _timeStamp;} | 63 /** |
64 /** | 64 * Get frame timestamp (90kHz) |
65 * Get render time in milliseconds | 65 */ |
66 */ | 66 uint32_t TimeStamp() const { return _timeStamp; } |
67 int64_t RenderTimeMs() const {return _renderTimeMs;} | 67 /** |
68 /** | 68 * Get render time in milliseconds |
69 * Get frame type | 69 */ |
70 */ | 70 int64_t RenderTimeMs() const { return _renderTimeMs; } |
71 webrtc::FrameType FrameType() const { return _frameType; } | 71 /** |
72 /** | 72 * Get frame type |
73 * Get frame rotation | 73 */ |
74 */ | 74 webrtc::FrameType FrameType() const { return _frameType; } |
75 VideoRotation rotation() const { return _rotation; } | 75 /** |
76 /** | 76 * Get frame rotation |
77 * True if this frame is complete, false otherwise | 77 */ |
78 */ | 78 VideoRotation rotation() const { return _rotation; } |
79 bool Complete() const { return _completeFrame; } | 79 /** |
80 /** | 80 * True if this frame is complete, false otherwise |
81 * True if there's a frame missing before this frame | 81 */ |
82 */ | 82 bool Complete() const { return _completeFrame; } |
83 bool MissingFrame() const { return _missingFrame; } | 83 /** |
84 /** | 84 * True if there's a frame missing before this frame |
85 * Payload type of the encoded payload | 85 */ |
86 */ | 86 bool MissingFrame() const { return _missingFrame; } |
87 uint8_t PayloadType() const { return _payloadType; } | 87 /** |
88 /** | 88 * Payload type of the encoded payload |
89 * Get codec specific info. | 89 */ |
90 * The returned pointer is only valid as long as the VCMEncodedFrame | 90 uint8_t PayloadType() const { return _payloadType; } |
91 * is valid. Also, VCMEncodedFrame owns the pointer and will delete | 91 /** |
92 * the object. | 92 * Get codec specific info. |
93 */ | 93 * The returned pointer is only valid as long as the VCMEncodedFrame |
94 const CodecSpecificInfo* CodecSpecific() const {return &_codecSpecificInfo;} | 94 * is valid. Also, VCMEncodedFrame owns the pointer and will delete |
| 95 * the object. |
| 96 */ |
| 97 const CodecSpecificInfo* CodecSpecific() const { return &_codecSpecificInfo; } |
95 | 98 |
96 const RTPFragmentationHeader* FragmentationHeader() const; | 99 const RTPFragmentationHeader* FragmentationHeader() const; |
97 | 100 |
98 protected: | 101 protected: |
99 /** | 102 /** |
100 * Verifies that current allocated buffer size is larger than or equal to the
input size. | 103 * Verifies that current allocated buffer size is larger than or equal to the |
101 * If the current buffer size is smaller, a new allocation is made and the ol
d buffer data | 104 * input size. |
102 * is copied to the new buffer. | 105 * If the current buffer size is smaller, a new allocation is made and the old |
103 * Buffer size is updated to minimumSize. | 106 * buffer data |
104 */ | 107 * is copied to the new buffer. |
105 void VerifyAndAllocate(size_t minimumSize); | 108 * Buffer size is updated to minimumSize. |
| 109 */ |
| 110 void VerifyAndAllocate(size_t minimumSize); |
106 | 111 |
107 void Reset(); | 112 void Reset(); |
108 | 113 |
109 void CopyCodecSpecific(const RTPVideoHeader* header); | 114 void CopyCodecSpecific(const RTPVideoHeader* header); |
110 | 115 |
111 int64_t _renderTimeMs; | 116 int64_t _renderTimeMs; |
112 uint8_t _payloadType; | 117 uint8_t _payloadType; |
113 bool _missingFrame; | 118 bool _missingFrame; |
114 CodecSpecificInfo _codecSpecificInfo; | 119 CodecSpecificInfo _codecSpecificInfo; |
115 webrtc::VideoCodecType _codec; | 120 webrtc::VideoCodecType _codec; |
116 RTPFragmentationHeader _fragmentation; | 121 RTPFragmentationHeader _fragmentation; |
117 VideoRotation _rotation; | 122 VideoRotation _rotation; |
118 | 123 |
119 // Video rotation is only set along with the last packet for each frame | 124 // 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 | 125 // (same as marker bit). This |_rotation_set| is only for debugging purpose |
121 // to ensure we don't set it twice for a frame. | 126 // to ensure we don't set it twice for a frame. |
122 bool _rotation_set; | 127 bool _rotation_set; |
123 }; | 128 }; |
124 | 129 |
125 } // namespace webrtc | 130 } // namespace webrtc |
126 | 131 |
127 #endif // WEBRTC_MODULES_VIDEO_CODING_ENCODED_FRAME_H_ | 132 #endif // WEBRTC_MODULES_VIDEO_CODING_ENCODED_FRAME_H_ |
OLD | NEW |