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 // WebContents (i.e., the composition of an entire render frame tree), producing
20 // a stream of video frames.
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 the RenderWidgetHost that
25 // encompasses the currently active RenderFrameHost tree for that that
26 // WebContents instance. As the RenderFrameHost tree mutates (e.g., due to page
27 // navigations, or crashes/reloads), capture will continue without interruption.
28 class CONTENT_EXPORT WebContentsVideoCaptureDevice
29 : public media::VideoCaptureDevice
{
31 // Create a WebContentsVideoCaptureDevice instance from the given
32 // |device_id|. Returns NULL if |device_id| is invalid.
33 static media::VideoCaptureDevice
* Create(const std::string
& device_id
);
35 ~WebContentsVideoCaptureDevice() override
;
37 // VideoCaptureDevice implementation.
38 void AllocateAndStart(const media::VideoCaptureParams
& params
,
39 scoped_ptr
<Client
> client
) override
;
40 void StopAndDeAllocate() override
;
43 WebContentsVideoCaptureDevice(
44 int render_process_id
, int main_render_frame_id
);
46 const scoped_ptr
<ContentVideoCaptureDeviceCore
> core_
;
48 DISALLOW_COPY_AND_ASSIGN(WebContentsVideoCaptureDevice
);
52 } // namespace content
54 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_