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