Remove VideoCodingModule::VCMPacketizationCallback
And move encoder name cb to VCMSendStatisticsCallback. BUG=webrtc:5687 Review-Url: https://codereview.webrtc.org/1900193004 Cr-Commit-Position: refs/heads/master@{#12596}
This commit is contained in:
@ -72,11 +72,6 @@ int32_t VCMGenericEncoder::Encode(const VideoFrame& frame,
|
|||||||
|
|
||||||
int32_t result = encoder_->Encode(frame, codec_specific, &frame_types);
|
int32_t result = encoder_->Encode(frame, codec_specific, &frame_types);
|
||||||
|
|
||||||
if (vcm_encoded_frame_callback_) {
|
|
||||||
vcm_encoded_frame_callback_->SignalLastEncoderImplementationUsed(
|
|
||||||
encoder_->ImplementationName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_screenshare_ &&
|
if (is_screenshare_ &&
|
||||||
result == WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT) {
|
result == WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT) {
|
||||||
// Target bitrate exceeded, encoder state has been reset - try again.
|
// Target bitrate exceeded, encoder state has been reset - try again.
|
||||||
@ -86,6 +81,10 @@ int32_t VCMGenericEncoder::Encode(const VideoFrame& frame,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* VCMGenericEncoder::ImplementationName() const {
|
||||||
|
return encoder_->ImplementationName();
|
||||||
|
}
|
||||||
|
|
||||||
void VCMGenericEncoder::SetEncoderParameters(const EncoderParameters& params) {
|
void VCMGenericEncoder::SetEncoderParameters(const EncoderParameters& params) {
|
||||||
bool channel_parameters_have_changed;
|
bool channel_parameters_have_changed;
|
||||||
bool rates_have_changed;
|
bool rates_have_changed;
|
||||||
@ -139,20 +138,14 @@ bool VCMGenericEncoder::SupportsNativeHandle() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VCMEncodedFrameCallback::VCMEncodedFrameCallback(
|
VCMEncodedFrameCallback::VCMEncodedFrameCallback(
|
||||||
EncodedImageCallback* post_encode_callback)
|
EncodedImageCallback* post_encode_callback,
|
||||||
: send_callback_(),
|
media_optimization::MediaOptimization* media_opt)
|
||||||
media_opt_(nullptr),
|
: internal_source_(false),
|
||||||
internal_source_(false),
|
post_encode_callback_(post_encode_callback),
|
||||||
post_encode_callback_(post_encode_callback) {}
|
media_opt_(media_opt) {}
|
||||||
|
|
||||||
VCMEncodedFrameCallback::~VCMEncodedFrameCallback() {}
|
VCMEncodedFrameCallback::~VCMEncodedFrameCallback() {}
|
||||||
|
|
||||||
int32_t VCMEncodedFrameCallback::SetTransportCallback(
|
|
||||||
VCMPacketizationCallback* transport) {
|
|
||||||
send_callback_ = transport;
|
|
||||||
return VCM_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t VCMEncodedFrameCallback::Encoded(
|
int32_t VCMEncodedFrameCallback::Encoded(
|
||||||
const EncodedImage& encoded_image,
|
const EncodedImage& encoded_image,
|
||||||
const CodecSpecificInfo* codec_specific,
|
const CodecSpecificInfo* codec_specific,
|
||||||
@ -172,14 +165,4 @@ int32_t VCMEncodedFrameCallback::Encoded(
|
|||||||
return VCM_OK;
|
return VCM_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VCMEncodedFrameCallback::SetMediaOpt(
|
|
||||||
media_optimization::MediaOptimization* mediaOpt) {
|
|
||||||
media_opt_ = mediaOpt;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VCMEncodedFrameCallback::SignalLastEncoderImplementationUsed(
|
|
||||||
const char* implementation_name) {
|
|
||||||
if (send_callback_)
|
|
||||||
send_callback_->OnEncoderImplementationName(implementation_name);
|
|
||||||
}
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -35,27 +35,22 @@ struct EncoderParameters {
|
|||||||
|
|
||||||
class VCMEncodedFrameCallback : public EncodedImageCallback {
|
class VCMEncodedFrameCallback : public EncodedImageCallback {
|
||||||
public:
|
public:
|
||||||
explicit VCMEncodedFrameCallback(EncodedImageCallback* post_encode_callback);
|
VCMEncodedFrameCallback(EncodedImageCallback* post_encode_callback,
|
||||||
|
media_optimization::MediaOptimization* media_opt);
|
||||||
virtual ~VCMEncodedFrameCallback();
|
virtual ~VCMEncodedFrameCallback();
|
||||||
|
|
||||||
// Implements EncodedImageCallback.
|
// Implements EncodedImageCallback.
|
||||||
int32_t Encoded(const EncodedImage& encoded_image,
|
int32_t Encoded(const EncodedImage& encoded_image,
|
||||||
const CodecSpecificInfo* codec_specific,
|
const CodecSpecificInfo* codec_specific,
|
||||||
const RTPFragmentationHeader* fragmentation_header) override;
|
const RTPFragmentationHeader* fragmentation_header) override;
|
||||||
int32_t SetTransportCallback(VCMPacketizationCallback* transport);
|
|
||||||
void SetMediaOpt(media_optimization::MediaOptimization* media_opt);
|
|
||||||
void SetInternalSource(bool internal_source) {
|
void SetInternalSource(bool internal_source) {
|
||||||
internal_source_ = internal_source;
|
internal_source_ = internal_source;
|
||||||
}
|
}
|
||||||
void SignalLastEncoderImplementationUsed(
|
|
||||||
const char* encoder_implementation_name);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VCMPacketizationCallback* send_callback_;
|
|
||||||
media_optimization::MediaOptimization* media_opt_;
|
|
||||||
bool internal_source_;
|
bool internal_source_;
|
||||||
|
EncodedImageCallback* const post_encode_callback_;
|
||||||
EncodedImageCallback* post_encode_callback_;
|
media_optimization::MediaOptimization* const media_opt_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VCMGenericEncoder {
|
class VCMGenericEncoder {
|
||||||
@ -75,6 +70,8 @@ class VCMGenericEncoder {
|
|||||||
const CodecSpecificInfo* codec_specific,
|
const CodecSpecificInfo* codec_specific,
|
||||||
const std::vector<FrameType>& frame_types);
|
const std::vector<FrameType>& frame_types);
|
||||||
|
|
||||||
|
const char* ImplementationName() const;
|
||||||
|
|
||||||
void SetEncoderParameters(const EncoderParameters& params);
|
void SetEncoderParameters(const EncoderParameters& params);
|
||||||
EncoderParameters GetEncoderParameters() const;
|
EncoderParameters GetEncoderParameters() const;
|
||||||
|
|
||||||
|
|||||||
@ -184,32 +184,6 @@ class VideoCodingModule : public Module {
|
|||||||
// < 0, on error.
|
// < 0, on error.
|
||||||
virtual int32_t SetReceiveChannelParameters(int64_t rtt) = 0;
|
virtual int32_t SetReceiveChannelParameters(int64_t rtt) = 0;
|
||||||
|
|
||||||
// Register a transport callback which will be called to deliver the encoded
|
|
||||||
// data and
|
|
||||||
// side information.
|
|
||||||
//
|
|
||||||
// Input:
|
|
||||||
// - transport : The callback object to register.
|
|
||||||
//
|
|
||||||
// Return value : VCM_OK, on success.
|
|
||||||
// < 0, on error.
|
|
||||||
virtual int32_t RegisterTransportCallback(
|
|
||||||
VCMPacketizationCallback* transport) = 0;
|
|
||||||
|
|
||||||
// Register video output information callback which will be called to deliver
|
|
||||||
// information
|
|
||||||
// about the video stream produced by the encoder, for instance the average
|
|
||||||
// frame rate and
|
|
||||||
// bit rate.
|
|
||||||
//
|
|
||||||
// Input:
|
|
||||||
// - outputInformation : The callback object to register.
|
|
||||||
//
|
|
||||||
// Return value : VCM_OK, on success.
|
|
||||||
// < 0, on error.
|
|
||||||
virtual int32_t RegisterSendStatisticsCallback(
|
|
||||||
VCMSendStatisticsCallback* sendStats) = 0;
|
|
||||||
|
|
||||||
// Register a video protection callback which will be called to deliver
|
// Register a video protection callback which will be called to deliver
|
||||||
// the requested FEC rate and NACK status (on/off).
|
// the requested FEC rate and NACK status (on/off).
|
||||||
//
|
//
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
#ifndef WEBRTC_MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_
|
#ifndef WEBRTC_MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_
|
||||||
#define WEBRTC_MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_
|
#define WEBRTC_MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "webrtc/modules/include/module_common_types.h"
|
#include "webrtc/modules/include/module_common_types.h"
|
||||||
@ -56,18 +57,6 @@ struct VCMFrameCount {
|
|||||||
uint32_t numDeltaFrames;
|
uint32_t numDeltaFrames;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Callback class used for sending data ready to be packetized
|
|
||||||
// Deprecated.
|
|
||||||
// TODO(perkj): Remove once OnEncoderImplementationName is not used.
|
|
||||||
class VCMPacketizationCallback {
|
|
||||||
public:
|
|
||||||
// TODO(perkj): Refactor this. It does not belong in VCMPacketizationCallback.
|
|
||||||
virtual void OnEncoderImplementationName(const char* implementation_name) {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual ~VCMPacketizationCallback() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Callback class used for passing decoded frames which are ready to be
|
// Callback class used for passing decoded frames which are ready to be
|
||||||
// rendered.
|
// rendered.
|
||||||
class VCMReceiveCallback {
|
class VCMReceiveCallback {
|
||||||
@ -84,13 +73,13 @@ class VCMReceiveCallback {
|
|||||||
virtual ~VCMReceiveCallback() {}
|
virtual ~VCMReceiveCallback() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Callback class used for informing the user of the bit rate and frame rate
|
// Callback class used for informing the user of the bit rate and frame rate,
|
||||||
// produced by the
|
// and the name of the encoder.
|
||||||
// encoder.
|
|
||||||
class VCMSendStatisticsCallback {
|
class VCMSendStatisticsCallback {
|
||||||
public:
|
public:
|
||||||
virtual int32_t SendStatistics(const uint32_t bitRate,
|
virtual void SendStatistics(uint32_t bitRate,
|
||||||
const uint32_t frameRate) = 0;
|
uint32_t frameRate,
|
||||||
|
const std::string& encoder_name) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~VCMSendStatisticsCallback() {}
|
virtual ~VCMSendStatisticsCallback() {}
|
||||||
|
|||||||
@ -82,7 +82,8 @@ class VideoCodingModuleImpl : public VideoCodingModule {
|
|||||||
sender_(clock,
|
sender_(clock,
|
||||||
&post_encode_callback_,
|
&post_encode_callback_,
|
||||||
encoder_rate_observer,
|
encoder_rate_observer,
|
||||||
qm_settings_callback),
|
qm_settings_callback,
|
||||||
|
nullptr),
|
||||||
receiver_(clock,
|
receiver_(clock,
|
||||||
event_factory,
|
event_factory,
|
||||||
pre_decode_image_callback,
|
pre_decode_image_callback,
|
||||||
@ -132,16 +133,6 @@ class VideoCodingModuleImpl : public VideoCodingModule {
|
|||||||
return sender_.SetChannelParameters(target_bitrate, lossRate, rtt);
|
return sender_.SetChannelParameters(target_bitrate, lossRate, rtt);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RegisterTransportCallback(
|
|
||||||
VCMPacketizationCallback* transport) override {
|
|
||||||
return sender_.RegisterTransportCallback(transport);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t RegisterSendStatisticsCallback(
|
|
||||||
VCMSendStatisticsCallback* sendStats) override {
|
|
||||||
return sender_.RegisterSendStatisticsCallback(sendStats);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t RegisterProtectionCallback(
|
int32_t RegisterProtectionCallback(
|
||||||
VCMProtectionCallback* protection) override {
|
VCMProtectionCallback* protection) override {
|
||||||
return sender_.RegisterProtectionCallback(protection);
|
return sender_.RegisterProtectionCallback(protection);
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
#include "webrtc/modules/video_coding/include/video_coding.h"
|
#include "webrtc/modules/video_coding/include/video_coding.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "webrtc/base/onetimeevent.h"
|
#include "webrtc/base/onetimeevent.h"
|
||||||
@ -58,7 +59,8 @@ class VideoSender : public Module {
|
|||||||
VideoSender(Clock* clock,
|
VideoSender(Clock* clock,
|
||||||
EncodedImageCallback* post_encode_callback,
|
EncodedImageCallback* post_encode_callback,
|
||||||
VideoEncoderRateObserver* encoder_rate_observer,
|
VideoEncoderRateObserver* encoder_rate_observer,
|
||||||
VCMQMSettingsCallback* qm_settings_callback);
|
VCMQMSettingsCallback* qm_settings_callback,
|
||||||
|
VCMSendStatisticsCallback* send_stats_callback);
|
||||||
|
|
||||||
~VideoSender();
|
~VideoSender();
|
||||||
|
|
||||||
@ -79,10 +81,6 @@ class VideoSender : public Module {
|
|||||||
uint8_t lossRate,
|
uint8_t lossRate,
|
||||||
int64_t rtt);
|
int64_t rtt);
|
||||||
|
|
||||||
// Deprecated. Use |post_encode_callback| instead.
|
|
||||||
// TODO(perkj): Remove once |OnEncoderImplementationName| is not used.
|
|
||||||
int32_t RegisterTransportCallback(VCMPacketizationCallback* transport);
|
|
||||||
int32_t RegisterSendStatisticsCallback(VCMSendStatisticsCallback* sendStats);
|
|
||||||
int32_t RegisterProtectionCallback(VCMProtectionCallback* protection);
|
int32_t RegisterProtectionCallback(VCMProtectionCallback* protection);
|
||||||
void SetVideoProtection(VCMVideoProtection videoProtection);
|
void SetVideoProtection(VCMVideoProtection videoProtection);
|
||||||
|
|
||||||
@ -105,12 +103,11 @@ class VideoSender : public Module {
|
|||||||
|
|
||||||
Clock* const clock_;
|
Clock* const clock_;
|
||||||
|
|
||||||
rtc::CriticalSection process_crit_;
|
|
||||||
rtc::CriticalSection encoder_crit_;
|
rtc::CriticalSection encoder_crit_;
|
||||||
VCMGenericEncoder* _encoder;
|
VCMGenericEncoder* _encoder;
|
||||||
VCMEncodedFrameCallback _encodedFrameCallback GUARDED_BY(encoder_crit_);
|
|
||||||
media_optimization::MediaOptimization _mediaOpt;
|
media_optimization::MediaOptimization _mediaOpt;
|
||||||
VCMSendStatisticsCallback* _sendStatsCallback GUARDED_BY(process_crit_);
|
VCMEncodedFrameCallback _encodedFrameCallback GUARDED_BY(encoder_crit_);
|
||||||
|
VCMSendStatisticsCallback* const send_stats_callback_;
|
||||||
VCMCodecDataBase _codecDataBase GUARDED_BY(encoder_crit_);
|
VCMCodecDataBase _codecDataBase GUARDED_BY(encoder_crit_);
|
||||||
bool frame_dropper_enabled_ GUARDED_BY(encoder_crit_);
|
bool frame_dropper_enabled_ GUARDED_BY(encoder_crit_);
|
||||||
VCMProcessTimer _sendStatsTimer;
|
VCMProcessTimer _sendStatsTimer;
|
||||||
@ -125,6 +122,7 @@ class VideoSender : public Module {
|
|||||||
rtc::CriticalSection params_crit_;
|
rtc::CriticalSection params_crit_;
|
||||||
EncoderParameters encoder_params_ GUARDED_BY(params_crit_);
|
EncoderParameters encoder_params_ GUARDED_BY(params_crit_);
|
||||||
bool encoder_has_internal_source_ GUARDED_BY(params_crit_);
|
bool encoder_has_internal_source_ GUARDED_BY(params_crit_);
|
||||||
|
std::string encoder_name_ GUARDED_BY(params_crit_);
|
||||||
std::vector<FrameType> next_frame_types_ GUARDED_BY(params_crit_);
|
std::vector<FrameType> next_frame_types_ GUARDED_BY(params_crit_);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -27,12 +27,13 @@ namespace vcm {
|
|||||||
VideoSender::VideoSender(Clock* clock,
|
VideoSender::VideoSender(Clock* clock,
|
||||||
EncodedImageCallback* post_encode_callback,
|
EncodedImageCallback* post_encode_callback,
|
||||||
VideoEncoderRateObserver* encoder_rate_observer,
|
VideoEncoderRateObserver* encoder_rate_observer,
|
||||||
VCMQMSettingsCallback* qm_settings_callback)
|
VCMQMSettingsCallback* qm_settings_callback,
|
||||||
|
VCMSendStatisticsCallback* send_stats_callback)
|
||||||
: clock_(clock),
|
: clock_(clock),
|
||||||
_encoder(nullptr),
|
_encoder(nullptr),
|
||||||
_encodedFrameCallback(post_encode_callback),
|
|
||||||
_mediaOpt(clock_),
|
_mediaOpt(clock_),
|
||||||
_sendStatsCallback(nullptr),
|
_encodedFrameCallback(post_encode_callback, &_mediaOpt),
|
||||||
|
send_stats_callback_(send_stats_callback),
|
||||||
_codecDataBase(encoder_rate_observer, &_encodedFrameCallback),
|
_codecDataBase(encoder_rate_observer, &_encodedFrameCallback),
|
||||||
frame_dropper_enabled_(true),
|
frame_dropper_enabled_(true),
|
||||||
_sendStatsTimer(1000, clock_),
|
_sendStatsTimer(1000, clock_),
|
||||||
@ -54,12 +55,19 @@ VideoSender::~VideoSender() {}
|
|||||||
|
|
||||||
void VideoSender::Process() {
|
void VideoSender::Process() {
|
||||||
if (_sendStatsTimer.TimeUntilProcess() == 0) {
|
if (_sendStatsTimer.TimeUntilProcess() == 0) {
|
||||||
|
// |_sendStatsTimer.Processed()| must be called. Otherwise
|
||||||
|
// VideoSender::Process() will be called in an infinite loop.
|
||||||
_sendStatsTimer.Processed();
|
_sendStatsTimer.Processed();
|
||||||
rtc::CritScope cs(&process_crit_);
|
if (send_stats_callback_) {
|
||||||
if (_sendStatsCallback != nullptr) {
|
|
||||||
uint32_t bitRate = _mediaOpt.SentBitRate();
|
uint32_t bitRate = _mediaOpt.SentBitRate();
|
||||||
uint32_t frameRate = _mediaOpt.SentFrameRate();
|
uint32_t frameRate = _mediaOpt.SentFrameRate();
|
||||||
_sendStatsCallback->SendStatistics(bitRate, frameRate);
|
std::string encoder_name;
|
||||||
|
{
|
||||||
|
rtc::CritScope cs(¶ms_crit_);
|
||||||
|
// Copy the string here so that we don't hold |params_crit_| in the CB.
|
||||||
|
encoder_name = encoder_name_;
|
||||||
|
}
|
||||||
|
send_stats_callback_->SendStatistics(bitRate, frameRate, encoder_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,24 +243,6 @@ void VideoSender::SetEncoderParameters(EncoderParameters params) {
|
|||||||
_encoder->SetEncoderParameters(params);
|
_encoder->SetEncoderParameters(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t VideoSender::RegisterTransportCallback(
|
|
||||||
VCMPacketizationCallback* transport) {
|
|
||||||
rtc::CritScope lock(&encoder_crit_);
|
|
||||||
_encodedFrameCallback.SetMediaOpt(&_mediaOpt);
|
|
||||||
_encodedFrameCallback.SetTransportCallback(transport);
|
|
||||||
return VCM_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register video output information callback which will be called to deliver
|
|
||||||
// information about the video stream produced by the encoder, for instance the
|
|
||||||
// average frame rate and bit rate.
|
|
||||||
int32_t VideoSender::RegisterSendStatisticsCallback(
|
|
||||||
VCMSendStatisticsCallback* sendStats) {
|
|
||||||
rtc::CritScope cs(&process_crit_);
|
|
||||||
_sendStatsCallback = sendStats;
|
|
||||||
return VCM_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register a video protection callback which will be called to deliver the
|
// Register a video protection callback which will be called to deliver the
|
||||||
// requested FEC rate and NACK status (on/off).
|
// requested FEC rate and NACK status (on/off).
|
||||||
// Note: this callback is assumed to only be registered once and before it is
|
// Note: this callback is assumed to only be registered once and before it is
|
||||||
@ -329,9 +319,12 @@ int32_t VideoSender::AddVideoFrame(const VideoFrame& videoFrame,
|
|||||||
LOG(LS_ERROR) << "Failed to encode frame. Error code: " << ret;
|
LOG(LS_ERROR) << "Failed to encode frame. Error code: " << ret;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Change all keyframe requests to encode delta frames the next time.
|
|
||||||
rtc::CritScope lock(¶ms_crit_);
|
rtc::CritScope lock(¶ms_crit_);
|
||||||
|
encoder_name_ = _encoder->ImplementationName();
|
||||||
|
|
||||||
|
// Change all keyframe requests to encode delta frames the next time.
|
||||||
for (size_t i = 0; i < next_frame_types_.size(); ++i) {
|
for (size_t i = 0; i < next_frame_types_.size(); ++i) {
|
||||||
// Check for equality (same requested as before encoding) to not
|
// Check for equality (same requested as before encoding) to not
|
||||||
// accidentally drop a keyframe request while encoding.
|
// accidentally drop a keyframe request while encoding.
|
||||||
|
|||||||
@ -180,8 +180,8 @@ class TestVideoSender : public ::testing::Test {
|
|||||||
TestVideoSender() : clock_(1000), encoded_frame_callback_(&clock_) {}
|
TestVideoSender() : clock_(1000), encoded_frame_callback_(&clock_) {}
|
||||||
|
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
sender_.reset(
|
sender_.reset(new VideoSender(&clock_, &encoded_frame_callback_, nullptr,
|
||||||
new VideoSender(&clock_, &encoded_frame_callback_, nullptr, nullptr));
|
nullptr, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddFrame() {
|
void AddFrame() {
|
||||||
|
|||||||
@ -342,16 +342,14 @@ void SendStatisticsProxy::SetContentType(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendStatisticsProxy::OnEncoderImplementationName(
|
void SendStatisticsProxy::OnEncoderStatsUpdate(
|
||||||
const char* implementation_name) {
|
uint32_t framerate,
|
||||||
rtc::CritScope lock(&crit_);
|
uint32_t bitrate,
|
||||||
stats_.encoder_implementation_name = implementation_name;
|
const std::string& encoder_name) {
|
||||||
}
|
|
||||||
|
|
||||||
void SendStatisticsProxy::OnOutgoingRate(uint32_t framerate, uint32_t bitrate) {
|
|
||||||
rtc::CritScope lock(&crit_);
|
rtc::CritScope lock(&crit_);
|
||||||
stats_.encode_frame_rate = framerate;
|
stats_.encode_frame_rate = framerate;
|
||||||
stats_.media_bitrate_bps = bitrate;
|
stats_.media_bitrate_bps = bitrate;
|
||||||
|
stats_.encoder_implementation_name = encoder_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendStatisticsProxy::OnEncodedFrameTimeMeasured(
|
void SendStatisticsProxy::OnEncodedFrameTimeMeasured(
|
||||||
|
|||||||
@ -53,8 +53,9 @@ class SendStatisticsProxy : public CpuOveruseMetricsObserver,
|
|||||||
// Used to update incoming frame rate.
|
// Used to update incoming frame rate.
|
||||||
void OnIncomingFrame(int width, int height);
|
void OnIncomingFrame(int width, int height);
|
||||||
|
|
||||||
void OnEncoderImplementationName(const char* implementation_name);
|
void OnEncoderStatsUpdate(uint32_t framerate,
|
||||||
void OnOutgoingRate(uint32_t framerate, uint32_t bitrate);
|
uint32_t bitrate,
|
||||||
|
const std::string& encoder_name);
|
||||||
void OnSuspendChange(bool is_suspended);
|
void OnSuspendChange(bool is_suspended);
|
||||||
void OnInactiveSsrc(uint32_t ssrc);
|
void OnInactiveSsrc(uint32_t ssrc);
|
||||||
|
|
||||||
|
|||||||
@ -146,11 +146,13 @@ TEST_F(SendStatisticsProxyTest, EncodedBitrateAndFramerate) {
|
|||||||
int media_bitrate_bps = 500;
|
int media_bitrate_bps = 500;
|
||||||
int encode_fps = 29;
|
int encode_fps = 29;
|
||||||
|
|
||||||
statistics_proxy_->OnOutgoingRate(encode_fps, media_bitrate_bps);
|
statistics_proxy_->OnEncoderStatsUpdate(encode_fps, media_bitrate_bps,
|
||||||
|
"encoder name");
|
||||||
|
|
||||||
VideoSendStream::Stats stats = statistics_proxy_->GetStats();
|
VideoSendStream::Stats stats = statistics_proxy_->GetStats();
|
||||||
EXPECT_EQ(media_bitrate_bps, stats.media_bitrate_bps);
|
EXPECT_EQ(media_bitrate_bps, stats.media_bitrate_bps);
|
||||||
EXPECT_EQ(encode_fps, stats.encode_frame_rate);
|
EXPECT_EQ(encode_fps, stats.encode_frame_rate);
|
||||||
|
EXPECT_EQ("encoder name", stats.encoder_implementation_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SendStatisticsProxyTest, Suspended) {
|
TEST_F(SendStatisticsProxyTest, Suspended) {
|
||||||
|
|||||||
@ -405,7 +405,6 @@ VideoSendStream::VideoSendStream(
|
|||||||
RTC_DCHECK(congestion_controller_);
|
RTC_DCHECK(congestion_controller_);
|
||||||
RTC_DCHECK(remb_);
|
RTC_DCHECK(remb_);
|
||||||
|
|
||||||
RTC_CHECK(vie_encoder_.Init());
|
|
||||||
encoder_feedback_.Init(config_.rtp.ssrcs, &vie_encoder_);
|
encoder_feedback_.Init(config_.rtp.ssrcs, &vie_encoder_);
|
||||||
|
|
||||||
// RTP/RTCP initialization.
|
// RTP/RTCP initialization.
|
||||||
|
|||||||
@ -64,7 +64,11 @@ ViEEncoder::ViEEncoder(uint32_t number_of_cores,
|
|||||||
ssrcs_(ssrcs),
|
ssrcs_(ssrcs),
|
||||||
vp_(VideoProcessing::Create()),
|
vp_(VideoProcessing::Create()),
|
||||||
qm_callback_(new QMVideoSettingsCallback(vp_.get())),
|
qm_callback_(new QMVideoSettingsCallback(vp_.get())),
|
||||||
video_sender_(Clock::GetRealTimeClock(), this, this, qm_callback_.get()),
|
video_sender_(Clock::GetRealTimeClock(),
|
||||||
|
this,
|
||||||
|
this,
|
||||||
|
qm_callback_.get(),
|
||||||
|
this),
|
||||||
stats_proxy_(stats_proxy),
|
stats_proxy_(stats_proxy),
|
||||||
pre_encode_callback_(pre_encode_callback),
|
pre_encode_callback_(pre_encode_callback),
|
||||||
overuse_detector_(overuse_detector),
|
overuse_detector_(overuse_detector),
|
||||||
@ -84,23 +88,10 @@ ViEEncoder::ViEEncoder(uint32_t number_of_cores,
|
|||||||
picture_id_rpsi_(0),
|
picture_id_rpsi_(0),
|
||||||
video_suspended_(false) {
|
video_suspended_(false) {
|
||||||
module_process_thread_->RegisterModule(&video_sender_);
|
module_process_thread_->RegisterModule(&video_sender_);
|
||||||
}
|
|
||||||
|
|
||||||
bool ViEEncoder::Init() {
|
|
||||||
vp_->EnableTemporalDecimation(true);
|
vp_->EnableTemporalDecimation(true);
|
||||||
|
|
||||||
// Enable/disable content analysis: off by default for now.
|
// Enable/disable content analysis: off by default for now.
|
||||||
vp_->EnableContentAnalysis(false);
|
vp_->EnableContentAnalysis(false);
|
||||||
|
|
||||||
// TODO(perkj): Remove |RegisterTransportCallback| as soon as we don't use
|
|
||||||
// VCMPacketizationCallback::OnEncoderImplementationName.
|
|
||||||
if (video_sender_.RegisterTransportCallback(this) != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (video_sender_.RegisterSendStatisticsCallback(this) != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vcm::VideoSender* ViEEncoder::video_sender() {
|
vcm::VideoSender* ViEEncoder::video_sender() {
|
||||||
@ -353,11 +344,6 @@ void ViEEncoder::OnSetRates(uint32_t bitrate_bps, int framerate) {
|
|||||||
stats_proxy_->OnSetRates(bitrate_bps, framerate);
|
stats_proxy_->OnSetRates(bitrate_bps, framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::OnEncoderImplementationName(const char* implementation_name) {
|
|
||||||
if (stats_proxy_)
|
|
||||||
stats_proxy_->OnEncoderImplementationName(implementation_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ViEEncoder::Encoded(const EncodedImage& encoded_image,
|
int32_t ViEEncoder::Encoded(const EncodedImage& encoded_image,
|
||||||
const CodecSpecificInfo* codec_specific_info,
|
const CodecSpecificInfo* codec_specific_info,
|
||||||
const RTPFragmentationHeader* fragmentation) {
|
const RTPFragmentationHeader* fragmentation) {
|
||||||
@ -403,11 +389,11 @@ int32_t ViEEncoder::Encoded(const EncodedImage& encoded_image,
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ViEEncoder::SendStatistics(const uint32_t bit_rate,
|
void ViEEncoder::SendStatistics(uint32_t bit_rate,
|
||||||
const uint32_t frame_rate) {
|
uint32_t frame_rate,
|
||||||
|
const std::string& encoder_name) {
|
||||||
if (stats_proxy_)
|
if (stats_proxy_)
|
||||||
stats_proxy_->OnOutgoingRate(frame_rate, bit_rate);
|
stats_proxy_->OnEncoderStatsUpdate(frame_rate, bit_rate, encoder_name);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::OnReceivedSLI(uint32_t /*ssrc*/,
|
void ViEEncoder::OnReceivedSLI(uint32_t /*ssrc*/,
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
#define WEBRTC_VIDEO_VIE_ENCODER_H_
|
#define WEBRTC_VIDEO_VIE_ENCODER_H_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "webrtc/base/criticalsection.h"
|
#include "webrtc/base/criticalsection.h"
|
||||||
@ -52,7 +53,6 @@ class VideoEncoder;
|
|||||||
// 6. For each available raw video frame call EncodeVideoFrame.
|
// 6. For each available raw video frame call EncodeVideoFrame.
|
||||||
class ViEEncoder : public VideoEncoderRateObserver,
|
class ViEEncoder : public VideoEncoderRateObserver,
|
||||||
public EncodedImageCallback,
|
public EncodedImageCallback,
|
||||||
public VCMPacketizationCallback,
|
|
||||||
public VCMSendStatisticsCallback {
|
public VCMSendStatisticsCallback {
|
||||||
public:
|
public:
|
||||||
friend class ViEBitrateObserver;
|
friend class ViEBitrateObserver;
|
||||||
@ -67,8 +67,6 @@ class ViEEncoder : public VideoEncoderRateObserver,
|
|||||||
PacedSender* pacer);
|
PacedSender* pacer);
|
||||||
~ViEEncoder();
|
~ViEEncoder();
|
||||||
|
|
||||||
bool Init();
|
|
||||||
|
|
||||||
vcm::VideoSender* video_sender();
|
vcm::VideoSender* video_sender();
|
||||||
|
|
||||||
void SetNetworkTransmissionState(bool is_transmitting);
|
void SetNetworkTransmissionState(bool is_transmitting);
|
||||||
@ -102,17 +100,15 @@ class ViEEncoder : public VideoEncoderRateObserver,
|
|||||||
// Implements VideoEncoderRateObserver.
|
// Implements VideoEncoderRateObserver.
|
||||||
void OnSetRates(uint32_t bitrate_bps, int framerate) override;
|
void OnSetRates(uint32_t bitrate_bps, int framerate) override;
|
||||||
|
|
||||||
// Implements VCMPacketizationCallback.
|
|
||||||
void OnEncoderImplementationName(const char* implementation_name) override;
|
|
||||||
|
|
||||||
// Implements EncodedImageCallback.
|
// Implements EncodedImageCallback.
|
||||||
int32_t Encoded(const EncodedImage& encoded_image,
|
int32_t Encoded(const EncodedImage& encoded_image,
|
||||||
const CodecSpecificInfo* codec_specific_info,
|
const CodecSpecificInfo* codec_specific_info,
|
||||||
const RTPFragmentationHeader* fragmentation) override;
|
const RTPFragmentationHeader* fragmentation) override;
|
||||||
|
|
||||||
// Implements VideoSendStatisticsCallback.
|
// Implements VideoSendStatisticsCallback.
|
||||||
int32_t SendStatistics(const uint32_t bit_rate,
|
void SendStatistics(uint32_t bit_rate,
|
||||||
const uint32_t frame_rate) override;
|
uint32_t frame_rate,
|
||||||
|
const std::string& encoder_name) override;
|
||||||
|
|
||||||
// virtual to test EncoderStateFeedback with mocks.
|
// virtual to test EncoderStateFeedback with mocks.
|
||||||
virtual void OnReceivedIntraFrameRequest(uint32_t ssrc);
|
virtual void OnReceivedIntraFrameRequest(uint32_t ssrc);
|
||||||
|
|||||||
Reference in New Issue
Block a user