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 "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
9 #include "content/common/media/media_stream_messages.h" | 9 #include "content/common/media/media_stream_messages.h" |
10 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" | 10 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" |
11 #include "content/renderer/render_thread_impl.h" | 11 #include "content/renderer/render_thread_impl.h" |
12 #include "content/renderer/render_view_impl.h" | 12 #include "content/renderer/render_view_impl.h" |
13 #include "media/audio/audio_parameters.h" | |
13 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 14 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 bool RemoveStreamDeviceFromArray(const StreamDeviceInfo device_info, | 21 bool RemoveStreamDeviceFromArray(const StreamDeviceInfo device_info, |
21 StreamDeviceInfoArray* array) { | 22 StreamDeviceInfoArray* array) { |
22 for (StreamDeviceInfoArray::iterator device_it = array->begin(); | 23 for (StreamDeviceInfoArray::iterator device_it = array->begin(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 requests_.erase(it); | 99 requests_.erase(it); |
99 Send(new MediaStreamHostMsg_CancelGenerateStream(routing_id(), | 100 Send(new MediaStreamHostMsg_CancelGenerateStream(routing_id(), |
100 ipc_request)); | 101 ipc_request)); |
101 break; | 102 break; |
102 } | 103 } |
103 } | 104 } |
104 } | 105 } |
105 | 106 |
106 void MediaStreamDispatcher::StopStreamDevice( | 107 void MediaStreamDispatcher::StopStreamDevice( |
107 const StreamDeviceInfo& device_info) { | 108 const StreamDeviceInfo& device_info) { |
109 DCHECK(main_loop_->BelongsToCurrentThread()); | |
108 DVLOG(1) << "MediaStreamDispatcher::StopStreamDevice" | 110 DVLOG(1) << "MediaStreamDispatcher::StopStreamDevice" |
109 << ", {device_id = " << device_info.device.id << "}"; | 111 << ", {device_id = " << device_info.device.id << "}"; |
110 // Remove |device_info| from all streams in |label_stream_map_|. | 112 // Remove |device_info| from all streams in |label_stream_map_|. |
111 bool device_found = false; | 113 bool device_found = false; |
112 LabelStreamMap::iterator stream_it = label_stream_map_.begin(); | 114 LabelStreamMap::iterator stream_it = label_stream_map_.begin(); |
113 while (stream_it != label_stream_map_.end()) { | 115 while (stream_it != label_stream_map_.end()) { |
114 StreamDeviceInfoArray& audio_array = stream_it->second.audio_array; | 116 StreamDeviceInfoArray& audio_array = stream_it->second.audio_array; |
115 StreamDeviceInfoArray& video_array = stream_it->second.video_array; | 117 StreamDeviceInfoArray& video_array = stream_it->second.video_array; |
116 | 118 |
117 if (RemoveStreamDeviceFromArray(device_info, &audio_array) || | 119 if (RemoveStreamDeviceFromArray(device_info, &audio_array) || |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 << request.request_id << ")\n"; | 378 << request.request_id << ")\n"; |
377 } | 379 } |
378 requests_.erase(it); | 380 requests_.erase(it); |
379 break; | 381 break; |
380 } | 382 } |
381 } | 383 } |
382 } | 384 } |
383 | 385 |
384 int MediaStreamDispatcher::audio_session_id(const std::string& label, | 386 int MediaStreamDispatcher::audio_session_id(const std::string& label, |
385 int index) { | 387 int index) { |
388 DCHECK(main_loop_->BelongsToCurrentThread()); | |
386 LabelStreamMap::iterator it = label_stream_map_.find(label); | 389 LabelStreamMap::iterator it = label_stream_map_.find(label); |
387 if (it == label_stream_map_.end() || | 390 if (it == label_stream_map_.end() || |
388 it->second.audio_array.size() <= static_cast<size_t>(index)) { | 391 it->second.audio_array.size() <= static_cast<size_t>(index)) { |
389 return StreamDeviceInfo::kNoId; | 392 return StreamDeviceInfo::kNoId; |
390 } | 393 } |
391 return it->second.audio_array[index].session_id; | 394 return it->second.audio_array[index].session_id; |
392 } | 395 } |
393 | 396 |
394 bool MediaStreamDispatcher::IsStream(const std::string& label) { | 397 bool MediaStreamDispatcher::IsStream(const std::string& label) { |
398 DCHECK(main_loop_->BelongsToCurrentThread()); | |
395 return label_stream_map_.find(label) != label_stream_map_.end(); | 399 return label_stream_map_.find(label) != label_stream_map_.end(); |
396 } | 400 } |
397 | 401 |
398 int MediaStreamDispatcher::video_session_id(const std::string& label, | 402 int MediaStreamDispatcher::video_session_id(const std::string& label, |
399 int index) { | 403 int index) { |
404 DCHECK(main_loop_->BelongsToCurrentThread()); | |
400 LabelStreamMap::iterator it = label_stream_map_.find(label); | 405 LabelStreamMap::iterator it = label_stream_map_.find(label); |
401 if (it == label_stream_map_.end() || | 406 if (it == label_stream_map_.end() || |
402 it->second.video_array.size() <= static_cast<size_t>(index)) { | 407 it->second.video_array.size() <= static_cast<size_t>(index)) { |
403 return StreamDeviceInfo::kNoId; | 408 return StreamDeviceInfo::kNoId; |
404 } | 409 } |
405 return it->second.video_array[index].session_id; | 410 return it->second.video_array[index].session_id; |
406 } | 411 } |
407 | 412 |
413 bool MediaStreamDispatcher::IsAudioDuckingActive() const { | |
414 DCHECK(main_loop_->BelongsToCurrentThread()); | |
415 LabelStreamMap::const_iterator stream_it = label_stream_map_.begin(); | |
416 while (stream_it != label_stream_map_.end()) { | |
417 const StreamDeviceInfoArray& audio_array = stream_it->second.audio_array; | |
418 for (StreamDeviceInfoArray::const_iterator device_it = audio_array.begin(); | |
419 device_it != audio_array.end(); ++device_it) { | |
420 if (device_it->device.input.effects && media::AudioParameters::DUCKING) | |
no longer working on chromium
2014/07/08 10:42:35
should it be & instead of && ?
tommi (sloooow) - chröme
2014/07/08 12:30:56
Ah, good catch!
| |
421 return true; | |
422 } | |
423 ++stream_it; | |
424 } | |
425 return false; | |
426 } | |
427 | |
408 } // namespace content | 428 } // namespace content |
OLD | NEW |