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 3// found in the LICENSE file. 4 5#ifndef CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ 6#define CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ 7 8#include <vector> 9 10#include "base/memory/weak_ptr.h" 11#include "base/threading/non_thread_safe.h" 12#include "content/common/gpu/client/command_buffer_proxy_impl.h" 13#include "ipc/ipc_listener.h" 14#include "media/video/video_decode_accelerator.h" 15 16namespace content { 17class GpuChannelHost; 18 19// This class is used to talk to VideoDecodeAccelerator in the Gpu process 20// through IPC messages. 21class GpuVideoDecodeAcceleratorHost 22 : public IPC::Listener, 23 public media::VideoDecodeAccelerator, 24 public CommandBufferProxyImpl::DeletionObserver, 25 public base::NonThreadSafe { 26 public: 27 // |channel| is used to send IPC messages to GPU process. 28 GpuVideoDecodeAcceleratorHost(GpuChannelHost* channel, 29 int32 decoder_route_id, 30 media::VideoDecodeAccelerator::Client* client, 31 CommandBufferProxyImpl* impl); 32 33 // IPC::Listener implementation. 34 virtual void OnChannelError() OVERRIDE; 35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 36 37 // media::VideoDecodeAccelerator implementation. 38 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; 39 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; 40 virtual void AssignPictureBuffers( 41 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; 42 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; 43 virtual void Flush() OVERRIDE; 44 virtual void Reset() OVERRIDE; 45 virtual void Destroy() OVERRIDE; 46 47 // CommandBufferProxyImpl::DeletionObserver implemetnation. 48 virtual void OnWillDeleteImpl() OVERRIDE; 49 50 private: 51 // Only Destroy() should be deleting |this|. 52 virtual ~GpuVideoDecodeAcceleratorHost(); 53 54 void Send(IPC::Message* message); 55 56 void OnBitstreamBufferProcessed(int32 bitstream_buffer_id); 57 void OnProvidePictureBuffer(uint32 num_requested_buffers, 58 const gfx::Size& buffer_size, 59 uint32 texture_target); 60 void OnDismissPictureBuffer(int32 picture_buffer_id); 61 void OnPictureReady(int32 picture_buffer_id, int32 bitstream_buffer_id); 62 void OnFlushDone(); 63 void OnResetDone(); 64 void OnErrorNotification(uint32 error); 65 66 // Sends IPC messages to the Gpu process. 67 GpuChannelHost* channel_; 68 69 // Route ID for the associated decoder in the GPU process. 70 int32 decoder_route_id_; 71 72 // Reference to the client that will receive callbacks from the decoder. 73 media::VideoDecodeAccelerator::Client* client_; 74 75 // Unowned reference to the CommandBufferProxyImpl that created us. 76 CommandBufferProxyImpl* impl_; 77 78 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecodeAcceleratorHost); 79}; 80 81} // namespace content 82 83#endif // CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ 84