Ocean
IIOBufferImageRecorder.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_IMAGEIO_IIO_BUFFER_IMAGE_RECORDER_H
9 #define META_OCEAN_MEDIA_IMAGEIO_IIO_BUFFER_IMAGE_RECORDER_H
10 
13 
15 
16 namespace Ocean
17 {
18 
19 namespace Media
20 {
21 
22 namespace ImageIO
23 {
24 
25 /**
26  * This class implements a buffer image recorder for ImageIO.
27  * This recorder can be used to save images to files.
28  * @ingroup mediaiio
29  */
30 class OCEAN_MEDIA_IIO_EXPORT IIOBufferImageRecorder :
31  virtual public IIOObject,
32  virtual public BufferImageRecorder
33 {
34  friend class IIOLibrary;
35 
36  public:
37 
38  /**
39  * Saves a given frame as file explicity.
40  * @see BufferRecorder::saveImage().
41  */
42  bool saveImage(const Frame& frame, const std::string& imageType, std::vector<uint8_t>& buffer) override;
43 
44  /**
45  * Returns the buffer of the most recently saved image.
46  * @see BufferRecorder::buffer().
47  */
48  bool buffer(std::vector<uint8_t>& data) const override;
49 
50  /**
51  * Returns a list of possible frame encoders for this recorder.
52  * @see FrameRecorder::frameEncoders().
53  */
54  Encoders frameEncoders() const override;
55 
56  /**
57  * Returns a pointer to a framebuffer to be sfilled if a image save task has been asked before.
58  * @see BufferImageRecorder::lockBufferToFill().
59  */
60  bool lockBufferToFill(Frame& recorderFrame, const bool respectFrameFrequency = true) override;
61 
62  /**
63  * Unlocks the filled buffer.
64  * @see BufferImageRecorder::unlockBufferToFill().
65  */
66  void unlockBufferToFill() override;
67 
68  protected:
69 
70  /**
71  * Creates a new buffer image recorder object.
72  */
74 
75  /**
76  * Destructs a buffer image recorder object.
77  */
79 
80  protected:
81 
82  /// Image buffer if the image is not saved explicitly but by a buffer request.
84 
85  /// Internal image buffer if the image is not saved explicitly but by a buffer request.
86  std::vector<uint8_t> recorderBuffer;
87 };
88 
89 }
90 
91 }
92 
93 }
94 
95 #endif // META_OCEAN_MEDIA_IMAGEIO_IIO_BUFFER_IMAGE_RECORDER_H
This class implements Ocean's image class.
Definition: Frame.h:1792
This class is the base class for all buffer recorders.
Definition: BufferImageRecorder.h:45
This class implements a buffer image recorder for ImageIO.
Definition: IIOBufferImageRecorder.h:33
Frame recorderFrame_
Image buffer if the image is not saved explicitly but by a buffer request.
Definition: IIOBufferImageRecorder.h:83
std::vector< uint8_t > recorderBuffer
Internal image buffer if the image is not saved explicitly but by a buffer request.
Definition: IIOBufferImageRecorder.h:86
Encoders frameEncoders() const override
Returns a list of possible frame encoders for this recorder.
IIOBufferImageRecorder()
Creates a new buffer image recorder object.
bool lockBufferToFill(Frame &recorderFrame, const bool respectFrameFrequency=true) override
Returns a pointer to a framebuffer to be sfilled if a image save task has been asked before.
void unlockBufferToFill() override
Unlocks the filled buffer.
bool saveImage(const Frame &frame, const std::string &imageType, std::vector< uint8_t > &buffer) override
Saves a given frame as file explicity.
~IIOBufferImageRecorder() override
Destructs a buffer image recorder object.
bool buffer(std::vector< uint8_t > &data) const override
Returns the buffer of the most recently saved image.
This class implements the ImageIO library.
Definition: IIOLibrary.h:30
This class is the base class for all object inside this library.
Definition: IIOObject.h:35
std::vector< std::string > Encoders
Definition of a vector holding encoder names.
Definition: Recorder.h:80
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15