Shaka Player Embedded
pipeline_monitor.h
Go to the documentation of this file.
1 // Copyright 2017 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef SHAKA_EMBEDDED_MEDIA_PIPELINE_MONITOR_H_
16 #define SHAKA_EMBEDDED_MEDIA_PIPELINE_MONITOR_H_
17 
18 #include <functional>
19 
21 #include "src/debug/mutex.h"
22 #include "src/debug/thread.h"
23 #include "src/debug/thread_event.h"
25 #include "src/media/types.h"
26 #include "src/util/clock.h"
27 
28 namespace shaka {
29 namespace media {
30 
37  public:
38  PipelineMonitor(std::function<BufferedRanges()> get_buffered,
39  std::function<BufferedRanges()> get_decoded,
40  std::function<void(VideoReadyState)> ready_state_changed,
41  const util::Clock* clock, PipelineManager* pipeline);
43 
45  void Start();
46 
48  void Stop();
49 
50  private:
51  void ThreadMain();
52 
53  void ChangeReadyState(VideoReadyState new_state);
54 
55  Mutex mutex_;
56  ThreadEvent<void> start_;
57 
58  const std::function<BufferedRanges()> get_buffered_;
59  const std::function<BufferedRanges()> get_decoded_;
60  const std::function<void(VideoReadyState)> ready_state_changed_;
61  const util::Clock* const clock_;
62  PipelineManager* const pipeline_;
63  bool shutdown_;
64  bool running_;
65  VideoReadyState ready_state_;
66 
67  Thread thread_;
68 };
69 
70 } // namespace media
71 } // namespace shaka
72 
73 #endif // SHAKA_EMBEDDED_MEDIA_PIPELINE_MONITOR_H_
std::vector< BufferedRange > BufferedRanges
Definition: types.h:26
PipelineMonitor(std::function< BufferedRanges()> get_buffered, std::function< BufferedRanges()> get_decoded, std::function< void(VideoReadyState)> ready_state_changed, const util::Clock *clock, PipelineManager *pipeline)