Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: content/browser/renderer_host/media/web_contents_video_capture_device.h

Issue 12258042: Rewrite WebContentsVideoCaptureDeviceTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style fixes. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_RENDERER_HOST_MEDIA_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
(...skipping 14 matching lines...) Expand all
25 // routing ID for a RenderViewHost, and from the RenderViewHost instance, a 25 // routing ID for a RenderViewHost, and from the RenderViewHost instance, a
26 // reference to its associated WebContents instance is acquired. From then on, 26 // reference to its associated WebContents instance is acquired. From then on,
27 // WebContentsVideoCaptureDevice will capture from whatever render view is 27 // WebContentsVideoCaptureDevice will capture from whatever render view is
28 // currently associated with that WebContents instance. This allows the 28 // currently associated with that WebContents instance. This allows the
29 // underlying render view to be swapped out (e.g., due to navigation or 29 // underlying render view to be swapped out (e.g., due to navigation or
30 // crashes/reloads), without any interrpution in capturing. 30 // crashes/reloads), without any interrpution in capturing.
31 class CONTENT_EXPORT WebContentsVideoCaptureDevice 31 class CONTENT_EXPORT WebContentsVideoCaptureDevice
32 : public media::VideoCaptureDevice { 32 : public media::VideoCaptureDevice {
33 public: 33 public:
34 // Construct from the a |device_id| string of the form: 34 // Construct from the a |device_id| string of the form:
35 // "render_process_id:render_view_id" 35 // "virtual-media-stream://render_process_id:render_view_id", where
36 // |render_process_id| and |render_view_id| are decimal integers.
36 static media::VideoCaptureDevice* Create(const std::string& device_id); 37 static media::VideoCaptureDevice* Create(const std::string& device_id);
37 38
38 // Construct an instance with the following |test_source| injected for testing
39 // purposes. |destroy_cb| is invoked once all outstanding objects are
40 // completely destroyed.
41 // TODO(miu): Passing a destroy callback suggests needing to revisit the
42 // design philosophy of an asynchronous DeAllocate(). http://crbug.com/158641
miu 2013/02/20 06:45:10 Should 158641 be added to the BUG= line in the des
ncarter (slow) 2013/02/22 02:16:11 Done. Also, revived the TODO because it looks like
43 static media::VideoCaptureDevice* CreateForTesting(
44 RenderWidgetHost* test_source, const base::Closure& destroy_cb);
45
46 virtual ~WebContentsVideoCaptureDevice(); 39 virtual ~WebContentsVideoCaptureDevice();
47 40
48 // VideoCaptureDevice implementation. 41 // VideoCaptureDevice implementation.
49 virtual void Allocate(int width, 42 virtual void Allocate(int width,
50 int height, 43 int height,
51 int frame_rate, 44 int frame_rate,
52 VideoCaptureDevice::EventHandler* consumer) OVERRIDE; 45 VideoCaptureDevice::EventHandler* consumer) OVERRIDE;
53 virtual void Start() OVERRIDE; 46 virtual void Start() OVERRIDE;
54 virtual void Stop() OVERRIDE; 47 virtual void Stop() OVERRIDE;
55 virtual void DeAllocate() OVERRIDE; 48 virtual void DeAllocate() OVERRIDE;
56 49
57 // Note: The following is just a pass-through of the device_id provided to the 50 // Note: The following is just a pass-through of the device_id provided to the
58 // constructor. It does not change when the content of the page changes 51 // constructor. It does not change when the content of the page changes
59 // (e.g., due to navigation), or when the underlying RenderView is 52 // (e.g., due to navigation), or when the underlying RenderView is
60 // swapped-out. 53 // swapped-out.
61 virtual const Name& device_name() OVERRIDE; 54 virtual const Name& device_name() OVERRIDE;
62 55
63 private: 56 private:
64 // Constructors. The latter is used for testing. 57 WebContentsVideoCaptureDevice(const Name& name,
65 WebContentsVideoCaptureDevice( 58 int render_process_id,
66 const Name& name, int render_process_id, int render_view_id); 59 int render_view_id);
67 WebContentsVideoCaptureDevice(RenderWidgetHost* test_source,
68 const base::Closure& destroy_cb);
69 60
70 Name device_name_; 61 Name device_name_;
71 scoped_refptr<CaptureMachine> capturer_; 62 scoped_refptr<CaptureMachine> capturer_;
72 63
73 DISALLOW_COPY_AND_ASSIGN(WebContentsVideoCaptureDevice); 64 DISALLOW_COPY_AND_ASSIGN(WebContentsVideoCaptureDevice);
74 }; 65 };
75 66
76 } // namespace content 67 } // namespace content
77 68
78 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE _H_ 69 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698