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 // VideoCaptureHost serves video capture related messages from | 5 // VideoCaptureHost serves video capture related messages from |
| 6 // VideoCaptureMessageFilter which lives inside the render process. | 6 // VideoCaptureMessageFilter which lives inside the render process. |
| 7 // | 7 // |
| 8 // This class is owned by RenderProcessHostImpl, and instantiated on UI | 8 // This class is owned by RenderProcessHostImpl, and instantiated on UI |
| 9 // thread, but all other operations and method calls happen on IO thread. | 9 // thread, but all other operations and method calls happen on IO thread. |
| 10 // | 10 // |
| 11 // Here's an example of a typical IPC dialog for video capture: | 11 // Here's an example of a typical IPC dialog for video capture: |
| 12 // | 12 // |
| 13 // Renderer VideoCaptureHost | 13 // Renderer VideoCaptureHost |
| 14 // | | | 14 // | | |
| 15 // | --------- StartCapture --------> | | 15 // | --------- StartCapture --------> | |
| 16 // | < VideoCaptureMsg_StateChanged | | 16 // | <------ VideoCaptureObserver ------ | |
| 17 // | (VIDEO_CAPTURE_STATE_STARTED) | | 17 // | ::StateChanged(STARTED) | |
| 18 // | < VideoCaptureMsg_NewBuffer(1) | | 18 // | < VideoCaptureMsg_NewBuffer(1) | |
| 19 // | < VideoCaptureMsg_NewBuffer(2) | | 19 // | < VideoCaptureMsg_NewBuffer(2) | |
| 20 // | < VideoCaptureMsg_NewBuffer(3) | | 20 // | < VideoCaptureMsg_NewBuffer(3) | |
| 21 // | | | 21 // | | |
| 22 // | < VideoCaptureMsg_BufferReady(1) | | 22 // | < VideoCaptureMsg_BufferReady(1) | |
| 23 // | < VideoCaptureMsg_BufferReady(2) | | 23 // | < VideoCaptureMsg_BufferReady(2) | |
| 24 // | VideoCaptureHostMsg_BufferReady(1) > | | 24 // | -------- ReleaseBuffer(1) ---------> | |
| 25 // | < VideoCaptureMsg_BufferReady(3) | | 25 // | < VideoCaptureMsg_BufferReady(3) | |
| 26 // | VideoCaptureHostMsg_BufferReady(2) > | | 26 // | -------- ReleaseBuffer(2) ---------> | |
| 27 // | < VideoCaptureMsg_BufferReady(1) | | 27 // | < VideoCaptureMsg_BufferReady(1) | |
| 28 // | VideoCaptureHostMsg_BufferReady(3) > | | 28 // | -------- ReleaseBuffer(3) ---------> | |
| 29 // | < VideoCaptureMsg_BufferReady(2) | | 29 // | < VideoCaptureMsg_BufferReady(2) | |
| 30 // | VideoCaptureHostMsg_BufferReady(1) > | | 30 // | -------- ReleaseBuffer(1) ---------> | |
| 31 // | ... | | 31 // | ... | |
| 32 // | < VideoCaptureMsg_BufferReady(3) | | 32 // | < VideoCaptureMsg_BufferReady(3) | |
| 33 // | | | 33 // | | |
| 34 // | ... (resolution change) | | 34 // | ... (resolution change) | |
| 35 // | < VideoCaptureMsg_FreeBuffer(1) | Buffers are re-allocated | 35 // | < VideoCaptureMsg_FreeBuffer(1) | Buffers are re-allocated |
| 36 // | < VideoCaptureMsg_NewBuffer(4) | with a larger size, as | 36 // | < VideoCaptureMsg_NewBuffer(4) | with a larger size, as |
| 37 // | < VideoCaptureMsg_BufferReady(4) | needed. | 37 // | < VideoCaptureMsg_BufferReady(4) | needed. |
| 38 // | VideoCaptureHostMsg_BufferReady(2) > | | 38 // | -------- ReleaseBuffer(2) ---------> | |
| 39 // | < VideoCaptureMsg_FreeBuffer(2) | | 39 // | < VideoCaptureMsg_FreeBuffer(2) | |
| 40 // | < VideoCaptureMsg_NewBuffer(5) | | 40 // | < VideoCaptureMsg_NewBuffer(5) | |
| 41 // | < VideoCaptureMsg_BufferReady(5) | | 41 // | < VideoCaptureMsg_BufferReady(5) | |
| 42 // | ... | | 42 // | ... | |
| 43 // | | | 43 // | | |
| 44 // | < VideoCaptureMsg_BufferReady | | 44 // | < VideoCaptureMsg_BufferReady | |
| 45 // | --------- StopCapture ---------> | | 45 // | --------- StopCapture ---------> | |
| 46 // | VideoCaptureHostMsg_BufferReady > | | 46 // | -------- ReleaseBuffer(n) ---------> | |
| 47 // | < VideoCaptureMsg_StateChanged | | 47 // | <------ VideoCaptureObserver ------ | |
| 48 // | (VIDEO_CAPTURE_STATE_STOPPED) | | 48 // | ::StateChanged(STOPPED) | |
| 49 // v v | 49 // v v |
| 50 | 50 |
| 51 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_HOST_H_ | 51 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_HOST_H_ |
| 52 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_HOST_H_ | 52 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_HOST_H_ |
| 53 | 53 |
| 54 #include <map> | 54 #include <map> |
| 55 | 55 |
| 56 #include "base/macros.h" | 56 #include "base/macros.h" |
| 57 #include "base/memory/ref_counted.h" | 57 #include "base/memory/ref_counted.h" |
| 58 #include "base/memory/weak_ptr.h" | 58 #include "base/memory/weak_ptr.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 friend class BrowserThread; | 98 friend class BrowserThread; |
| 99 friend class base::DeleteHelper<VideoCaptureHost>; | 99 friend class base::DeleteHelper<VideoCaptureHost>; |
| 100 friend class MockVideoCaptureHost; | 100 friend class MockVideoCaptureHost; |
| 101 friend class VideoCaptureHostTest; | 101 friend class VideoCaptureHostTest; |
| 102 | 102 |
| 103 void DoError(VideoCaptureControllerID id); | 103 void DoError(VideoCaptureControllerID id); |
| 104 void DoEnded(VideoCaptureControllerID id); | 104 void DoEnded(VideoCaptureControllerID id); |
| 105 | 105 |
| 106 ~VideoCaptureHost() override; | 106 ~VideoCaptureHost() override; |
| 107 | 107 |
| 108 // IPC message handlers. | |
| 109 void OnRendererFinishedWithBuffer(int device_id, | |
| 110 int buffer_id, | |
| 111 const gpu::SyncToken& sync_token, | |
| 112 double consumer_resource_utilization); | |
| 113 | |
| 114 // mojom::VideoCaptureHost implementation | 108 // mojom::VideoCaptureHost implementation |
| 115 void Start(int32_t device_id, | 109 void Start(int32_t device_id, |
| 116 int32_t session_id, | 110 int32_t session_id, |
| 117 const media::VideoCaptureParams& params) override; | 111 const media::VideoCaptureParams& params, |
| 112 mojom::VideoCaptureObserverPtr observer) override; | |
| 118 void Stop(int32_t device_id) override; | 113 void Stop(int32_t device_id) override; |
| 119 void Pause(int32_t device_id) override; | 114 void Pause(int32_t device_id) override; |
| 120 void Resume(int32_t device_id, | 115 void Resume(int32_t device_id, |
| 121 int32_t session_id, | 116 int32_t session_id, |
| 122 const media::VideoCaptureParams& params) override; | 117 const media::VideoCaptureParams& params) override; |
| 123 void RequestRefreshFrame(int32_t device_id) override; | 118 void RequestRefreshFrame(int32_t device_id) override; |
| 119 void ReleaseBuffer(int32_t device_id, | |
| 120 int32_t buffer_id, | |
| 121 const gpu::SyncToken& sync_token, | |
| 122 double consumer_resource_utilization) override; | |
| 124 void GetDeviceSupportedFormats( | 123 void GetDeviceSupportedFormats( |
| 125 int32_t device_id, | 124 int32_t device_id, |
| 126 int32_t session_id, | 125 int32_t session_id, |
| 127 const GetDeviceSupportedFormatsCallback& callback) override; | 126 const GetDeviceSupportedFormatsCallback& callback) override; |
| 128 void GetDeviceFormatsInUse( | 127 void GetDeviceFormatsInUse( |
| 129 int32_t device_id, | 128 int32_t device_id, |
| 130 int32_t session_id, | 129 int32_t session_id, |
| 131 const GetDeviceFormatsInUseCallback& callback) override; | 130 const GetDeviceFormatsInUseCallback& callback) override; |
| 132 | 131 |
| 133 void OnControllerAdded( | 132 void OnControllerAdded( |
| 134 int device_id, | 133 int device_id, |
| 135 const base::WeakPtr<VideoCaptureController>& controller); | 134 const base::WeakPtr<VideoCaptureController>& controller); |
| 136 | 135 |
| 137 // Deletes the controller and notifies the VideoCaptureManager. |on_error| is | 136 // Deletes the controller and notifies the VideoCaptureManager. |on_error| is |
| 138 // true if this is triggered by VideoCaptureControllerEventHandler::OnError. | 137 // true if this is triggered by VideoCaptureControllerEventHandler::OnError. |
| 139 void DeleteVideoCaptureController(VideoCaptureControllerID controller_id, | 138 void DeleteVideoCaptureController(VideoCaptureControllerID controller_id, |
| 140 bool on_error); | 139 bool on_error); |
| 141 | 140 |
| 142 MediaStreamManager* const media_stream_manager_; | 141 MediaStreamManager* const media_stream_manager_; |
| 143 | 142 |
| 144 // A map of VideoCaptureControllerID to the VideoCaptureController to which it | 143 // A map of VideoCaptureControllerID to the VideoCaptureController to which it |
| 145 // is connected. An entry in this map holds a null controller while it is in | 144 // is connected. An entry in this map holds a null controller while it is in |
| 146 // the process of starting. | 145 // the process of starting. |
| 147 std::map<VideoCaptureControllerID, base::WeakPtr<VideoCaptureController>> | 146 std::map<VideoCaptureControllerID, base::WeakPtr<VideoCaptureController>> |
| 148 controllers_; | 147 controllers_; |
| 149 | 148 |
| 149 // VideoCaptureObservers map, each one is used and should be valid between | |
| 150 // Start() and the corresponding Stop(). | |
| 151 std::map<int32_t, mojom::VideoCaptureObserverPtr> observers_; | |
|
chfremer
2016/10/10 18:57:19
Unclear what the int32_t parameter is.
device_id?
mcasas
2016/10/10 19:39:44
The first or the last one :)
device_id == control
| |
| 152 | |
| 150 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHost); | 153 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHost); |
| 151 }; | 154 }; |
| 152 | 155 |
| 153 } // namespace content | 156 } // namespace content |
| 154 | 157 |
| 155 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_HOST_H_ | 158 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_HOST_H_ |
| OLD | NEW |