Chromium Code Reviews| 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::SUCCESS); | |
| 111 client_->OnError( | 112 client_->OnError( |
| 112 static_cast<::arc::mojom::VideoAcceleratorServiceClient::Error>(error)); | 113 static_cast<::arc::mojom::VideoAcceleratorService::Result>(error)); |
|
dcheng
2016/06/07 00:57:56
Until we have enum traits, can we static_assert so
kcwu
2016/06/07 01:50:08
Done.
| |
| 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 callback.Run( |
| 146 static_cast<::arc::mojom::VideoAcceleratorService::Result>(result)); | |
|
dcheng
2016/06/07 00:57:56
Ditto.
kcwu
2016/06/07 01:50:08
Done.
| |
| 147 } | |
| 148 | |
| 149 void GpuArcVideoService::DeprecatedInitialize( | |
| 150 ::arc::mojom::ArcVideoAcceleratorConfigPtr config, | |
| 151 const DeprecatedInitializeCallback& callback) { | |
| 152 DVLOG(2) << "DeprecatedInitialize"; | |
| 153 ArcVideoAccelerator::Result result = | |
| 154 accelerator_->Initialize(config.To<ArcVideoAccelerator::Config>(), this); | |
| 155 callback.Run(result == ArcVideoAccelerator::SUCCESS); | |
| 145 } | 156 } |
| 146 | 157 |
| 147 base::ScopedFD GpuArcVideoService::UnwrapFdFromMojoHandle( | 158 base::ScopedFD GpuArcVideoService::UnwrapFdFromMojoHandle( |
| 148 mojo::ScopedHandle handle) { | 159 mojo::ScopedHandle handle) { |
| 149 if (!handle.is_valid()) { | 160 if (!handle.is_valid()) { |
| 150 LOG(ERROR) << "handle is invalid"; | 161 LOG(ERROR) << "handle is invalid"; |
| 151 client_->OnError( | 162 client_->OnError( |
| 152 ::arc::mojom::VideoAcceleratorServiceClient::Error::INVALID_ARGUMENT); | 163 ::arc::mojom::VideoAcceleratorService::Result::INVALID_ARGUMENT); |
| 153 return base::ScopedFD(); | 164 return base::ScopedFD(); |
| 154 } | 165 } |
| 155 | 166 |
| 156 base::PlatformFile platform_file; | 167 base::PlatformFile platform_file; |
| 157 MojoResult mojo_result = | 168 MojoResult mojo_result = |
| 158 mojo::UnwrapPlatformFile(std::move(handle), &platform_file); | 169 mojo::UnwrapPlatformFile(std::move(handle), &platform_file); |
| 159 if (mojo_result != MOJO_RESULT_OK) { | 170 if (mojo_result != MOJO_RESULT_OK) { |
| 160 LOG(ERROR) << "UnwrapPlatformFile failed: " << mojo_result; | 171 LOG(ERROR) << "UnwrapPlatformFile failed: " << mojo_result; |
| 161 client_->OnError( | 172 client_->OnError( |
| 162 ::arc::mojom::VideoAcceleratorServiceClient::Error::PLATFORM_FAILURE); | 173 ::arc::mojom::VideoAcceleratorService::Result::PLATFORM_FAILURE); |
| 163 return base::ScopedFD(); | 174 return base::ScopedFD(); |
| 164 } | 175 } |
| 165 | 176 |
| 166 return base::ScopedFD(platform_file); | 177 return base::ScopedFD(platform_file); |
| 167 } | 178 } |
| 168 | 179 |
| 169 void GpuArcVideoService::BindSharedMemory(::arc::mojom::PortType port, | 180 void GpuArcVideoService::BindSharedMemory(::arc::mojom::PortType port, |
| 170 uint32_t index, | 181 uint32_t index, |
| 171 mojo::ScopedHandle ashmem_handle, | 182 mojo::ScopedHandle ashmem_handle, |
| 172 uint32_t offset, | 183 uint32_t offset, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 accelerator_->Reset(); | 223 accelerator_->Reset(); |
| 213 } | 224 } |
| 214 | 225 |
| 215 void GpuArcVideoService::Flush() { | 226 void GpuArcVideoService::Flush() { |
| 216 DVLOG(2) << "Flush"; | 227 DVLOG(2) << "Flush"; |
| 217 accelerator_->Flush(); | 228 accelerator_->Flush(); |
| 218 } | 229 } |
| 219 | 230 |
| 220 } // namespace arc | 231 } // namespace arc |
| 221 } // namespace chromeos | 232 } // namespace chromeos |
| OLD | NEW |