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

Unified Diff: webrtc/sdk/objc/Framework/Classes/videotoolboxvideocodecfactory.cc

Issue 2463313002: Add a webrtc{en,de}coderfactory implementation for VideoToolbox (Closed)
Patch Set: Code review comments Created 4 years, 1 month 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
« no previous file with comments | « webrtc/sdk/objc/Framework/Classes/videotoolboxvideocodecfactory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/sdk/objc/Framework/Classes/videotoolboxvideocodecfactory.cc
diff --git a/webrtc/sdk/objc/Framework/Classes/videotoolboxvideocodecfactory.cc b/webrtc/sdk/objc/Framework/Classes/videotoolboxvideocodecfactory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b7a5141dfd29a9432f9ee8f89a5cd3636f4ec256
--- /dev/null
+++ b/webrtc/sdk/objc/Framework/Classes/videotoolboxvideocodecfactory.cc
@@ -0,0 +1,103 @@
+/*
+ * Copyright 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.
+ */
+#include "webrtc/sdk/objc/Framework/Classes/videotoolboxvideocodecfactory.h"
+
+#include "webrtc/base/logging.h"
+#include "webrtc/media/base/codec.h"
+#if defined(WEBRTC_IOS)
+#include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h"
+#include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.h"
+#endif
+
+// TODO(kthelgason): delete this when CreateVideoDecoder takes
+// a cricket::VideoCodec instead of webrtc::VideoCodecType.
+static const char* NameFromCodecType(webrtc::VideoCodecType type) {
+ switch (type) {
+ case webrtc::kVideoCodecVP8:
+ return cricket::kVp8CodecName;
+ case webrtc::kVideoCodecVP9:
+ return cricket::kVp9CodecName;
+ case webrtc::kVideoCodecH264:
+ return cricket::kH264CodecName;
+ default:
+ return "Unknown codec";
+ }
+}
+
+namespace webrtc {
+
+// VideoToolboxVideoEncoderFactory
+
+VideoToolboxVideoEncoderFactory::VideoToolboxVideoEncoderFactory() {
+// Hardware H264 encoding only supported on iOS for now.
+#if defined(WEBRTC_IOS)
+ supported_codecs_.push_back(cricket::VideoCodec(cricket::kH264CodecName));
+#endif
+}
+
+VideoToolboxVideoEncoderFactory::~VideoToolboxVideoEncoderFactory() {}
+
+VideoEncoder* VideoToolboxVideoEncoderFactory::CreateVideoEncoder(
+ const cricket::VideoCodec& codec) {
+#if defined(WEBRTC_IOS)
+ if (IsCodecSupported(supported_codecs_, codec)) {
+ LOG(LS_INFO) << "Creating HW encoder for " << codec.name;
+ return new H264VideoToolboxEncoder();
+ }
+#endif
+ LOG(LS_INFO) << "No HW encoder found for codec " << codec.name;
+ return nullptr;
+}
+
+void VideoToolboxVideoEncoderFactory::DestroyVideoEncoder(
+ VideoEncoder* encoder) {
+#if defined(WEBRTC_IOS)
+ delete encoder;
+ encoder = nullptr;
+#endif
+}
+
+const std::vector<cricket::VideoCodec>&
+VideoToolboxVideoEncoderFactory::supported_codecs() const {
+ return supported_codecs_;
+}
+
+// VideoToolboxVideoDecoderFactory
+
+VideoToolboxVideoDecoderFactory::VideoToolboxVideoDecoderFactory() {
+#if defined(WEBRTC_IOS)
+ supported_codecs_.push_back(cricket::VideoCodec("H264"));
+#endif
+}
+
+VideoToolboxVideoDecoderFactory::~VideoToolboxVideoDecoderFactory() {}
+
+VideoDecoder* VideoToolboxVideoDecoderFactory::CreateVideoDecoder(
+ VideoCodecType type) {
+ const auto codec = cricket::VideoCodec(NameFromCodecType(type));
+#if defined(WEBRTC_IOS)
+ if (IsCodecSupported(supported_codecs_, codec)) {
+ LOG(LS_INFO) << "Creating HW decoder for " << codec.name;
+ return new H264VideoToolboxDecoder();
+ }
+#endif
+ LOG(LS_INFO) << "No HW decoder found for codec " << codec.name;
+ return nullptr;
+}
+
+void VideoToolboxVideoDecoderFactory::DestroyVideoDecoder(
+ VideoDecoder* decoder) {
+#if defined(WEBRTC_IOS)
+ delete decoder;
+ decoder = nullptr;
+#endif
+}
+
+} // namespace webrtc
« no previous file with comments | « webrtc/sdk/objc/Framework/Classes/videotoolboxvideocodecfactory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698