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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 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 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); | |
76 | |
77 if (components.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE || | |
perkj_chrome
2012/10/11 08:01:54
Why did you you keep MediaStreamHostMsg_GenerateSt
justinlin
2012/10/11 19:41:51
Done. Moved it to the host part and added TODO the
| |
78 components.video_type == content::MEDIA_TAB_VIDEO_CAPTURE) { | |
79 DVLOG(1) << "MediaStreamDispatcher::GenerateStreamForDevice(" | |
80 << request_id << ")"; | |
81 Send(new MediaStreamHostMsg_GenerateStreamForDevice( | |
82 routing_id(), next_ipc_id_++, components, components.video_device_id, | |
83 security_origin)); | |
84 return; | |
85 } | |
86 | |
75 DVLOG(1) << "MediaStreamDispatcher::GenerateStream(" << request_id << ")"; | 87 DVLOG(1) << "MediaStreamDispatcher::GenerateStream(" << request_id << ")"; |
76 | |
77 requests_.push_back(Request(event_handler, request_id, next_ipc_id_)); | |
78 Send(new MediaStreamHostMsg_GenerateStream(routing_id(), | 88 Send(new MediaStreamHostMsg_GenerateStream(routing_id(), |
79 next_ipc_id_++, | 89 next_ipc_id_++, |
80 components, | 90 components, |
81 security_origin)); | 91 security_origin)); |
82 } | 92 } |
83 | 93 |
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) { | 94 void MediaStreamDispatcher::CancelGenerateStream(int request_id) { |
103 DCHECK(main_loop_->BelongsToCurrentThread()); | 95 DCHECK(main_loop_->BelongsToCurrentThread()); |
104 DVLOG(1) << "MediaStreamDispatcher::CancelGenerateStream" | 96 DVLOG(1) << "MediaStreamDispatcher::CancelGenerateStream" |
105 << ", {request_id = " << request_id << "}"; | 97 << ", {request_id = " << request_id << "}"; |
106 | 98 |
107 RequestList::iterator it = requests_.begin(); | 99 RequestList::iterator it = requests_.begin(); |
108 for (; it != requests_.end(); ++it) { | 100 for (; it != requests_.end(); ++it) { |
109 Request& request = *it; | 101 Request& request = *it; |
110 if (request.request_id == request_id) { | 102 if (request.request_id == request_id) { |
111 requests_.erase(it); | 103 requests_.erase(it); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 | 427 |
436 int MediaStreamDispatcher::video_session_id(const std::string& label, | 428 int MediaStreamDispatcher::video_session_id(const std::string& label, |
437 int index) { | 429 int index) { |
438 LabelStreamMap::iterator it = label_stream_map_.find(label); | 430 LabelStreamMap::iterator it = label_stream_map_.find(label); |
439 if (it == label_stream_map_.end()) | 431 if (it == label_stream_map_.end()) |
440 return media_stream::StreamDeviceInfo::kNoId; | 432 return media_stream::StreamDeviceInfo::kNoId; |
441 | 433 |
442 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); | 434 DCHECK_GT(it->second.video_array.size(), static_cast<size_t>(index)); |
443 return it->second.video_array[index].session_id; | 435 return it->second.video_array[index].session_id; |
444 } | 436 } |
OLD | NEW |