Ocean
MFFiniteMedium.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_MEDIA_MF_FINITE_MEDIUM_H
9 #define META_OCEAN_MEDIA_MF_FINITE_MEDIUM_H
10 
13 
15 
16 #include "ocean/base/Scheduler.h"
17 
18 namespace Ocean
19 {
20 
21 namespace Media
22 {
23 
24 namespace MediaFoundation
25 {
26 
27 /**
28  * This class is the base class for all Media Foundation finite mediums.
29  * @ingroup mediamf
30  */
31 class OCEAN_MEDIA_MF_EXPORT MFFiniteMedium :
32  virtual public FiniteMedium,
33  virtual public MFMedium
34 {
35  friend class MFFrameMedium;
36 
37  public:
38 
39  /**
40  * Returns the duration of the finite medium.
41  * @see FiniteMedium::duration().
42  */
43  double duration() const override;
44 
45  /**
46  * Returns the duration without speed consideration.
47  * @see FiniteMedium::normalDuration().
48  */
49  double normalDuration() const override;
50 
51  /**
52  * Returns the recent position of the finite medium.
53  * @see FiniteMedium::position().
54  */
55  double position() const override;
56 
57  /**
58  * Sets the recent position of the finite medium.
59  * @see FiniteMedium::setPosition().
60  */
61  bool setPosition(const double position) override;
62 
63  /**
64  * Returns the speed of the finite medium.
65  * @see FiniteMedium::speed().
66  */
67  float speed() const override;
68 
69  /**
70  * Sets the speed of the finite medium.
71  * @see FiniteMedium::setSpeed().
72  */
73  bool setSpeed(const float speed) override;
74 
75  /**
76  * Returns whether a previous task has been finished.
77  * @see FiniteMedium::taskFinished().
78  */
79  bool taskFinished() const override;
80 
81  protected:
82 
83  /**
84  * Creates a new finite medium by a given URL.
85  * @param url The URL of the finite medium
86  */
87  explicit MFFiniteMedium(const std::string& url);
88 
89  /**
90  * Destructs a MFFiniteMedium object.
91  */
92  ~MFFiniteMedium() override;
93 
94  /**
95  * Informs this finite medium object that the medium has been stopped (without knowledge of this finite medium).
96  */
98 
99  /**
100  * Starts the media session.
101  * @return True, if succeeded or if the session is already started
102  */
103  bool startMediaSession() override;
104 
105  /**
106  * Session ended event function.
107  * @see MFMedium::onSessionEnded().
108  */
109  void onSessionEnded() override;
110 
111  /**
112  * Event function called for the scheduler, will be called on a regular basis.
113  */
114  virtual void onScheduler();
115 
116  protected:
117 
118  /// Explicit state that the medium has stopped.
119  bool hasStopped_ = false;
120 
121  /// Medium start position in 100 nanoseconds.
122  LONGLONG startPosition_ = LONGLONG(-1);
123 
124  /// Medium speed.
125  float speed_ = 1.0;
126 
127  /// Recent session ended event.
128  bool eventSessionEnded_ = false;
129 };
130 
131 }
132 
133 }
134 
135 }
136 
137 #endif // META_OCEAN_MEDIA_MF_FINITE_MEDIUM_H
This class is the base class for all finite mediums.
Definition: FiniteMedium.h:36
This class is the base class for all Media Foundation finite mediums.
Definition: MFFiniteMedium.h:34
float speed() const override
Returns the speed of the finite medium.
double duration() const override
Returns the duration of the finite medium.
void onSessionEnded() override
Session ended event function.
MFFiniteMedium(const std::string &url)
Creates a new finite medium by a given URL.
bool setSpeed(const float speed) override
Sets the speed of the finite medium.
double position() const override
Returns the recent position of the finite medium.
bool startMediaSession() override
Starts the media session.
bool taskFinished() const override
Returns whether a previous task has been finished.
virtual void onScheduler()
Event function called for the scheduler, will be called on a regular basis.
~MFFiniteMedium() override
Destructs a MFFiniteMedium object.
void mediumHasStopped()
Informs this finite medium object that the medium has been stopped (without knowledge of this finite ...
bool setPosition(const double position) override
Sets the recent position of the finite medium.
double normalDuration() const override
Returns the duration without speed consideration.
This is the base class for all Media Foundation frame mediums.
Definition: MFFrameMedium.h:35
This is the base class for all MediaFoundation mediums.
Definition: MFMedium.h:31
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15