Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / media / video_capture_manager.h
index b3537fa..64589a9 100644 (file)
@@ -24,6 +24,7 @@
 #include "content/common/content_export.h"
 #include "content/common/media/media_stream_options.h"
 #include "media/video/capture/video_capture_device.h"
+#include "media/video/capture/video_capture_device_factory.h"
 #include "media/video/capture/video_capture_types.h"
 
 namespace content {
@@ -37,7 +38,8 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
   typedef base::Callback<
       void(const base::WeakPtr<VideoCaptureController>&)> DoneCB;
 
-  VideoCaptureManager();
+  explicit VideoCaptureManager(
+      scoped_ptr<media::VideoCaptureDeviceFactory> factory);
 
   // Implements MediaStreamProvider.
   virtual void Register(MediaStreamProviderListener* listener,
@@ -52,11 +54,6 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
 
   virtual void Close(int capture_session_id) OVERRIDE;
 
-  // Used by unit test to make sure a fake device is used instead of a real
-  // video capture device. Due to timing requirements, the function must be
-  // called before EnumerateDevices and Open.
-  void UseFakeDevice();
-
   // Called by VideoCaptureHost to locate a capture device for |capture_params|,
   // adding the Host as a client of the device's controller if successful. The
   // value of |session_id| controls which device is selected;
@@ -82,7 +79,8 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
   // function.
   void StopCaptureForClient(VideoCaptureController* controller,
                             VideoCaptureControllerID client_id,
-                            VideoCaptureControllerEventHandler* client_handler);
+                            VideoCaptureControllerEventHandler* client_handler,
+                            bool aborted_due_to_error);
 
   // Retrieves all capture supported formats for a particular device. Returns
   // false if the |capture_session_id| is not found. The supported formats are
@@ -98,6 +96,16 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
   bool GetDeviceFormatsInUse(media::VideoCaptureSessionId capture_session_id,
                              media::VideoCaptureFormats* formats_in_use);
 
+  // Sets the platform-dependent window ID for the desktop capture notification
+  // UI for the given session.
+  void SetDesktopCaptureWindowId(media::VideoCaptureSessionId session_id,
+                                 gfx::NativeViewId window_id);
+
+  // Gets a weak reference to the device factory, used for tests.
+  media::VideoCaptureDeviceFactory* video_capture_device_factory() const {
+    return video_capture_device_factory_.get();
+  }
+
  private:
   virtual ~VideoCaptureManager();
   struct DeviceEntry;
@@ -140,7 +148,7 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
 
   // Find the DeviceEntry that owns a particular controller pointer.
   DeviceEntry* GetDeviceEntryForController(
-      const VideoCaptureController* controller);
+      const VideoCaptureController* controller) const;
 
   bool IsOnDeviceThread() const;
 
@@ -156,6 +164,7 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
   // |entry->video_capture_device|. Ownership of |client| passes to
   // the device.
   void DoStartDeviceOnDeviceThread(
+      media::VideoCaptureSessionId session_id,
       DeviceEntry* entry,
       const media::VideoCaptureParams& params,
       scoped_ptr<media::VideoCaptureDevice::Client> client);
@@ -167,6 +176,13 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
   DeviceInfo* FindDeviceInfoById(const std::string& id,
                                  DeviceInfos& device_vector);
 
+  void SetDesktopCaptureWindowIdOnDeviceThread(DeviceEntry* entry,
+                                               gfx::NativeViewId window_id);
+
+  void SaveDesktopCaptureWindowIdOnDeviceThread(
+      media::VideoCaptureSessionId session_id,
+      gfx::NativeViewId window_id);
+
   // The message loop of media stream device thread, where VCD's live.
   scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_;
 
@@ -174,11 +190,12 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
   MediaStreamProviderListener* listener_;
   media::VideoCaptureSessionId new_capture_session_id_;
 
+  typedef std::map<media::VideoCaptureSessionId, MediaStreamDevice> SessionMap;
   // An entry is kept in this map for every session that has been created via
   // the Open() entry point. The keys are session_id's. This map is used to
   // determine which device to use when StartCaptureForClient() occurs. Used
   // only on the IO thread.
-  std::map<media::VideoCaptureSessionId, MediaStreamDevice> sessions_;
+  SessionMap sessions_;
 
   // An entry, kept in a map, that owns a VideoCaptureDevice and its associated
   // VideoCaptureController. VideoCaptureManager owns all VideoCaptureDevices
@@ -207,6 +224,10 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
   typedef std::set<DeviceEntry*> DeviceEntries;
   DeviceEntries devices_;
 
+  // Device creation factory injected on construction from MediaStreamManager or
+  // from the test harness.
+  scoped_ptr<media::VideoCaptureDeviceFactory> video_capture_device_factory_;
+
   // Local cache of the enumerated video capture devices' names and capture
   // supported formats. A snapshot of the current devices and their capabilities
   // is composed in GetAvailableDevicesInfoOnDeviceThread() --coming
@@ -216,15 +237,9 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
   // active device capture format from the VideoCaptureController associated.
   DeviceInfos devices_info_cache_;
 
-  // For unit testing and for performance/quality tests, a test device can be
-  // used instead of a real one. The device can be a simple fake device (a
-  // rolling pacman), or a file that is played in a loop continuously. This only
-  // applies to the MEDIA_DEVICE_VIDEO_CAPTURE device type.
-  enum {
-    DISABLED,
-    TEST_PATTERN,
-    Y4M_FILE
-  } artificial_device_source_for_testing_;
+  // Accessed on the device thread only.
+  std::map<media::VideoCaptureSessionId, gfx::NativeViewId>
+      notification_window_ids_;
 
   DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager);
 };