Ocean
MovieFrameProviderInterface.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_MOVIE_FRAME_PROVIDER_INTERFACE_H
9 #define META_OCEAN_MEDIA_MOVIE_FRAME_PROVIDER_INTERFACE_H
10 
11 #include "ocean/media/Media.h"
13 
15 
16 namespace Ocean
17 {
18 
19 namespace Media
20 {
21 
22 /**
23  * This class implements a frame provider interface specialization using a movie frame provider object.
24  * Actually, this function is nothing else but a wrapper for a MovieFrameProvider object.<br>
25  * We should investigate whether we really need an own MovideFrameProvider class anymore.<br>
26  * However, the MovieFrameProvider is able to deliver preview images, which is not part of this interface.
27  * @see MovieFrameProvider.
28  * @ingroup media
29  */
31 {
32  private:
33 
34  /**
35  * Definition of pair combining a frame index with a frame reference.
36  */
37  typedef std::pair<unsigned int, FrameRef> FramePair;
38 
39  /**
40  * Definition of a queue storing frame pairs.
41  */
42  typedef std::queue<FramePair> FrameQueue;
43 
44  public:
45 
46  /**
47  * Creates a new media frame provider interface.
48  * @param movieFrameProvider Movie frame provider object that is connected with this interface and that provides the individual frames
49  */
51 
52  /**
53  * Destructs this frame provider interface.
54  */
56 
57  /**
58  * Returns whether the internal information of this interface has been initialized already and whether request functions can be handled.
59  * @see CV::FrameProviderInterface::isInitialized().
60  */
61  bool isInitialized() override;
62 
63  /**
64  * Sets a preferred frame type pixel format and pixel origin for this interface.
65  * @see CV::FrameProviderInterface::setPreferredFrameType().
66  */
67  bool setPreferredFrameType(const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin) override;
68 
69  /**
70  * Invokes an asynchronous frame request.
71  * @see CV::FrameProviderInterface::asynchronFrameRequest().
72  */
73  void asynchronFrameRequest(const unsigned int index, const bool priority) override;
74 
75  /**
76  * Invokes a synchronous frame request.
77  * @see CV::FrameProviderInterface::synchronFrameRequest().
78  */
79  FrameRef synchronFrameRequest(const unsigned int index, const double timeout, bool* abort = nullptr) override;
80 
81  /**
82  * Invokes a suggestion to pre-load or to cache some frames that might be requested soon.
83  * @see CV::FrameProviderInterface::frameCacheRequest().
84  */
85  void frameCacheRequest(const unsigned int index, const int range) override;
86 
87  /**
88  * Invokes an asynchronous frame number request.
89  * @see CV::FrameProviderInterface::asynchronFrameNumberRequest().
90  */
91  void asynchronFrameNumberRequest() override;
92 
93  /**
94  * Invokes a synchronous frame number request.
95  * @see CV::FrameProviderInterface::synchronFrameNumberRequest().
96  */
97  unsigned int synchronFrameNumberRequest(const double timeout, bool* abort = nullptr) override;
98 
99  /**
100  * Invokes an asynchronous frame type request.
101  * @see CV::FrameProviderInterface::asynchronFrameTypeRequest().
102  */
103  void asynchronFrameTypeRequest() override;
104 
105  /**
106  * Invokes a synchronous frame type request.
107  * @see CV::FrameProviderInterface::synchronFrameTypeRequest().
108  */
109  FrameType synchronFrameTypeRequest(const double timeout, bool* abort = nullptr) override;
110 
111  /**
112  * Releases all associated resources.
113  * @see CV::FrameProviderInterface::release().
114  */
115  void release() override;
116 
117  private:
118 
119  /**
120  * Scheduler event function.
121  */
122  void onScheduler();
123 
124  /**
125  * Internal callback function for frame requests arriving from the internal media frame provider.
126  * @param frameIndex Index of the frame that recently has been encoded by the media frame provider
127  * @param frameRequested True, if the frame has been requested, false if the frame just has been encoded without explicit request
128  */
129  void onFrame(const unsigned int frameIndex, const bool frameRequested);
130 
131  private:
132 
133  /// The movie frame provider that provides the individual frames for this interface.
135 
136  /// Frame queue for asynchronous frame requests.
138 
139  /// True, if an asynchronous frame number request has been invoked.
140  bool asynchronousFrameNumber_ = false;
141 
142  /// True, if an asynchronous frame type request has been invoked.
143  bool asynchronousFrameType_ = false;
144 
145  /// Interface lock.
147 };
148 
149 }
150 
151 }
152 
153 #endif // META_OCEAN_MEDIA_MOVIE_FRAME_PROVIDER_INTERFACE_H
This class defines an abstract interface allowing to request frames from any kind of frame provider.
Definition: FrameProviderInterface.h:38
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition: Frame.h:30
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition: Frame.h:183
PixelOrigin
Defines different types of frame origin positions.
Definition: Frame.h:1046
This class implements a recursive lock object.
Definition: Lock.h:31
This class implements a frame provider interface specialization using a movie frame provider object.
Definition: MovieFrameProviderInterface.h:31
void release() override
Releases all associated resources.
void asynchronFrameTypeRequest() override
Invokes an asynchronous frame type request.
~MovieFrameProviderInterface() override
Destructs this frame provider interface.
MovieFrameProviderRef movieFrameProvider_
The movie frame provider that provides the individual frames for this interface.
Definition: MovieFrameProviderInterface.h:134
bool isInitialized() override
Returns whether the internal information of this interface has been initialized already and whether r...
FrameRef synchronFrameRequest(const unsigned int index, const double timeout, bool *abort=nullptr) override
Invokes a synchronous frame request.
void asynchronFrameNumberRequest() override
Invokes an asynchronous frame number request.
void asynchronFrameRequest(const unsigned int index, const bool priority) override
Invokes an asynchronous frame request.
Lock lock_
Interface lock.
Definition: MovieFrameProviderInterface.h:146
std::queue< FramePair > FrameQueue
Definition of a queue storing frame pairs.
Definition: MovieFrameProviderInterface.h:42
void onFrame(const unsigned int frameIndex, const bool frameRequested)
Internal callback function for frame requests arriving from the internal media frame provider.
FrameType synchronFrameTypeRequest(const double timeout, bool *abort=nullptr) override
Invokes a synchronous frame type request.
void frameCacheRequest(const unsigned int index, const int range) override
Invokes a suggestion to pre-load or to cache some frames that might be requested soon.
std::pair< unsigned int, FrameRef > FramePair
Definition of pair combining a frame index with a frame reference.
Definition: MovieFrameProviderInterface.h:37
MovieFrameProviderInterface(const MovieFrameProviderRef &movieFrameProvider)
Creates a new media frame provider interface.
void onScheduler()
Scheduler event function.
FrameQueue frameQueue_
Frame queue for asynchronous frame requests.
Definition: MovieFrameProviderInterface.h:137
bool setPreferredFrameType(const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin) override
Sets a preferred frame type pixel format and pixel origin for this interface.
unsigned int synchronFrameNumberRequest(const double timeout, bool *abort=nullptr) override
Invokes a synchronous frame number request.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15