Skip to content

Commit

Permalink
Merge branch 'master' into devel/2019-render
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-kendall committed May 21, 2019
2 parents 46d9414 + af05a71 commit 543e645
Show file tree
Hide file tree
Showing 37 changed files with 1,072 additions and 177 deletions.
21 changes: 20 additions & 1 deletion mythplugins/configure
Expand Up @@ -645,7 +645,11 @@ if ! check_lib libexif/exif-data.h exif_loader_new -lexif ; then
fi

if enabled game; then
if ! check_lib minizip/unzip.h unzGetCurrentFileInfo -lminizip ; then
if check_lib unzip.h unzGetCurrentFileInfo -lminizip ; then
MINIZIP_PREFIX=
elif check_lib minizip/unzip.h unzGetCurrentFileInfo -lminizip ; then
MINIZIP_PREFIX="minizip/"
else
echo 'minizip required to compile mythgame'
disable game
fi
Expand Down Expand Up @@ -941,6 +945,21 @@ if enabled gallery ; then
fi
fi

###########################################################
# #
# MythGame related configuration options #
# #
###########################################################

if enabled game ; then

echo "/*" > ./mythgame/mythgame/config.h
echo " Automatically generated by configure - do not modify" >> ./mythgame/mythgame/config.h
echo "*/" >> ./mythgame/mythgame/config.h
echo "#define MINIZIP_UNZIP_H \"${MINIZIP_PREFIX}unzip.h\"" >> ./mythgame/mythgame/config.h

fi

###########################################################
# #
# MythMusic related configuration options #
Expand Down
4 changes: 3 additions & 1 deletion mythplugins/mythgame/mythgame/rom_metadata.cpp
@@ -1,10 +1,12 @@
#include "config.h"
#include "rom_metadata.h"

#include <QFile>

#include <mythcontext.h>

#include <minizip/unzip.h>
#include "zlib.h"
#include MINIZIP_UNZIP_H
#undef Z_NULL
#define Z_NULL nullptr

Expand Down
62 changes: 51 additions & 11 deletions mythplugins/mythzoneminder/mythzmserver/main.cpp
Expand Up @@ -33,8 +33,11 @@
// default port to listen on
#define PORT 6548

// default location of zoneminders config file
#define ZM_CONFIG "/etc/zm.conf"
// default location of zoneminders default config file
#define ZM_CONFIG "/etc/zm/zm.conf"

// default location of zoneminders override config file
#define ZM_OVERRIDECONFIG "/etc/zm/conf.d/01-system-paths.conf"

// Care should be taken to keep these in sync with the exit codes in
// libmythbase/exitcodes.h (which is not included here to keep this code
Expand Down Expand Up @@ -69,7 +72,8 @@ int main(int argc, char **argv)
bool daemon_mode = false; // is daemon mode enabled
int port = PORT; // port we're listening on
string logfile; // log file
string zmconfig = ZM_CONFIG; // location of zoneminders config file
string zmconfig = ZM_CONFIG; // location of zoneminders default config file
string zmoverideconfig = ZM_OVERRIDECONFIG; // location of zoneminders override config file

