This CL introduces two new functions to the WebRtcVideoEncoderFactory interface based on cricket::VideoFormat instead of WebRtcVideoEncoderFactory::VideoCodec. The functions are: WebRtcVideoEncoderFactory::CreateVideoEncoder() and WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth transition to the new interface, the old functions are kept, and default implementations are provided for both the old and new functions so that external clients can switch from the old to the new functions in peace. The default implementations will just convert between cricket::VideoFormat and WebRtcVideoEncoderFactory::VideoCodec. Once all external clients have updated their code, the plan is to remove the old functions and all default implementations to make WebRtcVideoEncoderFactory a pure interface again. BUG=webrtc:6402,webrtc:6337 Review-Url: https://codereview.webrtc.org/2449993003 Cr-Commit-Position: refs/heads/master@{#14826}
61 lines
1.9 KiB
C++
61 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2016 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/media/engine/webrtcvideoencoderfactory.h"
|
|
|
|
#include "webrtc/media/base/mediaconstants.h"
|
|
|
|
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 cricket {
|
|
|
|
webrtc::VideoEncoder* WebRtcVideoEncoderFactory::CreateVideoEncoder(
|
|
const cricket::VideoCodec& codec) {
|
|
return CreateVideoEncoder(CodecTypeFromName(codec.name));
|
|
}
|
|
|
|
const std::vector<cricket::VideoCodec>&
|
|
WebRtcVideoEncoderFactory::supported_codecs() const {
|
|
const std::vector<VideoCodec>& encoder_codecs = codecs();
|
|
for (const VideoCodec& encoder_codec : encoder_codecs) {
|
|
codecs_.push_back(cricket::VideoCodec(encoder_codec.name));
|
|
}
|
|
return codecs_;
|
|
}
|
|
|
|
webrtc::VideoEncoder* WebRtcVideoEncoderFactory::CreateVideoEncoder(
|
|
webrtc::VideoCodecType type) {
|
|
const cricket::VideoCodec codec(NameFromCodecType(type));
|
|
return CreateVideoEncoder(codec);
|
|
}
|
|
|
|
const std::vector<WebRtcVideoEncoderFactory::VideoCodec>&
|
|
WebRtcVideoEncoderFactory::codecs() const {
|
|
const std::vector<cricket::VideoCodec>& codecs = supported_codecs();
|
|
for (const cricket::VideoCodec& codec : codecs) {
|
|
encoder_codecs_.push_back(
|
|
VideoCodec(CodecTypeFromName(codec.name), codec.name));
|
|
}
|
|
return encoder_codecs_;
|
|
}
|
|
|
|
} // namespace cricket
|