OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/media/media_stream_dispatcher.h" | 5 #include "content/renderer/media/media_stream_dispatcher.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/common/media/media_stream_messages.h" | 8 #include "content/common/media/media_stream_messages.h" |
9 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" | 9 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" |
10 #include "content/renderer/render_view_impl.h" | 10 #include "content/renderer/render_view_impl.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 StopStream(label); | 218 StopStream(label); |
219 } | 219 } |
220 | 220 |
221 bool MediaStreamDispatcher::OnMessageReceived(const IPC::Message& message) { | 221 bool MediaStreamDispatcher::OnMessageReceived(const IPC::Message& message) { |
222 bool handled = true; | 222 bool handled = true; |
223 IPC_BEGIN_MESSAGE_MAP(MediaStreamDispatcher, message) | 223 IPC_BEGIN_MESSAGE_MAP(MediaStreamDispatcher, message) |
224 IPC_MESSAGE_HANDLER(MediaStreamMsg_StreamGenerated, | 224 IPC_MESSAGE_HANDLER(MediaStreamMsg_StreamGenerated, |
225 OnStreamGenerated) | 225 OnStreamGenerated) |
226 IPC_MESSAGE_HANDLER(MediaStreamMsg_StreamGenerationFailed, | 226 IPC_MESSAGE_HANDLER(MediaStreamMsg_StreamGenerationFailed, |
227 OnStreamGenerationFailed) | 227 OnStreamGenerationFailed) |
228 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_VideoDeviceFailed, | |
229 OnVideoDeviceFailed) | |
230 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_AudioDeviceFailed, | |
231 OnAudioDeviceFailed) | |
232 IPC_MESSAGE_HANDLER(MediaStreamMsg_DevicesEnumerated, | 228 IPC_MESSAGE_HANDLER(MediaStreamMsg_DevicesEnumerated, |
233 OnDevicesEnumerated) | 229 OnDevicesEnumerated) |
234 IPC_MESSAGE_HANDLER(MediaStreamMsg_DevicesEnumerationFailed, | 230 IPC_MESSAGE_HANDLER(MediaStreamMsg_DevicesEnumerationFailed, |
235 OnDevicesEnumerationFailed) | 231 OnDevicesEnumerationFailed) |
236 IPC_MESSAGE_HANDLER(MediaStreamMsg_DeviceOpened, | 232 IPC_MESSAGE_HANDLER(MediaStreamMsg_DeviceOpened, |
237 OnDeviceOpened) | 233 OnDeviceOpened) |
238 IPC_MESSAGE_HANDLER(MediaStreamMsg_DeviceOpenFailed, | 234 IPC_MESSAGE_HANDLER(MediaStreamMsg_DeviceOpenFailed, |
239 OnDeviceOpenFailed) | 235 OnDeviceOpenFailed) |
240 IPC_MESSAGE_UNHANDLED(handled = false) | 236 IPC_MESSAGE_UNHANDLED(handled = false) |
241 IPC_END_MESSAGE_MAP() | 237 IPC_END_MESSAGE_MAP() |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 request.handler->OnStreamGenerationFailed(request.request_id); | 276 request.handler->OnStreamGenerationFailed(request.request_id); |
281 DVLOG(1) << "MediaStreamDispatcher::OnStreamGenerationFailed(" | 277 DVLOG(1) << "MediaStreamDispatcher::OnStreamGenerationFailed(" |
282 << request.request_id << ")\n"; | 278 << request.request_id << ")\n"; |
283 } | 279 } |
284 requests_.erase(it); | 280 requests_.erase(it); |
285 break; | 281 break; |
286 } | 282 } |
287 } | 283 } |
288 } | 284 } |
289 | 285 |
290 void MediaStreamDispatcher::OnVideoDeviceFailed(const std::string& label, | |
291 int index) { | |
292 DCHECK(main_loop_->BelongsToCurrentThread()); | |
293 LabelStreamMap::iterator it = label_stream_map_.find(label); | |
294 if (it == label_stream_map_.end()) | |
295 return; | |
296 | |
297 // index is the index in the video_array that has failed. | |
298 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); | |
299 media_stream::StreamDeviceInfoArray::iterator device_it = | |
300 it->second.video_array.begin(); | |
301 it->second.video_array.erase(device_it + index); | |
302 if (it->second.handler) | |
303 it->second.handler->OnVideoDeviceFailed(label, index); | |
304 } | |
305 | |
306 void MediaStreamDispatcher::OnAudioDeviceFailed(const std::string& label, | |
307 int index) { | |
308 DCHECK(main_loop_->BelongsToCurrentThread()); | |
309 LabelStreamMap::iterator it = label_stream_map_.find(label); | |
310 if (it == label_stream_map_.end()) | |
311 return; | |
312 | |
313 // index is the index in the audio_array that has failed. | |
314 DCHECK_GT(it->second.audio_array.size(), static_cast<size_t>(index)); | |
315 media_stream::StreamDeviceInfoArray::iterator device_it = | |
316 it->second.audio_array.begin(); | |
317 it->second.audio_array.erase(device_it + index); | |
318 if (it->second.handler) | |
319 it->second.handler->OnAudioDeviceFailed(label, index); | |
320 } | |
321 | |
322 void MediaStreamDispatcher::OnDevicesEnumerated( | 286 void MediaStreamDispatcher::OnDevicesEnumerated( |
323 int request_id, | 287 int request_id, |
324 const std::string& label, | 288 const std::string& label, |
325 const media_stream::StreamDeviceInfoArray& device_array) { | 289 const media_stream::StreamDeviceInfoArray& device_array) { |
326 DCHECK(main_loop_->BelongsToCurrentThread()); | 290 DCHECK(main_loop_->BelongsToCurrentThread()); |
327 DCHECK_GE(request_id, 0); | 291 DCHECK_GE(request_id, 0); |
328 | 292 |
329 EnumerationState* state; | 293 EnumerationState* state; |
330 if (request_id == audio_enumeration_state_.ipc_id) { | 294 if (request_id == audio_enumeration_state_.ipc_id) { |
331 state = &audio_enumeration_state_; | 295 state = &audio_enumeration_state_; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 | 399 |
436 int MediaStreamDispatcher::video_session_id(const std::string& label, | 400 int MediaStreamDispatcher::video_session_id(const std::string& label, |
437 int index) { | 401 int index) { |
438 LabelStreamMap::iterator it = label_stream_map_.find(label); | 402 LabelStreamMap::iterator it = label_stream_map_.find(label); |
439 if (it == label_stream_map_.end()) | 403 if (it == label_stream_map_.end()) |
440 return media_stream::StreamDeviceInfo::kNoId; | 404 return media_stream::StreamDeviceInfo::kNoId; |
441 | 405 |
442 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); | 406 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); |
443 return it->second.video_array[index].session_id; | 407 return it->second.video_array[index].session_id; |
444 } | 408 } |
OLD | NEW |