// Check command line arguments
for (int argpos = 1; argpos < argc; ++argpos)
Expand Down Expand Up @@ -144,6 +148,26 @@ int main(int argc, char **argv)
return EXIT_INVALID_CMDLINE;
}
}
else if (strcmp(argv[argpos],"-o") == 0 ||
strcmp(argv[argpos],"--zmoverrideconfig") == 0)
{
if (argc > argpos)
{
zmconfig = argv[argpos+1];
if (zmconfig[0] == '-')
{
cerr << "Invalid or missing argument to -o/--zmoverrideconfig option\n";
return EXIT_INVALID_CMDLINE;
}

++argpos;
}
else
{
cerr << "Missing argument to -o/--zmoverrideconfig option\n";
return EXIT_INVALID_CMDLINE;
}
}
else if (strcmp(argv[argpos],"-v") == 0 ||
strcmp(argv[argpos],"--verbose") == 0)
{
Expand All @@ -156,7 +180,8 @@ int main(int argc, char **argv)
"-p or --port number A port number to listen on (default is 6548) " << endl <<
"-d or --daemon Runs mythzmserver as a daemon " << endl <<
"-n or --nodaemon Does not run mythzmserver as a daemon (default)" << endl <<
"-c or --zmconfig Location of zoneminders config file (default is " << ZM_CONFIG << ")" << endl <<
"-c or --zmconfig Location of zoneminders default config file (default is " << ZM_CONFIG << ")" << endl <<
"-o or --zmoverrideconfig Location of zoneminders override config file (default is " << ZM_OVERRIDECONFIG << ")" << endl <<
"-l or --logfile filename Writes STDERR and STDOUT messages to filename" << endl <<
"-v or --verbose Prints more debug output" << endl;
return EXIT_INVALID_CMDLINE;
Expand Down Expand Up @@ -204,19 +229,34 @@ int main(int argc, char **argv)

map<int, ZMServer*> serverList; // list of ZMServers

// load the config
// load the default config
loadZMConfig(zmconfig);

// we support version 1.24.0 or later
sscanf(g_zmversion.c_str(), "%10d.%10d.%10d", &g_majorVersion, &g_minorVersion, &g_revisionVersion);
if (checkVersion(1, 24, 0))
// load the override config
loadZMConfig(zmoverideconfig);

// check we have a version (default to 1.32.3 if not found)
if (g_zmversion.length() == 0)
{
cout << "ZM is version '" << g_zmversion << "'" << endl;
cout << "ZM version not found. Assuming at least v1.32.0 is installed" << endl;
g_majorVersion = 1;
g_minorVersion = 32;
g_revisionVersion = 3;
}
else
{
cout << "This version of ZM is to old you need 1.24.0 or later '" << g_zmversion << "'" << endl;
return EXIT_VERSION_ERROR;
sscanf(g_zmversion.c_str(), "%10d.%10d.%10d", &g_majorVersion, &g_minorVersion, &g_revisionVersion);

// we support version 1.24.0 or later
if (checkVersion(1, 24, 0))
{
cout << "ZM is version '" << g_zmversion << "'" << endl;
}
else
{
cout << "This version of ZM is to old you need 1.24.0 or later '" << g_zmversion << "'" << endl;
return EXIT_VERSION_ERROR;
}
}

// connect to the DB
Expand Down
106 changes: 91 additions & 15 deletions mythplugins/mythzoneminder/mythzmserver/zmserver.cpp
Expand Up @@ -87,6 +87,8 @@ string g_webPath;
string g_user;
string g_webUser;
string g_binPath;
string g_mmapPath;
string g_eventsPath;
int g_majorVersion = 0;
int g_minorVersion = 0;
int g_revisionVersion = 0;
Expand All @@ -110,8 +112,7 @@ void loadZMConfig(const string &configfile)

if ( (cfg = fopen(configfile.c_str(), "r")) == nullptr )
{
fprintf(stderr,"Can't open %s\n", configfile.c_str());
exit(1);
fprintf(stderr, "Can't open %s\n", configfile.c_str());
}

while ( fgets( line, sizeof(line), cfg ) != nullptr )
Expand Down Expand Up @@ -170,6 +171,8 @@ void loadZMConfig(const string &configfile)
else if ( strcasecmp( name_ptr, "ZM_PATH_BIN" ) == 0 ) g_binPath = val;
else if ( strcasecmp( name_ptr, "ZM_WEB_USER" ) == 0 ) g_webUser = val;
else if ( strcasecmp( name_ptr, "ZM_VERSION" ) == 0 ) g_zmversion = val;
else if ( strcasecmp( name_ptr, "ZM_PATH_MAP" ) == 0 ) g_mmapPath = val;
else if ( strcasecmp( name_ptr, "ZM_DIR_EVENTS" ) == 0 ) g_eventsPath = val;
}
fclose(cfg);
}
Expand Down Expand Up @@ -231,7 +234,14 @@ void MONITOR::initMonitor(bool debug, const string &mmapPath, int shmKey)
int shared_data_size;
int frame_size = m_width * m_height * m_bytes_per_pixel;

