| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/media/cast_session_delegate.h" | 5 #include "chrome/renderer/media/cast_session_delegate.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "media/cast/cast_config.h" | 22 #include "media/cast/cast_config.h" |
| 23 #include "media/cast/cast_environment.h" | 23 #include "media/cast/cast_environment.h" |
| 24 #include "media/cast/cast_sender.h" | 24 #include "media/cast/cast_sender.h" |
| 25 #include "media/cast/logging/log_serializer.h" | 25 #include "media/cast/logging/log_serializer.h" |
| 26 #include "media/cast/logging/logging_defines.h" | 26 #include "media/cast/logging/logging_defines.h" |
| 27 #include "media/cast/logging/proto/raw_events.pb.h" | 27 #include "media/cast/logging/proto/raw_events.pb.h" |
| 28 #include "media/cast/logging/raw_event_subscriber_bundle.h" | 28 #include "media/cast/logging/raw_event_subscriber_bundle.h" |
| 29 #include "media/cast/net/cast_transport.h" | 29 #include "media/cast/net/cast_transport.h" |
| 30 #include "media/cast/net/cast_transport_config.h" | 30 #include "media/cast/net/cast_transport_config.h" |
| 31 | 31 |
| 32 using media::cast::AudioSenderConfig; |
| 32 using media::cast::CastEnvironment; | 33 using media::cast::CastEnvironment; |
| 33 using media::cast::CastSender; | 34 using media::cast::CastSender; |
| 34 using media::cast::FrameSenderConfig; | 35 using media::cast::VideoSenderConfig; |
| 35 | 36 |
| 36 static base::LazyInstance<CastThreads> g_cast_threads = | 37 static base::LazyInstance<CastThreads> g_cast_threads = |
| 37 LAZY_INSTANCE_INITIALIZER; | 38 LAZY_INSTANCE_INITIALIZER; |
| 38 | 39 |
| 39 CastSessionDelegateBase::CastSessionDelegateBase() | 40 CastSessionDelegateBase::CastSessionDelegateBase() |
| 40 : io_task_runner_( | 41 : io_task_runner_( |
| 41 content::RenderThread::Get()->GetIOMessageLoopProxy()), | 42 content::RenderThread::Get()->GetIOMessageLoopProxy()), |
| 42 weak_factory_(this) { | 43 weak_factory_(this) { |
| 43 DCHECK(io_task_runner_.get()); | 44 DCHECK(io_task_runner_.get()); |
| 44 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 CastSessionDelegate::CastSessionDelegate() | 110 CastSessionDelegate::CastSessionDelegate() |
| 110 : weak_factory_(this) { | 111 : weak_factory_(this) { |
| 111 DCHECK(io_task_runner_.get()); | 112 DCHECK(io_task_runner_.get()); |
| 112 } | 113 } |
| 113 | 114 |
| 114 CastSessionDelegate::~CastSessionDelegate() { | 115 CastSessionDelegate::~CastSessionDelegate() { |
| 115 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 116 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
| 116 } | 117 } |
| 117 | 118 |
| 118 void CastSessionDelegate::StartAudio( | 119 void CastSessionDelegate::StartAudio( |
| 119 const FrameSenderConfig& config, | 120 const AudioSenderConfig& config, |
| 120 const AudioFrameInputAvailableCallback& callback, | 121 const AudioFrameInputAvailableCallback& callback, |
| 121 const ErrorCallback& error_callback) { | 122 const ErrorCallback& error_callback) { |
| 122 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 123 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
| 123 | 124 |
| 124 if (!cast_transport_ || !cast_sender_) { | 125 if (!cast_transport_ || !cast_sender_) { |
| 125 error_callback.Run("Destination not set."); | 126 error_callback.Run("Destination not set."); |
| 126 return; | 127 return; |
| 127 } | 128 } |
| 128 | 129 |
| 129 audio_frame_input_available_callback_ = callback; | 130 audio_frame_input_available_callback_ = callback; |
| 130 cast_sender_->InitializeAudio( | 131 cast_sender_->InitializeAudio( |
| 131 config, | 132 config, |
| 132 base::Bind(&CastSessionDelegate::OnOperationalStatusChange, | 133 base::Bind(&CastSessionDelegate::OnOperationalStatusChange, |
| 133 weak_factory_.GetWeakPtr(), true, error_callback)); | 134 weak_factory_.GetWeakPtr(), true, error_callback)); |
| 134 } | 135 } |
| 135 | 136 |
| 136 void CastSessionDelegate::StartVideo( | 137 void CastSessionDelegate::StartVideo( |
| 137 const FrameSenderConfig& config, | 138 const VideoSenderConfig& config, |
| 138 const VideoFrameInputAvailableCallback& callback, | 139 const VideoFrameInputAvailableCallback& callback, |
| 139 const ErrorCallback& error_callback, | 140 const ErrorCallback& error_callback, |
| 140 const media::cast::CreateVideoEncodeAcceleratorCallback& create_vea_cb, | 141 const media::cast::CreateVideoEncodeAcceleratorCallback& create_vea_cb, |
| 141 const media::cast::CreateVideoEncodeMemoryCallback& | 142 const media::cast::CreateVideoEncodeMemoryCallback& |
| 142 create_video_encode_mem_cb) { | 143 create_video_encode_mem_cb) { |
| 143 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 144 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
| 144 | 145 |
| 145 if (!cast_transport_ || !cast_sender_) { | 146 if (!cast_transport_ || !cast_sender_) { |
| 146 error_callback.Run("Destination not set."); | 147 error_callback.Run("Destination not set."); |
| 147 return; | 148 return; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 error_callback.Run(base::StringPrintf("%s codec runtime error.", | 307 error_callback.Run(base::StringPrintf("%s codec runtime error.", |
| 307 is_for_audio ? "Audio" : "Video")); | 308 is_for_audio ? "Audio" : "Video")); |
| 308 break; | 309 break; |
| 309 } | 310 } |
| 310 } | 311 } |
| 311 | 312 |
| 312 void CastSessionDelegate::ReceivePacket( | 313 void CastSessionDelegate::ReceivePacket( |
| 313 std::unique_ptr<media::cast::Packet> packet) { | 314 std::unique_ptr<media::cast::Packet> packet) { |
| 314 // Do nothing (frees packet) | 315 // Do nothing (frees packet) |
| 315 } | 316 } |
| OLD | NEW |