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/capture/content/screen_capture_device_core.h"
13 #include "media/capture/video/video_capture_device.h"
17 // A virtualized VideoCaptureDevice that mirrors the displayed contents of a
18 // WebContents (i.e., the composition of an entire render frame tree), producing
19 // a stream of video frames.
21 // An instance is created by providing a device_id. The device_id contains
22 // information necessary for finding a WebContents instance. From then on,
23 // WebContentsVideoCaptureDevice will capture from the RenderWidgetHost that
24 // encompasses the currently active RenderFrameHost tree for that that
25 // WebContents instance. As the RenderFrameHost tree mutates (e.g., due to page
26 // navigations, or crashes/reloads), capture will continue without interruption.
27 class CONTENT_EXPORT WebContentsVideoCaptureDevice
28 : public media::VideoCaptureDevice
{
30 // Create a WebContentsVideoCaptureDevice instance from the given
31 // |device_id|. Returns NULL if |device_id| is invalid.
32 static media::VideoCaptureDevice
* Create(const std::string
& device_id
);
34 ~WebContentsVideoCaptureDevice() override
;
36 // VideoCaptureDevice implementation.
37 void AllocateAndStart(const media::VideoCaptureParams
& params
,
38 scoped_ptr
<Client
> client
) override
;
39 void StopAndDeAllocate() override
;
42 WebContentsVideoCaptureDevice(
43 int render_process_id
,
44 int main_render_frame_id
,
45 bool enable_auto_throttling
);
47 const scoped_ptr
<media::ScreenCaptureDeviceCore
> core_
;
49 DISALLOW_COPY_AND_ASSIGN(WebContentsVideoCaptureDevice
);
53 } // namespace content
55 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_