Chromium Code Reviews| Index: chrome/renderer/media/cast_session_delegate.cc |
| diff --git a/chrome/renderer/media/cast_session_delegate.cc b/chrome/renderer/media/cast_session_delegate.cc |
| index 3d16c5b8d40e16fd66b3ca26f97bdc94db8fa958..dfcd343b6b450243a61bd47e9251429ff3abff06 100644 |
| --- a/chrome/renderer/media/cast_session_delegate.cc |
| +++ b/chrome/renderer/media/cast_session_delegate.cc |
| @@ -29,6 +29,32 @@ using media::cast::VideoSenderConfig; |
| static base::LazyInstance<CastThreads> g_cast_threads = |
| LAZY_INSTANCE_INITIALIZER; |
| +namespace { |
| + |
| +std::string CastErrorToString(media::cast::CastInitializationStatus status) { |
| + switch (status) { |
| + case media::cast::STATUS_INVALID_CAST_ENVIRONMENT: |
| + return "Invalid cast environment."; |
| + case media::cast::STATUS_INVALID_CRYPTO_CONFIGURATION: |
| + return "Invalid encryption keys."; |
| + case media::cast::STATUS_UNSUPPORTED_AUDIO_CODEC: |
| + return "Audio codec not supported."; |
| + case media::cast::STATUS_UNSUPPORTED_VIDEO_CODEC: |
| + return "Video codec not supported."; |
| + case media::cast::STATUS_INVALID_AUDIO_CONFIGURATION: |
| + return "Invalid audio configuration."; |
| + case media::cast::STATUS_INVALID_VIDEO_CONFIGURATION: |
| + return "Invalid video configuration."; |
| + case media::cast::STATUS_HW_VIDEO_ENCODER_NOT_SUPPORTED: |
| + return "Hardware video encoder not supported."; |
| + default: |
|
hubbe
2014/09/09 00:25:45
Remove the default so that we get a compile error
Alpha Left Google
2014/09/09 00:37:11
Done.
|
| + NOTREACHED() << "Not an error."; |
| + return ""; |
| + } |
| +} |
| + |
| +} // namespace |
| + |
| CastSessionDelegate::CastSessionDelegate() |
| : io_message_loop_proxy_( |
| content::RenderThread::Get()->GetIOMessageLoopProxy()), |
| @@ -55,7 +81,7 @@ void CastSessionDelegate::StartAudio( |
| cast_sender_->InitializeAudio( |
| config, |
| base::Bind(&CastSessionDelegate::InitializationResultCB, |
| - weak_factory_.GetWeakPtr())); |
| + weak_factory_.GetWeakPtr(), error_callback)); |
| } |
| void CastSessionDelegate::StartVideo( |
| @@ -77,7 +103,7 @@ void CastSessionDelegate::StartVideo( |
| cast_sender_->InitializeVideo( |
| config, |
| base::Bind(&CastSessionDelegate::InitializationResultCB, |
| - weak_factory_.GetWeakPtr()), |
| + weak_factory_.GetWeakPtr(), error_callback), |
| create_vea_cb, |
| create_video_encode_mem_cb); |
| } |
| @@ -203,16 +229,18 @@ void CastSessionDelegate::StatusNotificationCB( |
| } |
| void CastSessionDelegate::InitializationResultCB( |
| + const ErrorCallback& error_callback, |
| media::cast::CastInitializationStatus result) const { |
| DCHECK(cast_sender_); |
| - // TODO(pwestin): handle the error codes. |
| if (result == media::cast::STATUS_AUDIO_INITIALIZED) { |
|
hubbe
2014/09/09 00:25:45
might be better to just inline CastErrorToString h
Alpha Left Google
2014/09/09 00:37:11
Done.
|
| audio_frame_input_available_callback_.Run( |
| cast_sender_->audio_frame_input()); |
| } else if (result == media::cast::STATUS_VIDEO_INITIALIZED) { |
| video_frame_input_available_callback_.Run( |
| cast_sender_->video_frame_input()); |
| + } else if (result > media::cast::STATUS_VIDEO_INITIALIZED) { |
| + error_callback.Run(CastErrorToString(result)); |
| } |
| } |