OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SERVICES_MEDIA_FRAMEWORK_ENGINE_H_ | 5 #ifndef SERVICES_MEDIA_FRAMEWORK_ENGINE_H_ |
6 #define SERVICES_MEDIA_FRAMEWORK_ENGINE_H_ | 6 #define SERVICES_MEDIA_FRAMEWORK_ENGINE_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <queue> | 9 #include <queue> |
10 #include <stack> | 10 #include <stack> |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // Queues the stage for update and winds down the backlog. | 100 // Queues the stage for update and winds down the backlog. |
101 void RequestUpdate(Stage* stage); | 101 void RequestUpdate(Stage* stage); |
102 | 102 |
103 // Pushes the stage to the supply backlog if it isn't already there. | 103 // Pushes the stage to the supply backlog if it isn't already there. |
104 void PushToSupplyBacklog(Stage* stage); | 104 void PushToSupplyBacklog(Stage* stage); |
105 | 105 |
106 // Pushes the stage to the demand backlog if it isn't already there. | 106 // Pushes the stage to the demand backlog if it isn't already there. |
107 void PushToDemandBacklog(Stage* stage); | 107 void PushToDemandBacklog(Stage* stage); |
108 | 108 |
109 private: | 109 private: |
110 using UpstreamVisitor = std::function<void( | 110 using UpstreamVisitor = |
111 const InputRef& input, | 111 std::function<void(const InputRef& input, |
112 const OutputRef& output, | 112 const OutputRef& output, |
113 const Stage::UpstreamCallback& callback)>; | 113 const Stage::UpstreamCallback& callback)>; |
114 using DownstreamVisitor = std::function<void( | 114 using DownstreamVisitor = |
115 const OutputRef& output, | 115 std::function<void(const OutputRef& output, |
116 const InputRef& input, | 116 const InputRef& input, |
117 const Stage::DownstreamCallback& callback)>; | 117 const Stage::DownstreamCallback& callback)>; |
118 | 118 |
119 void VisitUpstream( | 119 void VisitUpstream(const InputRef& input, const UpstreamVisitor& vistor); |
120 const InputRef& input, | |
121 const UpstreamVisitor& vistor); | |
122 | 120 |
123 void VisitDownstream( | 121 void VisitDownstream(const OutputRef& output, |
124 const OutputRef& output, | 122 const DownstreamVisitor& vistor); |
125 const DownstreamVisitor& vistor); | |
126 | 123 |
127 // Processes the entire backlog. | 124 // Processes the entire backlog. |
128 void Update(); | 125 void Update(); |
129 | 126 |
130 // Performs processing for a single stage, updating the backlog accordingly. | 127 // Performs processing for a single stage, updating the backlog accordingly. |
131 void Update(Stage *stage); | 128 void Update(Stage* stage); |
132 | 129 |
133 // Pops a stage from the supply backlog and returns it or returns nullptr if | 130 // Pops a stage from the supply backlog and returns it or returns nullptr if |
134 // the supply backlog is empty. | 131 // the supply backlog is empty. |
135 Stage* PopFromSupplyBacklog(); | 132 Stage* PopFromSupplyBacklog(); |
136 | 133 |
137 // Pops a stage from the demand backlog and returns it or returns nullptr if | 134 // Pops a stage from the demand backlog and returns it or returns nullptr if |
138 // the demand backlog is empty. | 135 // the demand backlog is empty. |
139 Stage* PopFromDemandBacklog(); | 136 Stage* PopFromDemandBacklog(); |
140 | 137 |
141 mutable base::Lock lock_; | 138 mutable base::Lock lock_; |
142 // supply_backlog_ contains pointers to all the stages that have been supplied | 139 // supply_backlog_ contains pointers to all the stages that have been supplied |
143 // (packets or frames) but have not been updated since. demand_backlog_ does | 140 // (packets or frames) but have not been updated since. demand_backlog_ does |
144 // the same for demand. The use of queue vs stack here is a guess as to what | 141 // the same for demand. The use of queue vs stack here is a guess as to what |
145 // will yield the best results. It's possible that only a single backlog is | 142 // will yield the best results. It's possible that only a single backlog is |
146 // required. | 143 // required. |
147 // TODO(dalesat): Determine the best ordering and implement it. | 144 // TODO(dalesat): Determine the best ordering and implement it. |
148 std::queue<Stage*> supply_backlog_; | 145 std::queue<Stage*> supply_backlog_; |
149 std::stack<Stage*> demand_backlog_; | 146 std::stack<Stage*> demand_backlog_; |
150 bool packets_produced_; | 147 bool packets_produced_; |
151 }; | 148 }; |
152 | 149 |
153 } // namespace media | 150 } // namespace media |
154 } // namespace mojo | 151 } // namespace mojo |
155 | 152 |
156 #endif // SERVICES_MEDIA_FRAMEWORK_ENGINE_H_ | 153 #endif // SERVICES_MEDIA_FRAMEWORK_ENGINE_H_ |
OLD | NEW |