| 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_TRANSPORT_TEXTURE_SERVICE_H_ | |
| 6 #define CONTENT_RENDERER_TRANSPORT_TEXTURE_SERVICE_H_ | |
| 7 | |
| 8 #include <utility> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "content/renderer/gpu_channel_host.h" | |
| 13 #include "content/renderer/gpu_video_decoder_host.h" | |
| 14 #include "ipc/ipc_channel.h" | |
| 15 #include "media/base/buffers.h" | |
| 16 #include "media/base/video_frame.h" | |
| 17 | |
| 18 class RendererGLContext; | |
| 19 class TransportTextureHost; | |
| 20 | |
| 21 // This class implements MessageFilter to dispatch IPC messages to | |
| 22 // TransportTextureHost. | |
| 23 class TransportTextureService : public IPC::ChannelProxy::MessageFilter, | |
| 24 public IPC::Message::Sender { | |
| 25 public: | |
| 26 TransportTextureService(); | |
| 27 virtual ~TransportTextureService(); | |
| 28 | |
| 29 // IPC::ChannelProxy::MessageFilter implementations. | |
| 30 virtual bool OnMessageReceived(const IPC::Message& message); | |
| 31 virtual void OnFilterAdded(IPC::Channel* channel); | |
| 32 virtual void OnFilterRemoved(); | |
| 33 virtual void OnChannelClosing(); | |
| 34 | |
| 35 // Called on RenderThread to create a TransportTextureHost. | |
| 36 // | |
| 37 // A routing ID for the GLES2 context needs to be provided. This is | |
| 38 // important because the resources used needs to be shared with the GLES2 | |
| 39 // context corresponding to the RenderView. | |
| 40 scoped_refptr<TransportTextureHost> CreateTransportTextureHost( | |
| 41 RendererGLContext* context, int context_route_id); | |
| 42 | |
| 43 // Called by TransportTextureHost to remove a route. | |
| 44 void RemoveRoute(int32 host_id); | |
| 45 | |
| 46 // IPC::Message::Sender Implementation. | |
| 47 virtual bool Send(IPC::Message* msg); | |
| 48 | |
| 49 private: | |
| 50 typedef std::pair<int32, IPC::Channel::Listener*> PendingRoute; | |
| 51 | |
| 52 // Add a route from |host_id| to |listener|. If channel is not connected yet | |
| 53 // then the information is saved. | |
| 54 void AddRouteInternal(int32 host_id, IPC::Channel::Listener* listener); | |
| 55 | |
| 56 // Helper method to remove a route. | |
| 57 void RemoveRouteInternal(int32 host_id); | |
| 58 | |
| 59 // Helper method to send an IPC message. | |
| 60 void SendInternal(IPC::Message* msg); | |
| 61 | |
| 62 IPC::Channel* channel_; | |
| 63 | |
| 64 // Router to send messages to a TransportTextureHost. This is created when | |
| 65 // the filter is added on the IO thread. | |
| 66 scoped_ptr<MessageRouter> router_; | |
| 67 | |
| 68 // ID for the next TransportTextureHost. | |
| 69 int32 next_host_id_; | |
| 70 | |
| 71 std::vector<PendingRoute> pending_routes_; | |
| 72 std::vector<IPC::Message*> pending_messages_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(TransportTextureService); | |
| 75 }; | |
| 76 | |
| 77 #endif // CONTENT_RENDERER_TRANSPORT_TEXTURE_SERVICE_H_ | |
| OLD | NEW |