OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_ |
| 6 #define CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "ipc/ipc_listener.h" |
| 11 #include "ipc/ipc_sender.h" |
| 12 #include "media/video/jpeg_decode_accelerator.h" |
| 13 |
| 14 struct AcceleratedJpegDecoderMsg_Decode_Params; |
| 15 |
| 16 namespace base { |
| 17 class MessageLoopProxy; |
| 18 } |
| 19 |
| 20 namespace content { |
| 21 class GpuChannel; |
| 22 |
| 23 class GpuJpegDecodeAccelerator : public IPC::Listener, |
| 24 public IPC::Sender, |
| 25 public media::JpegDecodeAccelerator::Client { |
| 26 public: |
| 27 // |channel| must outlive this object. |
| 28 GpuJpegDecodeAccelerator( |
| 29 GpuChannel* channel, |
| 30 int32 host_route_id, |
| 31 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); |
| 32 |
| 33 // Creates and initializes JpegDecodeAccelerator. |
| 34 bool Initialize(); |
| 35 |
| 36 // Destroys and deletes itself. |
| 37 void Destroy(); |
| 38 |
| 39 // IPC::Listener implementation. |
| 40 bool OnMessageReceived(const IPC::Message& message) override; |
| 41 |
| 42 // media::JpegDecodeAccelerator::Client implementation. |
| 43 void VideoFrameReady(int32_t bitstream_buffer_id) override; |
| 44 void NotifyError(int32_t bitstream_buffer_id, |
| 45 media::JpegDecodeAccelerator::Error error) override; |
| 46 |
| 47 // Function to delegate sending to actual sender. |
| 48 bool Send(IPC::Message* message) override; |
| 49 |
| 50 private: |
| 51 ~GpuJpegDecodeAccelerator(); |
| 52 class MessageFilter; |
| 53 |
| 54 // Handlers for IPC messages. |
| 55 void OnDecode(const AcceleratedJpegDecoderMsg_Decode_Params& params); |
| 56 void OnDestroy(); |
| 57 |
| 58 // Called on IO thread when |filter_| has been removed. |
| 59 void OnFilterRemoved(); |
| 60 |
| 61 // The lifetime of objects of this class is managed by a GpuChannel. The |
| 62 // GpuChannels destroy all the GpuJpegDecodeAccelerator that they own when |
| 63 // they are destroyed. So a raw pointer is safe. |
| 64 GpuChannel* channel_; |
| 65 |
| 66 // Route ID to communicate with the host. |
| 67 int32 host_route_id_; |
| 68 |
| 69 // The underlying JpegDecodeAccelerator. |
| 70 scoped_ptr<media::JpegDecodeAccelerator> jpeg_decode_accelerator_; |
| 71 |
| 72 // The message filter to run JpegDecodeAccelerator::Decode on IO thread. |
| 73 scoped_refptr<MessageFilter> filter_; |
| 74 |
| 75 // Used to wait on for |filter_| to be removed, before we can safely |
| 76 // destroy the JpegDecodeAccelerator. |
| 77 base::WaitableEvent filter_removed_; |
| 78 |
| 79 // GPU child message loop. |
| 80 scoped_refptr<base::MessageLoopProxy> child_message_loop_; |
| 81 |
| 82 // GPU IO message loop. |
| 83 scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
| 84 |
| 85 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuJpegDecodeAccelerator); |
| 86 }; |
| 87 |
| 88 } // namespace content |
| 89 |
| 90 namespace base { |
| 91 |
| 92 template <class T> |
| 93 struct DefaultDeleter; |
| 94 |
| 95 // Specialize DefaultDeleter so that scoped_ptr<GpuJpegDecodeAccelerator> always |
| 96 // uses "Destroy()" instead of trying to use the destructor. |
| 97 template <> |
| 98 struct MEDIA_EXPORT DefaultDeleter<content::GpuJpegDecodeAccelerator> { |
| 99 public: |
| 100 void operator()(void* jpeg_decode_accelerator) const; |
| 101 }; |
| 102 |
| 103 } // namespace base |
| 104 |
| 105 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_ |
OLD | NEW |