| 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..866d68c504229a4f10c7f6994160d2745ddfc673 100644
|
| --- a/content/renderer/media/media_stream_dispatcher.cc
|
| +++ b/content/renderer/media/media_stream_dispatcher.cc
|
| @@ -117,26 +117,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);
|
| 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 +145,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 +306,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 +365,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) {
|
|
|