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/video_capture_controller.h

Issue 7002027: VideoCaptureHost (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 7 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
(Empty)
1 // Copyright (c) 2011 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.
4
5 // VideoCaptureController is the glue between VideoCaptureHost,
6 // VideoCaptureManager and VideoCaptrurDevice.
scherkus (not reviewing) 2011/05/23 05:05:09 s/VideoCaptrurDevice/VideoCaptureDevice/
Per K 2011/05/23 12:05:47 Done.
7 // It provides functions for VideoCaptureHost to start a VideoCaptureDevice and
8 // is responsible for keeping track of TransportDIBs and filling them with I420
9 // video frames for IPC communication between VideoCaptureHost and
10 // VideoCaptureMessageFilter.
11 // It implements media::VideoCaptureDevice::EventHandler to get video frames
12 // from a VideoCaptureDevice object and do color conversion straight into the
13 // TransportDIBs to avoid a memory copy.
14
15 #ifndef CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_CONTROLLER_H_
16 #define CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_CONTROLLER_H_
17
18 #include <list>
19 #include <map>
20
21 #include "base/memory/ref_counted.h"
22 #include "base/synchronization/lock.h"
23 #include "base/task.h"
24 #include "media/video/capture/video_capture_device.h"
25 #include "media/video/capture/video_capture_types.h"
26 #include "ui/gfx/surface/transport_dib.h"
27
28 class VideoCaptureController
29 : public base::RefCountedThreadSafe<VideoCaptureController>,
30 public media::VideoCaptureDevice::EventHandler {
31 public:
32 // Id used for identifying an object of VideoCaptureController
scherkus (not reviewing) 2011/05/23 05:05:09 comments end w/ periods
Per K 2011/05/23 12:05:47 Done.
33 typedef std::pair<int32, int> ControllerId;
34 class EventHandler {
35 public:
36 // An Error have occurred in the VideoCaptureDevice.
37 virtual void OnError(ControllerId id) = 0;
38 // An TransportDIB have been filled with I420 video.
scherkus (not reviewing) 2011/05/23 05:05:09 space these methods out
Per K 2011/05/23 12:05:47 Done.
39 virtual void OnBufferReady(ControllerId id,
40 TransportDIB::Handle handle,
41 base::Time timestamp) = 0;
42 // The frame resolution the VideoCaptureDevice capture video in.
43 virtual void OnFrameInfo(ControllerId id,
44 int width,
45 int height,
46 int frame_rate) = 0;
47 // Report that this object can be deleted.
48 virtual void OnReadyToDelete(ControllerId id) = 0;
49
50 protected:
51 virtual ~EventHandler() {}
52 };
53
54 VideoCaptureController(ControllerId id,
55 VideoCaptureController::EventHandler* event_handler);
scherkus (not reviewing) 2011/05/23 05:05:09 nit: you don't need to prefix w/ VideoCaptureContr
Per K 2011/05/23 12:05:47 Done.
56 ~VideoCaptureController();
scherkus (not reviewing) 2011/05/23 05:05:09 virtual
Per K 2011/05/23 12:05:47 Done.
57
58 // Starts video capturing and tries to use the resolution specified in
59 // params.
60 // When capturing has started EventHandler::OnFrameInfo is called with
61 // resolution that best matches the requested that the video capture device
62 // support.
63 void StartCapture(const media::VideoCaptureParams& params);
64 // Stop video capture.
scherkus (not reviewing) 2011/05/23 05:05:09 add a blank line to space these before comments
Per K 2011/05/23 12:05:47 Done.
65 // When the capture is stopped and all TransportDIBS have been returned
66 // EventHandler::OnReadyToDelete will be called.
67 // stopped_task may be null but it can be used to get a notification when the
68 // device is stopped.
69 void StopCapture(Task* stopped_task);
70 // Return a DIB previously given in EventHandler::OnBufferReady.
71 void ReturnTransportDIB(TransportDIB::Handle handle);
72
73 // Implement media::VideoCaptureDevice::EventHandler
scherkus (not reviewing) 2011/05/23 05:05:09 comments end w/ periods
Per K 2011/05/23 12:05:47 Done.
74 virtual void OnIncomingCapturedFrame(const uint8* data,
75 int length,
76 base::Time timestamp);
77 virtual void OnError();
78 virtual void OnFrameInfo(const media::VideoCaptureDevice::Capability& info);
79
80 private:
81 // Called by VideoCaptureManager when a device have been stopped.
82 void OnDeviceStopped(Task* stopped_task);
83
84 // Lock to protect free_dibs_.
scherkus (not reviewing) 2011/05/23 05:05:09 what about owned_dibs_? it looks like you lock in
Per K 2011/05/23 12:05:47 Done.
85 base::Lock lock_;
86 bool report_ready_to_delete_;
87 typedef std::list<TransportDIB::Handle> DIBHANDLEList;
scherkus (not reviewing) 2011/05/23 05:05:09 DIBHANDLEList -> DIBHandleList
Per K 2011/05/23 12:05:47 Done.
88 typedef std::map<TransportDIB::Handle, TransportDIB*> DIBMap;
89 // Free DIBS that can be filled with video frames.
scherkus (not reviewing) 2011/05/23 05:05:09 please add a blank line before these comments to m
Per K 2011/05/23 12:05:47 Done.
90 DIBHANDLEList free_dibs_;
91 // All DIBS created by this object.
92 DIBMap owned_dibs_;
93 EventHandler& event_handler_;
scherkus (not reviewing) 2011/05/23 05:05:09 no ref types -- use pointer please
Per K 2011/05/23 12:05:47 Done.
94 // The parameter that was requested when starting the capture device.
95 media::VideoCaptureParams params_;
96 // Id used for identifying this object.
97 ControllerId id_;
98 media::VideoCaptureDevice::Capability frame_info_;
99 };
scherkus (not reviewing) 2011/05/23 05:05:09 DISALLOW_IMPLICIT_DESTRUCTORS
Per K 2011/05/23 12:05:47 DISALLOW_IMPLICIT_CONSTRUCTORS?
100
101 #endif // CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698