2016-10-28 07:43:45 -07:00
|
|
|
/*
|
|
|
|
|
* 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"
|
|
|
|
|
|
2016-11-22 10:16:57 -08:00
|
|
|
#include "webrtc/common_types.h"
|
2016-10-28 07:43:45 -07:00
|
|
|
|
|
|
|
|
namespace cricket {
|
|
|
|
|
|
|
|
|
|
webrtc::VideoEncoder* WebRtcVideoEncoderFactory::CreateVideoEncoder(
|
|
|
|
|
const cricket::VideoCodec& codec) {
|
2016-11-22 10:16:57 -08:00
|
|
|
return CreateVideoEncoder(webrtc::PayloadNameToCodecType(codec.name)
|
|
|
|
|
.value_or(webrtc::kVideoCodecUnknown));
|
2016-10-28 07:43:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::vector<cricket::VideoCodec>&
|
|
|
|
|
WebRtcVideoEncoderFactory::supported_codecs() const {
|
2017-01-20 01:07:26 -08:00
|
|
|
codecs_.clear();
|
2016-10-28 07:43:45 -07:00
|
|
|
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) {
|
2016-11-22 10:16:57 -08:00
|
|
|
const cricket::VideoCodec codec(
|
|
|
|
|
webrtc::CodecTypeToPayloadName(type).value_or("Unknown codec"));
|
2016-10-28 07:43:45 -07:00
|
|
|
return CreateVideoEncoder(codec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::vector<WebRtcVideoEncoderFactory::VideoCodec>&
|
|
|
|
|
WebRtcVideoEncoderFactory::codecs() const {
|
2017-01-20 01:07:26 -08:00
|
|
|
encoder_codecs_.clear();
|
2016-10-28 07:43:45 -07:00
|
|
|
const std::vector<cricket::VideoCodec>& codecs = supported_codecs();
|
|
|
|
|
for (const cricket::VideoCodec& codec : codecs) {
|
|
|
|
|
encoder_codecs_.push_back(
|
2016-11-22 10:16:57 -08:00
|
|
|
VideoCodec(webrtc::PayloadNameToCodecType(codec.name)
|
|
|
|
|
.value_or(webrtc::kVideoCodecUnknown),
|
|
|
|
|
codec.name));
|
2016-10-28 07:43:45 -07:00
|
|
|
}
|
|
|
|
|
return encoder_codecs_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace cricket
|