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; | |
33 using media::cast::CastEnvironment; | 32 using media::cast::CastEnvironment; |
34 using media::cast::CastSender; | 33 using media::cast::CastSender; |
35 using media::cast::VideoSenderConfig; | 34 using media::cast::FrameSenderConfig; |
36 | 35 |
37 static base::LazyInstance<CastThreads> g_cast_threads = | 36 static base::LazyInstance<CastThreads> g_cast_threads = |
38 LAZY_INSTANCE_INITIALIZER; | 37 LAZY_INSTANCE_INITIALIZER; |
39 | 38 |
40 CastSessionDelegateBase::CastSessionDelegateBase() | 39 CastSessionDelegateBase::CastSessionDelegateBase() |
41 : io_task_runner_( | 40 : io_task_runner_( |
42 content::RenderThread::Get()->GetIOMessageLoopProxy()), | 41 content::RenderThread::Get()->GetIOMessageLoopProxy()), |
43 weak_factory_(this) { | 42 weak_factory_(this) { |
44 DCHECK(io_task_runner_.get()); | 43 DCHECK(io_task_runner_.get()); |
45 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 CastSessionDelegate::CastSessionDelegate() | 109 CastSessionDelegate::CastSessionDelegate() |
111 : weak_factory_(this) { | 110 : weak_factory_(this) { |
112 DCHECK(io_task_runner_.get()); | 111 DCHECK(io_task_runner_.get()); |
113 } | 112 } |
114 | 113 |
115 CastSessionDelegate::~CastSessionDelegate() { | 114 CastSessionDelegate::~CastSessionDelegate() { |
116 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 115 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
117 } | 116 } |
118 | 117 |
119 void CastSessionDelegate::StartAudio( | 118 void CastSessionDelegate::StartAudio( |
120 const AudioSenderConfig& config, | 119 const FrameSenderConfig& config, |
121 const AudioFrameInputAvailableCallback& callback, | 120 const AudioFrameInputAvailableCallback& callback, |
122 const ErrorCallback& error_callback) { | 121 const ErrorCallback& error_callback) { |
123 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 122 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
124 | 123 |
125 if (!cast_transport_ || !cast_sender_) { | 124 if (!cast_transport_ || !cast_sender_) { |
126 error_callback.Run("Destination not set."); | 125 error_callback.Run("Destination not set."); |
127 return; | 126 return; |
128 } | 127 } |
129 | 128 |
130 audio_frame_input_available_callback_ = callback; | 129 audio_frame_input_available_callback_ = callback; |
131 cast_sender_->InitializeAudio( | 130 cast_sender_->InitializeAudio( |
132 config, | 131 config, |
133 base::Bind(&CastSessionDelegate::OnOperationalStatusChange, | 132 base::Bind(&CastSessionDelegate::OnOperationalStatusChange, |
134 weak_factory_.GetWeakPtr(), true, error_callback)); | 133 weak_factory_.GetWeakPtr(), true, error_callback)); |
135 } | 134 } |
136 | 135 |
137 void CastSessionDelegate::StartVideo( | 136 void CastSessionDelegate::StartVideo( |
138 const VideoSenderConfig& config, | 137 const FrameSenderConfig& config, |
139 const VideoFrameInputAvailableCallback& callback, | 138 const VideoFrameInputAvailableCallback& callback, |
140 const ErrorCallback& error_callback, | 139 const ErrorCallback& error_callback, |
141 const media::cast::CreateVideoEncodeAcceleratorCallback& create_vea_cb, | 140 const media::cast::CreateVideoEncodeAcceleratorCallback& create_vea_cb, |
142 const media::cast::CreateVideoEncodeMemoryCallback& | 141 const media::cast::CreateVideoEncodeMemoryCallback& |
143 create_video_encode_mem_cb) { | 142 create_video_encode_mem_cb) { |
144 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 143 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
145 | 144 |
146 if (!cast_transport_ || !cast_sender_) { | 145 if (!cast_transport_ || !cast_sender_) { |
147 error_callback.Run("Destination not set."); | 146 error_callback.Run("Destination not set."); |
148 return; | 147 return; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 error_callback.Run(base::StringPrintf("%s codec runtime error.", | 306 error_callback.Run(base::StringPrintf("%s codec runtime error.", |
308 is_for_audio ? "Audio" : "Video")); | 307 is_for_audio ? "Audio" : "Video")); |
309 break; | 308 break; |
310 } | 309 } |
311 } | 310 } |
312 | 311 |
313 void CastSessionDelegate::ReceivePacket( | 312 void CastSessionDelegate::ReceivePacket( |
314 std::unique_ptr<media::cast::Packet> packet) { | 313 std::unique_ptr<media::cast::Packet> packet) { |
315 // Do nothing (frees packet) | 314 // Do nothing (frees packet) |
316 } | 315 } |
OLD | NEW |