Ocean
Loading...
Searching...
No Matches
FrameRecorder.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_FRAME_RECORDER_H
9#define META_OCEAN_MEDIA_FRAME_RECORDER_H
10
11#include "ocean/media/Media.h"
13
14#include "ocean/base/Frame.h"
16
17namespace Ocean
18{
19
20namespace Media
21{
22
23// Forward declaration.
24class FrameRecorder;
25
26/**
27 * Definition of a object reference holding a frame recorder.
28 * @see SmartObjectRef, Recorder.
29 * @ingroup media
30 */
32
33/**
34 * This class is the base class for all frame recorders.
35 * @ingroup media
36 */
37class OCEAN_MEDIA_EXPORT FrameRecorder : virtual public Recorder
38{
39 public:
40
41 /**
42 * Returns the actual frame type of this recorder.
43 * The actual frame type may be different from the preferred (requested) frametype.
44 * @return Frame type
45 * @see setPreferredFrameType().
46 */
47 inline const FrameType& frameType() const;
48
49 /**
50 * Returns the frame frequency of this recorder in Hz.
51 * @return Frame frequency
52 */
53 inline double frameFrequency() const;
54
55 /**
56 * Returns the name of the encoder used to encoder the frames.
57 * @return Encoder name
58 */
59 inline const std::string& frameEncoder() const;
60
61 /**
62 * Returns a list of possible frame encoders for this recorder.
63 * @return Encoder names
64 */
65 virtual Encoders frameEncoders() const;
66
67 /**
68 * Returns whether the selected frame encoder has a configuration possibility.
69 * @return True, if so
70 */
72
73 /**
74 * Sets the preferred frame type of this recorder.
75 * The recorder may not support the specific pixel format, therefore check the actual pixel format of the recorder.
76 * @param type The preferred frame type to record
77 * @return True, if succeeded
78 * @see frameType().
79 */
80 virtual bool setPreferredFrameType(const FrameType& type);
81
82 /**
83 * Sets the frame frequency of this recorder.
84 * @param frequency Frame frequency in Hz
85 * @return True, if succeeded
86 */
87 virtual bool setFrameFrequency(const double frequency);
88
89 /**
90 * Sets the frame encoder used to encode the frames.
91 * @param encoder Name of the encoder to use
92 * @return True, if succeeded
93 */
94 virtual bool setFrameEncoder(const std::string& encoder);
95
96 /**
97 * Starts the frame encoder configuration possibility.
98 * @param data Possible configuration data like gui handles.
99 * @return True, if succeeded
100 */
101 virtual bool frameEncoderConfiguration(long long data);
102
103 /**
104 * Locks the most recent frame and returns it so that the image data can be written to this frame.
105 * Beware: Call unlockBufferToFill() once the image data is written to the frame.
106 * @param recorderFrame The resulting frame in which the image data can be copied, the frame type of this frame must not be changed
107 * @param respectFrameFrequency Flag determining that a buffer will be returned if it is time for a new frame only
108 * @see unlockBufferToFill().
109 */
110 virtual bool lockBufferToFill(Frame& recorderFrame, const bool respectFrameFrequency = true) = 0;
111
112 /**
113 * Unlocks the filled buffer.
114 * Beware: The buffer has to be locked by FrameRecorder::lockBufferToFill() before.
115 */
116 virtual void unlockBufferToFill() = 0;
117
118 protected:
119
120 /**
121 * Creats a new frame recorder.
122 */
124
125 /**
126 * Destructs a frame recorder.
127 */
128 ~FrameRecorder() override;
129
130 protected:
131
132 /// Type of the frame to record.
134
135 /// Frame frequency used by the recorder.
137
138 /// Name of the frame encoder used to encode the frames.
140};
141
143{
144 return recorderFrameType;
145}
146
147inline double FrameRecorder::frameFrequency() const
148{
150}
151
152inline const std::string& FrameRecorder::frameEncoder() const
153{
155}
156
157}
158
159}
160
161#endif // META_OCEAN_MEDIA_FRAME_RECORDER_H
This class implements Ocean's image class.
Definition Frame.h:1808
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition Frame.h:30
This class is the base class for all frame recorders.
Definition FrameRecorder.h:38
virtual bool lockBufferToFill(Frame &recorderFrame, const bool respectFrameFrequency=true)=0
Locks the most recent frame and returns it so that the image data can be written to this frame.
virtual bool setPreferredFrameType(const FrameType &type)
Sets the preferred frame type of this recorder.
virtual void unlockBufferToFill()=0
Unlocks the filled buffer.
FrameRecorder()
Creats a new frame recorder.
virtual Encoders frameEncoders() const
Returns a list of possible frame encoders for this recorder.
double recorderFrameFrequency
Frame frequency used by the recorder.
Definition FrameRecorder.h:136
~FrameRecorder() override
Destructs a frame recorder.
const std::string & frameEncoder() const
Returns the name of the encoder used to encoder the frames.
Definition FrameRecorder.h:152
virtual bool frameEncoderConfiguration(long long data)
Starts the frame encoder configuration possibility.
std::string recorderFrameEncoder
Name of the frame encoder used to encode the frames.
Definition FrameRecorder.h:139
virtual bool frameEncoderHasConfiguration()
Returns whether the selected frame encoder has a configuration possibility.
virtual bool setFrameFrequency(const double frequency)
Sets the frame frequency of this recorder.
FrameType recorderFrameType
Type of the frame to record.
Definition FrameRecorder.h:133
virtual bool setFrameEncoder(const std::string &encoder)
Sets the frame encoder used to encode the frames.
double frameFrequency() const
Returns the frame frequency of this recorder in Hz.
Definition FrameRecorder.h:147
const FrameType & frameType() const
Returns the actual frame type of this recorder.
Definition FrameRecorder.h:142
This class is the base class for all recorder.
Definition Recorder.h:37
std::vector< std::string > Encoders
Definition of a vector holding encoder names.
Definition Recorder.h:80
This template class implements a smart object reference which is a specialization of an ObjectRef obj...
Definition SmartObjectRef.h:90
Ocean::SmartObjectRef< FrameRecorder, Recorder > FrameRecorderRef
Definition of a object reference holding a frame recorder.
Definition FrameRecorder.h:31
The namespace covering the entire Ocean framework.
Definition Accessor.h:15