Ocean
Loading...
Searching...
No Matches
BufferImage.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_BUFFER_IMAGE_H
9#define META_OCEAN_MEDIA_BUFFER_IMAGE_H
10
11#include "ocean/media/Media.h"
13
14#include "ocean/base/Memory.h"
15
16namespace Ocean
17{
18
19namespace Media
20{
21
22// Forward declaration.
23class BufferImage;
24
25/**
26 * Definition of a smart medium reference holding a buffer image object.
27 * @see SmartMediumRef, BufferImage.
28 * @ingroup media
29 */
31
32/**
33 * This class implements a frame medium object which is defined by a given buffer and image or frame type.
34 * A buffer image can be used to define an explicit frame without loading the content from e.g. a file but from a given memory buffer.
35 * @ingroup media
36 */
37class OCEAN_MEDIA_EXPORT BufferImage : virtual public FrameMedium
38{
39 friend class Manager;
40
41 public:
42
43 /**
44 * Returns whether the medium is started currently.
45 * @see Medium:isStarted().
46 */
47 bool isStarted() const override;
48
49 /**
50 * Returns the start timestamp.
51 * @see Medium::startTimestmap().
52 */
53 Timestamp startTimestamp() const override;
54
55 /**
56 * Returns the pause timestamp.
57 * @see Medium::pauseTimestamp().
58 */
59 Timestamp pauseTimestamp() const override;
60
61 /**
62 * Returns the stop timestamp.
63 * @see Medium::stopTimestamp().
64 */
65 Timestamp stopTimestamp() const override;
66
67 /**
68 * Sets or changes the buffer of this image, the given memory buffer is copied and stored internally.
69 * @param buffer The buffer to be copied, must be valid
70 * @param size The size of the given memory buffer in bytes, with range [1, infinity)
71 * @param imageBufferType Type of the image that is stored in the given buffer, should be specified if known (e.g. the file extension of a corresponding image file)
72 * @return True, if succeeded
73 */
74 virtual bool setBufferImage(const void* buffer, const size_t size, const std::string& imageBufferType = std::string());
75
76 /**
77 * Returns the image buffer type.
78 * @return Type of the image buffer, if known (e.g. the file extension of a corresponding image file)
79 */
80 inline const std::string& getImageBufferType() const;
81
82 protected:
83
84 /**
85 * Creates a new buffer image by an arbitrary url defining the name of the resulting object.
86 * @param url Arbitrary name to identify this pixel image later, if necessary
87 */
88 explicit BufferImage(const std::string& url);
89
90 /**
91 * Destructs a buffer image object.
92 */
93 ~BufferImage() override = default;
94
95 protected:
96
97 /// Start timestamp.
99
100 /// Pause timestamp.
102
103 /// Stop timestamp.
105
106 /// Determining whether this image is 'started' and holds valid image data.
107 bool started_ = false;
108
109 /// The object's memory.
111
112 /// The type of the buffer image.
113 std::string bufferType_;
114};
115
116inline const std::string& BufferImage::getImageBufferType() const
117{
118 return bufferType_;
119}
120
121}
122
123}
124
125#endif // META_OCEAN_MEDIA_BUFFER_IMAGE_H
This class implements a frame medium object which is defined by a given buffer and image or frame typ...
Definition BufferImage.h:38
Timestamp pauseTimestamp_
Pause timestamp.
Definition BufferImage.h:101
Timestamp stopTimestamp_
Stop timestamp.
Definition BufferImage.h:104
Timestamp stopTimestamp() const override
Returns the stop timestamp.
bool isStarted() const override
Returns whether the medium is started currently.
Timestamp startTimestamp() const override
Returns the start timestamp.
virtual bool setBufferImage(const void *buffer, const size_t size, const std::string &imageBufferType=std::string())
Sets or changes the buffer of this image, the given memory buffer is copied and stored internally.
Timestamp pauseTimestamp() const override
Returns the pause timestamp.
BufferImage(const std::string &url)
Creates a new buffer image by an arbitrary url defining the name of the resulting object.
Memory memory_
The object's memory.
Definition BufferImage.h:110
const std::string & getImageBufferType() const
Returns the image buffer type.
Definition BufferImage.h:116
std::string bufferType_
The type of the buffer image.
Definition BufferImage.h:113
~BufferImage() override=default
Destructs a buffer image object.
Timestamp startTimestamp_
Start timestamp.
Definition BufferImage.h:98
This is the base class for all frame mediums.
Definition FrameMedium.h:53
This class is the manager for all media objects.
Definition media/Manager.h:34
This class implements a smart medium reference.
Definition MediumRef.h:33
This class implements an object able to allocate memory.
Definition base/Memory.h:22
This class implements a timestamp.
Definition Timestamp.h:36
SmartMediumRef< BufferImage > BufferImageRef
Definition of a smart medium reference holding a buffer image object.
Definition BufferImage.h:30
The namespace covering the entire Ocean framework.
Definition Accessor.h:15