Index: content/renderer/media/media_stream_dispatcher.cc |
diff --git a/content/renderer/media/media_stream_dispatcher.cc b/content/renderer/media/media_stream_dispatcher.cc |
index 5d97ca0135a04ff79a8b149e1662bca9321c0b68..0235ea0f4bfbe0ac6de4b02c1a0509088473311a 100644 |
--- a/content/renderer/media/media_stream_dispatcher.cc |
+++ b/content/renderer/media/media_stream_dispatcher.cc |
@@ -81,6 +81,24 @@ void MediaStreamDispatcher::GenerateStream( |
security_origin)); |
} |
+void MediaStreamDispatcher::GenerateStreamForDevice( |
+ int request_id, |
+ const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
+ media_stream::StreamOptions components, |
+ const std::string& device_id, |
+ const GURL& security_origin) { |
+ DCHECK(main_loop_->BelongsToCurrentThread()); |
+ DVLOG(1) << "MediaStreamDispatcher::GenerateStreamForDevice(" |
+ << request_id << ")"; |
+ |
+ requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); |
+ Send(new MediaStreamHostMsg_GenerateStreamForDevice(routing_id(), |
+ next_ipc_id_++, |
+ components, |
+ device_id, |
+ security_origin)); |
+} |
+ |
void MediaStreamDispatcher::CancelGenerateStream(int request_id) { |
DCHECK(main_loop_->BelongsToCurrentThread()); |
DVLOG(1) << "MediaStreamDispatcher::CancelGenerateStream" |
@@ -117,26 +135,23 @@ void MediaStreamDispatcher::EnumerateDevices( |
media_stream::MediaStreamType type, |
const GURL& security_origin) { |
DCHECK(main_loop_->BelongsToCurrentThread()); |
- DCHECK(type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE || |
- type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE); |
+ DCHECK_LT(content::MEDIA_NO_SERVICE, type); |
+ DCHECK_GT(content::NUM_MEDIA_TYPES, type); |
wjia(left Chromium)
2012/09/07 17:16:30
For now, EnumerateDevices are still restricted to
miu
2012/09/07 23:14:28
Done. Also, reverted EnumerateDevices/StopEnumera
|
DVLOG(1) << "MediaStreamDispatcher::EnumerateDevices(" |
<< request_id << ")"; |
- EnumerationState* state = |
- (type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE ? |
- &audio_enumeration_state_ : &video_enumeration_state_); |
- state->requests.push_back( |
- EnumerationRequest(event_handler, request_id)); |
+ EnumerationState& state = enumeration_state_[type]; |
+ state.requests.push_back(EnumerationRequest(event_handler, request_id)); |
- if (state->cached_devices.get()) { |
+ if (state.cached_devices.get()) { |
event_handler->OnDevicesEnumerated( |
- request_id, state->cached_devices->devices); |
- } else if (state->ipc_id < 0) { |
+ request_id, state.cached_devices->devices); |
+ } else if (state.ipc_id < 0) { |
Send(new MediaStreamHostMsg_EnumerateDevices(routing_id(), |
next_ipc_id_, |
type, |
security_origin)); |
- state->ipc_id = next_ipc_id_++; |
+ state.ipc_id = next_ipc_id_++; |
} |
} |
@@ -148,10 +163,10 @@ void MediaStreamDispatcher::StopEnumerateDevices( |
<< request_id << ")"; |
// Remove the request. |
- RemoveEnumerationRequest( |
- request_id, event_handler, &audio_enumeration_state_); |
- RemoveEnumerationRequest( |
- request_id, event_handler, &video_enumeration_state_); |
+ for (int i = content::MEDIA_NO_SERVICE + 1; i < content::NUM_MEDIA_TYPES; |
+ ++i) { |
+ RemoveEnumerationRequest(request_id, event_handler, &enumeration_state_[i]); |
+ } |
} |
void MediaStreamDispatcher::RemoveEnumerationRequest( |
@@ -309,12 +324,15 @@ void MediaStreamDispatcher::OnDevicesEnumerated( |
DCHECK(main_loop_->BelongsToCurrentThread()); |
DCHECK_GE(request_id, 0); |
- EnumerationState* state; |
- if (request_id == audio_enumeration_state_.ipc_id) { |
- state = &audio_enumeration_state_; |
- } else if (request_id == video_enumeration_state_.ipc_id) { |
- state = &video_enumeration_state_; |
- } else { |
+ EnumerationState* state = NULL; |
+ for (int i = content::MEDIA_NO_SERVICE + 1; i < content::NUM_MEDIA_TYPES; |
+ ++i) { |
+ if (request_id == enumeration_state_[i].ipc_id) { |
+ state = &enumeration_state_[i]; |
+ break; |
+ } |
+ } |
+ if (state == NULL) { |
// This could happen when requester has stopped enumeration while some |
// enumerated response is on the way. Have to stop the |label| because |
// this might be the first enumerated device list is received. This also |
@@ -365,11 +383,12 @@ void MediaStreamDispatcher::OnDeviceOpened( |
if (request.ipc_request == request_id) { |
Stream new_stream; |
new_stream.handler = request.handler; |
- if (device_info.stream_type == |
- content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) { |
+ if (content::IsAudioMediaType(device_info.stream_type)) { |
+ new_stream.audio_array.push_back(device_info); |
+ } else if (content::IsVideoMediaType(device_info.stream_type)) { |
new_stream.video_array.push_back(device_info); |
} else { |
- new_stream.audio_array.push_back(device_info); |
+ NOTREACHED(); |
} |
label_stream_map_[label] = new_stream; |
if (request.handler) { |