summaryrefslogtreecommitdiffstats
path: root/chrome/gpu/gpu_video_service.h
blob: 371cf4b3ffe69097e9ad05b01b7af91b59289239 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_GPU_GPU_VIDEO_SERVICE_H_
#define CHROME_GPU_GPU_VIDEO_SERVICE_H_

#include <map>

#include "base/ref_counted.h"
#include "base/singleton.h"
#include "chrome/gpu/gpu_video_decoder.h"
#include "ipc/ipc_channel.h"

class GpuChannel;

class GpuVideoService : public IPC::Channel::Listener {
 public:
  static GpuVideoService* GetInstance();

  // IPC::Channel::Listener.
  virtual void OnChannelConnected(int32 peer_pid);
  virtual void OnChannelError();
  virtual bool OnMessageReceived(const IPC::Message& message);

  // TODO(hclam): Remove return value.
  bool CreateVideoDecoder(GpuChannel* channel,
                          MessageRouter* router,
                          int32 decoder_host_id,
                          int32 decoder_id,
                          gpu::gles2::GLES2Decoder* gles2_decoder);
  void DestroyVideoDecoder(MessageRouter* router,
                           int32 decoder_id);

 private:
  struct GpuVideoDecoderInfo;

  GpuVideoService();
  virtual ~GpuVideoService();

  std::map<int32, GpuVideoDecoderInfo> decoder_map_;

  // Specialize video service on different platform will override.
  virtual bool IntializeGpuVideoService();
  virtual bool UnintializeGpuVideoService();

  friend struct DefaultSingletonTraits<GpuVideoService>;
  DISALLOW_COPY_AND_ASSIGN(GpuVideoService);
};

#endif  // CHROME_GPU_GPU_VIDEO_SERVICE_H_