Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / browser / media / capture / web_contents_video_capture_device.h
blobe7d31f6b2bf9fcd489003283b253eddd22af8d1d
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_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "content/common/content_export.h"
12 #include "media/video/capture/video_capture_device.h"
14 namespace content {
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
20 // 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 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 {
34 public:
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;
46 private:
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_