ObjC: Implement HW codecs in ObjC instead of C++

The current ObjC HW encoder is implemented as a C++
webrtc::VideoEncoder. We then wrap it two times in the following way:
webrtc::VideoEncoder -> RTCVideoEncoder -> webrtc::VideoEncoder.
This was originally done to minimize the code diff when landing the
injectable encoder.

This CL removes the first wrapping and implements the ObjC HW encoder
as a RTCVideoEncoder directly. Similarly, the decoder is implemented
as a RTCVideoDecoder directly.

Based on andersc@ CL: https://codereview.webrtc.org/2978623002/.

BUG=webrtc:7924

Review-Url: https://codereview.webrtc.org/2987413002
Cr-Commit-Position: refs/heads/master@{#19255}
This commit is contained in:
magjed
2017-08-07 06:55:28 -07:00
committed by Commit Bot
parent bea36fdee8
commit 73c0eb5014
23 changed files with 1227 additions and 1480 deletions

View File

@ -0,0 +1,26 @@
/*
* Copyright 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_TEST_OBJC_CODEC_H264_TEST_H_
#define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_OBJC_CODEC_H264_TEST_H_
#include <memory>
#include "webrtc/media/engine/webrtcvideodecoderfactory.h"
#include "webrtc/media/engine/webrtcvideoencoderfactory.h"
namespace webrtc {
std::unique_ptr<cricket::WebRtcVideoEncoderFactory> CreateObjCEncoderFactory();
std::unique_ptr<cricket::WebRtcVideoDecoderFactory> CreateObjCDecoderFactory();
} // namespace webrtc
#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_OBJC_CODEC_H264_TEST_H_

View File

@ -0,0 +1,29 @@
/*
* Copyright 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.
*/
#include "webrtc/modules/video_coding/codecs/test/objc_codec_h264_test.h"
#import "WebRTC/RTCVideoCodecH264.h"
#include "webrtc/sdk/objc/Framework/Classes/VideoToolbox/objc_video_decoder_factory.h"
#include "webrtc/sdk/objc/Framework/Classes/VideoToolbox/objc_video_encoder_factory.h"
namespace webrtc {
std::unique_ptr<cricket::WebRtcVideoEncoderFactory> CreateObjCEncoderFactory() {
return std::unique_ptr<cricket::WebRtcVideoEncoderFactory>(
new ObjCVideoEncoderFactory([[RTCVideoEncoderFactoryH264 alloc] init]));
}
std::unique_ptr<cricket::WebRtcVideoDecoderFactory> CreateObjCDecoderFactory() {
return std::unique_ptr<cricket::WebRtcVideoDecoderFactory>(
new ObjCVideoDecoderFactory([[RTCVideoDecoderFactoryH264 alloc] init]));
}
} // namespace webrtc

View File

@ -23,8 +23,7 @@
#include "webrtc/sdk/android/src/jni/androidmediadecoder_jni.h"
#include "webrtc/sdk/android/src/jni/androidmediaencoder_jni.h"
#elif defined(WEBRTC_IOS)
#include "webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.h"
#include "webrtc/sdk/objc/Framework/Classes/VideoToolbox/encoder.h"
#include "webrtc/modules/video_coding/codecs/test/objc_codec_h264_test.h"
#endif
#include "webrtc/media/engine/webrtcvideodecoderfactory.h"
@ -178,9 +177,13 @@ class VideoProcessorIntegrationTest : public testing::Test {
#elif defined(WEBRTC_IOS)
ASSERT_EQ(kVideoCodecH264, config_.codec_settings->codecType)
<< "iOS HW codecs only support H264.";
encoder_.reset(new H264VideoToolboxEncoder(
cricket::VideoCodec(cricket::kH264CodecName)));
decoder_.reset(new H264VideoToolboxDecoder());
std::unique_ptr<cricket::WebRtcVideoEncoderFactory> encoder_factory =
CreateObjCEncoderFactory();
std::unique_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory =
CreateObjCDecoderFactory();
cricket::VideoCodec codecInfo = encoder_factory->supported_codecs().at(0);
encoder_.reset(encoder_factory->CreateVideoEncoder(codecInfo));
decoder_.reset(decoder_factory->CreateVideoDecoder(kVideoCodecH264));
#else
RTC_NOTREACHED() << "Only support HW codecs on Android and iOS.";
#endif