OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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_CODECS_I420_MAIN_INTERFACE_I420_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_I420_INCLUDE_I420_H_ |
12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_I420_MAIN_INTERFACE_I420_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_I420_INCLUDE_I420_H_ |
13 | 13 |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 16 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
17 #include "webrtc/typedefs.h" | 17 #include "webrtc/typedefs.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 | 20 |
21 class I420Encoder : public VideoEncoder { | 21 class I420Encoder : public VideoEncoder { |
22 public: | 22 public: |
23 I420Encoder(); | 23 I420Encoder(); |
24 | 24 |
25 virtual ~I420Encoder(); | 25 virtual ~I420Encoder(); |
26 | 26 |
27 // Initialize the encoder with the information from the VideoCodec. | 27 // Initialize the encoder with the information from the VideoCodec. |
28 // | 28 // |
29 // Input: | 29 // Input: |
30 // - codecSettings : Codec settings. | 30 // - codecSettings : Codec settings. |
31 // - numberOfCores : Number of cores available for the encoder. | 31 // - numberOfCores : Number of cores available for the encoder. |
32 // - maxPayloadSize : The maximum size each payload is allowed | 32 // - maxPayloadSize : The maximum size each payload is allowed |
33 // to have. Usually MTU - overhead. | 33 // to have. Usually MTU - overhead. |
34 // | 34 // |
35 // Return value : WEBRTC_VIDEO_CODEC_OK if OK. | 35 // Return value : WEBRTC_VIDEO_CODEC_OK if OK. |
36 // <0 - Error | 36 // <0 - Error |
37 int InitEncode(const VideoCodec* codecSettings, | 37 int InitEncode(const VideoCodec* codecSettings, |
38 int /*numberOfCores*/, | 38 int /*numberOfCores*/, |
39 size_t /*maxPayloadSize*/) override; | 39 size_t /*maxPayloadSize*/) override; |
40 | 40 |
41 // "Encode" an I420 image (as a part of a video stream). The encoded image | 41 // "Encode" an I420 image (as a part of a video stream). The encoded image |
42 // will be returned to the user via the encode complete callback. | 42 // will be returned to the user via the encode complete callback. |
43 // | 43 // |
44 // Input: | 44 // Input: |
45 // - inputImage : Image to be encoded. | 45 // - inputImage : Image to be encoded. |
46 // - codecSpecificInfo : Pointer to codec specific data. | 46 // - codecSpecificInfo : Pointer to codec specific data. |
47 // - frameType : Frame type to be sent (Key /Delta). | 47 // - frameType : Frame type to be sent (Key /Delta). |
48 // | 48 // |
49 // Return value : WEBRTC_VIDEO_CODEC_OK if OK. | 49 // Return value : WEBRTC_VIDEO_CODEC_OK if OK. |
50 // <0 - Error | 50 // <0 - Error |
51 int Encode(const VideoFrame& inputImage, | 51 int Encode(const VideoFrame& inputImage, |
52 const CodecSpecificInfo* /*codecSpecificInfo*/, | 52 const CodecSpecificInfo* /*codecSpecificInfo*/, |
53 const std::vector<FrameType>* /*frame_types*/) override; | 53 const std::vector<FrameType>* /*frame_types*/) override; |
54 | 54 |
55 // Register an encode complete callback object. | 55 // Register an encode complete callback object. |
56 // | 56 // |
57 // Input: | 57 // Input: |
58 // - callback : Callback object which handles encoded images. | 58 // - callback : Callback object which handles encoded images. |
59 // | 59 // |
60 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. | 60 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. |
61 int RegisterEncodeCompleteCallback(EncodedImageCallback* callback) override; | 61 int RegisterEncodeCompleteCallback(EncodedImageCallback* callback) override; |
62 | 62 |
63 // Free encoder memory. | 63 // Free encoder memory. |
64 // | 64 // |
65 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. | 65 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. |
66 int Release() override; | 66 int Release() override; |
67 | 67 |
68 int SetRates(uint32_t /*newBitRate*/, uint32_t /*frameRate*/) override { | 68 int SetRates(uint32_t /*newBitRate*/, uint32_t /*frameRate*/) override { |
69 return WEBRTC_VIDEO_CODEC_OK; | 69 return WEBRTC_VIDEO_CODEC_OK; |
70 } | 70 } |
71 | 71 |
72 int SetChannelParameters(uint32_t /*packetLoss*/, int64_t /*rtt*/) override { | 72 int SetChannelParameters(uint32_t /*packetLoss*/, int64_t /*rtt*/) override { |
73 return WEBRTC_VIDEO_CODEC_OK; | 73 return WEBRTC_VIDEO_CODEC_OK; |
74 } | 74 } |
75 | 75 |
76 void OnDroppedFrame() override {} | 76 void OnDroppedFrame() override {} |
77 | 77 |
78 private: | 78 private: |
79 static uint8_t* InsertHeader(uint8_t* buffer, uint16_t width, | 79 static uint8_t* InsertHeader(uint8_t* buffer, |
| 80 uint16_t width, |
80 uint16_t height); | 81 uint16_t height); |
81 | 82 |
82 bool _inited; | 83 bool _inited; |
83 EncodedImage _encodedImage; | 84 EncodedImage _encodedImage; |
84 EncodedImageCallback* _encodedCompleteCallback; | 85 EncodedImageCallback* _encodedCompleteCallback; |
85 }; // class I420Encoder | 86 }; // class I420Encoder |
86 | 87 |
87 class I420Decoder : public VideoDecoder { | 88 class I420Decoder : public VideoDecoder { |
88 public: | 89 public: |
89 I420Decoder(); | 90 I420Decoder(); |
90 | 91 |
91 virtual ~I420Decoder(); | 92 virtual ~I420Decoder(); |
92 | 93 |
93 // Initialize the decoder. | 94 // Initialize the decoder. |
94 // The user must notify the codec of width and height values. | 95 // The user must notify the codec of width and height values. |
95 // | 96 // |
96 // Return value : WEBRTC_VIDEO_CODEC_OK. | 97 // Return value : WEBRTC_VIDEO_CODEC_OK. |
97 // <0 - Errors | 98 // <0 - Errors |
98 int InitDecode(const VideoCodec* codecSettings, | 99 int InitDecode(const VideoCodec* codecSettings, |
99 int /*numberOfCores*/) override; | 100 int /*numberOfCores*/) override; |
100 | 101 |
101 // Decode encoded image (as a part of a video stream). The decoded image | 102 // Decode encoded image (as a part of a video stream). The decoded image |
102 // will be returned to the user through the decode complete callback. | 103 // will be returned to the user through the decode complete callback. |
103 // | 104 // |
104 // Input: | 105 // Input: |
105 // - inputImage : Encoded image to be decoded | 106 // - inputImage : Encoded image to be decoded |
106 // - missingFrames : True if one or more frames have been lost | 107 // - missingFrames : True if one or more frames have been lost |
107 // since the previous decode call. | 108 // since the previous decode call. |
108 // - codecSpecificInfo : pointer to specific codec data | 109 // - codecSpecificInfo : pointer to specific codec data |
109 // - renderTimeMs : Render time in Ms | 110 // - renderTimeMs : Render time in Ms |
110 // | 111 // |
111 // Return value : WEBRTC_VIDEO_CODEC_OK if OK | 112 // Return value : WEBRTC_VIDEO_CODEC_OK if OK |
112 // <0 - Error | 113 // <0 - Error |
113 int Decode(const EncodedImage& inputImage, | 114 int Decode(const EncodedImage& inputImage, |
114 bool missingFrames, | 115 bool missingFrames, |
115 const RTPFragmentationHeader* /*fragmentation*/, | 116 const RTPFragmentationHeader* /*fragmentation*/, |
116 const CodecSpecificInfo* /*codecSpecificInfo*/, | 117 const CodecSpecificInfo* /*codecSpecificInfo*/, |
117 int64_t /*renderTimeMs*/) override; | 118 int64_t /*renderTimeMs*/) override; |
118 | 119 |
119 // Register a decode complete callback object. | 120 // Register a decode complete callback object. |
120 // | 121 // |
121 // Input: | 122 // Input: |
122 // - callback : Callback object which handles decoded images. | 123 // - callback : Callback object which handles decoded images. |
123 // | 124 // |
124 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. | 125 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. |
125 int RegisterDecodeCompleteCallback(DecodedImageCallback* callback) override; | 126 int RegisterDecodeCompleteCallback(DecodedImageCallback* callback) override; |
126 | 127 |
127 // Free decoder memory. | 128 // Free decoder memory. |
128 // | 129 // |
129 // Return value : WEBRTC_VIDEO_CODEC_OK if OK. | 130 // Return value : WEBRTC_VIDEO_CODEC_OK if OK. |
130 // <0 - Error | 131 // <0 - Error |
131 int Release() override; | 132 int Release() override; |
132 | 133 |
133 // Reset decoder state and prepare for a new call. | 134 // Reset decoder state and prepare for a new call. |
134 // | 135 // |
135 // Return value : WEBRTC_VIDEO_CODEC_OK. | 136 // Return value : WEBRTC_VIDEO_CODEC_OK. |
136 // <0 - Error | 137 // <0 - Error |
137 int Reset() override; | 138 int Reset() override; |
138 | 139 |
139 private: | 140 private: |
140 static const uint8_t* ExtractHeader(const uint8_t* buffer, | 141 static const uint8_t* ExtractHeader(const uint8_t* buffer, |
141 uint16_t* width, | 142 uint16_t* width, |
142 uint16_t* height); | 143 uint16_t* height); |
143 | 144 |
144 VideoFrame _decodedImage; | 145 VideoFrame _decodedImage; |
145 int _width; | 146 int _width; |
146 int _height; | 147 int _height; |
147 bool _inited; | 148 bool _inited; |
148 DecodedImageCallback* _decodeCompleteCallback; | 149 DecodedImageCallback* _decodeCompleteCallback; |
149 }; // class I420Decoder | 150 }; // class I420Decoder |
150 | 151 |
151 } // namespace webrtc | 152 } // namespace webrtc |
152 | 153 |
153 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_I420_MAIN_INTERFACE_I420_H_ | 154 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_I420_INCLUDE_I420_H_ |
OLD | NEW |