Shaka Player Embedded
pipeline_manager.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_MANAGER_H_
16 #define SHAKA_EMBEDDED_MEDIA_PIPELINE_MANAGER_H_
17 
18 #include <atomic>
19 #include <thread>
20 
22 #include "src/debug/mutex.h"
23 #include "src/util/clock.h"
24 
25 namespace shaka {
26 namespace media {
27 
43  public:
44  PipelineManager(std::function<void(VideoPlaybackState)> on_status_changed,
45  std::function<void()> on_seek, const util::Clock* clock);
46  virtual ~PipelineManager();
47 
49  virtual void Reset();
50 
52  virtual void DoneInitializing();
53 
55  virtual VideoPlaybackState GetPlaybackState() const;
56 
58  virtual double GetDuration() const;
59 
61  virtual void SetDuration(double duration);
62 
64  virtual double GetCurrentTime() const;
65 
67  virtual void SetCurrentTime(double time);
68 
70  virtual double GetPlaybackRate() const;
71 
73  virtual void SetPlaybackRate(double rate);
74 
76  virtual void Play();
77 
79  virtual void Pause();
80 
82  virtual void Buffering();
83 
85  virtual void CanPlay();
86 
91  virtual void OnEnded();
92 
94  virtual void OnError();
95 
96  private:
98  double GetTimeFor(uint64_t wall_time) const;
99 
109  void SyncPoint();
110 
111  mutable SharedMutex mutex_;
112  const std::function<void(VideoPlaybackState)> on_status_changed_;
113  const std::function<void()> on_seek_;
114  const util::Clock* const clock_;
115  VideoPlaybackState status_;
116 
118  double prev_media_time_;
120  uint64_t prev_wall_time_;
121  double playback_rate_;
122  double duration_;
123  bool will_play_;
124 };
125 
126 } // namespace media
127 } // namespace shaka
128 
129 #endif // SHAKA_EMBEDDED_MEDIA_PIPELINE_MANAGER_H_
virtual VideoPlaybackState GetPlaybackState() const
PipelineManager(std::function< void(VideoPlaybackState)> on_status_changed, std::function< void()> on_seek, const util::Clock *clock)
virtual void SetCurrentTime(double time)
virtual double GetCurrentTime() const
virtual void SetDuration(double duration)
virtual void SetPlaybackRate(double rate)
virtual double GetPlaybackRate() const
virtual double GetDuration() const