| 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 <memory> | 10 #include <memory> |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 const GURL& security_origin); | 71 const GURL& security_origin); |
| 72 | 72 |
| 73 // Cancel the request to open a device. | 73 // Cancel the request to open a device. |
| 74 virtual void CancelOpenDevice( | 74 virtual void CancelOpenDevice( |
| 75 int request_id, | 75 int request_id, |
| 76 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler); | 76 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler); |
| 77 | 77 |
| 78 // Close a started device. |label| is provided in OnDeviceOpened. | 78 // Close a started device. |label| is provided in OnDeviceOpened. |
| 79 void CloseDevice(const std::string& label); | 79 void CloseDevice(const std::string& label); |
| 80 | 80 |
| 81 // Register and unregister event handlers for device-change notifications. |
| 82 // It is an error to try to subscribe a handler that is already subscribed or |
| 83 // to cancel the subscription of a handler that is not subscribed. Also, |
| 84 // each subscribed handler must make sure to invoke |
| 85 // CancelDeviceChangeNotifications() before the handler is destroyed. |
| 86 void SubscribeToDeviceChangeNotifications( |
| 87 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
| 88 const GURL& security_origin); |
| 89 void CancelDeviceChangeNotifications( |
| 90 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler); |
| 91 |
| 81 // Check if the label is a valid stream. | 92 // Check if the label is a valid stream. |
| 82 virtual bool IsStream(const std::string& label); | 93 virtual bool IsStream(const std::string& label); |
| 83 // Get the video session_id given a label. The label identifies a stream. | 94 // Get the video session_id given a label. The label identifies a stream. |
| 84 // index is the index in the video_device_array of the stream. | 95 // index is the index in the video_device_array of the stream. |
| 85 virtual int video_session_id(const std::string& label, int index); | 96 virtual int video_session_id(const std::string& label, int index); |
| 86 // Returns an audio session_id given a label and an index. | 97 // Returns an audio session_id given a label and an index. |
| 87 virtual int audio_session_id(const std::string& label, int index); | 98 virtual int audio_session_id(const std::string& label, int index); |
| 88 | 99 |
| 89 protected: | 100 protected: |
| 90 int GetNextIpcIdForTest() { return next_ipc_id_; } | 101 int GetNextIpcIdForTest() { return next_ipc_id_; } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 117 void OnDeviceStopped(const std::string& label, | 128 void OnDeviceStopped(const std::string& label, |
| 118 const StreamDeviceInfo& device_info); | 129 const StreamDeviceInfo& device_info); |
| 119 void OnDevicesEnumerated( | 130 void OnDevicesEnumerated( |
| 120 int request_id, | 131 int request_id, |
| 121 const StreamDeviceInfoArray& device_array); | 132 const StreamDeviceInfoArray& device_array); |
| 122 void OnDeviceOpened( | 133 void OnDeviceOpened( |
| 123 int request_id, | 134 int request_id, |
| 124 const std::string& label, | 135 const std::string& label, |
| 125 const StreamDeviceInfo& device_info); | 136 const StreamDeviceInfo& device_info); |
| 126 void OnDeviceOpenFailed(int request_id); | 137 void OnDeviceOpenFailed(int request_id); |
| 138 void OnDevicesChanged(); |
| 127 | 139 |
| 128 // Used for DCHECKs so methods calls won't execute in the wrong thread. | 140 // Used for DCHECKs so methods calls won't execute in the wrong thread. |
| 129 base::ThreadChecker thread_checker_; | 141 base::ThreadChecker thread_checker_; |
| 130 | 142 |
| 131 int next_ipc_id_; | 143 int next_ipc_id_; |
| 132 typedef std::map<std::string, Stream> LabelStreamMap; | 144 typedef std::map<std::string, Stream> LabelStreamMap; |
| 133 LabelStreamMap label_stream_map_; | 145 LabelStreamMap label_stream_map_; |
| 134 | 146 |
| 135 // List of calls made to the browser process that have not yet completed or | 147 // List of calls made to the browser process that have not yet completed or |
| 136 // been canceled. | 148 // been canceled. |
| 137 typedef std::list<Request> RequestList; | 149 typedef std::list<Request> RequestList; |
| 138 RequestList requests_; | 150 RequestList requests_; |
| 139 | 151 |
| 152 std::vector<base::WeakPtr<MediaStreamDispatcherEventHandler>> |
| 153 device_change_subscribers_; |
| 154 |
| 140 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); | 155 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); |
| 141 }; | 156 }; |
| 142 | 157 |
| 143 } // namespace content | 158 } // namespace content |
| 144 | 159 |
| 145 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ | 160 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ |
| OLD | NEW |