#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 {
typedef base::Callback<
void(const base::WeakPtr<VideoCaptureController>&)> DoneCB;
- VideoCaptureManager();
+ explicit VideoCaptureManager(
+ scoped_ptr<media::VideoCaptureDeviceFactory> factory);
// Implements MediaStreamProvider.
virtual void Register(MediaStreamProviderListener* listener,
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;
// 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
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;
// Find the DeviceEntry that owns a particular controller pointer.
DeviceEntry* GetDeviceEntryForController(
- const VideoCaptureController* controller);
+ const VideoCaptureController* controller) const;
bool IsOnDeviceThread() const;
// |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);
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_;
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
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
// 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);
};