Skip to content

Commit 2ed4930

Browse files
authored
Refactor ImageProvider (#52)
- Less static methods - Use object-oriented capabilities more - Use more C++ goodies Signed-off-by: Joakim Roubert <[email protected]>
1 parent 4b0be26 commit 2ed4930

File tree

4 files changed

+239
-338
lines changed

4 files changed

+239
-338
lines changed

include/ImageProvider.hpp

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,43 +42,36 @@
4242
class ImageProvider
4343
{
4444
public:
45-
ImageProvider(const unsigned int w, const unsigned int h, const unsigned int numFrames, const VdoFormat format);
46-
~ImageProvider();
47-
bool InitImageProvider();
4845
static bool ChooseStreamResolution(
49-
const unsigned int reqWidth,
50-
const unsigned int reqHeight,
51-
unsigned int &chosenWidth,
52-
unsigned int &chosenHeight);
53-
static bool CreateStream(ImageProvider &provider);
54-
static bool AllocateVdoBuffers(ImageProvider &provider, VdoStream &vdoStream);
55-
static void ReleaseVdoBuffers(ImageProvider &provider);
56-
static VdoBuffer *GetLastFrameBlocking(ImageProvider &provider);
57-
static void ReturnFrame(ImageProvider &provider, VdoBuffer &buffer);
58-
static void *threadEntry(void *data);
46+
const unsigned int req_width,
47+
const unsigned int req_height,
48+
unsigned int &chosen_width,
49+
unsigned int &chosen_height);
5950
static bool StartFrameFetch(ImageProvider &provider);
6051
static bool StopFrameFetch(ImageProvider &provider);
52+
static void *threadEntry(void *data);
53+
54+
ImageProvider(
55+
const unsigned int width,
56+
const unsigned int height,
57+
const unsigned int num_frames,
58+
const VdoFormat format);
59+
~ImageProvider();
60+
VdoBuffer *GetLastFrameBlocking();
61+
void ReturnFrame(VdoBuffer &buffer);
62+
63+
private:
64+
bool AllocateVdoBuffers();
65+
void ReleaseVdoBuffers();
66+
void RunLoopIteration();
6167

62-
// Keeping track of frames' statuses.
6368
GQueue *delivered_frames_;
6469
GQueue *processed_frames_;
65-
66-
// To support fetching frames asynchonously with VDO.
67-
pthread_mutex_t frame_mutex_;
6870
pthread_cond_t frame_deliver_cond_;
71+
pthread_mutex_t frame_mutex_;
6972
pthread_t fetcher_thread_;
7073
std::atomic_bool shutdown_;
71-
72-
private:
73-
void RunLoopIteration();
74-
bool initialized_;
75-
unsigned int width_;
76-
unsigned int height_;
77-
// Number of frames to keep in the delivered_frames queue.
78-
unsigned int num_app_frames_;
79-
// Stream configuration parameters.
80-
VdoFormat vdo_format_;
81-
// Vdo stream and buffers handling.
82-
VdoStream *vdo_stream_;
74+
unsigned int num_frames_;
8375
VdoBuffer *vdo_buffers_[NUM_VDO_BUFFERS];
76+
VdoStream *vdo_stream_;
8477
};

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"embeddedSdkVersion": "3.0",
99
"vendorUrl": "https://www.axis.com/",
1010
"runMode": "respawn",
11-
"version": "2.0.7"
11+
"version": "2.0.8"
1212
},
1313
"configuration": {
1414
"settingPage": "settings.html",

0 commit comments

Comments
 (0)