| 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 "base/memory/ref_counted.h" |
| 19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 20 #include "content/common/media/media_stream_options.h" | 20 #include "content/common/media/media_stream_options.h" |
| 21 | 21 |
| 22 namespace base { | |
| 23 class SingleThreadTaskRunner; | |
| 24 } | |
| 25 | |
| 26 namespace content { | 22 namespace content { |
| 27 | 23 |
| 28 enum MediaStreamProviderError { | 24 enum MediaStreamProviderError { |
| 29 kMediaStreamOk = 0, | 25 kMediaStreamOk = 0, |
| 30 kInvalidMediaStreamType, | 26 kInvalidMediaStreamType, |
| 31 kInvalidSession, | 27 kInvalidSession, |
| 32 kUnknownSession, | 28 kUnknownSession, |
| 33 kDeviceNotAvailable, | 29 kDeviceNotAvailable, |
| 34 kDeviceAlreadyInUse, | 30 kDeviceAlreadyInUse, |
| 35 kUnknownError | 31 kUnknownError |
| (...skipping 15 matching lines...) Expand all Loading... |
| 51 virtual void Aborted(MediaStreamType stream_type, int capture_session_id) = 0; | 47 virtual void Aborted(MediaStreamType stream_type, int capture_session_id) = 0; |
| 52 | 48 |
| 53 protected: | 49 protected: |
| 54 virtual ~MediaStreamProviderListener() {} | 50 virtual ~MediaStreamProviderListener() {} |
| 55 }; | 51 }; |
| 56 | 52 |
| 57 // Implemented by a manager class providing captured media. | 53 // Implemented by a manager class providing captured media. |
| 58 class CONTENT_EXPORT MediaStreamProvider | 54 class CONTENT_EXPORT MediaStreamProvider |
| 59 : public base::RefCountedThreadSafe<MediaStreamProvider> { | 55 : public base::RefCountedThreadSafe<MediaStreamProvider> { |
| 60 public: | 56 public: |
| 61 // Registers a listener and a device message loop. | 57 // Registers a listener. |
| 62 virtual void Register(MediaStreamProviderListener* listener, | 58 virtual void RegisterListener(MediaStreamProviderListener* listener) = 0; |
| 63 const scoped_refptr<base::SingleThreadTaskRunner>& | 59 |
| 64 device_task_runner) = 0; | 60 // Unregisters a previously registered listener. |
| 61 virtual void UnregisterListener() = 0; |
| 65 | 62 |
| 66 // Opens the specified device. The device is not started and it is still | 63 // Opens the specified device. The device is not started and it is still |
| 67 // possible for other applications to open the device before the device is | 64 // possible for other applications to open the device before the device is |
| 68 // started. |Opened| is called when the device is opened. | 65 // started. |Opened| is called when the device is opened. |
| 69 // kInvalidMediaCaptureSessionId is returned on error. | 66 // kInvalidMediaCaptureSessionId is returned on error. |
| 70 virtual int Open(const StreamDeviceInfo& device) = 0; | 67 virtual int Open(const StreamDeviceInfo& device) = 0; |
| 71 | 68 |
| 72 // Closes the specified device and calls |Closed| when done. | 69 // Closes the specified device and calls |Closed| when done. |
| 73 virtual void Close(int capture_session_id) = 0; | 70 virtual void Close(int capture_session_id) = 0; |
| 74 | 71 |
| 75 protected: | 72 protected: |
| 76 friend class base::RefCountedThreadSafe<MediaStreamProvider>; | 73 friend class base::RefCountedThreadSafe<MediaStreamProvider>; |
| 77 virtual ~MediaStreamProvider() {} | 74 virtual ~MediaStreamProvider() {} |
| 78 }; | 75 }; |
| 79 | 76 |
| 80 } // namespace content | 77 } // namespace content |
| 81 | 78 |
| 82 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_PROVIDER_H_ | 79 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_PROVIDER_H_ |
| OLD | NEW |