| 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 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // Carries a shared memory for transferring video frames from browser to | 73 // Carries a shared memory for transferring video frames from browser to |
| 74 // renderer. | 74 // renderer. |
| 75 class ClientBuffer; | 75 class ClientBuffer; |
| 76 | 76 |
| 77 // Contains information about a video capture client, including capture | 77 // Contains information about a video capture client, including capture |
| 78 // parameters callbacks to the client. | 78 // parameters callbacks to the client. |
| 79 struct ClientInfo; | 79 struct ClientInfo; |
| 80 using ClientInfoMap = std::map<int, ClientInfo>; | 80 using ClientInfoMap = std::map<int, ClientInfo>; |
| 81 | 81 |
| 82 using BufferFinishedCallback = | 82 using BufferFinishedCallback = |
| 83 base::Callback<void(const gpu::SyncToken& sync_token, | 83 base::Callback<void(double consumer_resource_utilization)>; |
| 84 double consumer_resource_utilization)>; | |
| 85 | 84 |
| 86 // mojom::VideoCaptureObserver implementation. | 85 // mojom::VideoCaptureObserver implementation. |
| 87 void OnStateChanged(mojom::VideoCaptureState state) override; | 86 void OnStateChanged(mojom::VideoCaptureState state) override; |
| 88 void OnBufferCreated(int32_t buffer_id, | 87 void OnBufferCreated(int32_t buffer_id, |
| 89 mojo::ScopedSharedBufferHandle handle) override; | 88 mojo::ScopedSharedBufferHandle handle) override; |
| 90 void OnBufferReady(int32_t buffer_id, | 89 void OnBufferReady(int32_t buffer_id, |
| 91 media::mojom::VideoFrameInfoPtr info) override; | 90 media::mojom::VideoFrameInfoPtr info) override; |
| 92 void OnBufferDestroyed(int32_t buffer_id) override; | 91 void OnBufferDestroyed(int32_t buffer_id) override; |
| 93 | 92 |
| 94 // Sends an IPC message to browser process when all clients are done with the | 93 // Sends an IPC message to browser process when all clients are done with the |
| 95 // buffer. | 94 // buffer. |
| 96 void OnClientBufferFinished(int buffer_id, | 95 void OnClientBufferFinished(int buffer_id, |
| 97 const scoped_refptr<ClientBuffer>& buffer, | 96 const scoped_refptr<ClientBuffer>& buffer, |
| 98 const gpu::SyncToken& release_sync_token, | |
| 99 double consumer_resource_utilization); | 97 double consumer_resource_utilization); |
| 100 | 98 |
| 101 void StopDevice(); | 99 void StopDevice(); |
| 102 void RestartCapture(); | 100 void RestartCapture(); |
| 103 void StartCaptureInternal(); | 101 void StartCaptureInternal(); |
| 104 | 102 |
| 105 void OnDeviceSupportedFormats( | 103 void OnDeviceSupportedFormats( |
| 106 const VideoCaptureDeviceFormatsCB& callback, | 104 const VideoCaptureDeviceFormatsCB& callback, |
| 107 const media::VideoCaptureFormats& supported_formats); | 105 const media::VideoCaptureFormats& supported_formats); |
| 108 void OnDeviceFormatsInUse( | 106 void OnDeviceFormatsInUse( |
| 109 const VideoCaptureDeviceFormatsCB& callback, | 107 const VideoCaptureDeviceFormatsCB& callback, |
| 110 const media::VideoCaptureFormats& formats_in_use); | 108 const media::VideoCaptureFormats& formats_in_use); |
| 111 | 109 |
| 112 // Tries to remove |client_id| from |clients|, returning false if not found. | 110 // Tries to remove |client_id| from |clients|, returning false if not found. |
| 113 bool RemoveClient(int client_id, ClientInfoMap* clients); | 111 bool RemoveClient(int client_id, ClientInfoMap* clients); |
| 114 | 112 |
| 115 mojom::VideoCaptureHost* GetVideoCaptureHost(); | 113 mojom::VideoCaptureHost* GetVideoCaptureHost(); |
| 116 | 114 |
| 117 // Called (by an unknown thread) when all consumers are done with a VideoFrame | 115 // Called (by an unknown thread) when all consumers are done with a VideoFrame |
| 118 // and its ref-count has gone to zero. This helper function grabs the | 116 // and its ref-count has gone to zero. This helper function grabs the |
| 119 // RESOURCE_UTILIZATION value from the |metadata| and then runs the given | 117 // RESOURCE_UTILIZATION value from the |metadata| and then runs the given |
| 120 // callback, to trampoline back to the IO thread with the values. | 118 // callback, to trampoline back to the IO thread with the values. |
| 121 static void DidFinishConsumingFrame( | 119 static void DidFinishConsumingFrame( |
| 122 const media::VideoFrameMetadata* metadata, | 120 const media::VideoFrameMetadata* metadata, |
| 123 std::unique_ptr<gpu::SyncToken> release_sync_token, | |
| 124 const BufferFinishedCallback& callback_to_io_thread); | 121 const BufferFinishedCallback& callback_to_io_thread); |
| 125 | 122 |
| 126 // |device_id_| and |session_id_| are different concepts, but we reuse the | 123 // |device_id_| and |session_id_| are different concepts, but we reuse the |
| 127 // same numerical value, passed on construction. | 124 // same numerical value, passed on construction. |
| 128 const int device_id_; | 125 const int device_id_; |
| 129 const int session_id_; | 126 const int session_id_; |
| 130 | 127 |
| 131 // |video_capture_host_| is an IO-thread InterfacePtr to a remote service | 128 // |video_capture_host_| is an IO-thread InterfacePtr to a remote service |
| 132 // implementation and is created by binding |video_capture_host_info_|, | 129 // implementation and is created by binding |video_capture_host_info_|, |
| 133 // unless a |video_capture_host_for_testing_| has been injected. | 130 // unless a |video_capture_host_for_testing_| has been injected. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 158 // media::VideoFrames constructed in OnBufferReceived() from buffers cached | 155 // media::VideoFrames constructed in OnBufferReceived() from buffers cached |
| 159 // in |client_buffers_|. | 156 // in |client_buffers_|. |
| 160 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; | 157 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; |
| 161 | 158 |
| 162 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); | 159 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); |
| 163 }; | 160 }; |
| 164 | 161 |
| 165 } // namespace content | 162 } // namespace content |
| 166 | 163 |
| 167 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 164 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
| OLD | NEW |