Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: content/renderer/media/media_stream_dispatcher.cc

Issue 10830063: refactor EnumerateDevices to make it a persistent request. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix unit test Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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::EnumerationRequest::~EnumerationRequest() {}
42
43 MediaStreamDispatcher::EnumerationState::EnumerationState()
44 : ipc_id(-1) {
45 }
46
47 MediaStreamDispatcher::EnumerationState::~EnumerationState() {}
48
49 struct MediaStreamDispatcher::EnumerationState::CachedDevices {
50 CachedDevices(const std::string& label,
51 const media_stream::StreamDeviceInfoArray& device_array)
52 : label(label),
53 devices(device_array) {
54 }
55 ~CachedDevices() {}
56
57 std::string label;
58 media_stream::StreamDeviceInfoArray devices;
59 };
60
34 MediaStreamDispatcher::MediaStreamDispatcher(RenderViewImpl* render_view) 61 MediaStreamDispatcher::MediaStreamDispatcher(RenderViewImpl* render_view)
35 : content::RenderViewObserver(render_view), 62 : content::RenderViewObserver(render_view),
63 main_loop_(base::MessageLoopProxy::current()),
36 next_ipc_id_(0) { 64 next_ipc_id_(0) {
37 } 65 }
38 66
39 MediaStreamDispatcher::~MediaStreamDispatcher() {} 67 MediaStreamDispatcher::~MediaStreamDispatcher() {}
40 68
41 void MediaStreamDispatcher::GenerateStream( 69 void MediaStreamDispatcher::GenerateStream(
42 int request_id, 70 int request_id,
43 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, 71 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler,
44 media_stream::StreamOptions components, 72 media_stream::StreamOptions components,
45 const GURL& security_origin) { 73 const GURL& security_origin) {
74 DCHECK(main_loop_->BelongsToCurrentThread());
46 DVLOG(1) << "MediaStreamDispatcher::GenerateStream(" << request_id << ")"; 75 DVLOG(1) << "MediaStreamDispatcher::GenerateStream(" << request_id << ")";
47 76
48 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); 77 requests_.push_back(Request(event_handler, request_id, next_ipc_id_));
49 Send(new MediaStreamHostMsg_GenerateStream(routing_id(), 78 Send(new MediaStreamHostMsg_GenerateStream(routing_id(),
50 next_ipc_id_++, 79 next_ipc_id_++,
51 components, 80 components,
52 security_origin)); 81 security_origin));
53 } 82 }
54 83
55 void MediaStreamDispatcher::CancelGenerateStream(int request_id) { 84 void MediaStreamDispatcher::CancelGenerateStream(int request_id) {
85 DCHECK(main_loop_->BelongsToCurrentThread());
56 DVLOG(1) << "MediaStreamDispatcher::CancelGenerateStream" 86 DVLOG(1) << "MediaStreamDispatcher::CancelGenerateStream"
57 << ", {request_id = " << request_id << "}"; 87 << ", {request_id = " << request_id << "}";
58 88
59 RequestList::iterator it = requests_.begin(); 89 RequestList::iterator it = requests_.begin();
60 for (; it != requests_.end(); ++it) { 90 for (; it != requests_.end(); ++it) {
61 Request& request = *it; 91 Request& request = *it;
62 if (request.request_id == request_id) { 92 if (request.request_id == request_id) {
63 requests_.erase(it); 93 requests_.erase(it);
64 Send(new MediaStreamHostMsg_CancelGenerateStream(routing_id(), 94 Send(new MediaStreamHostMsg_CancelGenerateStream(routing_id(),
65 request_id)); 95 request_id));
66 break; 96 break;
67 } 97 }
68 } 98 }
69 } 99 }
70 100
71 void MediaStreamDispatcher::StopStream(const std::string& label) { 101 void MediaStreamDispatcher::StopStream(const std::string& label) {
102 DCHECK(main_loop_->BelongsToCurrentThread());
72 DVLOG(1) << "MediaStreamDispatcher::StopStream" 103 DVLOG(1) << "MediaStreamDispatcher::StopStream"
73 << ", {label = " << label << "}"; 104 << ", {label = " << label << "}";
74 105
75 LabelStreamMap::iterator it = label_stream_map_.find(label); 106 LabelStreamMap::iterator it = label_stream_map_.find(label);
76 if (it == label_stream_map_.end()) 107 if (it == label_stream_map_.end())
77 return; 108 return;
78 109
79 Send(new MediaStreamHostMsg_StopGeneratedStream(routing_id(), label)); 110 Send(new MediaStreamHostMsg_StopGeneratedStream(routing_id(), label));
80 label_stream_map_.erase(it); 111 label_stream_map_.erase(it);
81 } 112 }
82 113
83 void MediaStreamDispatcher::EnumerateDevices( 114 void MediaStreamDispatcher::EnumerateDevices(
84 int request_id, 115 int request_id,
85 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, 116 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler,
86 media_stream::MediaStreamType type, 117 media_stream::MediaStreamType type,
87 const GURL& security_origin) { 118 const GURL& security_origin) {
119 DCHECK(main_loop_->BelongsToCurrentThread());
120 DCHECK(type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE ||
121 type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE);
88 DVLOG(1) << "MediaStreamDispatcher::EnumerateDevices(" 122 DVLOG(1) << "MediaStreamDispatcher::EnumerateDevices("
89 << request_id << ")"; 123 << request_id << ")";
90 124
91 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); 125 EnumerationState* state =
92 Send(new MediaStreamHostMsg_EnumerateDevices(routing_id(), 126 (type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE ?
93 next_ipc_id_++, 127 &audio_enumeration_state_ : &video_enumeration_state_);
94 type, 128 state->requests.push_back(
95 security_origin)); 129 EnumerationRequest(event_handler, request_id));
130
131 if (state->cached_devices.get()) {
132 event_handler->OnDevicesEnumerated(
133 request_id, state->cached_devices->devices);
134 } else if (state->ipc_id < 0) {
135 Send(new MediaStreamHostMsg_EnumerateDevices(routing_id(),
136 next_ipc_id_,
137 type,
138 security_origin));
139 state->ipc_id = next_ipc_id_++;
140 }
141 }
142
143 void MediaStreamDispatcher::StopEnumerateDevices(
144 int request_id,
145 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler) {
146 DCHECK(main_loop_->BelongsToCurrentThread());
147 DVLOG(1) << "MediaStreamDispatcher::StopEnumerateDevices("
148 << request_id << ")";
149
150 // Remove the request.
151 RemoveEnumerationRequest(
152 request_id, event_handler, &audio_enumeration_state_);
153 RemoveEnumerationRequest(
154 request_id, event_handler, &video_enumeration_state_);
155 }
156
157 void MediaStreamDispatcher::RemoveEnumerationRequest(
158 int request_id,
159 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler,
160 EnumerationState* state) {
161 EnumerationRequestList* requests = &state->requests;
162 for (EnumerationRequestList::iterator it = requests->begin();
163 it != requests->end(); ++it) {
164 if (it->request_id == request_id && it->handler == event_handler) {
165 requests->erase(it);
166 if (requests->empty() && !state->cached_devices.get()) {
167 // No more request and has a label, try to stop the label
168 // and invalidate the state.
169 Send(new MediaStreamHostMsg_StopGeneratedStream(
170 routing_id(), state->cached_devices->label));
171 state->ipc_id = -1;
172 state->cached_devices.reset();
173 }
174 return;
175 }
176 }
96 } 177 }
97 178
98 void MediaStreamDispatcher::OpenDevice( 179 void MediaStreamDispatcher::OpenDevice(
99 int request_id, 180 int request_id,
100 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, 181 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler,
101 const std::string& device_id, 182 const std::string& device_id,
102 media_stream::MediaStreamType type, 183 media_stream::MediaStreamType type,
103 const GURL& security_origin) { 184 const GURL& security_origin) {
185 DCHECK(main_loop_->BelongsToCurrentThread());
104 DVLOG(1) << "MediaStreamDispatcher::OpenDevice(" << request_id << ")"; 186 DVLOG(1) << "MediaStreamDispatcher::OpenDevice(" << request_id << ")";
105 187
106 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); 188 requests_.push_back(Request(event_handler, request_id, next_ipc_id_));
107 Send(new MediaStreamHostMsg_OpenDevice(routing_id(), 189 Send(new MediaStreamHostMsg_OpenDevice(routing_id(),
108 next_ipc_id_++, 190 next_ipc_id_++,
109 device_id, 191 device_id,
110 type, 192 type,
111 security_origin)); 193 security_origin));
112 } 194 }
113 195
114 void MediaStreamDispatcher::CloseDevice(const std::string& label) { 196 void MediaStreamDispatcher::CloseDevice(const std::string& label) {
197 DCHECK(main_loop_->BelongsToCurrentThread());
115 DVLOG(1) << "MediaStreamDispatcher::CloseDevice" 198 DVLOG(1) << "MediaStreamDispatcher::CloseDevice"
116 << ", {label = " << label << "}"; 199 << ", {label = " << label << "}";
117 200
118 StopStream(label); 201 StopStream(label);
119 } 202 }
120 203
121 bool MediaStreamDispatcher::OnMessageReceived(const IPC::Message& message) { 204 bool MediaStreamDispatcher::OnMessageReceived(const IPC::Message& message) {
122 bool handled = true; 205 bool handled = true;
123 IPC_BEGIN_MESSAGE_MAP(MediaStreamDispatcher, message) 206 IPC_BEGIN_MESSAGE_MAP(MediaStreamDispatcher, message)
124 IPC_MESSAGE_HANDLER(MediaStreamMsg_StreamGenerated, 207 IPC_MESSAGE_HANDLER(MediaStreamMsg_StreamGenerated,
(...skipping 15 matching lines...) Expand all
140 IPC_MESSAGE_UNHANDLED(handled = false) 223 IPC_MESSAGE_UNHANDLED(handled = false)
141 IPC_END_MESSAGE_MAP() 224 IPC_END_MESSAGE_MAP()
142 return handled; 225 return handled;
143 } 226 }
144 227
145 void MediaStreamDispatcher::OnStreamGenerated( 228 void MediaStreamDispatcher::OnStreamGenerated(
146 int request_id, 229 int request_id,
147 const std::string& label, 230 const std::string& label,
148 const media_stream::StreamDeviceInfoArray& audio_array, 231 const media_stream::StreamDeviceInfoArray& audio_array,
149 const media_stream::StreamDeviceInfoArray& video_array) { 232 const media_stream::StreamDeviceInfoArray& video_array) {
233 DCHECK(main_loop_->BelongsToCurrentThread());
150 234
151 for (RequestList::iterator it = requests_.begin(); 235 for (RequestList::iterator it = requests_.begin();
152 it != requests_.end(); ++it) { 236 it != requests_.end(); ++it) {
153 Request& request = *it; 237 Request& request = *it;
154 if (request.ipc_request == request_id) { 238 if (request.ipc_request == request_id) {
155 Stream new_stream; 239 Stream new_stream;
156 new_stream.handler = request.handler; 240 new_stream.handler = request.handler;
157 new_stream.audio_array = audio_array; 241 new_stream.audio_array = audio_array;
158 new_stream.video_array = video_array; 242 new_stream.video_array = video_array;
159 label_stream_map_[label] = new_stream; 243 label_stream_map_[label] = new_stream;
160 if (request.handler) { 244 if (request.handler) {
161 request.handler->OnStreamGenerated(request.request_id, label, 245 request.handler->OnStreamGenerated(request.request_id, label,
162 audio_array, video_array); 246 audio_array, video_array);
163 DVLOG(1) << "MediaStreamDispatcher::OnStreamGenerated(" 247 DVLOG(1) << "MediaStreamDispatcher::OnStreamGenerated("
164 << request.request_id << ", " << label << ")"; 248 << request.request_id << ", " << label << ")";
165 } 249 }
166 requests_.erase(it); 250 requests_.erase(it);
167 break; 251 break;
168 } 252 }
169 } 253 }
170 } 254 }
171 255
172 void MediaStreamDispatcher::OnStreamGenerationFailed(int request_id) { 256 void MediaStreamDispatcher::OnStreamGenerationFailed(int request_id) {
257 DCHECK(main_loop_->BelongsToCurrentThread());
173 for (RequestList::iterator it = requests_.begin(); 258 for (RequestList::iterator it = requests_.begin();
174 it != requests_.end(); ++it) { 259 it != requests_.end(); ++it) {
175 Request& request = *it; 260 Request& request = *it;
176 if (request.ipc_request == request_id) { 261 if (request.ipc_request == request_id) {
177 if (request.handler) { 262 if (request.handler) {
178 request.handler->OnStreamGenerationFailed(request.request_id); 263 request.handler->OnStreamGenerationFailed(request.request_id);
179 DVLOG(1) << "MediaStreamDispatcher::OnStreamGenerationFailed(" 264 DVLOG(1) << "MediaStreamDispatcher::OnStreamGenerationFailed("
180 << request.request_id << ")\n"; 265 << request.request_id << ")\n";
181 } 266 }
182 requests_.erase(it); 267 requests_.erase(it);
183 break; 268 break;
184 } 269 }
185 } 270 }
186 } 271 }
187 272
188 void MediaStreamDispatcher::OnVideoDeviceFailed(const std::string& label, 273 void MediaStreamDispatcher::OnVideoDeviceFailed(const std::string& label,
189 int index) { 274 int index) {
275 DCHECK(main_loop_->BelongsToCurrentThread());
190 LabelStreamMap::iterator it = label_stream_map_.find(label); 276 LabelStreamMap::iterator it = label_stream_map_.find(label);
191 if (it == label_stream_map_.end()) 277 if (it == label_stream_map_.end())
192 return; 278 return;
193 279
194 // index is the index in the video_array that has failed. 280 // index is the index in the video_array that has failed.
195 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); 281 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index));
196 media_stream::StreamDeviceInfoArray::iterator device_it = 282 media_stream::StreamDeviceInfoArray::iterator device_it =
197 it->second.video_array.begin(); 283 it->second.video_array.begin();
198 it->second.video_array.erase(device_it + index); 284 it->second.video_array.erase(device_it + index);
199 if (it->second.handler) 285 if (it->second.handler)
200 it->second.handler->OnVideoDeviceFailed(label, index); 286 it->second.handler->OnVideoDeviceFailed(label, index);
201 } 287 }
202 288
203 void MediaStreamDispatcher::OnAudioDeviceFailed(const std::string& label, 289 void MediaStreamDispatcher::OnAudioDeviceFailed(const std::string& label,
204 int index) { 290 int index) {
291 DCHECK(main_loop_->BelongsToCurrentThread());
205 LabelStreamMap::iterator it = label_stream_map_.find(label); 292 LabelStreamMap::iterator it = label_stream_map_.find(label);
206 if (it == label_stream_map_.end()) 293 if (it == label_stream_map_.end())
207 return; 294 return;
208 295
209 // index is the index in the audio_array that has failed. 296 // index is the index in the audio_array that has failed.
210 DCHECK_GT(it->second.audio_array.size(), static_cast<size_t>(index)); 297 DCHECK_GT(it->second.audio_array.size(), static_cast<size_t>(index));
211 media_stream::StreamDeviceInfoArray::iterator device_it = 298 media_stream::StreamDeviceInfoArray::iterator device_it =
212 it->second.audio_array.begin(); 299 it->second.audio_array.begin();
213 it->second.audio_array.erase(device_it + index); 300 it->second.audio_array.erase(device_it + index);
214 if (it->second.handler) 301 if (it->second.handler)
215 it->second.handler->OnAudioDeviceFailed(label, index); 302 it->second.handler->OnAudioDeviceFailed(label, index);
216 } 303 }
217 304
218 void MediaStreamDispatcher::OnDevicesEnumerated( 305 void MediaStreamDispatcher::OnDevicesEnumerated(
219 int request_id, 306 int request_id,
307 const std::string& label,
220 const media_stream::StreamDeviceInfoArray& device_array) { 308 const media_stream::StreamDeviceInfoArray& device_array) {
309 DCHECK(main_loop_->BelongsToCurrentThread());
310 DCHECK_GE(request_id, 0);
221 311
222 for (RequestList::iterator it = requests_.begin(); 312 EnumerationState* state;
223 it != requests_.end(); ++it) { 313 if (request_id == audio_enumeration_state_.ipc_id) {
224 Request& request = *it; 314 state = &audio_enumeration_state_;
225 if (request.ipc_request == request_id) { 315 } else if (request_id == video_enumeration_state_.ipc_id) {
226 if (request.handler) { 316 state = &video_enumeration_state_;
227 request.handler->OnDevicesEnumerated(request.request_id, device_array); 317 } else {
228 DVLOG(1) << "MediaStreamDispatcher::OnDevicesEnumerated(" 318 // This could happen when requester has stopped enumeration while some
229 << request.request_id << ")"; 319 // enumerated response is on the way. Have to stop the |label| because
230 } 320 // this might be the first enumerated device list is received. This also
231 requests_.erase(it); 321 // lead to same label being stopped multiple times.
232 break; 322 Send(new MediaStreamHostMsg_StopGeneratedStream(routing_id(), label));
323 return;
324 }
325
326 DCHECK(!label.empty());
327 state->cached_devices.reset(new EnumerationState::CachedDevices(
328 label, device_array));
329
330 for (EnumerationRequestList::iterator it = state->requests.begin();
331 it != state->requests.end(); ++it) {
332 if (it->handler) {
333 it->handler->OnDevicesEnumerated(it->request_id, device_array);
334 DVLOG(1) << "MediaStreamDispatcher::OnDevicesEnumerated("
335 << it->request_id << ")";
233 } 336 }
234 } 337 }
235 } 338 }
236 339
237 void MediaStreamDispatcher::OnDevicesEnumerationFailed(int request_id) { 340 void MediaStreamDispatcher::OnDevicesEnumerationFailed(int request_id) {
341 DCHECK(main_loop_->BelongsToCurrentThread());
238 for (RequestList::iterator it = requests_.begin(); 342 for (RequestList::iterator it = requests_.begin();
239 it != requests_.end(); ++it) { 343 it != requests_.end(); ++it) {
240 Request& request = *it; 344 Request& request = *it;
241 if (request.ipc_request == request_id) { 345 if (request.ipc_request == request_id) {
242 if (request.handler) { 346 if (request.handler) {
243 request.handler->OnDevicesEnumerationFailed(request.request_id); 347 request.handler->OnDevicesEnumerationFailed(request.request_id);
244 DVLOG(1) << "MediaStreamDispatcher::OnDevicesEnumerationFailed(" 348 DVLOG(1) << "MediaStreamDispatcher::OnDevicesEnumerationFailed("
245 << request.request_id << ")\n"; 349 << request.request_id << ")\n";
246 } 350 }
247 requests_.erase(it); 351 requests_.erase(it);
248 break; 352 break;
249 } 353 }
250 } 354 }
251 } 355 }
252 356
253 void MediaStreamDispatcher::OnDeviceOpened( 357 void MediaStreamDispatcher::OnDeviceOpened(
254 int request_id, 358 int request_id,
255 const std::string& label, 359 const std::string& label,
256 const media_stream::StreamDeviceInfo& device_info) { 360 const media_stream::StreamDeviceInfo& device_info) {
361 DCHECK(main_loop_->BelongsToCurrentThread());
257 for (RequestList::iterator it = requests_.begin(); 362 for (RequestList::iterator it = requests_.begin();
258 it != requests_.end(); ++it) { 363 it != requests_.end(); ++it) {
259 Request& request = *it; 364 Request& request = *it;
260 if (request.ipc_request == request_id) { 365 if (request.ipc_request == request_id) {
261 Stream new_stream; 366 Stream new_stream;
262 new_stream.handler = request.handler; 367 new_stream.handler = request.handler;
263 if (device_info.stream_type == 368 if (device_info.stream_type ==
264 content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) { 369 content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) {
265 new_stream.video_array.push_back(device_info); 370 new_stream.video_array.push_back(device_info);
266 } else { 371 } else {
267 new_stream.audio_array.push_back(device_info); 372 new_stream.audio_array.push_back(device_info);
268 } 373 }
269 label_stream_map_[label] = new_stream; 374 label_stream_map_[label] = new_stream;
270 if (request.handler) { 375 if (request.handler) {
271 request.handler->OnDeviceOpened(request.request_id, label, 376 request.handler->OnDeviceOpened(request.request_id, label,
272 device_info); 377 device_info);
273 DVLOG(1) << "MediaStreamDispatcher::OnDeviceOpened(" 378 DVLOG(1) << "MediaStreamDispatcher::OnDeviceOpened("
274 << request.request_id << ", " << label << ")"; 379 << request.request_id << ", " << label << ")";
275 } 380 }
276 requests_.erase(it); 381 requests_.erase(it);
277 break; 382 break;
278 } 383 }
279 } 384 }
280 } 385 }
281 386
282 void MediaStreamDispatcher::OnDeviceOpenFailed(int request_id) { 387 void MediaStreamDispatcher::OnDeviceOpenFailed(int request_id) {
388 DCHECK(main_loop_->BelongsToCurrentThread());
283 for (RequestList::iterator it = requests_.begin(); 389 for (RequestList::iterator it = requests_.begin();
284 it != requests_.end(); ++it) { 390 it != requests_.end(); ++it) {
285 Request& request = *it; 391 Request& request = *it;
286 if (request.ipc_request == request_id) { 392 if (request.ipc_request == request_id) {
287 if (request.handler) { 393 if (request.handler) {
288 request.handler->OnDeviceOpenFailed(request.request_id); 394 request.handler->OnDeviceOpenFailed(request.request_id);
289 DVLOG(1) << "MediaStreamDispatcher::OnDeviceOpenFailed(" 395 DVLOG(1) << "MediaStreamDispatcher::OnDeviceOpenFailed("
290 << request.request_id << ")\n"; 396 << request.request_id << ")\n";
291 } 397 }
292 requests_.erase(it); 398 requests_.erase(it);
(...skipping 18 matching lines...) Expand all
311 417
312 int MediaStreamDispatcher::video_session_id(const std::string& label, 418 int MediaStreamDispatcher::video_session_id(const std::string& label,
313 int index) { 419 int index) {
314 LabelStreamMap::iterator it = label_stream_map_.find(label); 420 LabelStreamMap::iterator it = label_stream_map_.find(label);
315 if (it == label_stream_map_.end()) 421 if (it == label_stream_map_.end())
316 return media_stream::StreamDeviceInfo::kNoId; 422 return media_stream::StreamDeviceInfo::kNoId;
317 423
318 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); 424 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index));
319 return it->second.video_array[index].session_id; 425 return it->second.video_array[index].session_id;
320 } 426 }
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_dispatcher.h ('k') | content/renderer/media/media_stream_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698