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_proxy.h" | 8 #include "base/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" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE || | 123 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE || |
124 type == MEDIA_DEVICE_VIDEO_CAPTURE); | 124 type == MEDIA_DEVICE_VIDEO_CAPTURE); |
125 DVLOG(1) << "MediaStreamDispatcher::EnumerateDevices(" | 125 DVLOG(1) << "MediaStreamDispatcher::EnumerateDevices(" |
126 << request_id << ")"; | 126 << request_id << ")"; |
127 | 127 |
128 EnumerationState* state = | 128 EnumerationState* state = |
129 (type == MEDIA_DEVICE_AUDIO_CAPTURE ? | 129 (type == MEDIA_DEVICE_AUDIO_CAPTURE ? |
130 &audio_enumeration_state_ : &video_enumeration_state_); | 130 &audio_enumeration_state_ : &video_enumeration_state_); |
131 state->requests.push_back(EnumerationRequest(event_handler, request_id)); | 131 state->requests.push_back(EnumerationRequest(event_handler, request_id)); |
132 | 132 |
133 if (state->cached_devices.get()) { | 133 if (state->cached_devices) { |
134 event_handler->OnDevicesEnumerated( | 134 event_handler->OnDevicesEnumerated( |
135 request_id, state->cached_devices->devices); | 135 request_id, state->cached_devices->devices); |
136 } else if (state->ipc_id < 0) { | 136 } else if (state->ipc_id < 0) { |
137 Send(new MediaStreamHostMsg_EnumerateDevices(routing_id(), | 137 Send(new MediaStreamHostMsg_EnumerateDevices(routing_id(), |
138 next_ipc_id_, | 138 next_ipc_id_, |
139 type, | 139 type, |
140 security_origin)); | 140 security_origin)); |
141 state->ipc_id = next_ipc_id_++; | 141 state->ipc_id = next_ipc_id_++; |
142 } | 142 } |
143 } | 143 } |
(...skipping 14 matching lines...) Expand all Loading... |
158 | 158 |
159 void MediaStreamDispatcher::RemoveEnumerationRequest( | 159 void MediaStreamDispatcher::RemoveEnumerationRequest( |
160 int request_id, | 160 int request_id, |
161 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 161 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
162 EnumerationState* state) { | 162 EnumerationState* state) { |
163 EnumerationRequestList* requests = &state->requests; | 163 EnumerationRequestList* requests = &state->requests; |
164 for (EnumerationRequestList::iterator it = requests->begin(); | 164 for (EnumerationRequestList::iterator it = requests->begin(); |
165 it != requests->end(); ++it) { | 165 it != requests->end(); ++it) { |
166 if (it->request_id == request_id && it->handler == event_handler) { | 166 if (it->request_id == request_id && it->handler == event_handler) { |
167 requests->erase(it); | 167 requests->erase(it); |
168 if (requests->empty() && state->cached_devices.get()) { | 168 if (requests->empty() && state->cached_devices) { |
169 // No more request and has a label, try to stop the label | 169 // No more request and has a label, try to stop the label |
170 // and invalidate the state. | 170 // and invalidate the state. |
171 Send(new MediaStreamHostMsg_StopGeneratedStream( | 171 Send(new MediaStreamHostMsg_StopGeneratedStream( |
172 routing_id(), state->cached_devices->label)); | 172 routing_id(), state->cached_devices->label)); |
173 state->ipc_id = -1; | 173 state->ipc_id = -1; |
174 state->cached_devices.reset(); | 174 state->cached_devices.reset(); |
175 } | 175 } |
176 return; | 176 return; |
177 } | 177 } |
178 } | 178 } |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 int index) { | 386 int index) { |
387 LabelStreamMap::iterator it = label_stream_map_.find(label); | 387 LabelStreamMap::iterator it = label_stream_map_.find(label); |
388 if (it == label_stream_map_.end()) | 388 if (it == label_stream_map_.end()) |
389 return StreamDeviceInfo::kNoId; | 389 return StreamDeviceInfo::kNoId; |
390 | 390 |
391 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); | 391 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); |
392 return it->second.video_array[index].session_id; | 392 return it->second.video_array[index].session_id; |
393 } | 393 } |
394 | 394 |
395 } // namespace content | 395 } // namespace content |
OLD | NEW |