| 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 19 matching lines...) Expand all Loading... |
| 30 // It's the complement of MediaStreamDispatcherHost (owned by | 30 // It's the complement of MediaStreamDispatcherHost (owned by |
| 31 // BrowserRenderProcessHost). | 31 // BrowserRenderProcessHost). |
| 32 class CONTENT_EXPORT MediaStreamDispatcher | 32 class CONTENT_EXPORT MediaStreamDispatcher |
| 33 : public content::RenderViewObserver, | 33 : public content::RenderViewObserver, |
| 34 public base::SupportsWeakPtr<MediaStreamDispatcher> { | 34 public base::SupportsWeakPtr<MediaStreamDispatcher> { |
| 35 public: | 35 public: |
| 36 explicit MediaStreamDispatcher(RenderViewImpl* render_view); | 36 explicit MediaStreamDispatcher(RenderViewImpl* render_view); |
| 37 virtual ~MediaStreamDispatcher(); | 37 virtual ~MediaStreamDispatcher(); |
| 38 | 38 |
| 39 // Request a new media stream to be created. | 39 // Request a new media stream to be created. |
| 40 // This can be used either of WebKit or a plugin. | 40 // This can be used either by WebKit or a plugin. |
| 41 // Note: The event_handler must be valid for as long as the stream exists. | 41 // Note: The event_handler must be valid for as long as the stream exists. |
| 42 virtual void GenerateStream( | 42 virtual void GenerateStream( |
| 43 int request_id, | 43 int request_id, |
| 44 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 44 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
| 45 media_stream::StreamOptions components, | 45 media_stream::StreamOptions components, |
| 46 const GURL& security_origin); | 46 const GURL& security_origin); |
| 47 | 47 |
| 48 // Like GenerateStream above, except use the device specified by |device_id| |
| 49 // rather than allow the user to choose one. |
| 50 virtual void GenerateStreamForDevice( |
| 51 int request_id, |
| 52 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
| 53 media_stream::StreamOptions components, |
| 54 const std::string& device_id, |
| 55 const GURL& security_origin); |
| 56 |
| 48 // Cancel the request for a new media stream to be created. | 57 // Cancel the request for a new media stream to be created. |
| 49 virtual void CancelGenerateStream(int request_id); | 58 virtual void CancelGenerateStream(int request_id); |
| 50 | 59 |
| 51 // Stop a started stream. Label is the label provided in OnStreamGenerated. | 60 // Stop a started stream. Label is the label provided in OnStreamGenerated. |
| 52 virtual void StopStream(const std::string& label); | 61 virtual void StopStream(const std::string& label); |
| 53 | 62 |
| 54 // Request to enumerate devices. | 63 // Request to enumerate devices. |
| 55 void EnumerateDevices( | 64 void EnumerateDevices( |
| 56 int request_id, | 65 int request_id, |
| 57 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 66 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 77 // Check if the label is a valid stream. | 86 // Check if the label is a valid stream. |
| 78 virtual bool IsStream(const std::string& label); | 87 virtual bool IsStream(const std::string& label); |
| 79 // Get the video session_id given a label. The label identifies a stream. | 88 // Get the video session_id given a label. The label identifies a stream. |
| 80 // index is the index in the video_device_array of the stream. | 89 // index is the index in the video_device_array of the stream. |
| 81 virtual int video_session_id(const std::string& label, int index); | 90 virtual int video_session_id(const std::string& label, int index); |
| 82 // Returns an audio session_id given a label and an index. | 91 // Returns an audio session_id given a label and an index. |
| 83 virtual int audio_session_id(const std::string& label, int index); | 92 virtual int audio_session_id(const std::string& label, int index); |
| 84 | 93 |
| 85 private: | 94 private: |
| 86 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicStream); | 95 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicStream); |
| 96 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicStreamForDevice); |
| 87 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicVideoDevice); | 97 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicVideoDevice); |
| 88 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure); | 98 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure); |
| 89 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, CancelGenerateStream); | 99 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, CancelGenerateStream); |
| 90 | 100 |
| 91 struct Request; | 101 struct Request; |
| 92 | 102 |
| 93 // Private class for keeping track of opened devices and who have | 103 // Private class for keeping track of opened devices and who have |
| 94 // opened it. | 104 // opened it. |
| 95 struct Stream; | 105 struct Stream; |
| 96 | 106 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // Used for DCHECKs so methods calls won't execute in the wrong thread. | 158 // Used for DCHECKs so methods calls won't execute in the wrong thread. |
| 149 scoped_refptr<base::MessageLoopProxy> main_loop_; | 159 scoped_refptr<base::MessageLoopProxy> main_loop_; |
| 150 | 160 |
| 151 int next_ipc_id_; | 161 int next_ipc_id_; |
| 152 typedef std::map<std::string, Stream> LabelStreamMap; | 162 typedef std::map<std::string, Stream> LabelStreamMap; |
| 153 LabelStreamMap label_stream_map_; | 163 LabelStreamMap label_stream_map_; |
| 154 | 164 |
| 155 EnumerationState audio_enumeration_state_; | 165 EnumerationState audio_enumeration_state_; |
| 156 EnumerationState video_enumeration_state_; | 166 EnumerationState video_enumeration_state_; |
| 157 | 167 |
| 158 // List of calls made to GenerateStream that has not yet completed. | 168 // List of calls made to GenerateStream/GenerateStreamForDevice that has not |
| 169 // yet completed. |
| 159 typedef std::list<Request> RequestList; | 170 typedef std::list<Request> RequestList; |
| 160 RequestList requests_; | 171 RequestList requests_; |
| 161 | 172 |
| 162 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); | 173 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); |
| 163 }; | 174 }; |
| 164 | 175 |
| 165 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ | 176 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ |
| OLD | NEW |