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
|