| Index: media/cast/sender/video_sender.cc
|
| diff --git a/media/cast/sender/video_sender.cc b/media/cast/sender/video_sender.cc
|
| index 16b7159befe1fd001ceb676d9ba1596a1ca90d99..7895d6c4429dc2464168d71eb3f6d6376efc3f12 100644
|
| --- a/media/cast/sender/video_sender.cc
|
| +++ b/media/cast/sender/video_sender.cc
|
| @@ -15,6 +15,7 @@
|
| #include "media/cast/net/cast_transport_config.h"
|
| #include "media/cast/sender/external_video_encoder.h"
|
| #include "media/cast/sender/video_encoder_impl.h"
|
| +#include "media/cast/sender/video_frame_factory_pool_impl.h"
|
|
|
| namespace media {
|
| namespace cast {
|
| @@ -47,22 +48,23 @@ VideoSender::VideoSender(
|
| CastTransportSender* const transport_sender,
|
| const PlayoutDelayChangeCB& playout_delay_change_cb)
|
| : FrameSender(
|
| - cast_environment,
|
| - false,
|
| - transport_sender,
|
| - base::TimeDelta::FromMilliseconds(video_config.rtcp_interval),
|
| - kVideoFrequency,
|
| - video_config.ssrc,
|
| - video_config.max_frame_rate,
|
| - video_config.min_playout_delay,
|
| - video_config.max_playout_delay,
|
| - video_config.use_external_encoder ?
|
| - NewFixedCongestionControl(
|
| - (video_config.min_bitrate + video_config.max_bitrate) / 2) :
|
| - NewAdaptiveCongestionControl(cast_environment->Clock(),
|
| - video_config.max_bitrate,
|
| - video_config.min_bitrate,
|
| - video_config.max_frame_rate)),
|
| + cast_environment,
|
| + false,
|
| + transport_sender,
|
| + base::TimeDelta::FromMilliseconds(video_config.rtcp_interval),
|
| + kVideoFrequency,
|
| + video_config.ssrc,
|
| + video_config.max_frame_rate,
|
| + video_config.min_playout_delay,
|
| + video_config.max_playout_delay,
|
| + video_config.use_external_encoder
|
| + ? NewFixedCongestionControl(
|
| + (video_config.min_bitrate + video_config.max_bitrate) / 2)
|
| + : NewAdaptiveCongestionControl(cast_environment->Clock(),
|
| + video_config.max_bitrate,
|
| + video_config.min_bitrate,
|
| + video_config.max_frame_rate)),
|
| + video_frame_factory_(new VideoFrameFactoryPoolImpl(video_config)),
|
| frames_in_encoder_(0),
|
| last_bitrate_(0),
|
| playout_delay_change_cb_(playout_delay_change_cb),
|
| @@ -80,14 +82,12 @@ VideoSender::VideoSender(
|
| } else {
|
| // Software encoder is initialized immediately.
|
| video_encoder_.reset(new VideoEncoderImpl(cast_environment, video_config));
|
| - cast_initialization_status_ = STATUS_VIDEO_INITIALIZED;
|
| - }
|
| -
|
| - if (cast_initialization_status_ == STATUS_VIDEO_INITIALIZED) {
|
| - cast_environment->PostTask(
|
| - CastEnvironment::MAIN,
|
| - FROM_HERE,
|
| - base::Bind(initialization_cb, cast_initialization_status_));
|
| + cast_environment->PostTask(CastEnvironment::MAIN,
|
| + FROM_HERE,
|
| + base::Bind(&VideoSender::OnEncoderInitialized,
|
| + weak_factory_.GetWeakPtr(),
|
| + initialization_cb,
|
| + STATUS_VIDEO_INITIALIZED));
|
| }
|
|
|
| media::cast::CastTransportRtpConfig transport_config;
|
| @@ -215,6 +215,13 @@ void VideoSender::OnEncoderInitialized(
|
| const CastInitializationCallback& initialization_cb,
|
| CastInitializationStatus status) {
|
| cast_initialization_status_ = status;
|
| + if (status == STATUS_VIDEO_INITIALIZED) {
|
| + DCHECK(video_encoder_.get()) << "Invalid state";
|
| + auto video_frame_factory = video_encoder_->GetVideoFrameFactory();
|
| + if (video_frame_factory.get()) {
|
| + video_frame_factory_ = video_frame_factory;
|
| + }
|
| + }
|
| initialization_cb.Run(status);
|
| }
|
|
|
|
|