| Index: media/cast/sender/video_sender.cc
|
| diff --git a/media/cast/sender/video_sender.cc b/media/cast/sender/video_sender.cc
|
| index c900187e74be166590322723e78d565aabffe25f..54e474c4b1472c5b8e41faec75e9b459d93ae683 100644
|
| --- a/media/cast/sender/video_sender.cc
|
| +++ b/media/cast/sender/video_sender.cc
|
| @@ -9,7 +9,6 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/logging.h"
|
| -#include "base/message_loop/message_loop.h"
|
| #include "base/trace_event/trace_event.h"
|
| #include "media/cast/cast_defines.h"
|
| #include "media/cast/net/cast_transport_config.h"
|
| @@ -46,7 +45,7 @@ const int kConstantTimeMs = 75;
|
| VideoSender::VideoSender(
|
| scoped_refptr<CastEnvironment> cast_environment,
|
| const VideoSenderConfig& video_config,
|
| - const CastInitializationCallback& initialization_cb,
|
| + const StatusChangeCallback& status_change_cb,
|
| const CreateVideoEncodeAcceleratorCallback& create_vea_cb,
|
| const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb,
|
| CastTransportSender* const transport_sender,
|
| @@ -72,8 +71,6 @@ VideoSender::VideoSender(
|
| last_bitrate_(0),
|
| playout_delay_change_cb_(playout_delay_change_cb),
|
| weak_factory_(this) {
|
| - cast_initialization_status_ = STATUS_VIDEO_UNINITIALIZED;
|
| -
|
| #if defined(OS_MACOSX)
|
| // On Apple platforms, use the hardware H.264 encoder if possible. It is the
|
| // only reasonable option for iOS.
|
| @@ -83,9 +80,7 @@ VideoSender::VideoSender(
|
| cast_environment,
|
| video_config,
|
| gfx::Size(video_config.width, video_config.height),
|
| - base::Bind(&VideoSender::OnEncoderInitialized,
|
| - weak_factory_.GetWeakPtr(),
|
| - initialization_cb)));
|
| + status_change_cb));
|
| }
|
| #endif // defined(OS_MACOSX)
|
| #if !defined(OS_IOS)
|
| @@ -94,18 +89,23 @@ VideoSender::VideoSender(
|
| cast_environment,
|
| video_config,
|
| gfx::Size(video_config.width, video_config.height),
|
| - base::Bind(&VideoSender::OnEncoderInitialized,
|
| - weak_factory_.GetWeakPtr(), initialization_cb),
|
| + status_change_cb,
|
| create_vea_cb,
|
| create_video_encode_mem_cb));
|
| } else if (!video_encoder_) {
|
| // Software encoder is initialized immediately.
|
| video_encoder_.reset(new VideoEncoderImpl(
|
| - cast_environment, video_config, initialization_cb));
|
| - cast_initialization_status_ = STATUS_VIDEO_INITIALIZED;
|
| + cast_environment, video_config, status_change_cb));
|
| }
|
| #endif // !defined(OS_IOS)
|
|
|
| + if (!video_encoder_) {
|
| + cast_environment_->PostTask(
|
| + CastEnvironment::MAIN,
|
| + FROM_HERE,
|
| + base::Bind(status_change_cb, STATUS_UNSUPPORTED_CODEC));
|
| + }
|
| +
|
| media::cast::CastTransportRtpConfig transport_config;
|
| transport_config.ssrc = video_config.ssrc;
|
| transport_config.feedback_ssrc = video_config.receiver_ssrc;
|
| @@ -128,11 +128,11 @@ void VideoSender::InsertRawVideoFrame(
|
| const scoped_refptr<media::VideoFrame>& video_frame,
|
| const base::TimeTicks& reference_time) {
|
| DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
|
| - if (cast_initialization_status_ != STATUS_VIDEO_INITIALIZED) {
|
| +
|
| + if (!video_encoder_) {
|
| NOTREACHED();
|
| return;
|
| }
|
| - DCHECK(video_encoder_.get()) << "Invalid state";
|
|
|
| const RtpTimestamp rtp_timestamp =
|
| TimeDeltaToRtpDelta(video_frame->timestamp(), kVideoFrequency);
|
| @@ -218,9 +218,7 @@ void VideoSender::InsertRawVideoFrame(
|
| }
|
|
|
| scoped_ptr<VideoFrameFactory> VideoSender::CreateVideoFrameFactory() {
|
| - DCHECK(cast_initialization_status_ == STATUS_VIDEO_INITIALIZED);
|
| - DCHECK(video_encoder_.get()) << "Invalid state";
|
| - return video_encoder_->CreateVideoFrameFactory();
|
| + return video_encoder_ ? video_encoder_->CreateVideoFrameFactory() : nullptr;
|
| }
|
|
|
| int VideoSender::GetNumberOfFramesInEncoder() const {
|
| @@ -241,13 +239,6 @@ void VideoSender::OnAck(uint32 frame_id) {
|
| video_encoder_->LatestFrameIdToReference(frame_id);
|
| }
|
|
|
| -void VideoSender::OnEncoderInitialized(
|
| - const CastInitializationCallback& initialization_cb,
|
| - CastInitializationStatus status) {
|
| - cast_initialization_status_ = status;
|
| - initialization_cb.Run(status);
|
| -}
|
| -
|
| void VideoSender::OnEncodedVideoFrame(
|
| int encoder_bitrate,
|
| scoped_ptr<EncodedFrame> encoded_frame) {
|
|
|