blob: e87e1031b543adca497de20ba24b1ac523f6ea2b [file] [log] [blame]
Florent Castellie7862cc2018-12-06 13:38:24 +01001/*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "media/engine/encoder_simulcast_proxy.h"
12
13#include "media/engine/simulcast_encoder_adapter.h"
14#include "modules/video_coding/include/video_error_codes.h"
15
16namespace webrtc {
17EncoderSimulcastProxy::EncoderSimulcastProxy(VideoEncoderFactory* factory,
18 const SdpVideoFormat& format)
19 : factory_(factory), video_format_(format), callback_(nullptr) {
20 encoder_ = factory_->CreateVideoEncoder(format);
21}
22
23EncoderSimulcastProxy::EncoderSimulcastProxy(VideoEncoderFactory* factory)
24 : EncoderSimulcastProxy(factory, SdpVideoFormat("VP8")) {}
25
26EncoderSimulcastProxy::~EncoderSimulcastProxy() {}
27
28int EncoderSimulcastProxy::Release() {
29 return encoder_->Release();
30}
31
32int EncoderSimulcastProxy::InitEncode(const VideoCodec* inst,
33 int number_of_cores,
34 size_t max_payload_size) {
35 int ret = encoder_->InitEncode(inst, number_of_cores, max_payload_size);
36 if (ret == WEBRTC_VIDEO_CODEC_ERR_SIMULCAST_PARAMETERS_NOT_SUPPORTED) {
37 encoder_.reset(new SimulcastEncoderAdapter(factory_, video_format_));
38 if (callback_) {
39 encoder_->RegisterEncodeCompleteCallback(callback_);
40 }
41 ret = encoder_->InitEncode(inst, number_of_cores, max_payload_size);
42 }
43 return ret;
44}
45
Niels Möller87e2d782019-03-07 10:18:23 +010046int EncoderSimulcastProxy::Encode(
47 const VideoFrame& input_image,
48 const std::vector<VideoFrameType>* frame_types) {
Niels Möllerc8d2e732019-03-06 12:00:33 +010049 return encoder_->Encode(input_image, frame_types);
Florent Castellie7862cc2018-12-06 13:38:24 +010050}
51
52int EncoderSimulcastProxy::RegisterEncodeCompleteCallback(
53 EncodedImageCallback* callback) {
54 callback_ = callback;
55 return encoder_->RegisterEncodeCompleteCallback(callback);
56}
57
58int EncoderSimulcastProxy::SetRateAllocation(
59 const VideoBitrateAllocation& bitrate,
60 uint32_t new_framerate) {
61 return encoder_->SetRateAllocation(bitrate, new_framerate);
62}
63
64VideoEncoder::EncoderInfo EncoderSimulcastProxy::GetEncoderInfo() const {
65 return encoder_->GetEncoderInfo();
66}
67
68} // namespace webrtc