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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 : content::RenderViewObserver(render_view), | 62 : content::RenderViewObserver(render_view), |
63 main_loop_(base::MessageLoopProxy::current()), | 63 main_loop_(base::MessageLoopProxy::current()), |
64 next_ipc_id_(0) { | 64 next_ipc_id_(0) { |
65 } | 65 } |
66 | 66 |
67 MediaStreamDispatcher::~MediaStreamDispatcher() {} | 67 MediaStreamDispatcher::~MediaStreamDispatcher() {} |
68 | 68 |
69 void MediaStreamDispatcher::GenerateStream( | 69 void MediaStreamDispatcher::GenerateStream( |
70 int request_id, | 70 int request_id, |
71 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 71 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
72 media_stream::StreamOptions components, | 72 const media_stream::StreamOptions& components, |
73 const GURL& security_origin) { | 73 const GURL& security_origin) { |
74 DCHECK(main_loop_->BelongsToCurrentThread()); | 74 DCHECK(main_loop_->BelongsToCurrentThread()); |
75 DVLOG(1) << "MediaStreamDispatcher::GenerateStream(" << request_id << ")"; | 75 DVLOG(1) << "MediaStreamDispatcher::GenerateStream(" << request_id << ")"; |
76 | 76 |
77 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); | 77 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); |
78 Send(new MediaStreamHostMsg_GenerateStream(routing_id(), | 78 Send(new MediaStreamHostMsg_GenerateStream(routing_id(), |
79 next_ipc_id_++, | 79 next_ipc_id_++, |
80 components, | 80 components, |
81 security_origin)); | 81 security_origin)); |
82 } | 82 } |
83 | 83 |
84 void MediaStreamDispatcher::GenerateStreamForDevice( | |
85 int request_id, | |
86 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | |
87 media_stream::StreamOptions components, | |
88 const std::string& device_id, | |
89 const GURL& security_origin) { | |
90 DCHECK(main_loop_->BelongsToCurrentThread()); | |
91 DVLOG(1) << "MediaStreamDispatcher::GenerateStreamForDevice(" | |
92 << request_id << ")"; | |
93 | |
94 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); | |
95 Send(new MediaStreamHostMsg_GenerateStreamForDevice(routing_id(), | |
96 next_ipc_id_++, | |
97 components, | |
98 device_id, | |
99 security_origin)); | |
100 } | |
101 | |
102 void MediaStreamDispatcher::CancelGenerateStream(int request_id) { | 84 void MediaStreamDispatcher::CancelGenerateStream(int request_id) { |
103 DCHECK(main_loop_->BelongsToCurrentThread()); | 85 DCHECK(main_loop_->BelongsToCurrentThread()); |
104 DVLOG(1) << "MediaStreamDispatcher::CancelGenerateStream" | 86 DVLOG(1) << "MediaStreamDispatcher::CancelGenerateStream" |
105 << ", {request_id = " << request_id << "}"; | 87 << ", {request_id = " << request_id << "}"; |
106 | 88 |
107 RequestList::iterator it = requests_.begin(); | 89 RequestList::iterator it = requests_.begin(); |
108 for (; it != requests_.end(); ++it) { | 90 for (; it != requests_.end(); ++it) { |
109 Request& request = *it; | 91 Request& request = *it; |
110 if (request.request_id == request_id) { | 92 if (request.request_id == request_id) { |
111 requests_.erase(it); | 93 requests_.erase(it); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 | 417 |
436 int MediaStreamDispatcher::video_session_id(const std::string& label, | 418 int MediaStreamDispatcher::video_session_id(const std::string& label, |
437 int index) { | 419 int index) { |
438 LabelStreamMap::iterator it = label_stream_map_.find(label); | 420 LabelStreamMap::iterator it = label_stream_map_.find(label); |
439 if (it == label_stream_map_.end()) | 421 if (it == label_stream_map_.end()) |
440 return media_stream::StreamDeviceInfo::kNoId; | 422 return media_stream::StreamDeviceInfo::kNoId; |
441 | 423 |
442 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)); |
443 return it->second.video_array[index].session_id; | 425 return it->second.video_array[index].session_id; |
444 } | 426 } |
OLD | NEW |