You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SimpleSkyCam/output.cc

95 lines
1.7 KiB

#include <unistd.h>
#include "convert.h"
#include "config.h"
#include "gui.h"
#include "output.h"
extern Output output;
//
// C / C++ Wrapper for the thread function
//
gpointer _OutputThread (gpointer data) {
output.Thread ();
return NULL;
};
Output::Output() { // @suppress("Class members should be properly initialized")
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
g_mutex_init (&mutexin);
g_mutex_init (&muteximage);
g_mutex_init (&mutextmp);
g_mutex_init (&mutex);
running = 1;
inFrame.Delete();
thread = NULL;
thread = g_thread_new("Output", _OutputThread, NULL);
};
Output::~Output() {
running = 0;
if (thread) {
g_thread_join (thread);
thread = NULL;
}
};
int Output::NewFrame(VideoFrameRaw *rawframe) {
if (rawframe == NULL) return -1;
printf ("%s:%d Output::NewFrame Frame Raw: %d x %d Type: %s\n", __FILE__, __LINE__, rawframe->w, rawframe->h, convert_from_pixelformat(rawframe->pixfmt).c_str());
LockInMutex();
inFrame.CopyFrom(rawframe);
inFrameNew = 1;
UnLockInMutex();
return 0;
};
void Output::NewImage() {
// newimage = 1;
}
//
// NewFrame: will set new frame
// Thread: newFrame |------> Find Object --- not found ---> send gui information
void Output::Thread() {
while (running) {
// check for new frame
LockInMutex();
if (inFrameNew == 1) {
inFrameNew = 0;
//
// do some other stuff use if possible only the oldFrame data
ComposeOutput();
UnLockInMutex();
// copy output image for gtk
}
else
UnLockInMutex();
usleep (10000); // sleep 10ms
}
}
void Output::ComposeOutput() {
// printf ("%s:%d inFrame (w:%d h:%d)\n", __FILE__, __LINE__, inFrame.w, inFrame.h);
}