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