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

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

Issue 12090109: Tab Capture: Backing store readbacks to YV12 VideoFrames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style fix per wjia 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
« no previous file with comments | « no previous file | content/browser/renderer_host/media/video_capture_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 VideoCaptureHost, 5 // VideoCaptureController is the glue between VideoCaptureHost,
6 // VideoCaptureManager and VideoCaptureDevice. 6 // VideoCaptureManager and VideoCaptureDevice.
7 // It provides functions for VideoCaptureHost to start a VideoCaptureDevice and 7 // It provides functions for VideoCaptureHost to start a VideoCaptureDevice and
8 // is responsible for keeping track of shared DIBs and filling them with I420 8 // is responsible for keeping track of shared DIBs and filling them with I420
9 // video frames for IPC communication between VideoCaptureHost and 9 // video frames for IPC communication between VideoCaptureHost and
10 // VideoCaptureMessageFilter. 10 // VideoCaptureMessageFilter.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // Return a buffer previously given in 61 // Return a buffer previously given in
62 // VideoCaptureControllerEventHandler::OnBufferReady. 62 // VideoCaptureControllerEventHandler::OnBufferReady.
63 void ReturnBuffer(const VideoCaptureControllerID& id, 63 void ReturnBuffer(const VideoCaptureControllerID& id,
64 VideoCaptureControllerEventHandler* event_handler, 64 VideoCaptureControllerEventHandler* event_handler,
65 int buffer_id); 65 int buffer_id);
66 66
67 // Implement media::VideoCaptureDevice::EventHandler. 67 // Implement media::VideoCaptureDevice::EventHandler.
68 virtual void OnIncomingCapturedFrame(const uint8* data, 68 virtual void OnIncomingCapturedFrame(const uint8* data,
69 int length, 69 int length,
70 base::Time timestamp) OVERRIDE; 70 base::Time timestamp) OVERRIDE;
71 virtual void OnIncomingCapturedVideoFrame(media::VideoFrame* frame,
72 base::Time timestamp) OVERRIDE;
71 virtual void OnError() OVERRIDE; 73 virtual void OnError() OVERRIDE;
72 virtual void OnFrameInfo( 74 virtual void OnFrameInfo(
73 const media::VideoCaptureCapability& info) OVERRIDE; 75 const media::VideoCaptureCapability& info) OVERRIDE;
74 76
75 protected: 77 protected:
76 virtual ~VideoCaptureController(); 78 virtual ~VideoCaptureController();
77 79
78 private: 80 private:
79 friend class base::RefCountedThreadSafe<VideoCaptureController>; 81 friend class base::RefCountedThreadSafe<VideoCaptureController>;
80 82
81 struct ControllerClient; 83 struct ControllerClient;
82 typedef std::list<ControllerClient*> ControllerClients; 84 typedef std::list<ControllerClient*> ControllerClients;
83 85
84 // Callback when manager has stopped device. 86 // Callback when manager has stopped device.
85 void OnDeviceStopped(); 87 void OnDeviceStopped();
86 88
87 // Worker functions on IO thread. 89 // Worker functions on IO thread.
88 void DoIncomingCapturedFrameOnIOThread(int buffer_id, base::Time timestamp); 90 void DoIncomingCapturedFrameOnIOThread(int buffer_id, base::Time timestamp);
89 void DoFrameInfoOnIOThread(); 91 void DoFrameInfoOnIOThread();
90 void DoErrorOnIOThread(); 92 void DoErrorOnIOThread();
91 void DoDeviceStoppedOnIOThread(); 93 void DoDeviceStoppedOnIOThread();
92 94
93 // Send frame info and init buffers to |client|. 95 // Send frame info and init buffers to |client|.
94 void SendFrameInfoAndBuffers(ControllerClient* client, int buffer_size); 96 void SendFrameInfoAndBuffers(ControllerClient* client, int buffer_size);
95 97
96 // Helpers.
97 // Find a client of |id| and |handler| in |clients|. 98 // Find a client of |id| and |handler| in |clients|.
98 ControllerClient* FindClient( 99 ControllerClient* FindClient(
99 const VideoCaptureControllerID& id, 100 const VideoCaptureControllerID& id,
100 VideoCaptureControllerEventHandler* handler, 101 VideoCaptureControllerEventHandler* handler,
101 const ControllerClients& clients); 102 const ControllerClients& clients);
103
102 // Find a client of |session_id| in |clients|. 104 // Find a client of |session_id| in |clients|.
103 ControllerClient* FindClient( 105 ControllerClient* FindClient(
104 int session_id, 106 int session_id,
105 const ControllerClients& clients); 107 const ControllerClients& clients);
108
106 // Decide what to do after kStopping state. Dependent on events, controller 109 // Decide what to do after kStopping state. Dependent on events, controller
107 // can stay in kStopping state, or go to kStopped, or restart capture. 110 // can stay in kStopping state, or go to kStopped, or restart capture.
108 void PostStopping(); 111 void PostStopping();
112
109 // Check if any DIB is used by client. 113 // Check if any DIB is used by client.
110 bool ClientHasDIB(); 114 bool ClientHasDIB();
111 115
116 // DIB reservation. Locate an available DIB object, reserve it, and provide
117 // the caller the reserved DIB's buffer_id as well as pointers to its color
118 // planes. Returns true if successful.
119 bool ReserveSharedMemory(int* buffer_id_out,
120 uint8** yplane,
121 uint8** uplane,
122 uint8** vplane);
123
112 // Lock to protect free_dibs_ and owned_dibs_. 124 // Lock to protect free_dibs_ and owned_dibs_.
113 base::Lock lock_; 125 base::Lock lock_;
114 126
115 struct SharedDIB; 127 struct SharedDIB;
116 typedef std::map<int /*buffer_id*/, SharedDIB*> DIBMap; 128 typedef std::map<int /*buffer_id*/, SharedDIB*> DIBMap;
117 // All DIBs created by this object. 129 // All DIBs created by this object.
118 // It's modified only on IO thread. 130 // It's modified only on IO thread.
119 DIBMap owned_dibs_; 131 DIBMap owned_dibs_;
120 132
121 // All clients served by this controller. 133 // All clients served by this controller.
(...skipping 20 matching lines...) Expand all
142 154
143 bool device_in_use_; 155 bool device_in_use_;
144 VideoCaptureState state_; 156 VideoCaptureState state_;
145 157
146 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureController); 158 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureController);
147 }; 159 };
148 160
149 } // namespace content 161 } // namespace content
150 162
151 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_ 163 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/media/video_capture_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698