Ocean
DSFrameRecorder.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_FRAME_RECORDER_H
9 #define META_OCEAN_MEDIA_DS_FRAME_RECORDER_H
10 
14 
16 
17 namespace Ocean
18 {
19 
20 namespace Media
21 {
22 
23 namespace DirectShow
24 {
25 
26 /**
27  * This class implements a DirectShow frame recorder.
28  * @ingroup mediads
29  */
30 class OCEAN_MEDIA_DS_EXPORT DSFrameRecorder :
31  virtual public DSRecorder,
32  virtual public FrameRecorder
33 {
34  public:
35 
36  /**
37  * Returns a list of possible frame encoders for this recorder.
38  * @see FrameRecorder::frameEncoders().
39  */
40  Encoders frameEncoders() const override;
41 
42  /**
43  * Returns whether the selected frame encoder has a configuration possibility.
44  * @see FrameRecorder::frameEncoderHasConfiguration().
45  */
47 
48  /**
49  * Sets the preferred frame type of this recorder.
50  * @see FrameRecorder::setPreferredFrameType().
51  */
52  bool setPreferredFrameType(const FrameType& type) override;
53 
54  /**
55  * Sets the frame frequency of this recorder.
56  * @see FrameRecorder::setFrameFrequency().
57  */
58  bool setFrameFrequency(const double frequency) override;
59 
60  /**
61  * Sets the frame encoder used to encode the frames.
62  * @see FrameRecorder::setFrameEncoder().
63  */
64  bool setFrameEncoder(const std::string& encoder) override;
65 
66  /**
67  * Starts the frame encoder configuration possibility.
68  * @see FrameRecorder::frameEncoderConfiguration().
69  */
70  bool frameEncoderConfiguration(long long data) override;
71 
72  /**
73  * Locks the most recent frame and returns it so that the image data can be written to this frame.
74  * @see FrameRecorder::lockBufferToFill().
75  */
76  bool lockBufferToFill(Frame& recorderFrame, const bool respectFrameFrequency = true) override;
77 
78  /**
79  * Unlocks the filled buffer.
80  * @see FrameRecorder::unlockBufferToFill().
81  */
82  void unlockBufferToFill() override;
83 
84  protected:
85 
86  /**
87  * Creates a new DirectShow frame recorder.
88  */
89  DSFrameRecorder() = default;
90 
91  /**
92  * Destructs a DirectShow frame recorder.
93  */
94  ~DSFrameRecorder() override;
95 
96  /**
97  * Inserts the frame source filter.
98  * @param sourceOutputPin Resulting source filter output pin which can be used for further connections
99  * @return True, if succeeded
100  */
101  bool insertSourceFilter(ScopedIPin& sourceOutputPin);
102 
103  /**
104  * Inserts the frame encoder filter.
105  * @param outputPin Output pin which will be connected with the encoder filter input pin
106  * @param encoderOutputPin Resulting encoder output pin which can be used for further connections
107  * @return True, if succeeded
108  */
109  bool insertFrameEncoderFilter(IPin* outputPin, ScopedIPin& encoderOutputPin);
110 
111  /**
112  * Releases the frame source filter.
113  */
115 
116  /**
117  * Releases the frame encoder filter.
118  */
120 
121  protected:
122 
123  /// DirectShow frame encoder filter.
125 
126  /// DirectShow sample source filter.
128 };
129 
130 }
131 
132 }
133 
134 }
135 
136 #endif // META_OCEAN_MEDIA_DS_FRAME_RECORDER_H
This class implements Ocean's image class.
Definition: Frame.h:1792
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition: Frame.h:30
This class implements a DirectShow frame recorder.
Definition: DSFrameRecorder.h:33
bool frameEncoderHasConfiguration() override
Returns whether the selected frame encoder has a configuration possibility.
void releaseFrameSourceFilter()
Releases the frame source filter.
bool setFrameEncoder(const std::string &encoder) override
Sets the frame encoder used to encode the frames.
void unlockBufferToFill() override
Unlocks the filled buffer.
void releaseFrameEncoderFilter()
Releases the frame encoder filter.
bool insertSourceFilter(ScopedIPin &sourceOutputPin)
Inserts the frame source filter.
Encoders frameEncoders() const override
Returns a list of possible frame encoders for this recorder.
~DSFrameRecorder() override
Destructs a DirectShow frame recorder.
bool frameEncoderConfiguration(long long data) override
Starts the frame encoder configuration possibility.
DSFrameRecorder()=default
Creates a new DirectShow frame recorder.
bool setPreferredFrameType(const FrameType &type) override
Sets the preferred frame type of this recorder.
ScopedIBaseFilter frameEncoderFilter_
DirectShow frame encoder filter.
Definition: DSFrameRecorder.h:124
bool lockBufferToFill(Frame &recorderFrame, const bool respectFrameFrequency=true) override
Locks the most recent frame and returns it so that the image data can be written to this frame.
bool insertFrameEncoderFilter(IPin *outputPin, ScopedIPin &encoderOutputPin)
Inserts the frame encoder filter.
ScopedDSSampleSourceFilter sampleSourceFilter_
DirectShow sample source filter.
Definition: DSFrameRecorder.h:127
bool setFrameFrequency(const double frequency) override
Sets the frame frequency of this recorder.
This class is the base class for all DirectShow recorders.
Definition: DSRecorder.h:32
This class is the base class for all frame recorders.
Definition: FrameRecorder.h:38
std::vector< std::string > Encoders
Definition of a vector holding encoder names.
Definition: Recorder.h:80
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