summaryrefslogtreecommitdiffstats
path: root/media/ozone/media_ozone_platform.cc
blob: 417d54c0e3d07d95f0151251382d8f7734df3f65 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright 2014 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.

#include "media/ozone/media_ozone_platform.h"

#include "base/logging.h"
#include "base/macros.h"
#include "base/trace_event/trace_event.h"
#include "ui/ozone/platform_object.h"
#include "ui/ozone/platform_selection.h"

namespace media {

namespace {

class MediaOzonePlatformStub : public MediaOzonePlatform {
 public:
  MediaOzonePlatformStub() {}

  ~MediaOzonePlatformStub() override {}

 private:
  DISALLOW_COPY_AND_ASSIGN(MediaOzonePlatformStub);
};

}  // namespace

// The following statics are just convenient stubs, declared by the
// generate_constructor_list.py script. They should be removed once the
// internal Ozone platforms decide to actually implement their media specifics.
MediaOzonePlatform* CreateMediaOzonePlatformCaca() {
  return new MediaOzonePlatformStub;
}

MediaOzonePlatform* CreateMediaOzonePlatformCast() {
  return new MediaOzonePlatformStub;
}

MediaOzonePlatform* CreateMediaOzonePlatformDri() {
  return new MediaOzonePlatformStub;
}

MediaOzonePlatform* CreateMediaOzonePlatformDrm() {
  return new MediaOzonePlatformStub;
}

MediaOzonePlatform* CreateMediaOzonePlatformEgltest() {
  return new MediaOzonePlatformStub;
}

MediaOzonePlatform* CreateMediaOzonePlatformGbm() {
  return new MediaOzonePlatformStub;
}

MediaOzonePlatform* CreateMediaOzonePlatformHeadless() {
  return new MediaOzonePlatformStub;
}

MediaOzonePlatform* CreateMediaOzonePlatformWayland() {
  return new MediaOzonePlatformStub;
}

MediaOzonePlatform* CreateMediaOzonePlatformX11() {
  return new MediaOzonePlatformStub;
}

MediaOzonePlatform::MediaOzonePlatform() {
  CHECK(!instance_) << "There should only be a single MediaOzonePlatform.";
  instance_ = this;
}

MediaOzonePlatform::~MediaOzonePlatform() {
  CHECK_EQ(instance_, this);
  instance_ = NULL;
}

// static
MediaOzonePlatform* MediaOzonePlatform::GetInstance() {
  if (!instance_)
    CreateInstance();
  return instance_;
}

VideoDecodeAccelerator* MediaOzonePlatform::CreateVideoDecodeAccelerator(
    const base::Callback<bool(void)>& make_context_current) {
  NOTIMPLEMENTED();
  return NULL;
}

// static
void MediaOzonePlatform::CreateInstance() {
  if (instance_)
    return;

  TRACE_EVENT1("ozone",
               "MediaOzonePlatform::Initialize",
               "platform",
               ui::GetOzonePlatformName());
  scoped_ptr<MediaOzonePlatform> platform =
      ui::PlatformObject<MediaOzonePlatform>::Create();

  // TODO(spang): Currently need to leak this object.
  CHECK_EQ(instance_, platform.release());
}

// static
MediaOzonePlatform* MediaOzonePlatform::instance_;

}  // namespace media