| OLD | NEW |
| (Empty) |
| 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_RENDERER_GPU_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ | |
| 6 #define CONTENT_RENDERER_GPU_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 "ipc/ipc_channel.h" | |
| 13 #include "media/video/video_decode_accelerator.h" | |
| 14 | |
| 15 class GpuChannelHost; | |
| 16 | |
| 17 // This class is used to talk to VideoDecodeAccelerator in the Gpu process | |
| 18 // through IPC messages. | |
| 19 class GpuVideoDecodeAcceleratorHost | |
| 20 : public IPC::Channel::Listener, | |
| 21 public media::VideoDecodeAccelerator, | |
| 22 public base::NonThreadSafe, | |
| 23 public base::SupportsWeakPtr<GpuVideoDecodeAcceleratorHost> { | |
| 24 public: | |
| 25 // |channel| is used to send IPC messages to GPU process. | |
| 26 GpuVideoDecodeAcceleratorHost(GpuChannelHost* channel, | |
| 27 int32 decoder_route_id, | |
| 28 media::VideoDecodeAccelerator::Client* client); | |
| 29 virtual ~GpuVideoDecodeAcceleratorHost(); | |
| 30 | |
| 31 // IPC::Channel::Listener implementation. | |
| 32 virtual void OnChannelError() OVERRIDE; | |
| 33 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 34 | |
| 35 // media::VideoDecodeAccelerator implementation. | |
| 36 virtual bool Initialize(Profile profile) OVERRIDE; | |
| 37 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | |
| 38 virtual void AssignPictureBuffers( | |
| 39 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; | |
| 40 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | |
| 41 virtual void Flush() OVERRIDE; | |
| 42 virtual void Reset() OVERRIDE; | |
| 43 virtual void Destroy() OVERRIDE; | |
| 44 | |
| 45 private: | |
| 46 void Send(IPC::Message* message); | |
| 47 | |
| 48 void OnBitstreamBufferProcessed(int32 bitstream_buffer_id); | |
| 49 void OnProvidePictureBuffer( | |
| 50 uint32 num_requested_buffers, const gfx::Size& buffer_size); | |
| 51 void OnDismissPictureBuffer(int32 picture_buffer_id); | |
| 52 void OnPictureReady(int32 picture_buffer_id, int32 bitstream_buffer_id); | |
| 53 void OnFlushDone(); | |
| 54 void OnResetDone(); | |
| 55 void OnErrorNotification(uint32 error); | |
| 56 | |
| 57 // Sends IPC messages to the Gpu process. | |
| 58 GpuChannelHost* channel_; | |
| 59 | |
| 60 // Route ID for the associated decoder in the GPU process. | |
| 61 // TODO(fischman): storing route_id's for GPU process entities in the renderer | |
| 62 // process is vulnerable to GPU process crashing & being respawned, and | |
| 63 // attempting to use an outdated or reused route id. | |
| 64 int32 decoder_route_id_; | |
| 65 | |
| 66 // Reference to the client that will receive callbacks from the decoder. | |
| 67 media::VideoDecodeAccelerator::Client* client_; | |
| 68 | |
| 69 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecodeAcceleratorHost); | |
| 70 }; | |
| 71 | |
| 72 #endif // CONTENT_RENDERER_GPU_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ | |
| OLD | NEW |