webrtc_m130/media/engine/encoder_simulcast_proxy.cc
Elad Alon 370f93a34a Reland "Inform VideoEncoder of negotiated capabilities"
This is a reland of 11dfff0878c949f2e19d95a0ddc209cdad94b3b4

Now that I am sure that WebRTC code is not calling the obsolete
versions, I will just remove the NOT_REACHED and call the
new version from the old ones, so as not to trip up downstream
projects.

Original change's description:
> Inform VideoEncoder of negotiated capabilities
>
> After this CL lands, an announcement will be made to
> discuss-webrtc about the deprecation of one version
> of InitEncode().
>
> Bug: webrtc:10720
> Change-Id: Ib992af0272bbb16ae16ef7e69491f365702d179e
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/140884
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
> Reviewed-by: Erik Språng <sprang@webrtc.org>
> Commit-Queue: Elad Alon <eladalon@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28224}

TBR=sakal@webrtc.org,kwiberg@webrtc.org,sprang@webrtc.org

Bug: webrtc:10720
Change-Id: I46c69e45c190805c07f7e51acbe277d7eebd1600
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/141412
Commit-Queue: Elad Alon <eladalon@webrtc.org>
Reviewed-by: Elad Alon <eladalon@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28236}
2019-06-11 14:49:37 +00:00

82 lines
2.7 KiB
C++

/*
* Copyright (c) 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 "media/engine/encoder_simulcast_proxy.h"
#include "api/video_codecs/video_encoder.h"
#include "media/engine/simulcast_encoder_adapter.h"
#include "modules/video_coding/include/video_error_codes.h"
namespace webrtc {
EncoderSimulcastProxy::EncoderSimulcastProxy(VideoEncoderFactory* factory,
const SdpVideoFormat& format)
: factory_(factory), video_format_(format), callback_(nullptr) {
encoder_ = factory_->CreateVideoEncoder(format);
}
EncoderSimulcastProxy::EncoderSimulcastProxy(VideoEncoderFactory* factory)
: EncoderSimulcastProxy(factory, SdpVideoFormat("VP8")) {}
EncoderSimulcastProxy::~EncoderSimulcastProxy() {}
int EncoderSimulcastProxy::Release() {
return encoder_->Release();
}
// TODO(eladalon): s/inst/codec_settings/g.
int EncoderSimulcastProxy::InitEncode(const VideoCodec* inst,
const VideoEncoder::Settings& settings) {
int ret = encoder_->InitEncode(inst, settings);
if (ret == WEBRTC_VIDEO_CODEC_ERR_SIMULCAST_PARAMETERS_NOT_SUPPORTED) {
encoder_.reset(new SimulcastEncoderAdapter(factory_, video_format_));
if (callback_) {
encoder_->RegisterEncodeCompleteCallback(callback_);
}
ret = encoder_->InitEncode(inst, settings);
}
return ret;
}
int EncoderSimulcastProxy::Encode(
const VideoFrame& input_image,
const std::vector<VideoFrameType>* frame_types) {
return encoder_->Encode(input_image, frame_types);
}
int EncoderSimulcastProxy::RegisterEncodeCompleteCallback(
EncodedImageCallback* callback) {
callback_ = callback;
return encoder_->RegisterEncodeCompleteCallback(callback);
}
void EncoderSimulcastProxy::SetRates(const RateControlParameters& parameters) {
encoder_->SetRates(parameters);
}
void EncoderSimulcastProxy::OnPacketLossRateUpdate(float packet_loss_rate) {
encoder_->OnPacketLossRateUpdate(packet_loss_rate);
}
void EncoderSimulcastProxy::OnRttUpdate(int64_t rtt_ms) {
encoder_->OnRttUpdate(rtt_ms);
}
void EncoderSimulcastProxy::OnLossNotification(
const LossNotification& loss_notification) {
encoder_->OnLossNotification(loss_notification);
}
VideoEncoder::EncoderInfo EncoderSimulcastProxy::GetEncoderInfo() const {
return encoder_->GetEncoderInfo();
}
} // namespace webrtc