| 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 CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
| 6 #define CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/shared_memory.h" | 16 #include "base/memory/shared_memory.h" |
| 17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
| 18 #include "content/common/gpu/gpu_command_buffer_stub.h" | |
| 19 #include "content/common/gpu/media/gpu_video_decode_accelerator_helpers.h" | 18 #include "content/common/gpu/media/gpu_video_decode_accelerator_helpers.h" |
| 20 #include "gpu/command_buffer/service/texture_manager.h" | 19 #include "gpu/command_buffer/service/texture_manager.h" |
| 21 #include "gpu/config/gpu_info.h" | 20 #include "gpu/config/gpu_info.h" |
| 21 #include "gpu/ipc/service/gpu_command_buffer_stub.h" |
| 22 #include "gpu/ipc/service/gpu_command_buffer_stub.h" |
| 22 #include "ipc/ipc_listener.h" | 23 #include "ipc/ipc_listener.h" |
| 23 #include "ipc/ipc_sender.h" | 24 #include "ipc/ipc_sender.h" |
| 24 #include "media/video/video_decode_accelerator.h" | 25 #include "media/video/video_decode_accelerator.h" |
| 25 #include "ui/gfx/geometry/size.h" | 26 #include "ui/gfx/geometry/size.h" |
| 26 | 27 |
| 27 namespace gpu { | 28 namespace gpu { |
| 28 struct GpuPreferences; | 29 struct GpuPreferences; |
| 29 } // namespace gpu | 30 } // namespace gpu |
| 30 | 31 |
| 31 namespace content { | 32 namespace content { |
| 32 | 33 |
| 33 class GpuVideoDecodeAccelerator | 34 class GpuVideoDecodeAccelerator |
| 34 : public IPC::Listener, | 35 : public IPC::Listener, |
| 35 public IPC::Sender, | 36 public IPC::Sender, |
| 36 public media::VideoDecodeAccelerator::Client, | 37 public media::VideoDecodeAccelerator::Client, |
| 37 public GpuCommandBufferStub::DestructionObserver { | 38 public gpu::GpuCommandBufferStub::DestructionObserver { |
| 38 public: | 39 public: |
| 39 // Each of the arguments to the constructor must outlive this object. | 40 // Each of the arguments to the constructor must outlive this object. |
| 40 // |stub->decoder()| will be made current around any operation that touches | 41 // |stub->decoder()| will be made current around any operation that touches |
| 41 // the underlying VDA so that it can make GL calls safely. | 42 // the underlying VDA so that it can make GL calls safely. |
| 42 GpuVideoDecodeAccelerator( | 43 GpuVideoDecodeAccelerator( |
| 43 int32_t host_route_id, | 44 int32_t host_route_id, |
| 44 GpuCommandBufferStub* stub, | 45 gpu::GpuCommandBufferStub* stub, |
| 45 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 46 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
| 46 | 47 |
| 47 // Static query for the capabilities, which includes the supported profiles. | 48 // Static query for the capabilities, which includes the supported profiles. |
| 48 // This query calls the appropriate platform-specific version. The returned | 49 // This query calls the appropriate platform-specific version. The returned |
| 49 // capabilities will not contain duplicate supported profile entries. | 50 // capabilities will not contain duplicate supported profile entries. |
| 50 static gpu::VideoDecodeAcceleratorCapabilities GetCapabilities( | 51 static gpu::VideoDecodeAcceleratorCapabilities GetCapabilities( |
| 51 const gpu::GpuPreferences& gpu_preferences); | 52 const gpu::GpuPreferences& gpu_preferences); |
| 52 | 53 |
| 53 // IPC::Listener implementation. | 54 // IPC::Listener implementation. |
| 54 bool OnMessageReceived(const IPC::Message& message) override; | 55 bool OnMessageReceived(const IPC::Message& message) override; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 67 void NotifyError(media::VideoDecodeAccelerator::Error error) override; | 68 void NotifyError(media::VideoDecodeAccelerator::Error error) override; |
| 68 | 69 |
| 69 // GpuCommandBufferStub::DestructionObserver implementation. | 70 // GpuCommandBufferStub::DestructionObserver implementation. |
| 70 void OnWillDestroyStub() override; | 71 void OnWillDestroyStub() override; |
| 71 | 72 |
| 72 // Function to delegate sending to actual sender. | 73 // Function to delegate sending to actual sender. |
| 73 bool Send(IPC::Message* message) override; | 74 bool Send(IPC::Message* message) override; |
| 74 | 75 |
| 75 // Initialize VDAs from the set of VDAs supported for current platform until | 76 // Initialize VDAs from the set of VDAs supported for current platform until |
| 76 // one of them succeeds for given |config|. Send the |init_done_msg| when | 77 // one of them succeeds for given |config|. Send the |init_done_msg| when |
| 77 // done. filter_ is passed to GpuCommandBufferStub channel only if the chosen | 78 // done. filter_ is passed to gpu::GpuCommandBufferStub channel only if the |
| 78 // VDA can decode on IO thread. | 79 // chosen VDA can decode on IO thread. |
| 79 bool Initialize(const media::VideoDecodeAccelerator::Config& config); | 80 bool Initialize(const media::VideoDecodeAccelerator::Config& config); |
| 80 | 81 |
| 81 private: | 82 private: |
| 82 class MessageFilter; | 83 class MessageFilter; |
| 83 | 84 |
| 84 // We only allow self-delete, from OnWillDestroyStub(), after cleanup there. | 85 // We only allow self-delete, from OnWillDestroyStub(), after cleanup there. |
| 85 ~GpuVideoDecodeAccelerator() override; | 86 ~GpuVideoDecodeAccelerator() override; |
| 86 | 87 |
| 87 // Handlers for IPC messages. | 88 // Handlers for IPC messages. |
| 88 void OnSetCdm(int cdm_id); | 89 void OnSetCdm(int cdm_id); |
| 89 void OnDecode(const media::BitstreamBuffer& bitstream_buffer); | 90 void OnDecode(const media::BitstreamBuffer& bitstream_buffer); |
| 90 void OnAssignPictureBuffers( | 91 void OnAssignPictureBuffers( |
| 91 const std::vector<int32_t>& buffer_ids, | 92 const std::vector<int32_t>& buffer_ids, |
| 92 const std::vector<media::PictureBuffer::TextureIds>& texture_ids); | 93 const std::vector<media::PictureBuffer::TextureIds>& texture_ids); |
| 93 void OnReusePictureBuffer(int32_t picture_buffer_id); | 94 void OnReusePictureBuffer(int32_t picture_buffer_id); |
| 94 void OnFlush(); | 95 void OnFlush(); |
| 95 void OnReset(); | 96 void OnReset(); |
| 96 void OnDestroy(); | 97 void OnDestroy(); |
| 97 | 98 |
| 98 // Called on IO thread when |filter_| has been removed. | 99 // Called on IO thread when |filter_| has been removed. |
| 99 void OnFilterRemoved(); | 100 void OnFilterRemoved(); |
| 100 | 101 |
| 101 // Sets the texture to cleared. | 102 // Sets the texture to cleared. |
| 102 void SetTextureCleared(const media::Picture& picture); | 103 void SetTextureCleared(const media::Picture& picture); |
| 103 | 104 |
| 104 // Route ID to communicate with the host. | 105 // Route ID to communicate with the host. |
| 105 const int32_t host_route_id_; | 106 const int32_t host_route_id_; |
| 106 | 107 |
| 107 // Unowned pointer to the underlying GpuCommandBufferStub. |this| is | 108 // Unowned pointer to the underlying gpu::GpuCommandBufferStub. |this| is |
| 108 // registered as a DestuctionObserver of |stub_| and will self-delete when | 109 // registered as a DestuctionObserver of |stub_| and will self-delete when |
| 109 // |stub_| is destroyed. | 110 // |stub_| is destroyed. |
| 110 GpuCommandBufferStub* const stub_; | 111 gpu::GpuCommandBufferStub* const stub_; |
| 111 | 112 |
| 112 // The underlying VideoDecodeAccelerator. | 113 // The underlying VideoDecodeAccelerator. |
| 113 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; | 114 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; |
| 114 | 115 |
| 115 // Callback to return current GLContext, if available. | 116 // Callback to return current GLContext, if available. |
| 116 GetGLContextCallback get_gl_context_cb_; | 117 GetGLContextCallback get_gl_context_cb_; |
| 117 | 118 |
| 118 // Callback for making the relevant context current for GL calls. | 119 // Callback for making the relevant context current for GL calls. |
| 119 MakeGLContextCurrentCallback make_context_current_cb_; | 120 MakeGLContextCurrentCallback make_context_current_cb_; |
| 120 | 121 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 158 |
| 158 // A map from picture buffer ID to TextureRef that have not been cleared. | 159 // A map from picture buffer ID to TextureRef that have not been cleared. |
| 159 std::map<int32_t, scoped_refptr<gpu::gles2::TextureRef>> uncleared_textures_; | 160 std::map<int32_t, scoped_refptr<gpu::gles2::TextureRef>> uncleared_textures_; |
| 160 | 161 |
| 161 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); | 162 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); |
| 162 }; | 163 }; |
| 163 | 164 |
| 164 } // namespace content | 165 } // namespace content |
| 165 | 166 |
| 166 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 167 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |