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 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ |
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 26 matching lines...) Expand all Loading... |
37 public: | 37 public: |
38 explicit MediaStreamDispatcher(RenderViewImpl* render_view); | 38 explicit MediaStreamDispatcher(RenderViewImpl* render_view); |
39 virtual ~MediaStreamDispatcher(); | 39 virtual ~MediaStreamDispatcher(); |
40 | 40 |
41 // Request a new media stream to be created. | 41 // Request a new media stream to be created. |
42 // This can be used either by WebKit or a plugin. | 42 // This can be used either by WebKit or a plugin. |
43 // Note: The event_handler must be valid for as long as the stream exists. | 43 // Note: The event_handler must be valid for as long as the stream exists. |
44 virtual void GenerateStream( | 44 virtual void GenerateStream( |
45 int request_id, | 45 int request_id, |
46 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 46 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
47 const media_stream::StreamOptions& components, | 47 const StreamOptions& components, |
48 const GURL& security_origin); | 48 const GURL& security_origin); |
49 | 49 |
50 // Cancel the request for a new media stream to be created. | 50 // Cancel the request for a new media stream to be created. |
51 virtual void CancelGenerateStream(int request_id); | 51 virtual void CancelGenerateStream(int request_id); |
52 | 52 |
53 // Stop a started stream. Label is the label provided in OnStreamGenerated. | 53 // Stop a started stream. Label is the label provided in OnStreamGenerated. |
54 virtual void StopStream(const std::string& label); | 54 virtual void StopStream(const std::string& label); |
55 | 55 |
56 // Request to enumerate devices. | 56 // Request to enumerate devices. |
57 void EnumerateDevices( | 57 void EnumerateDevices( |
58 int request_id, | 58 int request_id, |
59 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 59 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
60 media_stream::MediaStreamType type, | 60 MediaStreamType type, |
61 const GURL& security_origin); | 61 const GURL& security_origin); |
62 | 62 |
63 // Request to stop enumerating devices. | 63 // Request to stop enumerating devices. |
64 void StopEnumerateDevices( | 64 void StopEnumerateDevices( |
65 int request_id, | 65 int request_id, |
66 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler); | 66 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler); |
67 | 67 |
68 // Request to open a device. | 68 // Request to open a device. |
69 void OpenDevice( | 69 void OpenDevice( |
70 int request_id, | 70 int request_id, |
71 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 71 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
72 const std::string& device_id, | 72 const std::string& device_id, |
73 media_stream::MediaStreamType type, | 73 MediaStreamType type, |
74 const GURL& security_origin); | 74 const GURL& security_origin); |
75 | 75 |
76 // Close a started device. |label| is provided in OnDeviceOpened. | 76 // Close a started device. |label| is provided in OnDeviceOpened. |
77 void CloseDevice(const std::string& label); | 77 void CloseDevice(const std::string& label); |
78 | 78 |
79 // Check if the label is a valid stream. | 79 // Check if the label is a valid stream. |
80 virtual bool IsStream(const std::string& label); | 80 virtual bool IsStream(const std::string& label); |
81 // Get the video session_id given a label. The label identifies a stream. | 81 // Get the video session_id given a label. The label identifies a stream. |
82 // index is the index in the video_device_array of the stream. | 82 // index is the index in the video_device_array of the stream. |
83 virtual int video_session_id(const std::string& label, int index); | 83 virtual int video_session_id(const std::string& label, int index); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 int ipc_id; | 120 int ipc_id; |
121 scoped_ptr<CachedDevices> cached_devices; | 121 scoped_ptr<CachedDevices> cached_devices; |
122 EnumerationRequestList requests; | 122 EnumerationRequestList requests; |
123 }; | 123 }; |
124 | 124 |
125 // Messages from the browser. | 125 // Messages from the browser. |
126 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 126 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
127 void OnStreamGenerated( | 127 void OnStreamGenerated( |
128 int request_id, | 128 int request_id, |
129 const std::string& label, | 129 const std::string& label, |
130 const media_stream::StreamDeviceInfoArray& audio_array, | 130 const StreamDeviceInfoArray& audio_array, |
131 const media_stream::StreamDeviceInfoArray& video_array); | 131 const StreamDeviceInfoArray& video_array); |
132 void OnStreamGenerationFailed(int request_id); | 132 void OnStreamGenerationFailed(int request_id); |
133 void OnDevicesEnumerated( | 133 void OnDevicesEnumerated( |
134 int request_id, | 134 int request_id, |
135 const std::string& label, | 135 const std::string& label, |
136 const media_stream::StreamDeviceInfoArray& device_array); | 136 const StreamDeviceInfoArray& device_array); |
137 void OnDevicesEnumerationFailed(int request_id); | 137 void OnDevicesEnumerationFailed(int request_id); |
138 void OnDeviceOpened( | 138 void OnDeviceOpened( |
139 int request_id, | 139 int request_id, |
140 const std::string& label, | 140 const std::string& label, |
141 const media_stream::StreamDeviceInfo& device_info); | 141 const StreamDeviceInfo& device_info); |
142 void OnDeviceOpenFailed(int request_id); | 142 void OnDeviceOpenFailed(int request_id); |
143 | 143 |
144 void RemoveEnumerationRequest( | 144 void RemoveEnumerationRequest( |
145 int request_id, | 145 int request_id, |
146 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 146 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
147 EnumerationState* state); | 147 EnumerationState* state); |
148 | 148 |
149 // Used for DCHECKs so methods calls won't execute in the wrong thread. | 149 // Used for DCHECKs so methods calls won't execute in the wrong thread. |
150 scoped_refptr<base::MessageLoopProxy> main_loop_; | 150 scoped_refptr<base::MessageLoopProxy> main_loop_; |
151 | 151 |
152 int next_ipc_id_; | 152 int next_ipc_id_; |
153 typedef std::map<std::string, Stream> LabelStreamMap; | 153 typedef std::map<std::string, Stream> LabelStreamMap; |
154 LabelStreamMap label_stream_map_; | 154 LabelStreamMap label_stream_map_; |
155 | 155 |
156 EnumerationState audio_enumeration_state_; | 156 EnumerationState audio_enumeration_state_; |
157 EnumerationState video_enumeration_state_; | 157 EnumerationState video_enumeration_state_; |
158 | 158 |
159 // List of calls made to GenerateStream that have not yet completed. | 159 // List of calls made to GenerateStream that have not yet completed. |
160 typedef std::list<Request> RequestList; | 160 typedef std::list<Request> RequestList; |
161 RequestList requests_; | 161 RequestList requests_; |
162 | 162 |
163 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); | 163 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); |
164 }; | 164 }; |
165 | 165 |
166 } // namespace content | 166 } // namespace content |
167 | 167 |
168 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ | 168 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ |
OLD | NEW |