| Index: webrtc/modules/video_coding/video_sender.cc
|
| diff --git a/webrtc/modules/video_coding/video_sender.cc b/webrtc/modules/video_coding/video_sender.cc
|
| index 3a1debae520f7e1f40f9488ebd079d00ba98ce98..17cb4941f2561d5b60c92cee0ea1c5e8be272c4a 100644
|
| --- a/webrtc/modules/video_coding/video_sender.cc
|
| +++ b/webrtc/modules/video_coding/video_sender.cc
|
| @@ -27,12 +27,13 @@ namespace vcm {
|
| VideoSender::VideoSender(Clock* clock,
|
| EncodedImageCallback* post_encode_callback,
|
| VideoEncoderRateObserver* encoder_rate_observer,
|
| - VCMQMSettingsCallback* qm_settings_callback)
|
| + VCMQMSettingsCallback* qm_settings_callback,
|
| + VCMSendStatisticsCallback* send_stats_callback)
|
| : clock_(clock),
|
| _encoder(nullptr),
|
| _encodedFrameCallback(post_encode_callback),
|
| _mediaOpt(clock_),
|
| - _sendStatsCallback(nullptr),
|
| + send_stats_callback_(send_stats_callback),
|
| _codecDataBase(encoder_rate_observer, &_encodedFrameCallback),
|
| frame_dropper_enabled_(true),
|
| _sendStatsTimer(1000, clock_),
|
| @@ -47,6 +48,7 @@ VideoSender::VideoSender(Clock* clock,
|
| // one external project (diffractor).
|
| _mediaOpt.EnableQM(qm_settings_callback_ != nullptr);
|
| _mediaOpt.Reset();
|
| + _encodedFrameCallback.SetMediaOpt(&_mediaOpt);
|
| main_thread_.DetachFromThread();
|
| }
|
|
|
| @@ -54,13 +56,22 @@ VideoSender::~VideoSender() {}
|
|
|
| void VideoSender::Process() {
|
| if (_sendStatsTimer.TimeUntilProcess() == 0) {
|
| + // |_sendStatsTimer.Processed()| must be called. Otherwise
|
| + // VideoSender::Process() will be called in an infinit loop.
|
| _sendStatsTimer.Processed();
|
| - rtc::CritScope cs(&process_crit_);
|
| - if (_sendStatsCallback != nullptr) {
|
| - uint32_t bitRate = _mediaOpt.SentBitRate();
|
| - uint32_t frameRate = _mediaOpt.SentFrameRate();
|
| - _sendStatsCallback->SendStatistics(bitRate, frameRate);
|
| + if (!send_stats_callback_) {
|
| + return;
|
| + }
|
| + uint32_t bitRate = _mediaOpt.SentBitRate();
|
| + uint32_t frameRate = _mediaOpt.SentFrameRate();
|
| + 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,
|
| + std::move(encoder_name));
|
| }
|
|
|
| {
|
| @@ -235,24 +246,6 @@ void VideoSender::SetEncoderParameters(EncoderParameters 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
|
| // requested FEC rate and NACK status (on/off).
|
| // Note: this callback is assumed to only be registered once and before it is
|
| @@ -329,9 +322,12 @@ int32_t VideoSender::AddVideoFrame(const VideoFrame& videoFrame,
|
| LOG(LS_ERROR) << "Failed to encode frame. Error code: " << ret;
|
| return ret;
|
| }
|
| +
|
| {
|
| - // Change all keyframe requests to encode delta frames the next time.
|
| 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) {
|
| // Check for equality (same requested as before encoding) to not
|
| // accidentally drop a keyframe request while encoding.
|
|
|