Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 // prematurely closed. | 58 // prematurely closed. |
| 59 void StopSession(int session_id); | 59 void StopSession(int session_id); |
| 60 | 60 |
| 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, int length, |
| 69 int length, | |
| 70 base::Time timestamp) OVERRIDE; | 69 base::Time timestamp) OVERRIDE; |
| 70 virtual void OnIncomingCapturedVideoFrame(media::VideoFrame* frame, | |
| 71 base::Time timestamp) OVERRIDE; | |
| 71 virtual void OnError() OVERRIDE; | 72 virtual void OnError() OVERRIDE; |
| 72 virtual void OnFrameInfo( | 73 virtual void OnFrameInfo( |
| 73 const media::VideoCaptureCapability& info) OVERRIDE; | 74 const media::VideoCaptureCapability& info) OVERRIDE; |
| 74 | 75 |
| 75 protected: | 76 protected: |
| 76 virtual ~VideoCaptureController(); | 77 virtual ~VideoCaptureController(); |
| 77 | 78 |
| 78 private: | 79 private: |
| 79 friend class base::RefCountedThreadSafe<VideoCaptureController>; | 80 friend class base::RefCountedThreadSafe<VideoCaptureController>; |
| 80 | 81 |
| 81 struct ControllerClient; | 82 struct ControllerClient; |
| 82 typedef std::list<ControllerClient*> ControllerClients; | 83 typedef std::list<ControllerClient*> ControllerClients; |
| 83 | 84 |
| 84 // Callback when manager has stopped device. | 85 // Callback when manager has stopped device. |
| 85 void OnDeviceStopped(); | 86 void OnDeviceStopped(); |
| 86 | 87 |
| 87 // Worker functions on IO thread. | 88 // Worker functions on IO thread. |
| 88 void DoIncomingCapturedFrameOnIOThread(int buffer_id, base::Time timestamp); | 89 void DoIncomingCapturedFrameOnIOThread(int buffer_id, base::Time timestamp); |
| 89 void DoFrameInfoOnIOThread(); | 90 void DoFrameInfoOnIOThread(); |
| 90 void DoErrorOnIOThread(); | 91 void DoErrorOnIOThread(); |
| 91 void DoDeviceStoppedOnIOThread(); | 92 void DoDeviceStoppedOnIOThread(); |
| 92 | 93 |
| 93 // Send frame info and init buffers to |client|. | 94 // Send frame info and init buffers to |client|. |
| 94 void SendFrameInfoAndBuffers(ControllerClient* client, int buffer_size); | 95 void SendFrameInfoAndBuffers(ControllerClient* client, int buffer_size); |
| 95 | 96 |
| 96 // Helpers. | 97 // Helpers. |
|
scherkus (not reviewing)
2013/02/05 22:40:44
nit: this comment is useless -- mind removing?
ncarter (slow)
2013/02/06 23:54:44
Done, but I welcome wjia to contradict.
FWIW, I i
scherkus (not reviewing)
2013/02/07 18:25:03
My $0.02 is making it readable for the lowest comm
| |
| 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); |
| 102 // Find a client of |session_id| in |clients|. | 103 // Find a client of |session_id| in |clients|. |
| 103 ControllerClient* FindClient( | 104 ControllerClient* FindClient( |
| 104 int session_id, | 105 int session_id, |
| 105 const ControllerClients& clients); | 106 const ControllerClients& clients); |
| 106 // Decide what to do after kStopping state. Dependent on events, controller | 107 // Decide what to do after kStopping state. Dependent on events, controller |
| 107 // can stay in kStopping state, or go to kStopped, or restart capture. | 108 // can stay in kStopping state, or go to kStopped, or restart capture. |
| 108 void PostStopping(); | 109 void PostStopping(); |
| 109 // Check if any DIB is used by client. | 110 // Check if any DIB is used by client. |
| 110 bool ClientHasDIB(); | 111 bool ClientHasDIB(); |
| 112 // DIB allocator. Locate a free DIB object, reserve it, and return its id | |
|
scherkus (not reviewing)
2013/02/05 22:40:44
nit: can you add blank lines before each of these
ncarter (slow)
2013/02/06 23:54:44
Done.
| |
| 113 // as well as pointers to its color planes. Returns true if successful. | |
| 114 bool ReserveSharedMemory(int* buffer_id_out, | |
|
scherkus (not reviewing)
2013/02/05 22:40:44
nit: the comment is a bit misleading as there is n
ncarter (slow)
2013/02/06 23:54:44
I see what you mean. Fixed the comment language.
| |
| 115 uint8** yplane, | |
| 116 uint8** uplane, | |
| 117 uint8** vplane); | |
| 111 | 118 |
| 112 // Lock to protect free_dibs_ and owned_dibs_. | 119 // Lock to protect free_dibs_ and owned_dibs_. |
| 113 base::Lock lock_; | 120 base::Lock lock_; |
| 114 | 121 |
| 115 struct SharedDIB; | 122 struct SharedDIB; |
| 116 typedef std::map<int /*buffer_id*/, SharedDIB*> DIBMap; | 123 typedef std::map<int /*buffer_id*/, SharedDIB*> DIBMap; |
| 117 // All DIBs created by this object. | 124 // All DIBs created by this object. |
| 118 // It's modified only on IO thread. | 125 // It's modified only on IO thread. |
| 119 DIBMap owned_dibs_; | 126 DIBMap owned_dibs_; |
| 120 | 127 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 142 | 149 |
| 143 bool device_in_use_; | 150 bool device_in_use_; |
| 144 VideoCaptureState state_; | 151 VideoCaptureState state_; |
| 145 | 152 |
| 146 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureController); | 153 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureController); |
| 147 }; | 154 }; |
| 148 | 155 |
| 149 } // namespace content | 156 } // namespace content |
| 150 | 157 |
| 151 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_ | 158 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_ |
| OLD | NEW |