#include #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.SetSize(64, 64); thread = NULL; thread = g_thread_new("Output", _OutputThread, NULL); }; Output::~Output() { running = 0; if (thread) { g_thread_join (thread); thread = NULL; } }; int Output::NewFrame(VideoFrame *newframe, int posx, int posy) { if (newframe == NULL || posx == -1 || posy == -1) return -1; // printf ("%s:%d Output::NewFrame Frame w:%d h:%d posx:%d posy:%d\n", __FILE__, __LINE__, newframe->w, newframe->h, posx, posy); LockInMutex(); inFrame.CopyFrom(newframe); 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); }