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_COMMON_GPU_MEDIA_GPU_VIDEO_SERVICE_H_ | |
6 #define CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_SERVICE_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/memory/singleton.h" | |
12 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" | |
13 #include "ipc/ipc_channel.h" | |
14 | |
15 namespace gpu { | |
16 namespace gles2 { | |
17 class GLES2Decoder; | |
18 } // namespace gles2 | |
19 } // namespace gpu | |
20 | |
21 class GpuChannel; | |
22 class MessageRouter; | |
23 | |
24 class GpuVideoService : public IPC::Channel::Listener { | |
25 public: | |
26 static GpuVideoService* GetInstance(); | |
27 | |
28 // IPC::Channel::Listener. | |
29 virtual void OnChannelConnected(int32 peer_pid); | |
30 virtual void OnChannelError(); | |
31 virtual bool OnMessageReceived(const IPC::Message& message); | |
32 | |
33 // TODO(hclam): Remove return value. | |
34 bool CreateVideoDecoder(GpuChannel* channel, | |
35 MessageRouter* router, | |
36 int32 decoder_host_id, | |
37 int32 decoder_id, | |
38 GpuCommandBufferStub* stub, | |
39 const std::vector<uint32>& configs); | |
40 void InitializeVideoDecoder(int32 decoder_id); | |
41 void DestroyVideoDecoder(MessageRouter* router, | |
42 int32 decoder_id); | |
43 | |
44 // Passes given GLES textures to the decoder indicated by id. | |
45 void AssignTexturesToDecoder(int32 decoder_id, | |
46 const std::vector<int32>& buffer_ids, | |
47 const std::vector<uint32>& texture_ids, | |
48 const std::vector<gfx::Size>& sizes); | |
49 | |
50 private: | |
51 struct VideoDecoderInfo { | |
52 VideoDecoderInfo(scoped_refptr<GpuVideoDecodeAccelerator> g_v_d_a, | |
53 GpuCommandBufferStub* s) | |
54 : video_decoder(g_v_d_a), | |
55 stub(s) {} | |
56 ~VideoDecoderInfo() {} | |
57 scoped_refptr<GpuVideoDecodeAccelerator> video_decoder; | |
58 GpuCommandBufferStub* stub; | |
59 }; | |
60 // Map of video and command buffer decoders, indexed by video decoder id. | |
61 typedef std::map<int32, VideoDecoderInfo> DecoderMap; | |
62 | |
63 GpuVideoService(); | |
64 virtual ~GpuVideoService(); | |
65 | |
66 // Specialize video service on different platform will override. | |
67 virtual bool IntializeGpuVideoService(); | |
68 virtual bool UnintializeGpuVideoService(); | |
69 | |
70 DecoderMap decoder_map_; | |
71 | |
72 friend struct DefaultSingletonTraits<GpuVideoService>; | |
73 DISALLOW_COPY_AND_ASSIGN(GpuVideoService); | |
74 }; | |
75 | |
76 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_SERVICE_H_ | |
OLD | NEW |