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

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

Issue 23551011: From Video Capture, abolish OnFrameInfo and enable resolution changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add assert to vcbp unittest Created 7 years, 2 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 // VideoCaptureController is the glue between a VideoCaptureDevice and all 5 // VideoCaptureController is the glue between a VideoCaptureDevice and all
6 // VideoCaptureHosts that have connected to it. A controller exists on behalf of 6 // VideoCaptureHosts that have connected to it. A controller exists on behalf of
7 // one (and only one) VideoCaptureDevice; both are owned by the 7 // one (and only one) VideoCaptureDevice; both are owned by the
8 // VideoCaptureManager. 8 // VideoCaptureManager.
9 // 9 //
10 // The VideoCaptureController is responsible for: 10 // The VideoCaptureController is responsible for:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_ 48 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_
49 49
50 #include <list> 50 #include <list>
51 #include <map> 51 #include <map>
52 52
53 #include "base/compiler_specific.h" 53 #include "base/compiler_specific.h"
54 #include "base/memory/ref_counted.h" 54 #include "base/memory/ref_counted.h"
55 #include "base/memory/scoped_ptr.h" 55 #include "base/memory/scoped_ptr.h"
56 #include "base/memory/weak_ptr.h" 56 #include "base/memory/weak_ptr.h"
57 #include "base/process/process.h" 57 #include "base/process/process.h"
58 #include "base/synchronization/lock.h" 58 #include "base/synchronization/lock.h"
Ami GONE FROM CHROMIUM 2013/10/04 00:24:15 drop?
ncarter (slow) 2013/10/16 02:08:40 Done.
59 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h" 59 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h"
60 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" 60 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h"
61 #include "content/common/content_export.h" 61 #include "content/common/content_export.h"
62 #include "content/common/media/video_capture.h" 62 #include "content/common/media/video_capture.h"
63 #include "media/video/capture/video_capture.h" 63 #include "media/video/capture/video_capture.h"
64 #include "media/video/capture/video_capture_device.h" 64 #include "media/video/capture/video_capture_device.h"
65 #include "media/video/capture/video_capture_types.h" 65 #include "media/video/capture/video_capture_types.h"
66 66
67 namespace content { 67 namespace content {
68 class VideoCaptureBufferPool; 68 class VideoCaptureBufferPool;
69 69
70 class CONTENT_EXPORT VideoCaptureController { 70 class CONTENT_EXPORT VideoCaptureController {
71 public: 71 public:
72 VideoCaptureController(); 72 VideoCaptureController();
73 virtual ~VideoCaptureController(); 73 virtual ~VideoCaptureController();
74 74
75 base::WeakPtr<VideoCaptureController> GetWeakPtr(); 75 base::WeakPtr<VideoCaptureController> GetWeakPtr();
76 76
77 // Return a new VideoCaptureDeviceClient to forward capture events to this 77 // Return a new VideoCaptureDeviceClient to forward capture events to this
78 // instance. 78 // instance.
79 scoped_ptr<media::VideoCaptureDevice::Client> NewDeviceClient(); 79 scoped_ptr<media::VideoCaptureDevice::Client> NewDeviceClient();
80 80
81 // Start video capturing and try to use the resolution specified in 81 // Start video capturing and try to use the resolution specified in |params|.
82 // |params|. 82 // Buffers will be shared to the client as necessary. The client will continue
83 // When capturing starts, the |event_handler| will receive an OnFrameInfo() 83 // to receive frames from the device until RemoveClient() is called.
84 // call informing it of the resolution that was actually picked by the device.
85 void AddClient(const VideoCaptureControllerID& id, 84 void AddClient(const VideoCaptureControllerID& id,
86 VideoCaptureControllerEventHandler* event_handler, 85 VideoCaptureControllerEventHandler* event_handler,
87 base::ProcessHandle render_process, 86 base::ProcessHandle render_process,
88 const media::VideoCaptureParams& params); 87 const media::VideoCaptureParams& params);
89 88
90 // Stop video capture. This will take back all buffers held by by 89 // Stop video capture. This will take back all buffers held by by
91 // |event_handler|, and |event_handler| shouldn't use those buffers any more. 90 // |event_handler|, and |event_handler| shouldn't use those buffers any more.
92 // Returns the session_id of the stopped client, or 91 // Returns the session_id of the stopped client, or
93 // kInvalidMediaCaptureSessionId if the indicated client was not registered. 92 // kInvalidMediaCaptureSessionId if the indicated client was not registered.
94 int RemoveClient(const VideoCaptureControllerID& id, 93 int RemoveClient(const VideoCaptureControllerID& id,
(...skipping 13 matching lines...) Expand all
108 107
109 private: 108 private:
110 class VideoCaptureDeviceClient; 109 class VideoCaptureDeviceClient;
111 110
112 struct ControllerClient; 111 struct ControllerClient;
113 typedef std::list<ControllerClient*> ControllerClients; 112 typedef std::list<ControllerClient*> ControllerClients;
114 113
115 // Worker functions on IO thread. Called by the VideoCaptureDeviceClient. 114 // Worker functions on IO thread. Called by the VideoCaptureDeviceClient.
116 void DoIncomingCapturedFrameOnIOThread( 115 void DoIncomingCapturedFrameOnIOThread(
117 const scoped_refptr<media::VideoFrame>& captured_frame, 116 const scoped_refptr<media::VideoFrame>& captured_frame,
117 int frame_rate,
118 base::Time timestamp); 118 base::Time timestamp);
119 void DoFrameInfoOnIOThread(
120 const media::VideoCaptureCapability& frame_info,
121 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool);
122 void DoFrameInfoChangedOnIOThread(const media::VideoCaptureCapability& info);
123 void DoErrorOnIOThread(); 119 void DoErrorOnIOThread();
124 void DoDeviceStoppedOnIOThread(); 120 void DoDeviceStoppedOnIOThread();
125 121 void DoBufferDestroyedOnIOThread(int buffer_id_to_drop);
126 // Send frame info and init buffers to |client|.
127 void SendFrameInfoAndBuffers(ControllerClient* client);
128 122
129 // Find a client of |id| and |handler| in |clients|. 123 // Find a client of |id| and |handler| in |clients|.
130 ControllerClient* FindClient( 124 ControllerClient* FindClient(
131 const VideoCaptureControllerID& id, 125 const VideoCaptureControllerID& id,
132 VideoCaptureControllerEventHandler* handler, 126 VideoCaptureControllerEventHandler* handler,
133 const ControllerClients& clients); 127 const ControllerClients& clients);
134 128
135 // Find a client of |session_id| in |clients|. 129 // Find a client of |session_id| in |clients|.
136 ControllerClient* FindClient( 130 ControllerClient* FindClient(
137 int session_id, 131 int session_id,
138 const ControllerClients& clients); 132 const ControllerClients& clients);
139 133
140 // The pool of shared-memory buffers used for capturing. 134 // The pool of shared-memory buffers used for capturing.
141 scoped_refptr<VideoCaptureBufferPool> buffer_pool_; 135 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_;
142 136
143 // All clients served by this controller. 137 // All clients served by this controller.
144 ControllerClients controller_clients_; 138 ControllerClients controller_clients_;
145 139
146 // The parameter that currently used for the capturing.
147 media::VideoCaptureParams current_params_;
148
149 // Tracks the current frame format.
150 media::VideoCaptureCapability frame_info_;
151
152 // Takes on only the states 'STARTED' and 'ERROR'. 'ERROR' is an absorbing 140 // Takes on only the states 'STARTED' and 'ERROR'. 'ERROR' is an absorbing
153 // state which stops the flow of data to clients. 141 // state which stops the flow of data to clients.
154 VideoCaptureState state_; 142 VideoCaptureState state_;
155 143
156 base::WeakPtrFactory<VideoCaptureController> weak_ptr_factory_; 144 base::WeakPtrFactory<VideoCaptureController> weak_ptr_factory_;
157 145
158 DISALLOW_COPY_AND_ASSIGN(VideoCaptureController); 146 DISALLOW_COPY_AND_ASSIGN(VideoCaptureController);
159 }; 147 };
160 148
161 } // namespace content 149 } // namespace content
162 150
163 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_ 151 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698