[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / content / common / gpu / client / gpu_video_decode_accelerator_host.h
blob571bd0c94bfde64a3e1e8dd89a62b59298a7ac0b
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.
5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_
6 #define CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_
8 #include <vector>
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 #include "ui/gfx/size.h"
17 namespace content {
18 class GpuChannelHost;
20 // This class is used to talk to VideoDecodeAccelerator in the Gpu process
21 // through IPC messages.
22 class GpuVideoDecodeAcceleratorHost
23 : public IPC::Listener,
24 public media::VideoDecodeAccelerator,
25 public CommandBufferProxyImpl::DeletionObserver,
26 public base::NonThreadSafe {
27 public:
28 // |this| is guaranteed not to outlive |channel| and |impl|. (See comments
29 // for |channel_| and |impl_|.)
30 GpuVideoDecodeAcceleratorHost(GpuChannelHost* channel,
31 CommandBufferProxyImpl* impl);
33 // IPC::Listener implementation.
34 virtual void OnChannelError() OVERRIDE;
35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
37 // media::VideoDecodeAccelerator implementation.
38 virtual bool Initialize(media::VideoCodecProfile profile,
39 Client* client) OVERRIDE;
40 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
41 virtual void AssignPictureBuffers(
42 const std::vector<media::PictureBuffer>& buffers) OVERRIDE;
43 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE;
44 virtual void Flush() OVERRIDE;
45 virtual void Reset() OVERRIDE;
46 virtual void Destroy() OVERRIDE;
48 // CommandBufferProxyImpl::DeletionObserver implemetnation.
49 virtual void OnWillDeleteImpl() OVERRIDE;
51 private:
52 // Only Destroy() should be deleting |this|.
53 virtual ~GpuVideoDecodeAcceleratorHost();
55 // Notify |client_| of an error. Posts a task to avoid re-entrancy.
56 void PostNotifyError(Error);
58 void Send(IPC::Message* message);
60 // IPC handlers, proxying media::VideoDecodeAccelerator::Client for the GPU
61 // process. Should not be called directly.
62 void OnBitstreamBufferProcessed(int32 bitstream_buffer_id);
63 void OnProvidePictureBuffer(uint32 num_requested_buffers,
64 const gfx::Size& dimensions,
65 uint32 texture_target);
66 void OnDismissPictureBuffer(int32 picture_buffer_id);
67 void OnPictureReady(int32 picture_buffer_id, int32 bitstream_buffer_id);
68 void OnFlushDone();
69 void OnResetDone();
70 void OnNotifyError(uint32 error);
72 // Unowned reference to the GpuChannelHost to send IPC messages to the GPU
73 // process. |channel_| outlives |impl_|, so the reference is always valid as
74 // long as it is not NULL.
75 GpuChannelHost* channel_;
77 // Route ID for the associated decoder in the GPU process.
78 int32 decoder_route_id_;
80 // The client that will receive callbacks from the decoder.
81 Client* client_;
83 // Unowned reference to the CommandBufferProxyImpl that created us. |this|
84 // registers as a DeletionObserver of |impl_|, the so reference is always
85 // valid as long as it is not NULL.
86 CommandBufferProxyImpl* impl_;
88 // Requested dimensions of the buffer, from ProvidePictureBuffers().
89 gfx::Size picture_buffer_dimensions_;
91 // WeakPtr factory for posting tasks back to itself.
92 base::WeakPtrFactory<GpuVideoDecodeAcceleratorHost> weak_this_factory_;
94 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecodeAcceleratorHost);
97 } // namespace content
99 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_