OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_MEDIA_CAPTURE_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_CAPTURE_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_ |
6 #define CONTENT_BROWSER_MEDIA_CAPTURE_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_ | 6 #define CONTENT_BROWSER_MEDIA_CAPTURE_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "media/video/capture/video_capture_device.h" | 12 #include "media/video/capture/video_capture_device.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 class ContentVideoCaptureDeviceCore; | 16 class ContentVideoCaptureDeviceCore; |
17 | 17 |
18 // A virtualized VideoCaptureDevice that mirrors the displayed contents of a | 18 // A virtualized VideoCaptureDevice that mirrors the displayed contents of a |
19 // tab (accessed via its associated WebContents instance), producing a stream of | 19 // WebContents (i.e., the composition of an entire render frame tree), producing |
20 // video frames. | 20 // a stream of video frames. |
21 // | 21 // |
22 // An instance is created by providing a device_id. The device_id contains | 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, | 23 // information necessary for finding a WebContents instance. From then on, |
24 // WebContentsVideoCaptureDevice will capture from whatever render view is | 24 // WebContentsVideoCaptureDevice will capture from the RenderWidgetHost that |
25 // currently associated with that WebContents instance. This allows the | 25 // encompasses the currently active RenderFrameHost tree for that that |
26 // underlying render view to be swapped out (e.g., due to navigation or | 26 // WebContents instance. As the RenderFrameHost tree mutates (e.g., due to page |
27 // crashes/reloads), without any interruption in capturing. | 27 // navigations, or crashes/reloads), capture will continue without interruption. |
28 // | |
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 | 28 class CONTENT_EXPORT WebContentsVideoCaptureDevice |
33 : public media::VideoCaptureDevice { | 29 : public media::VideoCaptureDevice { |
34 public: | 30 public: |
35 // Create a WebContentsVideoCaptureDevice instance from the given | 31 // Create a WebContentsVideoCaptureDevice instance from the given |
36 // |device_id|. Returns NULL if |device_id| is invalid. | 32 // |device_id|. Returns NULL if |device_id| is invalid. |
37 static media::VideoCaptureDevice* Create(const std::string& device_id); | 33 static media::VideoCaptureDevice* Create(const std::string& device_id); |
38 | 34 |
39 virtual ~WebContentsVideoCaptureDevice(); | 35 virtual ~WebContentsVideoCaptureDevice(); |
40 | 36 |
41 // VideoCaptureDevice implementation. | 37 // VideoCaptureDevice implementation. |
42 virtual void AllocateAndStart(const media::VideoCaptureParams& params, | 38 virtual void AllocateAndStart(const media::VideoCaptureParams& params, |
43 scoped_ptr<Client> client) OVERRIDE; | 39 scoped_ptr<Client> client) OVERRIDE; |
44 virtual void StopAndDeAllocate() OVERRIDE; | 40 virtual void StopAndDeAllocate() OVERRIDE; |
45 | 41 |
46 private: | 42 private: |
47 WebContentsVideoCaptureDevice( | 43 WebContentsVideoCaptureDevice( |
48 int render_process_id, int main_render_frame_id); | 44 int render_process_id, int main_render_frame_id); |
49 | 45 |
50 const scoped_ptr<ContentVideoCaptureDeviceCore> core_; | 46 const scoped_ptr<ContentVideoCaptureDeviceCore> core_; |
51 | 47 |
52 DISALLOW_COPY_AND_ASSIGN(WebContentsVideoCaptureDevice); | 48 DISALLOW_COPY_AND_ASSIGN(WebContentsVideoCaptureDevice); |
53 }; | 49 }; |
54 | 50 |
55 | 51 |
56 } // namespace content | 52 } // namespace content |
57 | 53 |
58 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_ | 54 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_ |
OLD | NEW |