| 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 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" | 5 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "content/common/gpu/client/gpu_channel_host.h" | 10 #include "content/common/gpu/client/gpu_channel_host.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed, | 49 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed, |
| 50 OnBitstreamBufferProcessed) | 50 OnBitstreamBufferProcessed) |
| 51 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers, | 51 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers, |
| 52 OnProvidePictureBuffer) | 52 OnProvidePictureBuffer) |
| 53 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_PictureReady, | 53 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_PictureReady, |
| 54 OnPictureReady) | 54 OnPictureReady) |
| 55 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_FlushDone, | 55 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_FlushDone, |
| 56 OnFlushDone) | 56 OnFlushDone) |
| 57 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ResetDone, | 57 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ResetDone, |
| 58 OnResetDone) | 58 OnResetDone) |
| 59 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_CdmSet, OnCdmSet) |
| 59 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ErrorNotification, | 60 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ErrorNotification, |
| 60 OnNotifyError) | 61 OnNotifyError) |
| 61 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer, | 62 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer, |
| 62 OnDismissPictureBuffer) | 63 OnDismissPictureBuffer) |
| 63 IPC_MESSAGE_UNHANDLED(handled = false) | 64 IPC_MESSAGE_UNHANDLED(handled = false) |
| 64 IPC_END_MESSAGE_MAP() | 65 IPC_END_MESSAGE_MAP() |
| 65 DCHECK(handled); | 66 DCHECK(handled); |
| 66 // See OnNotifyError for why |this| mustn't be used after OnNotifyError might | 67 // See OnNotifyError for why |this| mustn't be used after OnNotifyError might |
| 67 // have been called above. | 68 // have been called above. |
| 68 return handled; | 69 return handled; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 Send(new AcceleratedVideoDecoderMsg_Flush(decoder_route_id_)); | 170 Send(new AcceleratedVideoDecoderMsg_Flush(decoder_route_id_)); |
| 170 } | 171 } |
| 171 | 172 |
| 172 void GpuVideoDecodeAcceleratorHost::Reset() { | 173 void GpuVideoDecodeAcceleratorHost::Reset() { |
| 173 DCHECK(CalledOnValidThread()); | 174 DCHECK(CalledOnValidThread()); |
| 174 if (!channel_) | 175 if (!channel_) |
| 175 return; | 176 return; |
| 176 Send(new AcceleratedVideoDecoderMsg_Reset(decoder_route_id_)); | 177 Send(new AcceleratedVideoDecoderMsg_Reset(decoder_route_id_)); |
| 177 } | 178 } |
| 178 | 179 |
| 180 void GpuVideoDecodeAcceleratorHost::SetCdm(int cdm_id) { |
| 181 DCHECK(CalledOnValidThread()); |
| 182 if (!channel_) |
| 183 return; |
| 184 Send(new AcceleratedVideoDecoderMsg_SetCdm(decoder_route_id_, cdm_id)); |
| 185 } |
| 186 |
| 179 void GpuVideoDecodeAcceleratorHost::Destroy() { | 187 void GpuVideoDecodeAcceleratorHost::Destroy() { |
| 180 DCHECK(CalledOnValidThread()); | 188 DCHECK(CalledOnValidThread()); |
| 181 if (channel_) | 189 if (channel_) |
| 182 Send(new AcceleratedVideoDecoderMsg_Destroy(decoder_route_id_)); | 190 Send(new AcceleratedVideoDecoderMsg_Destroy(decoder_route_id_)); |
| 183 client_ = NULL; | 191 client_ = NULL; |
| 184 delete this; | 192 delete this; |
| 185 } | 193 } |
| 186 | 194 |
| 187 void GpuVideoDecodeAcceleratorHost::OnWillDeleteImpl() { | 195 void GpuVideoDecodeAcceleratorHost::OnWillDeleteImpl() { |
| 188 DCHECK(CalledOnValidThread()); | 196 DCHECK(CalledOnValidThread()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 if (client_) | 261 if (client_) |
| 254 client_->NotifyFlushDone(); | 262 client_->NotifyFlushDone(); |
| 255 } | 263 } |
| 256 | 264 |
| 257 void GpuVideoDecodeAcceleratorHost::OnResetDone() { | 265 void GpuVideoDecodeAcceleratorHost::OnResetDone() { |
| 258 DCHECK(CalledOnValidThread()); | 266 DCHECK(CalledOnValidThread()); |
| 259 if (client_) | 267 if (client_) |
| 260 client_->NotifyResetDone(); | 268 client_->NotifyResetDone(); |
| 261 } | 269 } |
| 262 | 270 |
| 271 void GpuVideoDecodeAcceleratorHost::OnCdmSet(bool success) { |
| 272 DCHECK(CalledOnValidThread()); |
| 273 if (client_) |
| 274 client_->NotifyCdmSet(success); |
| 275 } |
| 276 |
| 263 void GpuVideoDecodeAcceleratorHost::OnNotifyError(uint32 error) { | 277 void GpuVideoDecodeAcceleratorHost::OnNotifyError(uint32 error) { |
| 264 DCHECK(CalledOnValidThread()); | 278 DCHECK(CalledOnValidThread()); |
| 265 if (!client_) | 279 if (!client_) |
| 266 return; | 280 return; |
| 267 weak_this_factory_.InvalidateWeakPtrs(); | 281 weak_this_factory_.InvalidateWeakPtrs(); |
| 268 | 282 |
| 269 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the | 283 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
| 270 // last thing done on this stack! | 284 // last thing done on this stack! |
| 271 media::VideoDecodeAccelerator::Client* client = NULL; | 285 media::VideoDecodeAccelerator::Client* client = NULL; |
| 272 std::swap(client, client_); | 286 std::swap(client, client_); |
| 273 client->NotifyError(static_cast<media::VideoDecodeAccelerator::Error>(error)); | 287 client->NotifyError(static_cast<media::VideoDecodeAccelerator::Error>(error)); |
| 274 } | 288 } |
| 275 | 289 |
| 276 } // namespace content | 290 } // namespace content |
| OLD | NEW |