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

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: Fix constant declaration issue. 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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,
sheu 2013/10/12 00:37:52 It's confusing to have AddClient()/RemoveClient()
ncarter (slow) 2013/10/16 02:08:40 It's not relevant to this CL, but the intent here
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,
sheu 2013/10/12 00:37:52 (see above)
ncarter (slow) 2013/10/16 02:08:40 Done.
95 VideoCaptureControllerEventHandler* event_handler); 94 VideoCaptureControllerEventHandler* event_handler);
96 95
97 int GetClientCount(); 96 int GetClientCount();
98 97
99 // API called directly by VideoCaptureManager in case the device is 98 // API called directly by VideoCaptureManager in case the device is
100 // prematurely closed. 99 // prematurely closed.
101 void StopSession(int session_id); 100 void StopSession(int session_id);
102 101
103 // Return a buffer previously given in 102 // Return a buffer previously given in
104 // VideoCaptureControllerEventHandler::OnBufferReady. 103 // VideoCaptureControllerEventHandler::OnBufferReady.
105 void ReturnBuffer(const VideoCaptureControllerID& id, 104 void ReturnBuffer(const VideoCaptureControllerID& id,
106 VideoCaptureControllerEventHandler* event_handler, 105 VideoCaptureControllerEventHandler* event_handler,
107 int buffer_id); 106 int buffer_id);
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