Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1067)

Unified Diff: webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h

Issue 1306813009: H.264 video codec support using OpenH264/FFmpeg (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Misc (WebRtcVideoChannel2::...::ConfigureVideoEncoderSettings care about H264 case) Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h
diff --git a/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h b/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..1010adf1011e5ecee3ade346f5762807a7ddd412
--- /dev/null
+++ b/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ *
+ */
+
+#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_ENCODER_IMPL_H_
+#define WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_ENCODER_IMPL_H_
+
+#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
+
+#include <vector>
+
+class ISVCEncoder;
+
+namespace webrtc {
+
+class H264EncoderImpl : public H264Encoder {
+ public:
+ // Copies |encoded_image._buffer| data with NAL headers excluded to
+ // |enc_buffer_with_nal|, inserting missing NAL headers between each fragment
+ // based on |frag_header|. RTPFragmentize in .cc documents why you might want
+ // to do this. |enc_buffer_with_nal_length| must be at least
+ // RTPDefragmentizeBufferLengthWithNAL(encoded_image, frag_header).
+ static void RTPDefragmentize(
stefan-webrtc 2015/09/28 11:19:02 RtpDefragmentize
hbos 2015/09/30 15:35:19 (Removed, no longer needed due to including start
+ const EncodedImage& encoded_image,
+ const RTPFragmentationHeader* frag_header,
+ uint8_t* enc_buffer_with_nal, size_t enc_buffer_with_nal_length);
+ static size_t RTPDefragmentizeBufferLengthWithNAL(
+ const EncodedImage& encoded_image,
+ const webrtc::RTPFragmentationHeader* frag_header);
+
+ H264EncoderImpl();
+ ~H264EncoderImpl() override;
+
+ // |number_of_cores| and |max_payload_size| are ignored.
+ // The following members of |codec_settings| are used. The rest are ignored.
+ // - codecType (must be kVideoCodecH264)
+ // - targetBitrate
+ // - maxFramerate
+ // - width
+ // - height
+ int32_t InitEncode(const VideoCodec* codec_settings,
+ int32_t /*number_of_cores*/,
+ size_t /*max_payload_size*/) override;
+ int32_t Release() override;
+
+ int32_t RegisterEncodeCompleteCallback(
+ EncodedImageCallback* callback) override;
+ int32_t SetRates(uint32_t bitrate, uint32_t framerate) override;
+
+ // The result of encoding - an EncodedImage and RTPFragmentationHeader - are
+ // passed to the encode complete callback. The encoded image data has had its
+ // NAL headers removed. In order to be able to decode this data with an
+ // H264Decoder, the NAL headers need to be re-inserted, see RTPFragmentize in
+ // .cc and RTPDefragmentize for more information.
+ int32_t Encode(const VideoFrame& frame,
+ const CodecSpecificInfo* codec_specific_info,
+ const std::vector<VideoFrameType>* frame_types) override;
+
+ bool IsInitialized();
+
+ // Unsupported / Do nothing.
+ int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
+ int32_t SetPeriodicKeyFrames(bool enable) override;
+ int32_t CodecConfigParameters(uint8_t* buffer, int32_t size) override;
+ void OnDroppedFrame() override;
+
+ private:
+ ISVCEncoder* openh264_encoder_;
+ VideoCodec codec_settings_;
+
+ EncodedImage encoded_image_;
+ EncodedImageCallback* encoded_image_callback_;
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_ENCODER_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698