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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 accelerator_.reset(new ArcGpuVideoDecodeAccelerator()); | 100 accelerator_.reset(new ArcGpuVideoDecodeAccelerator()); |
101 | 101 |
102 ::arc::mojom::VideoAcceleratorServicePtr service; | 102 ::arc::mojom::VideoAcceleratorServicePtr service; |
103 binding_.Bind(GetProxy(&service)); | 103 binding_.Bind(GetProxy(&service)); |
104 binding_.set_connection_error_handler(base::Bind(&OnConnectionError)); | 104 binding_.set_connection_error_handler(base::Bind(&OnConnectionError)); |
105 | 105 |
106 client_->Init(std::move(service)); | 106 client_->Init(std::move(service)); |
107 } | 107 } |
108 | 108 |
109 void GpuArcVideoService::OnError(ArcVideoAccelerator::Error error) { | 109 void GpuArcVideoService::OnError(ArcVideoAccelerator::Result error) { |
110 DVLOG(2) << "OnError " << error; | 110 DVLOG(2) << "OnError " << error; |
| 111 DCHECK_NE(error, ArcVideoAccelerator::NO_ERROR); |
111 client_->OnError( | 112 client_->OnError( |
112 static_cast<::arc::mojom::VideoAcceleratorServiceClient::Error>(error)); | 113 static_cast<::arc::mojom::VideoAcceleratorService::Result>(error)); |
113 } | 114 } |
114 | 115 |
115 void GpuArcVideoService::OnBufferDone(PortType port, | 116 void GpuArcVideoService::OnBufferDone(PortType port, |
116 uint32_t index, | 117 uint32_t index, |
117 const BufferMetadata& metadata) { | 118 const BufferMetadata& metadata) { |
118 DVLOG(2) << "OnBufferDone " << port << "," << index; | 119 DVLOG(2) << "OnBufferDone " << port << "," << index; |
119 client_->OnBufferDone(static_cast<::arc::mojom::PortType>(port), index, | 120 client_->OnBufferDone(static_cast<::arc::mojom::PortType>(port), index, |
120 ::arc::mojom::BufferMetadata::From(metadata)); | 121 ::arc::mojom::BufferMetadata::From(metadata)); |
121 } | 122 } |
122 | 123 |
123 void GpuArcVideoService::OnFlushDone() { | 124 void GpuArcVideoService::OnFlushDone() { |
124 DVLOG(2) << "OnFlushDone"; | 125 DVLOG(2) << "OnFlushDone"; |
125 client_->OnFlushDone(); | 126 client_->OnFlushDone(); |
126 } | 127 } |
127 | 128 |
128 void GpuArcVideoService::OnResetDone() { | 129 void GpuArcVideoService::OnResetDone() { |
129 DVLOG(2) << "OnResetDone"; | 130 DVLOG(2) << "OnResetDone"; |
130 client_->OnResetDone(); | 131 client_->OnResetDone(); |
131 } | 132 } |
132 | 133 |
133 void GpuArcVideoService::OnOutputFormatChanged(const VideoFormat& format) { | 134 void GpuArcVideoService::OnOutputFormatChanged(const VideoFormat& format) { |
134 DVLOG(2) << "OnOutputFormatChanged"; | 135 DVLOG(2) << "OnOutputFormatChanged"; |
135 client_->OnOutputFormatChanged(::arc::mojom::VideoFormat::From(format)); | 136 client_->OnOutputFormatChanged(::arc::mojom::VideoFormat::From(format)); |
136 } | 137 } |
137 | 138 |
138 void GpuArcVideoService::Initialize( | 139 void GpuArcVideoService::Initialize( |
139 ::arc::mojom::ArcVideoAcceleratorConfigPtr config, | 140 ::arc::mojom::ArcVideoAcceleratorConfigPtr config, |
140 const InitializeCallback& callback) { | 141 const InitializeCallback& callback) { |
141 DVLOG(2) << "Initialize"; | 142 DVLOG(2) << "Initialize"; |
142 bool result = | 143 ArcVideoAccelerator::Result result = |
143 accelerator_->Initialize(config.To<ArcVideoAccelerator::Config>(), this); | 144 accelerator_->Initialize(config.To<ArcVideoAccelerator::Config>(), this); |
144 callback.Run(result); | 145 if (result == ArcVideoAccelerator::NO_ERROR) { |
| 146 callback.Run(true, ::arc::mojom::VideoAcceleratorService::Result::NO_ERROR); |
| 147 } else { |
| 148 callback.Run( |
| 149 false, |
| 150 static_cast<::arc::mojom::VideoAcceleratorService::Result>(result)); |
| 151 } |
145 } | 152 } |
146 | 153 |
147 base::ScopedFD GpuArcVideoService::UnwrapFdFromMojoHandle( | 154 base::ScopedFD GpuArcVideoService::UnwrapFdFromMojoHandle( |
148 mojo::ScopedHandle handle) { | 155 mojo::ScopedHandle handle) { |
149 if (!handle.is_valid()) { | 156 if (!handle.is_valid()) { |
150 LOG(ERROR) << "handle is invalid"; | 157 LOG(ERROR) << "handle is invalid"; |
151 client_->OnError( | 158 client_->OnError( |
152 ::arc::mojom::VideoAcceleratorServiceClient::Error::INVALID_ARGUMENT); | 159 ::arc::mojom::VideoAcceleratorService::Result::INVALID_ARGUMENT); |
153 return base::ScopedFD(); | 160 return base::ScopedFD(); |
154 } | 161 } |
155 | 162 |
156 base::PlatformFile platform_file; | 163 base::PlatformFile platform_file; |
157 MojoResult mojo_result = | 164 MojoResult mojo_result = |
158 mojo::UnwrapPlatformFile(std::move(handle), &platform_file); | 165 mojo::UnwrapPlatformFile(std::move(handle), &platform_file); |
159 if (mojo_result != MOJO_RESULT_OK) { | 166 if (mojo_result != MOJO_RESULT_OK) { |
160 LOG(ERROR) << "UnwrapPlatformFile failed: " << mojo_result; | 167 LOG(ERROR) << "UnwrapPlatformFile failed: " << mojo_result; |
161 client_->OnError( | 168 client_->OnError( |
162 ::arc::mojom::VideoAcceleratorServiceClient::Error::PLATFORM_FAILURE); | 169 ::arc::mojom::VideoAcceleratorService::Result::PLATFORM_FAILURE); |
163 return base::ScopedFD(); | 170 return base::ScopedFD(); |
164 } | 171 } |
165 | 172 |
166 return base::ScopedFD(platform_file); | 173 return base::ScopedFD(platform_file); |
167 } | 174 } |
168 | 175 |
169 void GpuArcVideoService::BindSharedMemory(::arc::mojom::PortType port, | 176 void GpuArcVideoService::BindSharedMemory(::arc::mojom::PortType port, |
170 uint32_t index, | 177 uint32_t index, |
171 mojo::ScopedHandle ashmem_handle, | 178 mojo::ScopedHandle ashmem_handle, |
172 uint32_t offset, | 179 uint32_t offset, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 accelerator_->Reset(); | 219 accelerator_->Reset(); |
213 } | 220 } |
214 | 221 |
215 void GpuArcVideoService::Flush() { | 222 void GpuArcVideoService::Flush() { |
216 DVLOG(2) << "Flush"; | 223 DVLOG(2) << "Flush"; |
217 accelerator_->Flush(); | 224 accelerator_->Flush(); |
218 } | 225 } |
219 | 226 |
220 } // namespace arc | 227 } // namespace arc |
221 } // namespace chromeos | 228 } // namespace chromeos |
OLD | NEW |