OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2015 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 |
| 12 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_ENCODER_IMPL_H_ |
| 13 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_ENCODER_IMPL_H_ |
| 14 |
| 15 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" |
| 16 |
| 17 #include <vector> |
| 18 |
| 19 class ISVCEncoder; |
| 20 |
| 21 namespace webrtc { |
| 22 |
| 23 class H264EncoderImpl : public H264Encoder { |
| 24 public: |
| 25 // Copies |encoded_image._buffer| data with NAL headers excluded to |
| 26 // |enc_buffer_with_nal|, inserting missing NAL headers between each fragment |
| 27 // based on |frag_header|. RTPFragmentize in .cc documents why you might want |
| 28 // to do this. |enc_buffer_with_nal_length| must be at least |
| 29 // RTPDefragmentizeBufferLengthWithNAL(encoded_image, frag_header). |
| 30 static void RTPDefragmentize( |
| 31 const EncodedImage& encoded_image, |
| 32 const RTPFragmentationHeader* frag_header, |
| 33 uint8_t* enc_buffer_with_nal, size_t enc_buffer_with_nal_length); |
| 34 static size_t RTPDefragmentizeBufferLengthWithNAL( |
| 35 const EncodedImage& encoded_image, |
| 36 const webrtc::RTPFragmentationHeader* frag_header); |
| 37 |
| 38 H264EncoderImpl(); |
| 39 ~H264EncoderImpl() override; |
| 40 |
| 41 // |number_of_cores| and |max_payload_size| are ignored. |
| 42 // The following members of |codec_settings| are used. The rest are ignored. |
| 43 // - codecType (must be kVideoCodecH264) |
| 44 // - targetBitrate |
| 45 // - maxFramerate |
| 46 // - width |
| 47 // - height |
| 48 int32_t InitEncode(const VideoCodec* codec_settings, |
| 49 int32_t /*number_of_cores*/, |
| 50 size_t /*max_payload_size*/) override; |
| 51 int32_t Release() override; |
| 52 |
| 53 int32_t RegisterEncodeCompleteCallback( |
| 54 EncodedImageCallback* callback) override; |
| 55 int32_t SetRates(uint32_t bitrate, uint32_t framerate) override; |
| 56 |
| 57 // The result of encoding, an EncodedImage and RTPFragmentationHeader, are |
| 58 // passed to the encode complete callback. The encoded image data has had its |
| 59 // NAL headers removed. In order to be able to decode this data with an |
| 60 // H264Decoder, the NAL headers need to be re-inserted, see RTPFragmentize in |
| 61 // .cc and RTPDefragmentize for more information. |
| 62 int32_t Encode(const VideoFrame& frame, |
| 63 const CodecSpecificInfo* codec_specific_info, |
| 64 const std::vector<VideoFrameType>* frame_types) override; |
| 65 |
| 66 bool IsInitialized(); |
| 67 |
| 68 // Unsupported / Do nothing. |
| 69 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override; |
| 70 int32_t SetPeriodicKeyFrames(bool enable) override; |
| 71 int32_t CodecConfigParameters(uint8_t* buffer, int32_t size) override; |
| 72 void OnDroppedFrame() override; |
| 73 |
| 74 private: |
| 75 ISVCEncoder* openh264_encoder_; |
| 76 VideoCodec codec_settings_; |
| 77 |
| 78 EncodedImage encoded_image_; |
| 79 EncodedImageCallback* encoded_image_callback_; |
| 80 }; |
| 81 |
| 82 } // namespace webrtc |
| 83 |
| 84 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_ENCODER_IMPL_H_ |
OLD | NEW |