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 // MediaStreamProvider is used to capture media of the types defined in | 5 // MediaStreamProvider is used to capture media of the types defined in |
6 // MediaStreamType. There is only one MediaStreamProvider instance per media | 6 // MediaStreamType. There is only one MediaStreamProvider instance per media |
7 // type and a MediaStreamProvider instance can have only one registered | 7 // type and a MediaStreamProvider instance can have only one registered |
8 // listener. | 8 // listener. |
9 // The MediaStreamManager is expected to be called on Browser::IO thread and | 9 // The MediaStreamManager is expected to be called on Browser::IO thread and |
10 // the listener will be called on the same thread. | 10 // the listener will be called on the same thread. |
11 | 11 |
12 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_PROVIDER_H_ | 12 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_PROVIDER_H_ |
13 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_PROVIDER_H_ | 13 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_PROVIDER_H_ |
14 | 14 |
15 #include <list> | 15 #include <list> |
16 #include <string> | 16 #include <string> |
17 | 17 |
| 18 #include "base/memory/ref_counted.h" |
18 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
19 #include "content/common/media/media_stream_options.h" | 20 #include "content/common/media/media_stream_options.h" |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 class MessageLoopProxy; | 23 class MessageLoopProxy; |
23 } | 24 } |
24 | 25 |
25 namespace media_stream { | 26 namespace media_stream { |
26 | 27 |
27 enum MediaStreamProviderError { | 28 enum MediaStreamProviderError { |
(...skipping 26 matching lines...) Expand all Loading... |
54 // Called by a MediaStreamProvider when an error has occured. | 55 // Called by a MediaStreamProvider when an error has occured. |
55 virtual void Error(MediaStreamType stream_type, | 56 virtual void Error(MediaStreamType stream_type, |
56 int capture_session_id, | 57 int capture_session_id, |
57 MediaStreamProviderError error) = 0; | 58 MediaStreamProviderError error) = 0; |
58 | 59 |
59 protected: | 60 protected: |
60 virtual ~MediaStreamProviderListener() {} | 61 virtual ~MediaStreamProviderListener() {} |
61 }; | 62 }; |
62 | 63 |
63 // Implemented by a manager class providing captured media. | 64 // Implemented by a manager class providing captured media. |
64 class CONTENT_EXPORT MediaStreamProvider { | 65 class CONTENT_EXPORT MediaStreamProvider |
| 66 : public base::RefCountedThreadSafe<MediaStreamProvider> { |
65 public: | 67 public: |
66 // Registers a listener and a device message loop. | 68 // Registers a listener and a device message loop. |
67 virtual void Register(MediaStreamProviderListener* listener, | 69 virtual void Register(MediaStreamProviderListener* listener, |
68 base::MessageLoopProxy* device_thread_loop) = 0; | 70 base::MessageLoopProxy* device_thread_loop) = 0; |
69 | 71 |
70 // Unregisters the previously registered listener. | 72 // Unregisters the previously registered listener. |
71 virtual void Unregister() = 0; | 73 virtual void Unregister() = 0; |
72 | 74 |
73 // Enumerates existing capture devices and calls |DevicesEnumerated|. | 75 // Enumerates existing capture devices and calls |DevicesEnumerated|. |
74 virtual void EnumerateDevices() = 0; | 76 virtual void EnumerateDevices() = 0; |
75 | 77 |
76 // Opens the specified device. The device is not started and it is still | 78 // Opens the specified device. The device is not started and it is still |
77 // possible for other applications to open the device before the device is | 79 // possible for other applications to open the device before the device is |
78 // started. |Opened| is called when the device is opened. | 80 // started. |Opened| is called when the device is opened. |
79 // kInvalidMediaCaptureSessionId is returned on error. | 81 // kInvalidMediaCaptureSessionId is returned on error. |
80 virtual int Open(const StreamDeviceInfo& device) = 0; | 82 virtual int Open(const StreamDeviceInfo& device) = 0; |
81 | 83 |
82 // Closes the specified device and calls |Closed| when done. | 84 // Closes the specified device and calls |Closed| when done. |
83 virtual void Close(int capture_session_id) = 0; | 85 virtual void Close(int capture_session_id) = 0; |
84 | 86 |
85 protected: | 87 protected: |
| 88 friend class base::RefCountedThreadSafe<MediaStreamProvider>; |
86 virtual ~MediaStreamProvider() {} | 89 virtual ~MediaStreamProvider() {} |
87 }; | 90 }; |
88 | 91 |
89 } // namespace media_stream | 92 } // namespace media_stream |
90 | 93 |
91 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_PROVIDER_H_ | 94 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_PROVIDER_H_ |
OLD | NEW |