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

Unified Diff: modules/video_coding/codecs/stereo/include/stereo_encoder_adapter.h

Issue 2951033003: [EXPERIMENTAL] Generic stereo codec with index header sending single frames
Patch Set: Rebase and add external codec support. Created 3 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: modules/video_coding/codecs/stereo/include/stereo_encoder_adapter.h
diff --git a/modules/video_coding/codecs/stereo/include/stereo_encoder_adapter.h b/modules/video_coding/codecs/stereo/include/stereo_encoder_adapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..741f7c3c9ba6a7b491b8b357117f78f695a88f5c
--- /dev/null
+++ b/modules/video_coding/codecs/stereo/include/stereo_encoder_adapter.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2017 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_ALPHA_INCLUDE_ALPHA_ENCODER_ADAPTER_H_
+#define WEBRTC_MODULES_VIDEO_CODING_CODECS_ALPHA_INCLUDE_ALPHA_ENCODER_ADAPTER_H_
+
+#include <map>
+#include <memory>
+#include <vector>
+
+#include "api/video_codecs/video_encoder.h"
+#include "media/engine/scopedvideoencoder.h"
+#include "media/engine/webrtcvideoencoderfactory.h"
+#include "modules/video_coding/include/video_codec_interface.h"
+
+namespace webrtc {
+
+enum StereoCodecStream {
+ kYUVStream = 0,
+ kAXXStream = 1,
+ kStereoCodecStreams = 2,
+};
+
+class StereoEncoderAdapter : public VideoEncoder {
+ public:
+ explicit StereoEncoderAdapter(cricket::WebRtcVideoEncoderFactory* factory);
+ virtual ~StereoEncoderAdapter();
+
+ // Implements VideoEncoder
+ int InitEncode(const VideoCodec* inst,
+ int number_of_cores,
+ size_t max_payload_size) override;
+ int Encode(const VideoFrame& input_image,
+ const CodecSpecificInfo* codec_specific_info,
+ const std::vector<FrameType>* frame_types) override;
+ int RegisterEncodeCompleteCallback(EncodedImageCallback* callback) override;
+ int SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
+ int SetRateAllocation(const BitrateAllocation& bitrate,
+ uint32_t new_framerate) override;
+ int Release() override;
+ const char* ImplementationName() const override {
+ return "StereoEncoderAdapter";
+ }
+
+ EncodedImageCallback::Result OnEncodedImage(
+ StereoCodecStream stream_idx,
+ const EncodedImage& encodedImage,
+ const CodecSpecificInfo* codecSpecificInfo,
+ const RTPFragmentationHeader* fragmentation);
+
+ private:
+ // Wrapper class that redirects OnEncodedImage() calls.
+ class AdapterEncodedImageCallback;
+
+ // Holds the encoded image output of a frame.
+ struct EncodedImageData;
+
+ cricket::WebRtcVideoEncoderFactory* const factory_;
+ std::vector<std::unique_ptr<VideoEncoder>> encoders_;
+ std::vector<std::unique_ptr<AdapterEncodedImageCallback>> adapter_callbacks_;
+ EncodedImageCallback* encoded_complete_callback_;
+
+ // Map timestamp.
+ std::map<uint32_t /* timestamp */, int /*count*/> frame_count_;
+
+ uint64_t picture_index_ = 0;
+ std::vector<uint8_t> merged_image_buffer_;
+ std::vector<uint8_t> stereo_dummy_planes_;
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_ALPHA_INCLUDE_ALPHA_ENCODER_ADAPTER_H_

Powered by Google App Engine
This is Rietveld 408576698