| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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_VIDEO_SERVICE_HOST_H_ | |
| 6 #define CONTENT_RENDERER_GPU_VIDEO_SERVICE_HOST_H_ | |
| 7 | |
| 8 #include "base/memory/singleton.h" | |
| 9 #include "content/renderer/gpu_channel_host.h" | |
| 10 #include "content/renderer/gpu_video_decoder_host.h" | |
| 11 #include "ipc/ipc_channel.h" | |
| 12 #include "media/base/buffers.h" | |
| 13 #include "media/base/video_frame.h" | |
| 14 #include "media/video/video_decode_accelerator.h" | |
| 15 | |
| 16 class GpuVideoDecodeAcceleratorHost; | |
| 17 | |
| 18 // GpuVideoServiceHost lives on IO thread and is used to dispatch IPC messages | |
| 19 // to GpuVideoDecoderHost objects. | |
| 20 class GpuVideoServiceHost : public IPC::ChannelProxy::MessageFilter { | |
| 21 public: | |
| 22 GpuVideoServiceHost(); | |
| 23 virtual ~GpuVideoServiceHost(); | |
| 24 | |
| 25 // IPC::ChannelProxy::MessageFilter implementations, called on IO thread. | |
| 26 virtual bool OnMessageReceived(const IPC::Message& message); | |
| 27 virtual void OnFilterAdded(IPC::Channel* channel); | |
| 28 virtual void OnFilterRemoved(); | |
| 29 virtual void OnChannelClosing(); | |
| 30 | |
| 31 // Register a callback to be notified when |*this| can be used to | |
| 32 // CreateVideo{Decoder,Accelerator} below. Called on RenderThread. | |
| 33 // |on_initialized| will get invoked in-line in this function if |*this| is | |
| 34 // already ready for use, and asynchronously after this function returns | |
| 35 // otherwise. | |
| 36 void SetOnInitialized(const base::Closure& on_initialized); | |
| 37 | |
| 38 // Called on RenderThread to create a hardware accelerated video decoder | |
| 39 // in the GPU process. | |
| 40 // | |
| 41 // A routing ID for the GLES2 context needs to be provided when creating a | |
| 42 // hardware video decoder. This is important because the resources used by | |
| 43 // the video decoder needs to be shared with the GLES2 context corresponding | |
| 44 // to the RenderView. | |
| 45 // | |
| 46 // This means that a GPU video decoder is tied to a specific RenderView and | |
| 47 // its GLES2 context in the GPU process. | |
| 48 // | |
| 49 // Returns a GpuVideoDecoderHost as a handle to control the video decoder. | |
| 50 // | |
| 51 // Note: OnFilterAdded() MUST be called before these methods are called, | |
| 52 // because they require |channel_| to be non-NULL. | |
| 53 GpuVideoDecoderHost* CreateVideoDecoder(int context_route_id); | |
| 54 | |
| 55 GpuVideoDecodeAcceleratorHost* CreateVideoAccelerator( | |
| 56 media::VideoDecodeAccelerator::Client* client); | |
| 57 | |
| 58 private: | |
| 59 // Guards all members other than |router_|. | |
| 60 base::Lock lock_; | |
| 61 | |
| 62 // Reference to the channel that the service listens to. | |
| 63 IPC::Channel* channel_; | |
| 64 | |
| 65 // Router to send messages to a GpuVideoDecoderHost. | |
| 66 MessageRouter router_; | |
| 67 | |
| 68 // ID for the next GpuVideoDecoderHost. | |
| 69 int32 next_decoder_host_id_; | |
| 70 | |
| 71 // Callback to invoke when initialized. | |
| 72 base::Closure on_initialized_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(GpuVideoServiceHost); | |
| 75 }; | |
| 76 | |
| 77 #endif // CONTENT_RENDERER_GPU_VIDEO_SERVICE_HOST_H_ | |
| OLD | NEW |