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 #ifndef MEDIA_GPU_IPC_SERVICE_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef MEDIA_GPU_IPC_SERVICE_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
6 #define MEDIA_GPU_IPC_SERVICE_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define MEDIA_GPU_IPC_SERVICE_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 namespace gpu { | 28 namespace gpu { |
29 struct GpuPreferences; | 29 struct GpuPreferences; |
30 } // namespace gpu | 30 } // namespace gpu |
31 | 31 |
32 namespace media { | 32 namespace media { |
33 | 33 |
34 class GpuVideoDecodeAccelerator | 34 class GpuVideoDecodeAccelerator |
35 : public IPC::Listener, | 35 : public IPC::Listener, |
36 public IPC::Sender, | 36 public IPC::Sender, |
37 public media::VideoDecodeAccelerator::Client, | 37 public VideoDecodeAccelerator::Client, |
38 public gpu::GpuCommandBufferStub::DestructionObserver { | 38 public gpu::GpuCommandBufferStub::DestructionObserver { |
39 public: | 39 public: |
40 // Each of the arguments to the constructor must outlive this object. | 40 // Each of the arguments to the constructor must outlive this object. |
41 // |stub->decoder()| will be made current around any operation that touches | 41 // |stub->decoder()| will be made current around any operation that touches |
42 // the underlying VDA so that it can make GL calls safely. | 42 // the underlying VDA so that it can make GL calls safely. |
43 GpuVideoDecodeAccelerator( | 43 GpuVideoDecodeAccelerator( |
44 int32_t host_route_id, | 44 int32_t host_route_id, |
45 gpu::GpuCommandBufferStub* stub, | 45 gpu::GpuCommandBufferStub* stub, |
46 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 46 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
47 | 47 |
48 // Static query for the capabilities, which includes the supported profiles. | 48 // Static query for the capabilities, which includes the supported profiles. |
49 // This query calls the appropriate platform-specific version. The returned | 49 // This query calls the appropriate platform-specific version. The returned |
50 // capabilities will not contain duplicate supported profile entries. | 50 // capabilities will not contain duplicate supported profile entries. |
51 static gpu::VideoDecodeAcceleratorCapabilities GetCapabilities( | 51 static gpu::VideoDecodeAcceleratorCapabilities GetCapabilities( |
52 const gpu::GpuPreferences& gpu_preferences); | 52 const gpu::GpuPreferences& gpu_preferences); |
53 | 53 |
54 // IPC::Listener implementation. | 54 // IPC::Listener implementation. |
55 bool OnMessageReceived(const IPC::Message& message) override; | 55 bool OnMessageReceived(const IPC::Message& message) override; |
56 | 56 |
57 // media::VideoDecodeAccelerator::Client implementation. | 57 // VideoDecodeAccelerator::Client implementation. |
58 void NotifyInitializationComplete(bool success) override; | 58 void NotifyInitializationComplete(bool success) override; |
59 void ProvidePictureBuffers(uint32_t requested_num_of_buffers, | 59 void ProvidePictureBuffers(uint32_t requested_num_of_buffers, |
60 VideoPixelFormat format, | 60 VideoPixelFormat format, |
61 uint32_t textures_per_buffer, | 61 uint32_t textures_per_buffer, |
62 const gfx::Size& dimensions, | 62 const gfx::Size& dimensions, |
63 uint32_t texture_target) override; | 63 uint32_t texture_target) override; |
64 void DismissPictureBuffer(int32_t picture_buffer_id) override; | 64 void DismissPictureBuffer(int32_t picture_buffer_id) override; |
65 void PictureReady(const media::Picture& picture) override; | 65 void PictureReady(const Picture& picture) override; |
66 void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override; | 66 void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override; |
67 void NotifyFlushDone() override; | 67 void NotifyFlushDone() override; |
68 void NotifyResetDone() override; | 68 void NotifyResetDone() override; |
69 void NotifyError(media::VideoDecodeAccelerator::Error error) override; | 69 void NotifyError(VideoDecodeAccelerator::Error error) override; |
70 | 70 |
71 // GpuCommandBufferStub::DestructionObserver implementation. | 71 // GpuCommandBufferStub::DestructionObserver implementation. |
72 void OnWillDestroyStub() override; | 72 void OnWillDestroyStub() override; |
73 | 73 |
74 // Function to delegate sending to actual sender. | 74 // Function to delegate sending to actual sender. |
75 bool Send(IPC::Message* message) override; | 75 bool Send(IPC::Message* message) override; |
76 | 76 |
77 // Initialize VDAs from the set of VDAs supported for current platform until | 77 // Initialize VDAs from the set of VDAs supported for current platform until |
78 // one of them succeeds for given |config|. Send the |init_done_msg| when | 78 // one of them succeeds for given |config|. Send the |init_done_msg| when |
79 // done. filter_ is passed to gpu::GpuCommandBufferStub channel only if the | 79 // done. filter_ is passed to gpu::GpuCommandBufferStub channel only if the |
80 // chosen VDA can decode on IO thread. | 80 // chosen VDA can decode on IO thread. |
81 bool Initialize(const media::VideoDecodeAccelerator::Config& config); | 81 bool Initialize(const VideoDecodeAccelerator::Config& config); |
82 | 82 |
83 private: | 83 private: |
84 class MessageFilter; | 84 class MessageFilter; |
85 | 85 |
86 // We only allow self-delete, from OnWillDestroyStub(), after cleanup there. | 86 // We only allow self-delete, from OnWillDestroyStub(), after cleanup there. |
87 ~GpuVideoDecodeAccelerator() override; | 87 ~GpuVideoDecodeAccelerator() override; |
88 | 88 |
89 // Handlers for IPC messages. | 89 // Handlers for IPC messages. |
90 void OnDecode(const media::BitstreamBuffer& bitstream_buffer); | 90 void OnDecode(const BitstreamBuffer& bitstream_buffer); |
91 void OnAssignPictureBuffers( | 91 void OnAssignPictureBuffers( |
92 const std::vector<int32_t>& buffer_ids, | 92 const std::vector<int32_t>& buffer_ids, |
93 const std::vector<media::PictureBuffer::TextureIds>& texture_ids); | 93 const std::vector<PictureBuffer::TextureIds>& texture_ids); |
94 void OnReusePictureBuffer(int32_t picture_buffer_id); | 94 void OnReusePictureBuffer(int32_t picture_buffer_id); |
95 void OnFlush(); | 95 void OnFlush(); |
96 void OnReset(); | 96 void OnReset(); |
97 void OnDestroy(); | 97 void OnDestroy(); |
98 | 98 |
99 // Called on IO thread when |filter_| has been removed. | 99 // Called on IO thread when |filter_| has been removed. |
100 void OnFilterRemoved(); | 100 void OnFilterRemoved(); |
101 | 101 |
102 // Sets the texture to cleared. | 102 // Sets the texture to cleared. |
103 void SetTextureCleared(const media::Picture& picture); | 103 void SetTextureCleared(const Picture& picture); |
104 | 104 |
105 // Route ID to communicate with the host. | 105 // Route ID to communicate with the host. |
106 const int32_t host_route_id_; | 106 const int32_t host_route_id_; |
107 | 107 |
108 // Unowned pointer to the underlying gpu::GpuCommandBufferStub. |this| is | 108 // Unowned pointer to the underlying gpu::GpuCommandBufferStub. |this| is |
109 // registered as a DestuctionObserver of |stub_| and will self-delete when | 109 // registered as a DestuctionObserver of |stub_| and will self-delete when |
110 // |stub_| is destroyed. | 110 // |stub_| is destroyed. |
111 gpu::GpuCommandBufferStub* const stub_; | 111 gpu::GpuCommandBufferStub* const stub_; |
112 | 112 |
113 // The underlying VideoDecodeAccelerator. | 113 // The underlying VideoDecodeAccelerator. |
114 std::unique_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; | 114 std::unique_ptr<VideoDecodeAccelerator> video_decode_accelerator_; |
115 | 115 |
116 // Callback to return current GLContext, if available. | 116 // Callback to return current GLContext, if available. |
117 GetGLContextCallback get_gl_context_cb_; | 117 GetGLContextCallback get_gl_context_cb_; |
118 | 118 |
119 // Callback for making the relevant context current for GL calls. | 119 // Callback for making the relevant context current for GL calls. |
120 MakeGLContextCurrentCallback make_context_current_cb_; | 120 MakeGLContextCurrentCallback make_context_current_cb_; |
121 | 121 |
122 // Callback to bind a GLImage to a given texture id and target. | 122 // Callback to bind a GLImage to a given texture id and target. |
123 BindGLImageCallback bind_image_cb_; | 123 BindGLImageCallback bind_image_cb_; |
124 | 124 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // cleared. | 160 // cleared. |
161 std::map<int32_t, std::vector<scoped_refptr<gpu::gles2::TextureRef>>> | 161 std::map<int32_t, std::vector<scoped_refptr<gpu::gles2::TextureRef>>> |
162 uncleared_textures_; | 162 uncleared_textures_; |
163 | 163 |
164 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); | 164 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); |
165 }; | 165 }; |
166 | 166 |
167 } // namespace media | 167 } // namespace media |
168 | 168 |
169 #endif // MEDIA_GPU_IPC_SERVICE_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 169 #endif // MEDIA_GPU_IPC_SERVICE_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |