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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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::Error error) { |
| 110 DVLOG(2) << "OnError " << error; | 110 DVLOG(2) << "OnError " << error; |
| 111 client_->OnError( | 111 client_->OnError( |
| 112 static_cast<::arc::mojom::VideoAcceleratorServiceClient::Error>(error)); | 112 static_cast<::arc::mojom::VideoAcceleratorService::Error>(error)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void GpuArcVideoService::OnBufferDone(PortType port, | 115 void GpuArcVideoService::OnBufferDone(PortType port, |
| 116 uint32_t index, | 116 uint32_t index, |
| 117 const BufferMetadata& metadata) { | 117 const BufferMetadata& metadata) { |
| 118 DVLOG(2) << "OnBufferDone " << port << "," << index; | 118 DVLOG(2) << "OnBufferDone " << port << "," << index; |
| 119 client_->OnBufferDone(static_cast<::arc::mojom::PortType>(port), index, | 119 client_->OnBufferDone(static_cast<::arc::mojom::PortType>(port), index, |
| 120 ::arc::mojom::BufferMetadata::From(metadata)); | 120 ::arc::mojom::BufferMetadata::From(metadata)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void GpuArcVideoService::OnFlushDone() { | 123 void GpuArcVideoService::OnFlushDone() { |
| 124 DVLOG(2) << "OnFlushDone"; | 124 DVLOG(2) << "OnFlushDone"; |
| 125 client_->OnFlushDone(); | 125 client_->OnFlushDone(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void GpuArcVideoService::OnResetDone() { | 128 void GpuArcVideoService::OnResetDone() { |
| 129 DVLOG(2) << "OnResetDone"; | 129 DVLOG(2) << "OnResetDone"; |
| 130 client_->OnResetDone(); | 130 client_->OnResetDone(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void GpuArcVideoService::OnOutputFormatChanged(const VideoFormat& format) { | 133 void GpuArcVideoService::OnOutputFormatChanged(const VideoFormat& format) { |
| 134 DVLOG(2) << "OnOutputFormatChanged"; | 134 DVLOG(2) << "OnOutputFormatChanged"; |
| 135 client_->OnOutputFormatChanged(::arc::mojom::VideoFormat::From(format)); | 135 client_->OnOutputFormatChanged(::arc::mojom::VideoFormat::From(format)); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void GpuArcVideoService::Initialize( | 138 void GpuArcVideoService::Initialize( |
| 139 ::arc::mojom::ArcVideoAcceleratorConfigPtr config, | 139 ::arc::mojom::ArcVideoAcceleratorConfigPtr config, |
| 140 const InitializeCallback& callback) { | 140 const InitializeCallback& callback) { |
| 141 DVLOG(2) << "Initialize"; | 141 DVLOG(2) << "Initialize"; |
| 142 bool result = | 142 ArcVideoAccelerator::Error result = |
| 143 accelerator_->Initialize(config.To<ArcVideoAccelerator::Config>(), this); | 143 accelerator_->Initialize(config.To<ArcVideoAccelerator::Config>(), this); |
| 144 callback.Run(result); | 144 if (result == ArcVideoAccelerator::NO_ERROR) { |
| 145 callback.Run(true, ::arc::mojom::VideoAcceleratorService::Error::NO_ERROR); | |
|
Pawel Osciak
2016/06/03 03:56:18
Do we need true/false in the first argument, if we
kcwu
2016/06/03 08:28:58
It's backward compatible if appending parameters,
| |
| 146 } else { | |
| 147 callback.Run(false, ::arc::mojom::VideoAcceleratorService::Error(result)); | |
| 148 } | |
| 145 } | 149 } |
| 146 | 150 |
| 147 base::ScopedFD GpuArcVideoService::UnwrapFdFromMojoHandle( | 151 base::ScopedFD GpuArcVideoService::UnwrapFdFromMojoHandle( |
| 148 mojo::ScopedHandle handle) { | 152 mojo::ScopedHandle handle) { |
| 149 if (!handle.is_valid()) { | 153 if (!handle.is_valid()) { |
| 150 LOG(ERROR) << "handle is invalid"; | 154 LOG(ERROR) << "handle is invalid"; |
| 151 client_->OnError( | 155 client_->OnError( |
| 152 ::arc::mojom::VideoAcceleratorServiceClient::Error::INVALID_ARGUMENT); | 156 ::arc::mojom::VideoAcceleratorService::Error::INVALID_ARGUMENT); |
| 153 return base::ScopedFD(); | 157 return base::ScopedFD(); |
| 154 } | 158 } |
| 155 | 159 |
| 156 base::PlatformFile platform_file; | 160 base::PlatformFile platform_file; |
| 157 MojoResult mojo_result = | 161 MojoResult mojo_result = |
| 158 mojo::UnwrapPlatformFile(std::move(handle), &platform_file); | 162 mojo::UnwrapPlatformFile(std::move(handle), &platform_file); |
| 159 if (mojo_result != MOJO_RESULT_OK) { | 163 if (mojo_result != MOJO_RESULT_OK) { |
| 160 LOG(ERROR) << "UnwrapPlatformFile failed: " << mojo_result; | 164 LOG(ERROR) << "UnwrapPlatformFile failed: " << mojo_result; |
| 161 client_->OnError( | 165 client_->OnError( |
| 162 ::arc::mojom::VideoAcceleratorServiceClient::Error::PLATFORM_FAILURE); | 166 ::arc::mojom::VideoAcceleratorService::Error::PLATFORM_FAILURE); |
| 163 return base::ScopedFD(); | 167 return base::ScopedFD(); |
| 164 } | 168 } |
| 165 | 169 |
| 166 return base::ScopedFD(platform_file); | 170 return base::ScopedFD(platform_file); |
| 167 } | 171 } |
| 168 | 172 |
| 169 void GpuArcVideoService::BindSharedMemory(::arc::mojom::PortType port, | 173 void GpuArcVideoService::BindSharedMemory(::arc::mojom::PortType port, |
| 170 uint32_t index, | 174 uint32_t index, |
| 171 mojo::ScopedHandle ashmem_handle, | 175 mojo::ScopedHandle ashmem_handle, |
| 172 uint32_t offset, | 176 uint32_t offset, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 accelerator_->Reset(); | 216 accelerator_->Reset(); |
| 213 } | 217 } |
| 214 | 218 |
| 215 void GpuArcVideoService::Flush() { | 219 void GpuArcVideoService::Flush() { |
| 216 DVLOG(2) << "Flush"; | 220 DVLOG(2) << "Flush"; |
| 217 accelerator_->Flush(); | 221 accelerator_->Flush(); |
| 218 } | 222 } |
| 219 | 223 |
| 220 } // namespace arc | 224 } // namespace arc |
| 221 } // namespace chromeos | 225 } // namespace chromeos |
| OLD | NEW |