if (checkVersion(1, 26, 0))
if (checkVersion(1, 32, 0))
{
shared_data_size = sizeof(SharedData32) +
sizeof(TriggerData26) +
((m_image_buffer_count) * (sizeof(struct timeval))) +
((m_image_buffer_count) * frame_size) + 64;
}
else if (checkVersion(1, 26, 0))
{
shared_data_size = sizeof(SharedData26) +
sizeof(TriggerData26) +
Expand Down Expand Up @@ -297,7 +307,7 @@ void MONITOR::initMonitor(bool debug, const string &mmapPath, int shmKey)
// fail back to shmget() functionality if mapping memory above failed.
int shmid;

if ((shmid = shmget((shmKey & 0xffffff00) | m_mon_id,
if ((shmid = shmget((shmKey & 0xffff0000) | m_mon_id,
shared_data_size, SHM_R)) == -1)
{
cout << "Failed to shmget for monitor: " << m_mon_id << endl;
Expand Down Expand Up @@ -327,10 +337,27 @@ void MONITOR::initMonitor(bool debug, const string &mmapPath, int shmKey)
}
}

if (checkVersion(1, 26, 0))
if (checkVersion(1, 32, 0))
{
m_shared_data = nullptr;
m_shared_data26 = nullptr;
m_shared_data32 = (SharedData32*)m_shm_ptr;

m_shared_images = (unsigned char*) m_shm_ptr +
sizeof(SharedData32) + sizeof(TriggerData26) + sizeof(VideoStoreData) +
((m_image_buffer_count) * sizeof(struct timeval)) ;

if (((unsigned long)m_shared_images % 64) != 0)
{
// align images buffer to nearest 64 byte boundary
m_shared_images = (unsigned char*)((unsigned long)m_shared_images + (64 - ((unsigned long)m_shared_images % 64)));
}
}
else if (checkVersion(1, 26, 0))
{
m_shared_data = nullptr;
m_shared_data26 = (SharedData26*)m_shm_ptr;
m_shared_data32 = nullptr;

m_shared_images = (unsigned char*) m_shm_ptr +
sizeof(SharedData26) + sizeof(TriggerData26) +
Expand All @@ -344,8 +371,9 @@ void MONITOR::initMonitor(bool debug, const string &mmapPath, int shmKey)
}
else
{
m_shared_data26 = nullptr;
m_shared_data = (SharedData*)m_shm_ptr;
m_shared_data26 = nullptr;
m_shared_data32 = nullptr;

m_shared_images = (unsigned char*) m_shm_ptr +
sizeof(SharedData) + sizeof(TriggerData) +
Expand All @@ -355,6 +383,9 @@ void MONITOR::initMonitor(bool debug, const string &mmapPath, int shmKey)

bool MONITOR::isValid(void)
{
if (checkVersion(1, 32, 0))
return m_shared_data32 != nullptr && m_shared_images != nullptr;

if (checkVersion(1, 26, 0))
return m_shared_data26 != nullptr && m_shared_images != nullptr;

Expand Down Expand Up @@ -382,6 +413,9 @@ int MONITOR::getLastWriteIndex(void)
if (m_shared_data26)
return m_shared_data26->last_write_index;

if (m_shared_data32)
return m_shared_data32->last_write_index;

return 0;
}

Expand All @@ -393,6 +427,9 @@ int MONITOR::getState(void)
if (m_shared_data26)
return m_shared_data26->state;

if (m_shared_data32)
return m_shared_data32->state;

return 0;
}

Expand All @@ -408,6 +445,9 @@ int MONITOR::getSubpixelOrder(void)
if (m_shared_data26)
return m_shared_data26->format;

if (m_shared_data32)
return m_shared_data32->format;

return ZM_SUBPIX_ORDER_NONE;
}

Expand All @@ -419,6 +459,9 @@ int MONITOR::getFrameSize(void)
if (m_shared_data26)
return m_shared_data26->imagesize;

if (m_shared_data32)
return m_shared_data32->imagesize;

return 0;
}

Expand Down Expand Up @@ -451,7 +494,11 @@ ZMServer::ZMServer(int sock, bool debug)
}

// get the MMAP path
m_mmapPath = getZMSetting("ZM_PATH_MAP");
if (checkVersion(1, 32, 0))
m_mmapPath = g_mmapPath;
else
m_mmapPath = getZMSetting("ZM_PATH_MAP");

if (m_debug)
{
cout << "Memory path directory is: " << m_mmapPath << endl;
Expand Down Expand Up @@ -1092,17 +1139,33 @@ void ZMServer::handleGetEventFrame(vector<string> tokens)
string filepath;
char str[100];

if (m_useDeepStorage)
if (checkVersion(1, 32, 0))
{
filepath = g_webPath + "/events/" + monitorID + "/" + eventTime + "/";
int year;
int month;
int day;

sscanf(eventTime.c_str(), "%2d/%2d/%2d", &year, &month, &day);
sprintf(str, "20%02d-%02d-%02d", year, month, day);

filepath = g_eventsPath + "/" + monitorID + "/" + str + "/" + eventID + "/";
sprintf(str, m_eventFileFormat.c_str(), frameNo);
filepath += str;
}
else
{
filepath = g_webPath + "/events/" + monitorID + "/" + eventID + "/";
sprintf(str, m_eventFileFormat.c_str(), frameNo);
filepath += str;
if (m_useDeepStorage)
{
filepath = g_webPath + "/events/" + monitorID + "/" + eventTime + "/";
sprintf(str, m_eventFileFormat.c_str(), frameNo);
filepath += str;
}
else
{
filepath = g_webPath + "/events/" + monitorID + "/" + eventID + "/";
sprintf(str, m_eventFileFormat.c_str(), frameNo);
filepath += str;
}
}

FILE *fd;
Expand Down Expand Up @@ -1226,10 +1289,23 @@ void ZMServer::handleGetAnalysisFrame(vector<string> tokens)
string filepath;
string frameFile;

if (m_useDeepStorage)
filepath = g_webPath + "/events/" + monitorID + "/" + eventTime + "/";
if (checkVersion(1, 32, 0))
{
int year;
int month;
int day;

sscanf(eventTime.c_str(), "%2d/%2d/%2d", &year, &month, &day);
sprintf(str, "20%02d-%02d-%02d", year, month, day);
filepath = g_eventsPath + "/" + monitorID + "/" + str + "/" + eventID + "/";
}
else
filepath = g_webPath + "/events/" + monitorID + "/" + eventID + "/";
{
if (m_useDeepStorage)
filepath = g_webPath + "/events/" + monitorID + "/" + eventTime + "/";
else
filepath = g_webPath + "/events/" + monitorID + "/" + eventID + "/";
}

ADD_STR(outStr, "OK")

Expand Down

0 comments on commit 543e645

Please sign in to comment.