OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "chrome/gpu/gpu_arc_video_service.h" | 5 #include "chrome/gpu/gpu_arc_video_service.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
14 #include "chrome/gpu/arc_gpu_video_decode_accelerator.h" | 14 #include "chrome/gpu/arc_gpu_video_decode_accelerator.h" |
15 #include "chrome/gpu/arc_video_accelerator.h" | 15 #include "chrome/gpu/arc_video_accelerator.h" |
16 #include "components/arc/common/video_accelerator.mojom.h" | 16 #include "components/arc/common/video_accelerator.mojom.h" |
17 #include "mojo/edk/embedder/embedder.h" | 17 #include "mojo/edk/embedder/embedder.h" |
18 #include "mojo/public/cpp/bindings/binding.h" | 18 #include "mojo/public/cpp/bindings/binding.h" |
19 #include "mojo/public/cpp/bindings/type_converter.h" | 19 #include "mojo/public/cpp/bindings/type_converter.h" |
20 | 20 |
21 namespace mojo { | 21 namespace mojo { |
22 | 22 |
23 template <> | 23 template <> |
24 struct TypeConverter<arc::mojom::BufferMetadataPtr, | 24 struct TypeConverter<arc::mojom::BufferMetadataPtr, |
25 chromeos::arc::BufferMetadata> { | 25 chromeos::arc::BufferMetadata> { |
26 static arc::mojom::BufferMetadataPtr Convert( | 26 static arc::mojom::BufferMetadataPtr Convert( |
27 const chromeos::arc::BufferMetadata& input) { | 27 const chromeos::arc::BufferMetadata& input) { |
28 arc::mojom::BufferMetadataPtr result = arc::mojom::BufferMetadata::New(); | 28 arc::mojom::BufferMetadataPtr result = arc::mojom::BufferMetadata::New(); |
29 result->timestamp = input.timestamp; | 29 result->timestamp = input.timestamp; |
30 result->flags = input.flags; | |
31 result->bytes_used = input.bytes_used; | 30 result->bytes_used = input.bytes_used; |
32 return result; | 31 return result; |
33 } | 32 } |
34 }; | 33 }; |
35 | 34 |
36 template <> | 35 template <> |
37 struct TypeConverter<chromeos::arc::BufferMetadata, | 36 struct TypeConverter<chromeos::arc::BufferMetadata, |
38 arc::mojom::BufferMetadataPtr> { | 37 arc::mojom::BufferMetadataPtr> { |
39 static chromeos::arc::BufferMetadata Convert( | 38 static chromeos::arc::BufferMetadata Convert( |
40 const arc::mojom::BufferMetadataPtr& input) { | 39 const arc::mojom::BufferMetadataPtr& input) { |
41 chromeos::arc::BufferMetadata result; | 40 chromeos::arc::BufferMetadata result; |
42 result.timestamp = input->timestamp; | 41 result.timestamp = input->timestamp; |
43 result.flags = input->flags; | |
44 result.bytes_used = input->bytes_used; | 42 result.bytes_used = input->bytes_used; |
45 return result; | 43 return result; |
46 } | 44 } |
47 }; | 45 }; |
48 | 46 |
49 template <> | 47 template <> |
50 struct TypeConverter<arc::mojom::VideoFormatPtr, chromeos::arc::VideoFormat> { | 48 struct TypeConverter<arc::mojom::VideoFormatPtr, chromeos::arc::VideoFormat> { |
51 static arc::mojom::VideoFormatPtr Convert( | 49 static arc::mojom::VideoFormatPtr Convert( |
52 const chromeos::arc::VideoFormat& input) { | 50 const chromeos::arc::VideoFormat& input) { |
53 arc::mojom::VideoFormatPtr result = arc::mojom::VideoFormat::New(); | 51 arc::mojom::VideoFormatPtr result = arc::mojom::VideoFormat::New(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 DVLOG(2) << "OnBufferDone " << port << "," << index; | 143 DVLOG(2) << "OnBufferDone " << port << "," << index; |
146 client_->OnBufferDone(static_cast<::arc::mojom::PortType>(port), index, | 144 client_->OnBufferDone(static_cast<::arc::mojom::PortType>(port), index, |
147 ::arc::mojom::BufferMetadata::From(metadata)); | 145 ::arc::mojom::BufferMetadata::From(metadata)); |
148 } | 146 } |
149 | 147 |
150 void OnResetDone() override { | 148 void OnResetDone() override { |
151 DVLOG(2) << "OnResetDone"; | 149 DVLOG(2) << "OnResetDone"; |
152 client_->OnResetDone(); | 150 client_->OnResetDone(); |
153 } | 151 } |
154 | 152 |
| 153 void OnFlushDone() override { |
| 154 DVLOG(2) << "OnFlushDone"; |
| 155 client_->OnFlushDone(); |
| 156 } |
| 157 |
155 void OnOutputFormatChanged(const VideoFormat& format) override { | 158 void OnOutputFormatChanged(const VideoFormat& format) override { |
156 DVLOG(2) << "OnOutputFormatChanged"; | 159 DVLOG(2) << "OnOutputFormatChanged"; |
157 client_->OnOutputFormatChanged(::arc::mojom::VideoFormat::From(format)); | 160 client_->OnOutputFormatChanged(::arc::mojom::VideoFormat::From(format)); |
158 } | 161 } |
159 | 162 |
160 // ::arc::mojom::VideoAcceleratorService impementation. | 163 // ::arc::mojom::VideoAcceleratorService impementation. |
161 void Initialize(::arc::mojom::ArcVideoAcceleratorConfigPtr config, | 164 void Initialize(::arc::mojom::ArcVideoAcceleratorConfigPtr config, |
162 const InitializeCallback& callback) override { | 165 const InitializeCallback& callback) override { |
163 DVLOG(2) << "Initialize"; | 166 DVLOG(2) << "Initialize"; |
164 bool result = accelerator_->Initialize( | 167 bool result = accelerator_->Initialize( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 metadata.To<BufferMetadata>()); | 209 metadata.To<BufferMetadata>()); |
207 } | 210 } |
208 | 211 |
209 void SetNumberOfOutputBuffers(uint32_t number) override { | 212 void SetNumberOfOutputBuffers(uint32_t number) override { |
210 DVLOG(2) << "SetNumberOfOutputBuffers number=" << number; | 213 DVLOG(2) << "SetNumberOfOutputBuffers number=" << number; |
211 accelerator_->SetNumberOfOutputBuffers(number); | 214 accelerator_->SetNumberOfOutputBuffers(number); |
212 } | 215 } |
213 | 216 |
214 void Reset() override { accelerator_->Reset(); } | 217 void Reset() override { accelerator_->Reset(); } |
215 | 218 |
| 219 void Flush() override { accelerator_->Flush(); } |
| 220 |
216 private: | 221 private: |
217 base::ThreadChecker thread_checker_; | 222 base::ThreadChecker thread_checker_; |
218 GpuArcVideoService* const owner_; | 223 GpuArcVideoService* const owner_; |
219 std::unique_ptr<ArcVideoAccelerator> accelerator_; | 224 std::unique_ptr<ArcVideoAccelerator> accelerator_; |
220 ::arc::mojom::VideoAcceleratorServiceClientPtr client_; | 225 ::arc::mojom::VideoAcceleratorServiceClientPtr client_; |
221 mojo::Binding<::arc::mojom::VideoAcceleratorService> binding_; | 226 mojo::Binding<::arc::mojom::VideoAcceleratorService> binding_; |
222 }; | 227 }; |
223 | 228 |
224 GpuArcVideoService::GpuArcVideoService( | 229 GpuArcVideoService::GpuArcVideoService( |
225 mojo::InterfaceRequest<::arc::mojom::VideoHost> request) | 230 mojo::InterfaceRequest<::arc::mojom::VideoHost> request) |
(...skipping 30 matching lines...) Expand all Loading... |
256 | 261 |
257 callback.Run(mojo::ScopedHandle(mojo::Handle(wrapped_handle)), token); | 262 callback.Run(mojo::ScopedHandle(mojo::Handle(wrapped_handle)), token); |
258 } | 263 } |
259 | 264 |
260 void GpuArcVideoService::RemoveClient(AcceleratorStub* stub) { | 265 void GpuArcVideoService::RemoveClient(AcceleratorStub* stub) { |
261 accelerator_stubs_.erase(stub); | 266 accelerator_stubs_.erase(stub); |
262 } | 267 } |
263 | 268 |
264 } // namespace arc | 269 } // namespace arc |
265 } // namespace chromeos | 270 } // namespace chromeos |
OLD | NEW |