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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_MEDIA_CAPTURE_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_
6 #define CONTENT_BROWSER_MEDIA_CAPTURE_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "content/common/content_export.h"
12 #include "media/video/capture/video_capture_device.h"
16 class ContentVideoCaptureDeviceCore
;
18 // A virtualized VideoCaptureDevice that mirrors the displayed contents of a
19 // tab (accessed via its associated WebContents instance), producing a stream of
22 // An instance is created by providing a device_id. The device_id contains
23 // information necessary for finding a WebContents instance. From then on,
24 // WebContentsVideoCaptureDevice will capture from whatever render view is
25 // currently associated with that WebContents instance. This allows the
26 // underlying render view to be swapped out (e.g., due to navigation or
27 // crashes/reloads), without any interruption in capturing.
29 // TODO(miu): In a soon upcoming change, the cross-site isolation migration of
30 // this code will be completed such that the main RenderFrameHost is tracked
31 // instead of the RenderViewHost.
32 class CONTENT_EXPORT WebContentsVideoCaptureDevice
33 : public media::VideoCaptureDevice
{
35 // Create a WebContentsVideoCaptureDevice instance from the given
36 // |device_id|. Returns NULL if |device_id| is invalid.
37 static media::VideoCaptureDevice
* Create(const std::string
& device_id
);
39 virtual ~WebContentsVideoCaptureDevice();
41 // VideoCaptureDevice implementation.
42 virtual void AllocateAndStart(const media::VideoCaptureParams
& params
,
43 scoped_ptr
<Client
> client
) OVERRIDE
;
44 virtual void StopAndDeAllocate() OVERRIDE
;
47 WebContentsVideoCaptureDevice(
48 int render_process_id
, int main_render_frame_id
);
50 const scoped_ptr
<ContentVideoCaptureDeviceCore
> core_
;
52 DISALLOW_COPY_AND_ASSIGN(WebContentsVideoCaptureDevice
);
56 } // namespace content
58 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_