Chromium Code Reviews| 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 // TODO(hbos): This is essentially a copy of an encoder class in WebRTC that as | |
| 13 // of this statement has not yet landed, but that I want to have accessible in | |
| 14 // Chromium before that CL lands. This is because I use it in order to validate | |
| 15 // the build files for OpenH264 and the WebRTC encoder/decoder CL cannot land | |
| 16 // until I can build OpenH264 from source. Once the build files are stable I | |
| 17 // will land both CLs and remove this copy of the encoder. | |
| 18 | |
| 19 #ifndef OPENH264_TESTING_H264_ENCODER_IMPL_H_ | |
| 20 #define OPENH264_TESTING_H264_ENCODER_IMPL_H_ | |
| 21 | |
| 22 #include "webrtc/base/scoped_ptr.h" | |
| 23 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" | |
| 24 | |
| 25 #include <vector> | |
| 26 | |
| 27 class ISVCEncoder; | |
| 28 | |
| 29 using webrtc::CodecSpecificInfo; | |
| 30 using webrtc::EncodedImage; | |
| 31 using webrtc::EncodedImageCallback; | |
| 32 using webrtc::FrameType; | |
| 33 using webrtc::VideoCodec; | |
| 34 using webrtc::VideoEncoder; | |
| 35 using webrtc::VideoFrame; | |
| 36 | |
| 37 namespace openh264 { | |
| 38 | |
| 39 class H264EncoderImpl : public webrtc::H264Encoder { | |
| 40 public: | |
| 41 H264EncoderImpl(); | |
| 42 ~H264EncoderImpl() override; | |
| 43 | |
| 44 // |number_of_cores| and |max_payload_size| are ignored. | |
| 45 // The following members of |codec_settings| are used. The rest are ignored. | |
| 46 // - codecType (must be kVideoCodecH264) | |
| 47 // - targetBitrate | |
| 48 // - maxFramerate | |
| 49 // - width | |
| 50 // - height | |
| 51 int32_t InitEncode(const VideoCodec* codec_settings, | |
| 52 int32_t /*number_of_cores*/, | |
| 53 size_t /*max_payload_size*/) override; | |
| 54 int32_t Release() override; | |
| 55 | |
| 56 int32_t RegisterEncodeCompleteCallback( | |
|
torbjorng
2015/11/18 14:41:09
Nit: Unneeded linebreak. :-)
hbos_chromium
2015/11/18 15:55:04
(Actually it is needed. From "int" to ";" it's exa
| |
| 57 EncodedImageCallback* callback) override; | |
| 58 int32_t SetRates(uint32_t bitrate, uint32_t framerate) override; | |
| 59 | |
| 60 // The result of encoding - an EncodedImage and RTPFragmentationHeader - are | |
| 61 // passed to the encode complete callback. | |
| 62 int32_t Encode(const VideoFrame& frame, | |
| 63 const CodecSpecificInfo* codec_specific_info, | |
| 64 const std::vector<FrameType>* 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 void OnDroppedFrame() override; | |
| 72 | |
| 73 private: | |
| 74 ISVCEncoder* openh264_encoder_; | |
| 75 VideoCodec codec_settings_; | |
| 76 | |
| 77 EncodedImage encoded_image_; | |
| 78 rtc::scoped_ptr<uint8_t[]> encoded_image_buffer_; | |
| 79 EncodedImageCallback* encoded_image_callback_; | |
| 80 }; | |
| 81 | |
| 82 } // namespace openh264 | |
| 83 | |
| 84 #endif // OPENH264_TESTING_H264_ENCODER_IMPL_H_ | |
| OLD | NEW |