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 13 matching lines...) Expand all Loading... | |
24 }; | 24 }; |
25 | 25 |
26 struct MediaStreamDispatcher::Stream { | 26 struct MediaStreamDispatcher::Stream { |
27 Stream() {} | 27 Stream() {} |
28 ~Stream() {} | 28 ~Stream() {} |
29 base::WeakPtr<MediaStreamDispatcherEventHandler> handler; | 29 base::WeakPtr<MediaStreamDispatcherEventHandler> handler; |
30 media_stream::StreamDeviceInfoArray audio_array; | 30 media_stream::StreamDeviceInfoArray audio_array; |
31 media_stream::StreamDeviceInfoArray video_array; | 31 media_stream::StreamDeviceInfoArray video_array; |
32 }; | 32 }; |
33 | 33 |
34 MediaStreamDispatcher::EnumerationRequest::EnumerationRequest( | |
35 const base::WeakPtr<MediaStreamDispatcherEventHandler>& handler, | |
36 int request_id) | |
37 : handler(handler), | |
38 request_id(request_id) { | |
39 } | |
40 | |
41 MediaStreamDispatcher::EnumerationState::EnumerationState() | |
42 : started(false), | |
43 ipc_id(0), | |
44 cache_valid(false) { | |
45 } | |
46 | |
34 MediaStreamDispatcher::MediaStreamDispatcher(RenderViewImpl* render_view) | 47 MediaStreamDispatcher::MediaStreamDispatcher(RenderViewImpl* render_view) |
35 : content::RenderViewObserver(render_view), | 48 : content::RenderViewObserver(render_view), |
49 main_loop_(MessageLoop::current()), | |
36 next_ipc_id_(0) { | 50 next_ipc_id_(0) { |
37 } | 51 } |
38 | 52 |
39 MediaStreamDispatcher::~MediaStreamDispatcher() {} | 53 MediaStreamDispatcher::~MediaStreamDispatcher() {} |
40 | 54 |
41 void MediaStreamDispatcher::GenerateStream( | 55 void MediaStreamDispatcher::GenerateStream( |
42 int request_id, | 56 int request_id, |
43 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 57 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
44 media_stream::StreamOptions components, | 58 media_stream::StreamOptions components, |
45 const GURL& security_origin) { | 59 const GURL& security_origin) { |
60 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
tommi (sloooow) - chröme
2012/08/01 10:21:38
I really like all the added DCHECKS in this file!
| |
46 DVLOG(1) << "MediaStreamDispatcher::GenerateStream(" << request_id << ")"; | 61 DVLOG(1) << "MediaStreamDispatcher::GenerateStream(" << request_id << ")"; |
47 | 62 |
48 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); | 63 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); |
49 Send(new MediaStreamHostMsg_GenerateStream(routing_id(), | 64 Send(new MediaStreamHostMsg_GenerateStream(routing_id(), |
50 next_ipc_id_++, | 65 next_ipc_id_++, |
51 components, | 66 components, |
52 security_origin)); | 67 security_origin)); |
53 } | 68 } |
54 | 69 |
55 void MediaStreamDispatcher::CancelGenerateStream(int request_id) { | 70 void MediaStreamDispatcher::CancelGenerateStream(int request_id) { |
71 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
56 DVLOG(1) << "MediaStreamDispatcher::CancelGenerateStream" | 72 DVLOG(1) << "MediaStreamDispatcher::CancelGenerateStream" |
57 << ", {request_id = " << request_id << "}"; | 73 << ", {request_id = " << request_id << "}"; |
58 | 74 |
59 RequestList::iterator it = requests_.begin(); | 75 RequestList::iterator it = requests_.begin(); |
60 for (; it != requests_.end(); ++it) { | 76 for (; it != requests_.end(); ++it) { |
61 Request& request = *it; | 77 Request& request = *it; |
62 if (request.request_id == request_id) { | 78 if (request.request_id == request_id) { |
63 requests_.erase(it); | 79 requests_.erase(it); |
64 Send(new MediaStreamHostMsg_CancelGenerateStream(routing_id(), | 80 Send(new MediaStreamHostMsg_CancelGenerateStream(routing_id(), |
65 request_id)); | 81 request_id)); |
66 break; | 82 break; |
67 } | 83 } |
68 } | 84 } |
69 } | 85 } |
70 | 86 |
71 void MediaStreamDispatcher::StopStream(const std::string& label) { | 87 void MediaStreamDispatcher::StopStream(const std::string& label) { |
88 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
72 DVLOG(1) << "MediaStreamDispatcher::StopStream" | 89 DVLOG(1) << "MediaStreamDispatcher::StopStream" |
73 << ", {label = " << label << "}"; | 90 << ", {label = " << label << "}"; |
74 | 91 |
75 LabelStreamMap::iterator it = label_stream_map_.find(label); | 92 LabelStreamMap::iterator it = label_stream_map_.find(label); |
76 if (it == label_stream_map_.end()) | 93 if (it == label_stream_map_.end()) |
77 return; | 94 return; |
78 | 95 |
79 Send(new MediaStreamHostMsg_StopGeneratedStream(routing_id(), label)); | 96 Send(new MediaStreamHostMsg_StopGeneratedStream(routing_id(), label)); |
80 label_stream_map_.erase(it); | 97 label_stream_map_.erase(it); |
81 } | 98 } |
82 | 99 |
83 void MediaStreamDispatcher::EnumerateDevices( | 100 void MediaStreamDispatcher::EnumerateDevices( |
84 int request_id, | 101 int request_id, |
85 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 102 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
86 media_stream::MediaStreamType type, | 103 media_stream::MediaStreamType type, |
87 const GURL& security_origin) { | 104 const GURL& security_origin) { |
105 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
106 DCHECK(type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE || | |
107 type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE); | |
88 DVLOG(1) << "MediaStreamDispatcher::EnumerateDevices(" | 108 DVLOG(1) << "MediaStreamDispatcher::EnumerateDevices(" |
89 << request_id << ")"; | 109 << request_id << ")"; |
90 | 110 |
91 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); | 111 EnumerationState* state = |
92 Send(new MediaStreamHostMsg_EnumerateDevices(routing_id(), | 112 (type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE ? |
93 next_ipc_id_++, | 113 &audio_enumeration_state_ : &video_enumeration_state_); |
94 type, | 114 state->requests.push_back( |
95 security_origin)); | 115 EnumerationRequest(event_handler, request_id)); |
116 | |
117 if (state->cache_valid) { | |
118 event_handler->OnDevicesEnumerated(request_id, state->cached_device); | |
119 } else if (!state->started) { | |
120 state->started = true; | |
121 Send(new MediaStreamHostMsg_EnumerateDevices(routing_id(), | |
122 next_ipc_id_, | |
123 type, | |
124 security_origin)); | |
125 state->ipc_id = next_ipc_id_++; | |
126 } | |
127 } | |
128 | |
129 void MediaStreamDispatcher::StopEnumerateDevices( | |
130 int request_id, | |
131 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler) { | |
132 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
133 DVLOG(1) << "MediaStreamDispatcher::StopEnumerateDevices(" | |
134 << request_id << ")"; | |
135 | |
136 // Just need remove the request from one type. | |
137 RemoveEnumerationRequest(request_id, event_handler, | |
138 &audio_enumeration_state_) || | |
139 RemoveEnumerationRequest(request_id, event_handler, | |
140 &video_enumeration_state_); | |
141 } | |
142 | |
143 bool MediaStreamDispatcher::RemoveEnumerationRequest( | |
144 int request_id, | |
145 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | |
146 EnumerationState* state) { | |
147 EnumerationRequestList* requests = &state->requests; | |
148 for (EnumerationRequestList::iterator it = requests->begin(); | |
149 it != requests->end(); ++it) { | |
150 if (it->request_id == request_id && it->handler == event_handler) { | |
151 requests->erase(it); | |
152 if (requests->empty() && !state->label.empty()) { | |
153 // No more request and has a label, try to stop the label | |
154 // and invalidate the state. | |
155 Send(new MediaStreamHostMsg_StopGeneratedStream( | |
156 routing_id(), state->label)); | |
157 state->started = false; | |
158 state->cache_valid = false; | |
159 } | |
160 return true; | |
161 } | |
162 } | |
163 return false; | |
96 } | 164 } |
97 | 165 |
98 void MediaStreamDispatcher::OpenDevice( | 166 void MediaStreamDispatcher::OpenDevice( |
99 int request_id, | 167 int request_id, |
100 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 168 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
101 const std::string& device_id, | 169 const std::string& device_id, |
102 media_stream::MediaStreamType type, | 170 media_stream::MediaStreamType type, |
103 const GURL& security_origin) { | 171 const GURL& security_origin) { |
172 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
104 DVLOG(1) << "MediaStreamDispatcher::OpenDevice(" << request_id << ")"; | 173 DVLOG(1) << "MediaStreamDispatcher::OpenDevice(" << request_id << ")"; |
105 | 174 |
106 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); | 175 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); |
107 Send(new MediaStreamHostMsg_OpenDevice(routing_id(), | 176 Send(new MediaStreamHostMsg_OpenDevice(routing_id(), |
108 next_ipc_id_++, | 177 next_ipc_id_++, |
109 device_id, | 178 device_id, |
110 type, | 179 type, |
111 security_origin)); | 180 security_origin)); |
112 } | 181 } |
113 | 182 |
114 void MediaStreamDispatcher::CloseDevice(const std::string& label) { | 183 void MediaStreamDispatcher::CloseDevice(const std::string& label) { |
184 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
115 DVLOG(1) << "MediaStreamDispatcher::CloseDevice" | 185 DVLOG(1) << "MediaStreamDispatcher::CloseDevice" |
116 << ", {label = " << label << "}"; | 186 << ", {label = " << label << "}"; |
117 | 187 |
118 StopStream(label); | 188 StopStream(label); |
119 } | 189 } |
120 | 190 |
121 bool MediaStreamDispatcher::OnMessageReceived(const IPC::Message& message) { | 191 bool MediaStreamDispatcher::OnMessageReceived(const IPC::Message& message) { |
122 bool handled = true; | 192 bool handled = true; |
123 IPC_BEGIN_MESSAGE_MAP(MediaStreamDispatcher, message) | 193 IPC_BEGIN_MESSAGE_MAP(MediaStreamDispatcher, message) |
124 IPC_MESSAGE_HANDLER(MediaStreamMsg_StreamGenerated, | 194 IPC_MESSAGE_HANDLER(MediaStreamMsg_StreamGenerated, |
(...skipping 15 matching lines...) Expand all Loading... | |
140 IPC_MESSAGE_UNHANDLED(handled = false) | 210 IPC_MESSAGE_UNHANDLED(handled = false) |
141 IPC_END_MESSAGE_MAP() | 211 IPC_END_MESSAGE_MAP() |
142 return handled; | 212 return handled; |
143 } | 213 } |
144 | 214 |
145 void MediaStreamDispatcher::OnStreamGenerated( | 215 void MediaStreamDispatcher::OnStreamGenerated( |
146 int request_id, | 216 int request_id, |
147 const std::string& label, | 217 const std::string& label, |
148 const media_stream::StreamDeviceInfoArray& audio_array, | 218 const media_stream::StreamDeviceInfoArray& audio_array, |
149 const media_stream::StreamDeviceInfoArray& video_array) { | 219 const media_stream::StreamDeviceInfoArray& video_array) { |
220 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
150 | 221 |
151 for (RequestList::iterator it = requests_.begin(); | 222 for (RequestList::iterator it = requests_.begin(); |
152 it != requests_.end(); ++it) { | 223 it != requests_.end(); ++it) { |
153 Request& request = *it; | 224 Request& request = *it; |
154 if (request.ipc_request == request_id) { | 225 if (request.ipc_request == request_id) { |
155 Stream new_stream; | 226 Stream new_stream; |
156 new_stream.handler = request.handler; | 227 new_stream.handler = request.handler; |
157 new_stream.audio_array = audio_array; | 228 new_stream.audio_array = audio_array; |
158 new_stream.video_array = video_array; | 229 new_stream.video_array = video_array; |
159 label_stream_map_[label] = new_stream; | 230 label_stream_map_[label] = new_stream; |
160 if (request.handler) { | 231 if (request.handler) { |
161 request.handler->OnStreamGenerated(request.request_id, label, | 232 request.handler->OnStreamGenerated(request.request_id, label, |
162 audio_array, video_array); | 233 audio_array, video_array); |
163 DVLOG(1) << "MediaStreamDispatcher::OnStreamGenerated(" | 234 DVLOG(1) << "MediaStreamDispatcher::OnStreamGenerated(" |
164 << request.request_id << ", " << label << ")"; | 235 << request.request_id << ", " << label << ")"; |
165 } | 236 } |
166 requests_.erase(it); | 237 requests_.erase(it); |
167 break; | 238 break; |
168 } | 239 } |
169 } | 240 } |
170 } | 241 } |
171 | 242 |
172 void MediaStreamDispatcher::OnStreamGenerationFailed(int request_id) { | 243 void MediaStreamDispatcher::OnStreamGenerationFailed(int request_id) { |
244 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
173 for (RequestList::iterator it = requests_.begin(); | 245 for (RequestList::iterator it = requests_.begin(); |
174 it != requests_.end(); ++it) { | 246 it != requests_.end(); ++it) { |
175 Request& request = *it; | 247 Request& request = *it; |
176 if (request.ipc_request == request_id) { | 248 if (request.ipc_request == request_id) { |
177 if (request.handler) { | 249 if (request.handler) { |
178 request.handler->OnStreamGenerationFailed(request.request_id); | 250 request.handler->OnStreamGenerationFailed(request.request_id); |
179 DVLOG(1) << "MediaStreamDispatcher::OnStreamGenerationFailed(" | 251 DVLOG(1) << "MediaStreamDispatcher::OnStreamGenerationFailed(" |
180 << request.request_id << ")\n"; | 252 << request.request_id << ")\n"; |
181 } | 253 } |
182 requests_.erase(it); | 254 requests_.erase(it); |
183 break; | 255 break; |
184 } | 256 } |
185 } | 257 } |
186 } | 258 } |
187 | 259 |
188 void MediaStreamDispatcher::OnVideoDeviceFailed(const std::string& label, | 260 void MediaStreamDispatcher::OnVideoDeviceFailed(const std::string& label, |
189 int index) { | 261 int index) { |
262 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
190 LabelStreamMap::iterator it = label_stream_map_.find(label); | 263 LabelStreamMap::iterator it = label_stream_map_.find(label); |
191 if (it == label_stream_map_.end()) | 264 if (it == label_stream_map_.end()) |
192 return; | 265 return; |
193 | 266 |
194 // index is the index in the video_array that has failed. | 267 // index is the index in the video_array that has failed. |
195 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); | 268 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); |
196 media_stream::StreamDeviceInfoArray::iterator device_it = | 269 media_stream::StreamDeviceInfoArray::iterator device_it = |
197 it->second.video_array.begin(); | 270 it->second.video_array.begin(); |
198 it->second.video_array.erase(device_it + index); | 271 it->second.video_array.erase(device_it + index); |
199 if (it->second.handler) | 272 if (it->second.handler) |
200 it->second.handler->OnVideoDeviceFailed(label, index); | 273 it->second.handler->OnVideoDeviceFailed(label, index); |
201 } | 274 } |
202 | 275 |
203 void MediaStreamDispatcher::OnAudioDeviceFailed(const std::string& label, | 276 void MediaStreamDispatcher::OnAudioDeviceFailed(const std::string& label, |
204 int index) { | 277 int index) { |
278 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
205 LabelStreamMap::iterator it = label_stream_map_.find(label); | 279 LabelStreamMap::iterator it = label_stream_map_.find(label); |
206 if (it == label_stream_map_.end()) | 280 if (it == label_stream_map_.end()) |
207 return; | 281 return; |
208 | 282 |
209 // index is the index in the audio_array that has failed. | 283 // index is the index in the audio_array that has failed. |
210 DCHECK_GT(it->second.audio_array.size(), static_cast<size_t>(index)); | 284 DCHECK_GT(it->second.audio_array.size(), static_cast<size_t>(index)); |
211 media_stream::StreamDeviceInfoArray::iterator device_it = | 285 media_stream::StreamDeviceInfoArray::iterator device_it = |
212 it->second.audio_array.begin(); | 286 it->second.audio_array.begin(); |
213 it->second.audio_array.erase(device_it + index); | 287 it->second.audio_array.erase(device_it + index); |
214 if (it->second.handler) | 288 if (it->second.handler) |
215 it->second.handler->OnAudioDeviceFailed(label, index); | 289 it->second.handler->OnAudioDeviceFailed(label, index); |
216 } | 290 } |
217 | 291 |
218 void MediaStreamDispatcher::OnDevicesEnumerated( | 292 void MediaStreamDispatcher::OnDevicesEnumerated( |
219 int request_id, | 293 int request_id, |
294 const std::string& label, | |
220 const media_stream::StreamDeviceInfoArray& device_array) { | 295 const media_stream::StreamDeviceInfoArray& device_array) { |
296 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
297 EnumerationState* state; | |
298 if (audio_enumeration_state_.started && | |
299 request_id == audio_enumeration_state_.ipc_id) { | |
300 state = &audio_enumeration_state_; | |
301 } else if (video_enumeration_state_.started && | |
302 request_id == video_enumeration_state_.ipc_id) { | |
303 state = &video_enumeration_state_; | |
304 } else { | |
305 return; | |
306 } | |
221 | 307 |
222 for (RequestList::iterator it = requests_.begin(); | 308 DCHECK(!label.empty()); |
223 it != requests_.end(); ++it) { | 309 state->label = label; |
224 Request& request = *it; | 310 state->cache_valid = true; |
225 if (request.ipc_request == request_id) { | 311 state->cached_device = device_array; |
226 if (request.handler) { | 312 |
227 request.handler->OnDevicesEnumerated(request.request_id, device_array); | 313 for (EnumerationRequestList::iterator it = state->requests.begin(); |
228 DVLOG(1) << "MediaStreamDispatcher::OnDevicesEnumerated(" | 314 it != state->requests.end(); ++it) { |
229 << request.request_id << ")"; | 315 if (it->handler) { |
230 } | 316 it->handler->OnDevicesEnumerated(it->request_id, device_array); |
231 requests_.erase(it); | 317 DVLOG(1) << "MediaStreamDispatcher::OnDevicesEnumerated(" |
232 break; | 318 << it->request_id << ")"; |
233 } | 319 } |
234 } | 320 } |
235 } | 321 } |
236 | 322 |
237 void MediaStreamDispatcher::OnDevicesEnumerationFailed(int request_id) { | 323 void MediaStreamDispatcher::OnDevicesEnumerationFailed(int request_id) { |
324 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
238 for (RequestList::iterator it = requests_.begin(); | 325 for (RequestList::iterator it = requests_.begin(); |
239 it != requests_.end(); ++it) { | 326 it != requests_.end(); ++it) { |
240 Request& request = *it; | 327 Request& request = *it; |
241 if (request.ipc_request == request_id) { | 328 if (request.ipc_request == request_id) { |
242 if (request.handler) { | 329 if (request.handler) { |
243 request.handler->OnStreamGenerationFailed(request.request_id); | 330 request.handler->OnStreamGenerationFailed(request.request_id); |
244 DVLOG(1) << "MediaStreamDispatcher::OnDevicesEnumerationFailed(" | 331 DVLOG(1) << "MediaStreamDispatcher::OnDevicesEnumerationFailed(" |
245 << request.request_id << ")\n"; | 332 << request.request_id << ")\n"; |
246 } | 333 } |
247 requests_.erase(it); | 334 requests_.erase(it); |
248 break; | 335 break; |
249 } | 336 } |
250 } | 337 } |
251 } | 338 } |
252 | 339 |
253 void MediaStreamDispatcher::OnDeviceOpened( | 340 void MediaStreamDispatcher::OnDeviceOpened( |
254 int request_id, | 341 int request_id, |
255 const std::string& label, | 342 const std::string& label, |
256 const media_stream::StreamDeviceInfo& device_info) { | 343 const media_stream::StreamDeviceInfo& device_info) { |
344 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
257 for (RequestList::iterator it = requests_.begin(); | 345 for (RequestList::iterator it = requests_.begin(); |
258 it != requests_.end(); ++it) { | 346 it != requests_.end(); ++it) { |
259 Request& request = *it; | 347 Request& request = *it; |
260 if (request.ipc_request == request_id) { | 348 if (request.ipc_request == request_id) { |
261 Stream new_stream; | 349 Stream new_stream; |
262 new_stream.handler = request.handler; | 350 new_stream.handler = request.handler; |
263 if (device_info.stream_type == | 351 if (device_info.stream_type == |
264 content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) { | 352 content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) { |
265 new_stream.video_array.push_back(device_info); | 353 new_stream.video_array.push_back(device_info); |
266 } else { | 354 } else { |
267 new_stream.audio_array.push_back(device_info); | 355 new_stream.audio_array.push_back(device_info); |
268 } | 356 } |
269 label_stream_map_[label] = new_stream; | 357 label_stream_map_[label] = new_stream; |
270 if (request.handler) { | 358 if (request.handler) { |
271 request.handler->OnDeviceOpened(request.request_id, label, | 359 request.handler->OnDeviceOpened(request.request_id, label, |
272 device_info); | 360 device_info); |
273 DVLOG(1) << "MediaStreamDispatcher::OnDeviceOpened(" | 361 DVLOG(1) << "MediaStreamDispatcher::OnDeviceOpened(" |
274 << request.request_id << ", " << label << ")"; | 362 << request.request_id << ", " << label << ")"; |
275 } | 363 } |
276 requests_.erase(it); | 364 requests_.erase(it); |
277 break; | 365 break; |
278 } | 366 } |
279 } | 367 } |
280 } | 368 } |
281 | 369 |
282 void MediaStreamDispatcher::OnDeviceOpenFailed(int request_id) { | 370 void MediaStreamDispatcher::OnDeviceOpenFailed(int request_id) { |
371 DCHECK_EQ(main_loop_, MessageLoop::current()); | |
283 for (RequestList::iterator it = requests_.begin(); | 372 for (RequestList::iterator it = requests_.begin(); |
284 it != requests_.end(); ++it) { | 373 it != requests_.end(); ++it) { |
285 Request& request = *it; | 374 Request& request = *it; |
286 if (request.ipc_request == request_id) { | 375 if (request.ipc_request == request_id) { |
287 if (request.handler) { | 376 if (request.handler) { |
288 request.handler->OnDeviceOpenFailed(request.request_id); | 377 request.handler->OnDeviceOpenFailed(request.request_id); |
289 DVLOG(1) << "MediaStreamDispatcher::OnDeviceOpenFailed(" | 378 DVLOG(1) << "MediaStreamDispatcher::OnDeviceOpenFailed(" |
290 << request.request_id << ")\n"; | 379 << request.request_id << ")\n"; |
291 } | 380 } |
292 requests_.erase(it); | 381 requests_.erase(it); |
(...skipping 18 matching lines...) Expand all Loading... | |
311 | 400 |
312 int MediaStreamDispatcher::video_session_id(const std::string& label, | 401 int MediaStreamDispatcher::video_session_id(const std::string& label, |
313 int index) { | 402 int index) { |
314 LabelStreamMap::iterator it = label_stream_map_.find(label); | 403 LabelStreamMap::iterator it = label_stream_map_.find(label); |
315 if (it == label_stream_map_.end()) | 404 if (it == label_stream_map_.end()) |
316 return media_stream::StreamDeviceInfo::kNoId; | 405 return media_stream::StreamDeviceInfo::kNoId; |
317 | 406 |
318 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); | 407 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); |
319 return it->second.video_array[index].session_id; | 408 return it->second.video_array[index].session_id; |
320 } | 409 } |
OLD | NEW |