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

Unified Diff: webrtc/sdk/objc/Framework/Classes/VideoToolbox/videocodecfactory.mm

Issue 2977213002: Reland of Injectable Obj-C video codecs (Closed)
Patch Set: Add checks to make sure destroy is called Created 3 years, 5 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/sdk/objc/Framework/Classes/VideoToolbox/videocodecfactory.mm
diff --git a/webrtc/sdk/objc/Framework/Classes/VideoToolbox/videocodecfactory.mm b/webrtc/sdk/objc/Framework/Classes/VideoToolbox/videocodecfactory.mm
deleted file mode 100644
index 880047aa645d08e2858567332d27a70d66c27229..0000000000000000000000000000000000000000
--- a/webrtc/sdk/objc/Framework/Classes/VideoToolbox/videocodecfactory.mm
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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/VideoToolbox/videocodecfactory.h"
-
-#include "webrtc/common_video/h264/profile_level_id.h"
-#include "webrtc/media/base/codec.h"
-#include "webrtc/rtc_base/logging.h"
-#include "webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.h"
-#include "webrtc/sdk/objc/Framework/Classes/VideoToolbox/encoder.h"
-#include "webrtc/system_wrappers/include/field_trial.h"
-
-namespace webrtc {
-
-namespace {
-const char kHighProfileExperiment[] = "WebRTC-H264HighProfile";
-
-bool IsHighProfileEnabled() {
- return field_trial::IsEnabled(kHighProfileExperiment);
-}
-}
-
-// VideoToolboxVideoEncoderFactory
-
-VideoToolboxVideoEncoderFactory::VideoToolboxVideoEncoderFactory() {}
-
-VideoToolboxVideoEncoderFactory::~VideoToolboxVideoEncoderFactory() {}
-
-VideoEncoder* VideoToolboxVideoEncoderFactory::CreateVideoEncoder(
- const cricket::VideoCodec& codec) {
- if (FindMatchingCodec(supported_codecs_, codec)) {
- LOG(LS_INFO) << "Creating HW encoder for " << codec.name;
- return new H264VideoToolboxEncoder(codec);
- }
- LOG(LS_INFO) << "No HW encoder found for codec " << codec.name;
- return nullptr;
-}
-
-void VideoToolboxVideoEncoderFactory::DestroyVideoEncoder(VideoEncoder* encoder) {
- delete encoder;
- encoder = nullptr;
-}
-
-const std::vector<cricket::VideoCodec>& VideoToolboxVideoEncoderFactory::supported_codecs() const {
- supported_codecs_.clear();
-
- // TODO(magjed): Enumerate actual level instead of using hardcoded level 3.1.
- // Level 3.1 is 1280x720@30fps which is enough for now.
- const H264::Level level = H264::kLevel3_1;
-
- if (IsHighProfileEnabled()) {
- cricket::VideoCodec constrained_high(cricket::kH264CodecName);
- const H264::ProfileLevelId constrained_high_profile(H264::kProfileConstrainedHigh, level);
- constrained_high.SetParam(cricket::kH264FmtpProfileLevelId,
- *H264::ProfileLevelIdToString(constrained_high_profile));
- constrained_high.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1");
- constrained_high.SetParam(cricket::kH264FmtpPacketizationMode, "1");
- supported_codecs_.push_back(constrained_high);
- }
-
- cricket::VideoCodec constrained_baseline(cricket::kH264CodecName);
- const H264::ProfileLevelId constrained_baseline_profile(H264::kProfileConstrainedBaseline, level);
- constrained_baseline.SetParam(cricket::kH264FmtpProfileLevelId,
- *H264::ProfileLevelIdToString(constrained_baseline_profile));
- constrained_baseline.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1");
- constrained_baseline.SetParam(cricket::kH264FmtpPacketizationMode, "1");
- supported_codecs_.push_back(constrained_baseline);
-
- return supported_codecs_;
-}
-
-// VideoToolboxVideoDecoderFactory
-
-VideoToolboxVideoDecoderFactory::VideoToolboxVideoDecoderFactory() {
- supported_codecs_.push_back(cricket::VideoCodec("H264"));
-}
-
-VideoToolboxVideoDecoderFactory::~VideoToolboxVideoDecoderFactory() {}
-
-VideoDecoder* VideoToolboxVideoDecoderFactory::CreateVideoDecoder(VideoCodecType type) {
- const rtc::Optional<const char*> codec_name = CodecTypeToPayloadName(type);
- if (!codec_name) {
- LOG(LS_ERROR) << "Invalid codec type: " << type;
- return nullptr;
- }
- const cricket::VideoCodec codec(*codec_name);
- if (FindMatchingCodec(supported_codecs_, codec)) {
- LOG(LS_INFO) << "Creating HW decoder for " << codec.name;
- return new H264VideoToolboxDecoder();
- }
- LOG(LS_INFO) << "No HW decoder found for codec " << codec.name;
- return nullptr;
-}
-
-void VideoToolboxVideoDecoderFactory::DestroyVideoDecoder(VideoDecoder* decoder) {
- delete decoder;
- decoder = nullptr;
-}
-
-} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698