Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: services/media/framework/refs.h

Issue 1678433002: Motown: Remove LPCM optimizations, fix prepare, add flush, add ActiveMultistreamSink model/stage (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Sync Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/media/framework/ptr.h ('k') | services/media/framework/refs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 SERVICES_MEDIA_FRAMEWORK_REFS_H_
6 #define SERVICES_MEDIA_FRAMEWORK_REFS_H_
7
8 #include <stdint.h>
9
10 namespace mojo {
11 namespace media {
12
13 class Graph;
14 class Stage;
15 class Input;
16 class Output;
17 class Engine;
18 class InputRef;
19 class OutputRef;
20
21 // Opaque Stage pointer used for graph building.
22 class PartRef {
23 public:
24 PartRef() : stage_(nullptr) {}
25
26 PartRef& operator=(std::nullptr_t) {
27 stage_ = nullptr;
28 return *this;
29 }
30
31 // Returns the number of inputs the part has.
32 size_t input_count() const;
33
34 // Returns a reference to the specified input.
35 InputRef input(size_t index) const;
36
37 // Returns a reference to the only input. input_count must return 1 for this
38 // call to be valid.
39 InputRef input() const;
40
41 // Returns the number of outputs the part has.
42 size_t output_count() const;
43
44 // Returns a reference to the specified output.
45 OutputRef output(size_t index) const;
46
47 // Returns a reference to the only output. output_count must return 1 for this
48 // call to be valid.
49 OutputRef output() const;
50
51 // Returns true if the reference refers to a part, false if it's null.
52 explicit operator bool() const { return stage_ != nullptr; }
53
54 private:
55 explicit PartRef(Stage* stage) : stage_(stage) {}
56
57 // Determines if the reference is non-null and otherwise valid. Useful for
58 // DCHECKs.
59 bool valid() const { return stage_ != nullptr; }
60
61 Stage* stage_;
62
63 friend Graph;
64 friend InputRef;
65 friend OutputRef;
66 friend Engine;
67 };
68
69 // Opaque Input pointer used for graph building.
70 class InputRef {
71 public:
72 InputRef() : stage_(nullptr), index_(0) {}
73
74 InputRef& operator=(std::nullptr_t) {
75 stage_ = nullptr;
76 index_ = 0;
77 return *this;
78 }
79
80 // Returns true if the reference refers to an input, false if it's null.
81 explicit operator bool() const { return stage_ != nullptr; }
82
83 // Returns a reference to the part that owns this input. Returns a null
84 // reference if this reference is null.
85 PartRef part() const { return PartRef(stage_); }
86
87 // Indicates whether this input is connected to an output.
88 bool connected() const;
89
90 // Returns a reference to the output to which this input is connected. Returns
91 // an invalid reference if this input isn't connected to an output.
92 const OutputRef& mate() const;
93
94 private:
95 InputRef(Stage* stage, size_t index);
96
97 // Returns the actual input referenced by this object.
98 Input& actual() const;
99
100 // Determines if the reference is non-null and otherwise valid. Useful for
101 // DCHECKs.
102 bool valid() const;
103
104 Stage* stage_;
105 size_t index_;
106
107 friend Graph;
108 friend PartRef;
109 friend OutputRef;
110 friend Output;
111 friend Engine;
112 };
113
114 // Opaque Output pointer used for graph building.
115 class OutputRef {
116 public:
117 OutputRef() : stage_(nullptr), index_(0) {}
118
119 OutputRef& operator=(std::nullptr_t) {
120 stage_ = nullptr;
121 index_ = 0;
122 return *this;
123 }
124
125 // Returns true if the reference refers to an output, false if it's null.
126 explicit operator bool() const { return stage_ != nullptr; }
127
128 // Returns a reference to the part that owns this output. Returns a null
129 // reference if this reference is null.
130 PartRef part() const { return PartRef(stage_); }
131
132 // Indicates whether this output is connected to an input.
133 bool connected() const;
134
135 // Returns a reference to the input to which this output is connected. Returns
136 // an invalid reference if this output isn't connected to an input.
137 const InputRef& mate() const;
138
139 private:
140 OutputRef(Stage* stage, size_t index);
141
142 // Returns the actual input referenced by this object.
143 Output& actual() const;
144
145 // Determines if the reference is non-null and otherwise valid. Useful for
146 // DCHECKs.
147 bool valid() const;
148
149 Stage* stage_;
150 size_t index_;
151
152 friend Graph;
153 friend PartRef;
154 friend InputRef;
155 friend Input;
156 friend Engine;
157 };
158
159 } // namespace media
160 } // namespace mojo
161
162 #endif // SERVICES_MEDIA_FRAMEWORK_REFS_H_
OLDNEW
« no previous file with comments | « services/media/framework/ptr.h ('k') | services/media/framework/refs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698