Ocean
DSFiniteMedium.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_DS_FINITE_MEDIUM_H
9 #define META_OCEAN_MEDIA_DS_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 DirectShow
25 {
26 
27 /**
28  * This class is the base class for all direct show finite mediums.
29  * @ingroup mediads
30  */
31 class OCEAN_MEDIA_DS_EXPORT DSFiniteMedium :
32  virtual public FiniteMedium,
33  virtual public DSMedium
34 {
35  friend class DSFrameMedium;
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 finit 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 Url of the finite medium
86  */
87  explicit DSFiniteMedium(const std::string& url);
88 
89  /**
90  * Destructs a DSFiniteMedium object.
91  */
92  ~DSFiniteMedium() override;
93 
94  /**
95  * Stars the filter graph.
96  * @see DSGraphObject::startGraph().
97  */
98  bool startGraph() override;
99 
100  /**
101  * Creates several DirectShow interface.
102  * @return True, if succeeded
103  */
105 
106  /**
107  * Release the DirectShow interface.
108  */
110 
111  /**
112  * Informs this finite medium object that the medium has been stopped (without knowledge of this finite medium).
113  */
114  void hasStopped();
115 
116  /**
117  * Function called by the scheduler repeatedly.
118  */
119  virtual void onScheduler();
120 
121  protected:
122 
123  /// DirectShow media seeking interface.
125 
126  /// Explicit state that the medium has stopped.
127  bool hasStopped_ = false;
128 
129  /// Medium speed.
130  float speed_ = 1.0f;
131 };
132 
133 }
134 
135 }
136 
137 }
138 
139 #endif // META_OCEAN_MEDIA_DS_FINITE_MEDIUM_H
This class is the base class for all direct show finite mediums.
Definition: DSFiniteMedium.h:34
bool setSpeed(const float speed) override
Sets the speed of the finite medium.
bool createFiniteInterface()
Creates several DirectShow interface.
void releaseFiniteInterface()
Release the DirectShow interface.
~DSFiniteMedium() override
Destructs a DSFiniteMedium object.
double position() const override
Returns the recent position of the finite medium.
bool taskFinished() const override
Returns whether a previous task has been finished.
virtual void onScheduler()
Function called by the scheduler repeatedly.
ScopedIMediaSeeking seekingInterface_
DirectShow media seeking interface.
Definition: DSFiniteMedium.h:124
void hasStopped()
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 finit medium.
double duration() const override
Returns the duration of the finite medium.
float speed() const override
Returns the speed of the finite medium.
double normalDuration() const override
Returns the duration without speed consideration.
bool startGraph() override
Stars the filter graph.
DSFiniteMedium(const std::string &url)
Creates a new finite medium by a given url.
This is the base class for all DirectShow frame mediums.
Definition: DSFrameMedium.h:35
This is the base class for all direct show mediums.
Definition: DSMedium.h:36
This class is the base class for all finite mediums.
Definition: FiniteMedium.h:36
This class wraps an unmanaged object (or reference) which needs to be released after usage.
Definition: ScopedObject.h:166
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15