Chromium Code Reviews| 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/message_loop_proxy.h" | 8 #include "base/message_loop/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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 DCHECK(main_loop_->BelongsToCurrentThread()); | 78 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 79 DVLOG(1) << "MediaStreamDispatcher::GenerateStream(" << request_id << ")"; | 79 DVLOG(1) << "MediaStreamDispatcher::GenerateStream(" << request_id << ")"; |
| 80 | 80 |
| 81 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); | 81 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); |
| 82 Send(new MediaStreamHostMsg_GenerateStream(routing_id(), | 82 Send(new MediaStreamHostMsg_GenerateStream(routing_id(), |
| 83 next_ipc_id_++, | 83 next_ipc_id_++, |
| 84 components, | 84 components, |
| 85 security_origin)); | 85 security_origin)); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void MediaStreamDispatcher::CancelGenerateStream(int request_id) { | 88 void MediaStreamDispatcher::CancelGenerateStream( |
| 89 int request_id, | |
| 90 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler) { | |
| 89 DCHECK(main_loop_->BelongsToCurrentThread()); | 91 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 90 DVLOG(1) << "MediaStreamDispatcher::CancelGenerateStream" | 92 DVLOG(1) << "MediaStreamDispatcher::CancelGenerateStream" |
| 91 << ", {request_id = " << request_id << "}"; | 93 << ", {request_id = " << request_id << "}"; |
| 92 | 94 |
| 93 RequestList::iterator it = requests_.begin(); | 95 RequestList::iterator it = requests_.begin(); |
| 94 for (; it != requests_.end(); ++it) { | 96 for (; it != requests_.end(); ++it) { |
| 95 Request& request = *it; | 97 if (it->request_id == request_id && |
| 96 if (request.request_id == request_id) { | 98 it->handler.get() == event_handler.get()) { |
|
tommi (sloooow) - chröme
2013/07/03 08:05:12
is this the right thing to do? it seems to me tha
wjia(left Chromium)
2013/07/03 17:41:36
Yes, it's the right thing to do. The request_id is
| |
| 99 int ipc_request = it->ipc_request; | |
| 97 requests_.erase(it); | 100 requests_.erase(it); |
| 98 Send(new MediaStreamHostMsg_CancelGenerateStream(routing_id(), | 101 Send(new MediaStreamHostMsg_CancelGenerateStream(routing_id(), |
| 99 request_id)); | 102 ipc_request)); |
| 100 break; | 103 break; |
| 101 } | 104 } |
| 102 } | 105 } |
| 103 } | 106 } |
| 104 | 107 |
| 105 void MediaStreamDispatcher::StopStream(const std::string& label) { | 108 void MediaStreamDispatcher::StopStream(const std::string& label) { |
| 106 DCHECK(main_loop_->BelongsToCurrentThread()); | 109 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 107 DVLOG(1) << "MediaStreamDispatcher::StopStream" | 110 DVLOG(1) << "MediaStreamDispatcher::StopStream" |
| 108 << ", {label = " << label << "}"; | 111 << ", {label = " << label << "}"; |
| 109 | 112 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 DVLOG(1) << "MediaStreamDispatcher::OpenDevice(" << request_id << ")"; | 193 DVLOG(1) << "MediaStreamDispatcher::OpenDevice(" << request_id << ")"; |
| 191 | 194 |
| 192 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); | 195 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); |
| 193 Send(new MediaStreamHostMsg_OpenDevice(routing_id(), | 196 Send(new MediaStreamHostMsg_OpenDevice(routing_id(), |
| 194 next_ipc_id_++, | 197 next_ipc_id_++, |
| 195 device_id, | 198 device_id, |
| 196 type, | 199 type, |
| 197 security_origin)); | 200 security_origin)); |
| 198 } | 201 } |
| 199 | 202 |
| 203 void MediaStreamDispatcher::CancelOpenDevice( | |
| 204 int request_id, | |
| 205 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler) { | |
| 206 CancelGenerateStream(request_id, event_handler); | |
| 207 } | |
| 208 | |
| 200 void MediaStreamDispatcher::CloseDevice(const std::string& label) { | 209 void MediaStreamDispatcher::CloseDevice(const std::string& label) { |
| 201 DCHECK(main_loop_->BelongsToCurrentThread()); | 210 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 202 DVLOG(1) << "MediaStreamDispatcher::CloseDevice" | 211 DVLOG(1) << "MediaStreamDispatcher::CloseDevice" |
| 203 << ", {label = " << label << "}"; | 212 << ", {label = " << label << "}"; |
| 204 | 213 |
| 205 StopStream(label); | 214 StopStream(label); |
| 206 } | 215 } |
| 207 | 216 |
| 208 bool MediaStreamDispatcher::Send(IPC::Message* message) { | 217 bool MediaStreamDispatcher::Send(IPC::Message* message) { |
| 209 if (!RenderThread::Get()) { | 218 if (!RenderThread::Get()) { |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 int index) { | 405 int index) { |
| 397 LabelStreamMap::iterator it = label_stream_map_.find(label); | 406 LabelStreamMap::iterator it = label_stream_map_.find(label); |
| 398 if (it == label_stream_map_.end()) | 407 if (it == label_stream_map_.end()) |
| 399 return StreamDeviceInfo::kNoId; | 408 return StreamDeviceInfo::kNoId; |
| 400 | 409 |
| 401 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); | 410 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); |
| 402 return it->second.video_array[index].session_id; | 411 return it->second.video_array[index].session_id; |
| 403 } | 412 } |
| 404 | 413 |
| 405 } // namespace content | 414 } // namespace content |
| OLD | NEW |