Ocean
MovieFrameProvider.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_H
9 #define META_OCEAN_MEDIA_MOVIE_FRAME_PROVIDER_H
10 
11 #include "ocean/media/Media.h"
12 #include "ocean/media/Movie.h"
13 
14 #include "ocean/base/Callback.h"
15 #include "ocean/base/Frame.h"
16 #include "ocean/base/RingMap.h"
17 #include "ocean/base/Thread.h"
18 
19 #include <list>
20 
21 namespace Ocean
22 {
23 
24 namespace Media
25 {
26 
27 // Forward declaration.
28 class MovieFrameProvider;
29 
30 /**
31  * Definition of an object reference holding a frame provider.
32  * @see MovieFrameProvider.
33  * @ingroup media
34  */
36 
37 /**
38  * This class implements a frame provider for movie mediums.
39  * In addition to allowing access to the movie's frame, this provider also allows access to smaller preview frames.
40  * @ingroup media
41  */
42 class OCEAN_MEDIA_EXPORT MovieFrameProvider : protected Thread
43 {
44  public:
45 
46  /**
47  * Definition of individual event types.
48  */
49  enum EventType
50  {
51  /// Invalid event type.
53  /// New media object assigned, the parameter is zero.
55  /// The determination of all preview frames has been completed, the parameter stores the number of frames.
57  /// The size of the frames has been changed, the parameters stores the width in the upper 32 bit and the height in the lower 32 bit.
59  /// A requested frame cannot be delivered, the parameter stores the index of the frame.
60  ET_REQUESTED_FRAME_FAILED
61  };
62 
63  /**
64  * Definition of frame callback function.
65  * The first parameter defines the index of the frame.<br>
66  * The second parameter states whether the frames has been explicitly requested.
67  */
69 
70  /**
71  * Definition of a preview frame callback function.
72  * The first parameter defines the index of the preview frame.<br>
73  */
75 
76  /**
77  * Definition of an event callback function.
78  * The first parameter specifies the event type.<br>
79  * The second parameter holds an optional event parameter.<br>
80  */
82 
83  /**
84  * Definition of a pair of sizes.
85  */
87 
88  private:
89 
90  /**
91  * Definition of a non-thread-safe ring map mapping frame indices to frame references.
92  */
94 
95  /**
96  * Definition of a preview frame composed of a finished-state and the frame data.
97  */
98  typedef std::pair<bool, FrameRef> PreviewFrame;
99 
100  /**
101  * Definition of a vector holding preview frames.
102  */
103  typedef std::vector<PreviewFrame> PreviewFrames;
104 
105  /**
106  * Definition of a queue holding frames.
107  */
108  typedef std::queue<FrameRef> FrameQueue;
109 
110  /**
111  * Definition of a list holding frame indices.
112  */
113  typedef std::list<unsigned int> RequestList;
114 
115  /**
116  * Definition of a callback container storing frame callbacks.
117  */
119 
120  /**
121  * Definition of a callback container storing preview frame callbacks.
122  */
124 
125  /**
126  * Definition of a callback container storing event callbacks.
127  */
129 
130  public:
131 
132  /**
133  * Creates a new movie frame provider.
134  * @param enabled True, to enable the provider directly
135  * @param maximalFrameStorage The maximal number of frames that will be stored inside the frame provider concurrently
136  * @param maximalQueueStorage The maximal number of frames that will be queued inside the frame provider concurrently
137  */
138  explicit MovieFrameProvider(const bool enabled = true, const unsigned int maximalFrameStorage = 150u, const unsigned int maximalQueueStorage = 50u);
139 
140  /**
141  * Destructs the movie frame provider.
142  */
144 
145  /**
146  * Returns whether the provider is enabled.
147  * @return True, if so
148  */
149  inline bool isEnabled() const;
150 
151  /**
152  * Enables or disables the provider.
153  * @param state True, to enable the provider
154  * @return True, if succeeded
155  */
156  bool setEnabled(const bool state);
157 
158  /**
159  * Returns the url of the media.
160  * @return Media url of the media
161  */
162  std::string url() const;
163 
164  /**
165  * Sets the movie providing the frames.
166  * The movie must be exclusive so that the frame provider can use the movie's resources alone.<br>
167  * @param movie The movie to set
168  * @return True, if succeeded
169  * @see Medium::isExlusive(), Manager::newMedium().
170  */
171  bool setMovie(const MovieRef& movie);
172 
173  /**
174  * Sets the preferred frame type of the frames of this provider.
175  * However, there is no guarantee that this interface will be able to provided the requested frame type.<br>
176  * @param pixelFormat The preferred pixel format
177  * @param pixelOrigin The preferred pixel origin
178  * @return True, if succeeded
179  */
180  bool setPreferredFrameType(const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin);
181 
182  /**
183  * Sets the dimension of the preview frames.
184  * Only one parameter has to be provided, either the width or the size.<br>
185  * The other parameter has to be zero.
186  * @param width The width of each preview frame in pixel, with range [0u, infinity)
187  * @param height the height of each preview frame in pixel, with range [0u, infinity)
188  * @return True, if succeeded
189  */
190  bool setPreferredPreviewDimension(const unsigned int width, const unsigned int height);
191 
192  /**
193  * Returns the current duration of the media in seconds.
194  * @return Duration time in seconds
195  */
196  inline double duration() const;
197 
198  /**
199  * Returns the frame dimension of the frames of this provider.
200  * @return Frame dimension, width and height in pixel
201  */
202  inline Dimension frameDimension() const;
203 
204  /**
205  * Returns the frame type of the frames of this provider.
206  * @return Frame type
207  */
208  inline const FrameType& frameType() const;
209 
210  /**
211  * Returns the preferred frame dimension of the preview frames.
212  * @return Preferred frame dimension, width and high in pixel
213  */
215 
216  /**
217  * Returns the capacity of frames that can be stored concurrently.
218  * The capacity does not reflect the preview frames.<br>
219  * @return Number of frames
220  * @see setFrameCapacity().
221  */
222  inline size_t frameCapacity() const;
223 
224  /**
225  * Sets or changes the capacity of the frames to be stored concurrently.
226  * The capacity does not reflect the preview frames.
227  * @param capacity The capacity to be set, with range [1, infinity)
228  * @return True, if succeeded
229  * @see frameCapacity().
230  */
231  bool setFrameCapacity(const size_t capacity);
232 
233  /**
234  * Adds a new frame callback event function.
235  * Each callback has to be removed before this frame provider is disposed.<br>
236  * @param callback The callback function to be added
237  * @see removeFrameCallback().
238  */
239  inline void addFrameCallback(const FrameCallback& callback);
240 
241  /**
242  * Adds a new preview frame callback event function.
243  * Each callback has to be removed before this frame provider is disposed.<br>
244  * @param callback The callback function to be added
245  * @see removePreviewFrameCallback().
246  */
247  inline void addPreviewFrameCallback(const PreviewFrameCallback& callback);
248 
249  /**
250  * Adds a new event callback event function.
251  * Each callback has to be removed before this frame provider is disposed.<br>
252  * @param callback The callback function to be added
253  * @see removeEventCallback().
254  */
255  inline void addEventCallback(const EventCallback& callback);
256 
257  /**
258  * Removes a frame callback event function.
259  * @param callback The callback function to be removed
260  * @see addFrameCallback().
261  */
262  inline void removeFrameCallback(const FrameCallback& callback);
263 
264  /**
265  * Removes a preview frame callback event function.
266  * @param callback The callback function to be removed
267  * @see addPreviewFrameCallback().
268  */
269  inline void removePreviewFrameCallback(const PreviewFrameCallback& callback);
270 
271  /**
272  * Removes an event callback event function.
273  * @param callback The callback function to be removed
274  * @see addEventCallback().
275  */
276  inline void removeEventCallback(const EventCallback& callback);
277 
278  /**
279  * Returns the number of frames the media actually provides.
280  * The number of actual frames is unknown until all preview frames have been determined.<br>
281  * @return Number of actual frames
282  * @see estimatedFrameNumber(), currentFrameNumber(), frameNumber().
283  */
284  unsigned int actualFrameNumber();
285 
286  /**
287  * Returns the estimated number of frames that can be provided.
288  * This number is an estimation due to the media information and may be an approximation only.<br>
289  * @return Number of estimated frames
290  * @see actualFrameNumber(), currentFrameNumber(), frameNumber().
291  */
292  unsigned int estimatedFrameNumber();
293 
294  /**
295  * Returns the current number of frames that can be provided.
296  * This number is identical to the number of existing preview frames.<br>
297  * @return Number of current frames
298  * @see actualFrameNumber(), estimatedFrameNumber(), frameNumber().
299  */
300  unsigned int currentFrameNumber();
301 
302  /**
303  * Returns the best guess of the number of frames of this provider.
304  * If the actual number of frames is known, this number is returned.<br>
305  * Otherwise the highest value of estimatedFrameNumber() and currentFrameNumber() is returned.<br>
306  * @return Number of frames
307  * @see actualFrameNumber(), estimatedFrameNumber(), currentFrameNumber().
308  */
309  unsigned int frameNumber();
310 
311  /**
312  * Requests a frame synchronously.
313  * The function blocks until the requested frame can be provided.<br>
314  * If the frame cannot be provided, the function returns directly after the timeout has been reached or the abort statement has been set.
315  * @param index The index of the frame that is requested
316  * @param timeout Time period in that the function will wait if the requested frame cannot be provided directly, with range [0, infinity)
317  * @param abort Optional abort statement allowing to abort the frame request at any time; set the value True to abort the request
318  * @return Requested frame, if it can be provided within the specified timeout period
319  * @see asynchronFrameRequest().
320  */
321  FrameRef synchronFrameRequest(const unsigned int index, const double timeout = 10.0, bool* abort = nullptr);
322 
323  /**
324  * Requests a frame asynchronously.
325  * If the frame is available the frame can be accessed by e.g. the frame() or frameRequest() function.<br>
326  * If a frame event callback has been defined, an event will occur if the requested frame is available.<br>
327  * @param index The index of the frame that is requested
328  * @param priority True, to receive the frame as fast as possible
329  * @see frame(), frameRequest(), synchronFrameRequest().
330  */
331  void asynchronFrameRequest(const unsigned int index, const bool priority = true);
332 
333  /**
334  * Returns a frame directly if the frame is currently available.
335  * If the frame does not exist, nothing happens.<br>
336  * @param index The index of the frame that is requested
337  * @return Resulting frame, if it currently exists
338  * @see frameRequest()
339  */
340  FrameRef frame(const unsigned index);
341 
342  /**
343  * Returns a frame directly if the frame is currently available, otherwise the frame will be requested asynchronously (by internally calling asynchronously).
344  * If the frame is requested asynchronously the frame will be provided after this function returns.<br>
345  * If the frame is provided asynchronously, the an event will occur if the requested frame is available.<br>
346  * @param index The index of the frame that is requested
347  * @return Resulting frame, if it currently exists
348  * @see frame(), asynchronFrameRequest().
349  */
350  FrameRef frameRequest(const unsigned int index);
351 
352  /**
353  * Returns a preview frame.
354  * The provided index should lie inside the number of expected media frame.<br>
355  * @param index The index of the preview frame, with range [0, infinity)
356  * @return Resulting preview frame, if it does exist already
357  */
358  FrameRef previewFrame(const unsigned int index);
359 
360  /**
361  * Returns several preview frames.
362  * The provided index should lie inside the number of expected media frame.<br>
363  * A zooming factor may be used to return e.g. each 2nd, 3rd or each 10th preview frame (beginning at the specified index).<br>
364  * @param index The index of the first preview frame to be returned
365  * @param size Number of preview frames to be returned
366  * @param zoom The zoom factor, with range [1, infinity)
367  * @return Resulting preview frames
368  */
369  FrameRefs previewFrames(const unsigned int index, const unsigned int size, const unsigned int zoom = 1u);
370 
371  /**
372  * Determines the current preview dimension for the current frame size and specified preferred preview dimension.
373  * @return Resulting preview dimension, zero if invalid
374  */
376 
377  /**
378  * Returns the preview progress of this frame provider.
379  * @return Preview progress in percent
380  */
381  unsigned int previewProgress() const;
382 
383  protected:
384 
385  /**
386  * Releases the frame provider.
387  */
388  void release();
389 
390  /**
391  * Thread run function.
392  */
393  void threadRun() override;
394 
395  /**
396  * Internal event function for new preview frames.
397  * @param frame The new preview frame, will be valid
398  * @param camera The camera profile associated with the frame, invalid if unknown
399  */
400  void onPreviewFrame(const Frame& frame, const SharedAnyCamera& camera);
401 
402  /**
403  * Internal event function for new frames.
404  * @param frame The new frame, will be valid
405  * @param camera The camera profile associated with the frame, invalid if unknown
406  */
407  void onFrame(const Frame& frame, const SharedAnyCamera& camera);
408 
409  /**
410  * Creates a new preview frame by a given original frame.
411  * @param frame The frame for that a preview frame has to be created
412  * @param index The index of the given frame
413  * @param previewWidth Width of the resulting preview frame in pixel, with range [1, infinity)
414  * @param previewHeight Height of the resulting preview frame in pixel, with range [1, infinity)
415  * @return True, if succeeded
416  */
417  bool handlePreviewFrame(const Frame& frame, unsigned int index, const unsigned int previewWidth, const unsigned int previewHeight);
418 
419  /**
420  * Determines the frame index for a given timestamp.
421  * If the frame preview creation has not been completed yet, the index is incremented with each new function call.
422  * @param timestamp Timestamp for that the index has to be determined
423  * @param lookup True, ensure that the index is returned only if a corresponding preview frame exists already
424  * @return Resulting frame index
425  */
426  unsigned int timestamp2index(const double timestamp, const bool lookup = false);
427 
428  /**
429  * Converts the index of a frame into the corresponding timestamp.
430  * @param index The index for that the timestamp has to be found
431  * @return Resulting timestamp, -1 if the index is invalid
432  */
433  double index2timestamp(const unsigned int index);
434 
435  protected:
436 
437  /// Provider enabled state.
438  bool enabled_ = false;
439 
440  /// State that is set directly if the provider has been invoked to be disposed.
441  bool released_ = false;
442 
443  /// Movie providing the preview frames.
445 
446  /// Movie providing the frames.
448 
449  /// The subscription objects for previewing frame callback events.
451 
452  /// The subscription objects for frame callback events.
454 
455  /// Duration of the media in seconds.
456  double mediaDuration_ = 0.0;
457 
458  /// Frequency of the media in Hz.
459  double mediaFrameFrequency_ = 0.0;
460 
461  /// Average time for one frame in the media.
462  double mediaFrameTime_ = 0.0;
463 
464  /// Actual number of frames that the provider organizes.
465  unsigned int actualFrameNumber_ = 0u;
466 
467  /// Estimated number of frames that the provider will organize.
468  unsigned int estimatedFrameNumber_ = 0u;
469 
470  /// Number of frames that the provider currently organizes.
471  unsigned int currentFrameNumber_ = 0u;
472 
473  /// Maximal size of the internal intermediate frame queues.
474  unsigned int maximalQueueSize_ = 0u;
475 
476  /// The preferred pixel format of the provider's frames.
478 
479  /// The preferred pixel origin of the provider's frames.
481 
482  /// Intermediate queue for preview frames.
484 
485  /// Intermediate queue for frames.
487 
488  /// Database holding the media frames.
490 
491  /// Vector holding the preview frames.
493 
494  /// List of frames that are explicitly requested.
496 
497  /// Frame type of the media frames.
499 
500  /// Preferred width of the preview frames in pixel.
501  unsigned int preferredPreviewWidth_ = 0u;
502 
503  /// Preferred height of the preview frames in pixel.
504  unsigned int preferredPreviewHeight_ = 100u;
505 
506  /// Frame event callback functions.
508 
509  /// Preview frame event callback functions.
511 
512  /// Event callback functions.
514 
515  /// Index of the currently requested frame.
516  unsigned int frameRequestIndex_ = (unsigned int)(-1);
517 
518  /// Timestamp as the last frame has been arrived.
520 
521  /// Timestamp that stops the standard frame medium.
523 
524  /// Time period that may exceed until a frame is expected to be unavailable, in seconds, with range (0, infinity)
525  double frameRequestTimeout_ = 1.0;
526 
527  /// Provider lock.
528  mutable Lock lock_;
529 
530  /// Frame lock.
532 };
533 
534 inline bool MovieFrameProvider::isEnabled() const
535 {
536  return enabled_;
537 }
538 
539 inline double MovieFrameProvider::duration() const
540 {
541  return mediaDuration_;
542 }
543 
545 {
546  const ScopedLock scopedLock(lock_);
548 }
549 
551 {
552  const ScopedLock scopedLock(lock_);
553  return frameType_;
554 }
555 
557 {
558  return frames_.capacity();
559 }
560 
562 {
563  frameCallbacks_.addCallback(callback);
564 }
565 
567 {
569 }
570 
572 {
573  eventCallbacks_.addCallback(callback);
574 }
575 
577 {
579 }
580 
582 {
584 }
585 
587 {
589 }
590 
591 }
592 
593 }
594 
595 #endif // META_OCEAN_MEDIA_MOVIE_FRAME_PROVIDER_H
This class implements a container for callback functions.
Definition: Callback.h:3456
void addCallback(const T &callback)
Adds a new callback object.
Definition: Callback.h:4304
void removeCallback(const T &callback)
Removes a callback object.
Definition: Callback.h:4329
This class implements Ocean's image class.
Definition: Frame.h:1760
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
@ FORMAT_UNDEFINED
Undefined pixel format.
Definition: Frame.h:187
unsigned int width() const
Returns the width of the frame format in pixel.
Definition: Frame.h:3111
PixelOrigin
Defines different types of frame origin positions.
Definition: Frame.h:1014
@ ORIGIN_INVALID
Invalid origin type.
Definition: Frame.h:1016
unsigned int height() const
Returns the height of the frame in pixel.
Definition: Frame.h:3116
This class implements a recursive lock object.
Definition: Lock.h:31
This class implements a frame provider for movie mediums.
Definition: MovieFrameProvider.h:43
void removeEventCallback(const EventCallback &callback)
Removes an event callback event function.
Definition: MovieFrameProvider.h:586
EventCallbacks eventCallbacks_
Event callback functions.
Definition: MovieFrameProvider.h:513
Callback< void, const unsigned int > PreviewFrameCallback
Definition of a preview frame callback function.
Definition: MovieFrameProvider.h:74
Dimension determinePreviewDimensions() const
Determines the current preview dimension for the current frame size and specified preferred preview d...
MovieRef moviePreview_
Movie providing the preview frames.
Definition: MovieFrameProvider.h:444
double mediaDuration_
Duration of the media in seconds.
Definition: MovieFrameProvider.h:456
std::queue< FrameRef > FrameQueue
Definition of a queue holding frames.
Definition: MovieFrameProvider.h:108
bool isEnabled() const
Returns whether the provider is enabled.
Definition: MovieFrameProvider.h:534
RequestList requestList_
List of frames that are explicitly requested.
Definition: MovieFrameProvider.h:495
FrameCallbacks frameCallbacks_
Frame event callback functions.
Definition: MovieFrameProvider.h:507
ConcurrentCallbacks< EventCallback > EventCallbacks
Definition of a callback container storing event callbacks.
Definition: MovieFrameProvider.h:128
Timestamp movieStopTimestamp_
Timestamp that stops the standard frame medium.
Definition: MovieFrameProvider.h:522
FrameRefs previewFrames(const unsigned int index, const unsigned int size, const unsigned int zoom=1u)
Returns several preview frames.
FrameQueue previewFrameQueue_
Intermediate queue for preview frames.
Definition: MovieFrameProvider.h:483
Lock frameLock_
Frame lock.
Definition: MovieFrameProvider.h:531
void removePreviewFrameCallback(const PreviewFrameCallback &callback)
Removes a preview frame callback event function.
Definition: MovieFrameProvider.h:581
size_t frameCapacity() const
Returns the capacity of frames that can be stored concurrently.
Definition: MovieFrameProvider.h:556
bool setEnabled(const bool state)
Enables or disables the provider.
std::list< unsigned int > RequestList
Definition of a list holding frame indices.
Definition: MovieFrameProvider.h:113
unsigned int previewProgress() const
Returns the preview progress of this frame provider.
FrameMedium::FrameCallbackScopedSubscription scopedSubscriptionFrames_
The subscription objects for frame callback events.
Definition: MovieFrameProvider.h:453
~MovieFrameProvider() override
Destructs the movie frame provider.
bool handlePreviewFrame(const Frame &frame, unsigned int index, const unsigned int previewWidth, const unsigned int previewHeight)
Creates a new preview frame by a given original frame.
Callback< void, const EventType, const unsigned long long > EventCallback
Definition of an event callback function.
Definition: MovieFrameProvider.h:81
Timestamp lastFrameEventTimestamp_
Timestamp as the last frame has been arrived.
Definition: MovieFrameProvider.h:519
FrameType frameType_
Frame type of the media frames.
Definition: MovieFrameProvider.h:498
Dimension frameDimension() const
Returns the frame dimension of the frames of this provider.
Definition: MovieFrameProvider.h:544
FrameRef synchronFrameRequest(const unsigned int index, const double timeout=10.0, bool *abort=nullptr)
Requests a frame synchronously.
unsigned int frameNumber()
Returns the best guess of the number of frames of this provider.
RingMapT< unsigned int, FrameRef, false > FrameDatabase
Definition of a non-thread-safe ring map mapping frame indices to frame references.
Definition: MovieFrameProvider.h:93
bool setMovie(const MovieRef &movie)
Sets the movie providing the frames.
FrameRef frame(const unsigned index)
Returns a frame directly if the frame is currently available.
FrameRef frameRequest(const unsigned int index)
Returns a frame directly if the frame is currently available, otherwise the frame will be requested a...
const FrameType & frameType() const
Returns the frame type of the frames of this provider.
Definition: MovieFrameProvider.h:550
void addEventCallback(const EventCallback &callback)
Adds a new event callback event function.
Definition: MovieFrameProvider.h:571
void onPreviewFrame(const Frame &frame, const SharedAnyCamera &camera)
Internal event function for new preview frames.
bool enabled_
Provider enabled state.
Definition: MovieFrameProvider.h:438
unsigned int timestamp2index(const double timestamp, const bool lookup=false)
Determines the frame index for a given timestamp.
ConcurrentCallbacks< FrameCallback > FrameCallbacks
Definition of a callback container storing frame callbacks.
Definition: MovieFrameProvider.h:118
bool setFrameCapacity(const size_t capacity)
Sets or changes the capacity of the frames to be stored concurrently.
double duration() const
Returns the current duration of the media in seconds.
Definition: MovieFrameProvider.h:539
Lock lock_
Provider lock.
Definition: MovieFrameProvider.h:528
PreviewFrames previewFrames_
Vector holding the preview frames.
Definition: MovieFrameProvider.h:492
void release()
Releases the frame provider.
void addPreviewFrameCallback(const PreviewFrameCallback &callback)
Adds a new preview frame callback event function.
Definition: MovieFrameProvider.h:566
Callback< void, const unsigned int, const bool > FrameCallback
Definition of frame callback function.
Definition: MovieFrameProvider.h:68
unsigned int currentFrameNumber()
Returns the current number of frames that can be provided.
bool setPreferredFrameType(const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin)
Sets the preferred frame type of the frames of this provider.
void addFrameCallback(const FrameCallback &callback)
Adds a new frame callback event function.
Definition: MovieFrameProvider.h:561
FrameMedium::FrameCallbackScopedSubscription scopedSubscriptionPreviewFrames_
The subscription objects for previewing frame callback events.
Definition: MovieFrameProvider.h:450
MovieRef movie_
Movie providing the frames.
Definition: MovieFrameProvider.h:447
Dimension preferredPreviewDimension() const
Returns the preferred frame dimension of the preview frames.
ConcurrentCallbacks< PreviewFrameCallback > PreviewFrameCallbacks
Definition of a callback container storing preview frame callbacks.
Definition: MovieFrameProvider.h:123
void threadRun() override
Thread run function.
unsigned int actualFrameNumber()
Returns the number of frames the media actually provides.
std::pair< bool, FrameRef > PreviewFrame
Definition of a preview frame composed of a finished-state and the frame data.
Definition: MovieFrameProvider.h:98
MovieFrameProvider(const bool enabled=true, const unsigned int maximalFrameStorage=150u, const unsigned int maximalQueueStorage=50u)
Creates a new movie frame provider.
void removeFrameCallback(const FrameCallback &callback)
Removes a frame callback event function.
Definition: MovieFrameProvider.h:576
IndexPair32 Dimension
Definition of a pair of sizes.
Definition: MovieFrameProvider.h:86
FrameDatabase frames_
Database holding the media frames.
Definition: MovieFrameProvider.h:489
bool setPreferredPreviewDimension(const unsigned int width, const unsigned int height)
Sets the dimension of the preview frames.
double index2timestamp(const unsigned int index)
Converts the index of a frame into the corresponding timestamp.
PreviewFrameCallbacks previewFrameCallbacks_
Preview frame event callback functions.
Definition: MovieFrameProvider.h:510
FrameRef previewFrame(const unsigned int index)
Returns a preview frame.
unsigned int estimatedFrameNumber()
Returns the estimated number of frames that can be provided.
void asynchronFrameRequest(const unsigned int index, const bool priority=true)
Requests a frame asynchronously.
EventType
Definition of individual event types.
Definition: MovieFrameProvider.h:50
@ ET_FRAME_SIZE_CHANGED
The size of the frames has been changed, the parameters stores the width in the upper 32 bit and the ...
Definition: MovieFrameProvider.h:58
@ ET_INVALID
Invalid event type.
Definition: MovieFrameProvider.h:52
@ ET_NEW_MEDIA
New media object assigned, the parameter is zero.
Definition: MovieFrameProvider.h:54
@ ET_PREVIEW_COMPLETED
The determination of all preview frames has been completed, the parameter stores the number of frames...
Definition: MovieFrameProvider.h:56
FrameQueue frameQueue_
Intermediate queue for frames.
Definition: MovieFrameProvider.h:486
std::vector< PreviewFrame > PreviewFrames
Definition of a vector holding preview frames.
Definition: MovieFrameProvider.h:103
std::string url() const
Returns the url of the media.
void onFrame(const Frame &frame, const SharedAnyCamera &camera)
Internal event function for new frames.
size_t capacity() const
Returns the capacity of this storage container.
Definition: RingMap.h:287
This class implements a scoped lock object for recursive lock objects.
Definition: Lock.h:135
This class implements a subscription object which can be used unique subscriptions to e....
Definition: ScopedSubscription.h:28
This class implements a thread.
Definition: Thread.h:115
This class implements a timestamp.
Definition: Timestamp.h:36
std::vector< FrameRef > FrameRefs
Definition of a vector holding frame references.
Definition: Frame.h:1735
std::pair< Index32, Index32 > IndexPair32
Definition of a pair holding 32 bit indices.
Definition: Base.h:138
std::shared_ptr< AnyCamera > SharedAnyCamera
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition: AnyCamera.h:60
ObjectRef< MovieFrameProvider > MovieFrameProviderRef
Definition of an object reference holding a frame provider.
Definition: MovieFrameProvider.h:28
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15