Chromium Code Reviews| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 // Stop a started stream. Label is the label provided in OnStreamGenerated. | 45 // Stop a started stream. Label is the label provided in OnStreamGenerated. |
| 46 virtual void StopStream(const std::string& label); | 46 virtual void StopStream(const std::string& label); |
| 47 | 47 |
| 48 // Request to enumerate devices. | 48 // Request to enumerate devices. |
| 49 void EnumerateDevices( | 49 void EnumerateDevices( |
| 50 int request_id, | 50 int request_id, |
| 51 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 51 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
| 52 media_stream::MediaStreamType type, | 52 media_stream::MediaStreamType type, |
| 53 const GURL& security_origin); | 53 const GURL& security_origin); |
| 54 | 54 |
| 55 // Request to stop enumerating devices. | |
| 56 void StopEnumerateDevices( | |
| 57 int request_id, | |
| 58 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler); | |
| 59 | |
| 55 // Request to open a device. | 60 // Request to open a device. |
| 56 void OpenDevice( | 61 void OpenDevice( |
| 57 int request_id, | 62 int request_id, |
| 58 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 63 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
| 59 const std::string& device_id, | 64 const std::string& device_id, |
| 60 media_stream::MediaStreamType type, | 65 media_stream::MediaStreamType type, |
| 61 const GURL& security_origin); | 66 const GURL& security_origin); |
| 62 | 67 |
| 63 // Close a started device. |label| is provided in OnDeviceOpened. | 68 // Close a started device. |label| is provided in OnDeviceOpened. |
| 64 void CloseDevice(const std::string& label); | 69 void CloseDevice(const std::string& label); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 76 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicVideoDevice); | 81 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicVideoDevice); |
| 77 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure); | 82 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure); |
| 78 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, CancelGenerateStream); | 83 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, CancelGenerateStream); |
| 79 | 84 |
| 80 struct Request; | 85 struct Request; |
| 81 | 86 |
| 82 // Private class for keeping track of opened devices and who have | 87 // Private class for keeping track of opened devices and who have |
| 83 // opened it. | 88 // opened it. |
| 84 struct Stream; | 89 struct Stream; |
| 85 | 90 |
| 91 struct EnumerationRequest { | |
| 92 EnumerationRequest( | |
| 93 const base::WeakPtr<MediaStreamDispatcherEventHandler>& handler, | |
| 94 int request_id); | |
| 95 | |
| 96 base::WeakPtr<MediaStreamDispatcherEventHandler> handler; | |
| 97 int request_id; | |
| 98 }; | |
| 99 | |
| 100 // List of requests made to EnumerateDevices. | |
| 101 typedef std::list<EnumerationRequest> EnumerationRequestList; | |
| 102 | |
| 103 struct EnumerationState { | |
| 104 EnumerationState(); | |
| 105 | |
| 106 bool started; | |
| 107 int ipc_id; | |
| 108 std::string label; | |
| 109 bool cache_valid; | |
| 110 media_stream::StreamDeviceInfoArray cached_device; | |
| 111 EnumerationRequestList requests; | |
| 112 }; | |
| 113 | |
| 86 // Messages from the browser. | 114 // Messages from the browser. |
| 87 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 115 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 88 void OnStreamGenerated( | 116 void OnStreamGenerated( |
| 89 int request_id, | 117 int request_id, |
| 90 const std::string& label, | 118 const std::string& label, |
| 91 const media_stream::StreamDeviceInfoArray& audio_array, | 119 const media_stream::StreamDeviceInfoArray& audio_array, |
| 92 const media_stream::StreamDeviceInfoArray& video_array); | 120 const media_stream::StreamDeviceInfoArray& video_array); |
| 93 void OnStreamGenerationFailed(int request_id); | 121 void OnStreamGenerationFailed(int request_id); |
| 94 void OnVideoDeviceFailed(const std::string& label, int index); | 122 void OnVideoDeviceFailed(const std::string& label, int index); |
| 95 void OnAudioDeviceFailed(const std::string& label, int index); | 123 void OnAudioDeviceFailed(const std::string& label, int index); |
| 96 void OnDevicesEnumerated( | 124 void OnDevicesEnumerated( |
| 97 int request_id, | 125 int request_id, |
| 126 const std::string& label, | |
| 98 const media_stream::StreamDeviceInfoArray& device_array); | 127 const media_stream::StreamDeviceInfoArray& device_array); |
| 99 void OnDevicesEnumerationFailed(int request_id); | 128 void OnDevicesEnumerationFailed(int request_id); |
| 100 void OnDeviceOpened( | 129 void OnDeviceOpened( |
| 101 int request_id, | 130 int request_id, |
| 102 const std::string& label, | 131 const std::string& label, |
| 103 const media_stream::StreamDeviceInfo& device_info); | 132 const media_stream::StreamDeviceInfo& device_info); |
| 104 void OnDeviceOpenFailed(int request_id); | 133 void OnDeviceOpenFailed(int request_id); |
| 105 | 134 |
| 135 bool RemoveEnumerationRequest( | |
| 136 int request_id, | |
| 137 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | |
| 138 EnumerationState* state); | |
| 139 | |
| 140 // Used for DCHECKs so methods calls won't execute in the wrong thread. | |
| 141 MessageLoop* main_loop_; | |
|
tommi (sloooow) - chröme
2012/08/01 10:21:38
Remember John's comment on MessageLoop pointers.
wjia(left Chromium)
2012/08/01 14:24:03
Right. Changed to MLP.
| |
| 142 | |
| 106 int next_ipc_id_; | 143 int next_ipc_id_; |
| 107 typedef std::map<std::string, Stream> LabelStreamMap; | 144 typedef std::map<std::string, Stream> LabelStreamMap; |
| 108 LabelStreamMap label_stream_map_; | 145 LabelStreamMap label_stream_map_; |
| 109 | 146 |
| 147 EnumerationState audio_enumeration_state_; | |
| 148 EnumerationState video_enumeration_state_; | |
| 149 | |
| 110 // List of calls made to GenerateStream that has not yet completed. | 150 // List of calls made to GenerateStream that has not yet completed. |
| 111 typedef std::list<Request> RequestList; | 151 typedef std::list<Request> RequestList; |
| 112 RequestList requests_; | 152 RequestList requests_; |
| 113 | 153 |
| 114 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); | 154 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); |
| 115 }; | 155 }; |
| 116 | 156 |
| 117 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ | 157 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ |
| OLD | NEW |