|
|
|
@ -127,6 +127,18 @@ bool servaMySQLDBC::cleanWebCmd(){ |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
bool servaMySQLDBC::deleteSession(uint64_t id ){ |
|
|
|
if( m_bIsConnected ){ |
|
|
|
char tQBuf[MAX_PATH_LEN]; |
|
|
|
sprintf( tQBuf, "DELETE FROM `sessions` WHERE `id`=%"PRIu64, id ); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
m_pDatabase->SilentQuery( tQBuf ); |
|
|
|
}; |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
char servaMySQLDBC::getMojoWM( uint64_t id ){ |
|
|
|
char RetVal = 'N'; |
|
|
|
if( m_bIsConnected ){ |
|
|
|
@ -278,7 +290,7 @@ uint64_t servaMySQLDBC::getRecentMediaId(){ |
|
|
|
if( m_bIsConnected ){ |
|
|
|
char tQBuf[MAX_PATH_LEN]; |
|
|
|
AAssoc *result; |
|
|
|
sprintf( tQBuf, "SELECT `id` FROM `media_queue` WHERE `status`=1 LIMIT 1" ); |
|
|
|
sprintf( tQBuf, "SELECT `id` FROM `media_queue` WHERE `status`=1 ORDER BY `ts` LIMIT 1" ); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
@ -417,6 +429,58 @@ DBC_RPC_MEDIA_INFO_EX *servaMySQLDBC::getRemoteMediaInfoEx( uint64_t id ){ |
|
|
|
return RetVal; |
|
|
|
}; |
|
|
|
|
|
|
|
DBC_SERVA_CONFIG *servaMySQLDBC::getServaConfig( ){ |
|
|
|
DBC_SERVA_CONFIG *RetVal = NULL; |
|
|
|
if( m_bIsConnected ){ |
|
|
|
char tQBuf[MAX_PATH_LEN]; |
|
|
|
AAssoc *result; |
|
|
|
sprintf( tQBuf, "SELECT * FROM `system_props` WHERE `id`=1" ); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
result = m_pDatabase->Query( tQBuf ); |
|
|
|
if( result!= NULL ) { |
|
|
|
if (result->size() > 0) { |
|
|
|
Assoc *cArr; |
|
|
|
Assoc::iterator it; |
|
|
|
RetVal = ( DBC_SERVA_CONFIG *) malloc(sizeof(DBC_SERVA_CONFIG)); |
|
|
|
if ( RetVal ) { |
|
|
|
memset( RetVal, 0, sizeof(DBC_SERVA_CONFIG)); |
|
|
|
cArr = result->at(0); |
|
|
|
it = cArr->find("encoder_limit"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
RetVal->encoderLimit = atoi( it->second.c_str() ); |
|
|
|
}; |
|
|
|
it = cArr->find("histo_days"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
RetVal->historyDaysLimit = atoi( it->second.c_str() ); |
|
|
|
}; |
|
|
|
it = cArr->find("histo_perc"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
RetVal->historyPreserveFreeSpacePerc = atoi( it->second.c_str() ); |
|
|
|
}; |
|
|
|
it = cArr->find("histo_megs"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
RetVal->historyPreserveFreeSpaceMB = atoi( it->second.c_str() ); |
|
|
|
}; |
|
|
|
it = cArr->find("histo_limit"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
RetVal->historyAutoDeleteLimit = atoi( it->second.c_str() ); |
|
|
|
}; |
|
|
|
//RetVal->lts = time(NULL);
|
|
|
|
//it = cArr->find("uuid");
|
|
|
|
//if( it != cArr->end() ){
|
|
|
|
// strncpy( RetVal->uuid, it->second.c_str(), 64 );
|
|
|
|
// RetVal->uuid[64] = (char)0;
|
|
|
|
//};
|
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
deleteResult( result ); |
|
|
|
}; |
|
|
|
return RetVal; |
|
|
|
}; |
|
|
|
|
|
|
|
SESSION_DATA *servaMySQLDBC::getSessionData( uint64_t id ){ |
|
|
|
SESSION_DATA *RetVal = NULL; |
|
|
|
if( m_bIsConnected ){ |
|
|
|
@ -466,6 +530,83 @@ SESSION_DATA *servaMySQLDBC::getSessionData( uint64_t id ){ |
|
|
|
return RetVal; |
|
|
|
}; |
|
|
|
|
|
|
|
uint64_t servaMySQLDBC::getSessionOlderThan( uint32_t ts, uint8_t min_lvl ){ |
|
|
|
uint64_t RetVal = 0; |
|
|
|
if( m_bIsConnected ){ |
|
|
|
char tQBuf[MAX_PATH_LEN]; |
|
|
|
AAssoc *result; |
|
|
|
sprintf( tQBuf, "SELECT `id` FROM `sessions` WHERE `ts`<=%d AND `status`<=%d AND `final`='Y' LIMIT 1", ts, min_lvl ); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
result = m_pDatabase->Query( tQBuf ); |
|
|
|
if( result!= NULL ) { |
|
|
|
if( result->size() > 0 ) { |
|
|
|
Assoc *cArr; |
|
|
|
Assoc::iterator it; |
|
|
|
cArr = result->at(0); |
|
|
|
it = cArr->find("id"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
RetVal = atoll( it->second.c_str() ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
deleteResult( result ); |
|
|
|
}; |
|
|
|
return RetVal; |
|
|
|
}; |
|
|
|
uint64_t servaMySQLDBC::getSessionOldest( uint8_t min_lvl ){ |
|
|
|
uint64_t RetVal = 0; |
|
|
|
if( m_bIsConnected ){ |
|
|
|
char tQBuf[MAX_PATH_LEN]; |
|
|
|
AAssoc *result; |
|
|
|
sprintf( tQBuf, "SELECT `id` FROM `sessions` WHERE `status`<=%d AND `final`='Y' ORDER BY `ts` LIMIT 1", min_lvl ); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
result = m_pDatabase->Query( tQBuf ); |
|
|
|
if( result!= NULL ) { |
|
|
|
if( result->size() > 0 ) { |
|
|
|
Assoc *cArr; |
|
|
|
Assoc::iterator it; |
|
|
|
cArr = result->at(0); |
|
|
|
it = cArr->find("id"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
RetVal = atoll( it->second.c_str() ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
deleteResult( result ); |
|
|
|
}; |
|
|
|
return RetVal; |
|
|
|
}; |
|
|
|
|
|
|
|
uint64_t servaMySQLDBC::getSessionTrackId( uint64_t id ){ |
|
|
|
uint64_t RetVal = 0; |
|
|
|
if( m_bIsConnected ){ |
|
|
|
char tQBuf[MAX_PATH_LEN]; |
|
|
|
AAssoc *result; |
|
|
|
sprintf( tQBuf, "SELECT `track_id` FROM `sessions` WHERE `id`=%" PRIu64, id ); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
result = m_pDatabase->Query( tQBuf ); |
|
|
|
if( result!= NULL ) { |
|
|
|
if( result->size() > 0 ) { |
|
|
|
Assoc *cArr; |
|
|
|
Assoc::iterator it; |
|
|
|
cArr = result->at(0); |
|
|
|
it = cArr->find("track_id"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
RetVal = atoll( it->second.c_str() ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
deleteResult( result ); |
|
|
|
}; |
|
|
|
return RetVal; |
|
|
|
}; |
|
|
|
|
|
|
|
uint64_t servaMySQLDBC::getTrackIdByMojo( uint64_t id ){ |
|
|
|
uint64_t RetVal = 0; |
|
|
|
if( m_bIsConnected ){ |
|
|
|
@ -518,6 +659,37 @@ uint64_t servaMySQLDBC::getUpperLRF( uint64_t id ){ |
|
|
|
return RetVal; |
|
|
|
}; |
|
|
|
|
|
|
|
DBC_UINT64_LIST *servaMySQLDBC::listMediaQueueItems( uint8_t status ){ |
|
|
|
DBC_UINT64_LIST * tVal = NULL; |
|
|
|
if( m_bIsConnected ){ |
|
|
|
char tQBuf[MAX_PATH_LEN]; |
|
|
|
AAssoc *result; |
|
|
|
sprintf( tQBuf, "SELECT `id` FROM `media_queue` WHERE `status`=%d", status ); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
result = m_pDatabase->Query( tQBuf ); |
|
|
|
if( result!= NULL ) { |
|
|
|
if( result->size() > 0 ) { |
|
|
|
Assoc *cArr; |
|
|
|
tVal = new DBC_UINT64_LIST(); |
|
|
|
if( tVal != NULL ) { |
|
|
|
Assoc::iterator it; |
|
|
|
for(int i=0;i<result->size();i++) { |
|
|
|
cArr = result->at(i); |
|
|
|
it = cArr->find("id"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
tVal->push_back( atoll( it->second.c_str() )); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
deleteResult( result ); |
|
|
|
}; |
|
|
|
return tVal; |
|
|
|
}; |
|
|
|
|
|
|
|
bool servaMySQLDBC::putIntoLog( CSTR A, CSTR B, CSTR C ){ |
|
|
|
if( m_bIsConnected ){ |
|
|
|
char tQBuf[MAX_PATH_LEN]; |
|
|
|
@ -526,7 +698,9 @@ bool servaMySQLDBC::putIntoLog( CSTR A, CSTR B, CSTR C ){ |
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
m_pDatabase->SilentQuery( tQBuf ); |
|
|
|
} else LOG("Not Connected!"); |
|
|
|
return true; |
|
|
|
}; |
|
|
|
return false; |
|
|
|
}; |
|
|
|
|
|
|
|
uint64_t servaMySQLDBC::registerMojo( CSTR A, CSTR B ){ |
|
|
|
@ -552,9 +726,10 @@ uint64_t servaMySQLDBC::registerMojo( CSTR A, CSTR B ){ |
|
|
|
}; |
|
|
|
deleteResult( result ); |
|
|
|
}; |
|
|
|
if ( RetVal ) { |
|
|
|
sprintf( tQBuf, "INSERT INTO `mem_online_cloud` SET `id` FROM `metro_modules` WHERE `IP4`='%s' AND `identity`='%s'", A, B ); |
|
|
|
}; |
|
|
|
//if ( RetVal ) {
|
|
|
|
// sprintf( tQBuf, "INSERT INTO `mem_online_cloud` SET `id` FROM `metro_modules` WHERE `IP4`='%s' AND `identity`='%s'", A, B );
|
|
|
|
// m_pDatabase->SilentQuery( tQBuf );
|
|
|
|
//};
|
|
|
|
return RetVal; |
|
|
|
}; |
|
|
|
|
|
|
|
@ -711,7 +886,7 @@ bool servaMySQLDBC::sessionClose( uint64_t session_id ){ |
|
|
|
if( m_bIsConnected ){ |
|
|
|
char tQBuf[CTEXT]; |
|
|
|
sprintf(tQBuf, "UPDATE `sessions` SET `lts`=UNIX_TIMESTAMP(now()), `final`='Y' WHERE `id`=%" PRIu64, session_id ); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
#ifdef DEBUG
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
m_pDatabase->SilentQuery(tQBuf); |
|
|
|
@ -726,7 +901,7 @@ uint64_t servaMySQLDBC::sessionCreate( uint64_t track_id, uint32_t ts, uint16_t |
|
|
|
sprintf(tQBuf, "INSERT INTO `sessions` SET `ts`=%d, `ts_ms`=%d, `lts`=UNIX_TIMESTAMP(now()), `track_id`=%" PRIu64 ", `src`='%c', `uuid`='%s'", |
|
|
|
ts, tsms, |
|
|
|
track_id, src, uuid ); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
#ifdef DEBUG
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
return m_pDatabase->QueryID(tQBuf); |
|
|
|
@ -810,7 +985,7 @@ bool servaMySQLDBC::updateModuleData( uint64_t DBID, uint32_t UPPER_ID, uint32_t |
|
|
|
if( m_bIsConnected ) { |
|
|
|
char tQBuf[MAX_PATH_LEN]; |
|
|
|
sprintf( tQBuf, "UPDATE `metro_modules` SET `cam_stream`=%d, `top_id`=%d, `bottom_id`=%d, `cam_id`=%d, `tls_version`='%s', `lls_version`='%s' WHERE `id`=%" PRIu64, CAM_STREAM_ID, UPPER_ID, BOTTOM_ID, CAM_ID, vstr, lstr, DBID ); |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
m_pDatabase->SilentQuery( tQBuf ); |
|
|
|
|