|
|
|
@ -298,12 +298,12 @@ bool sqliteDBC::updateLocalCam( uint32_t CamID ){ |
|
|
|
if(m_bIsConnected) { |
|
|
|
char tQBuf[MAX_PATH_LEN]; |
|
|
|
sprintf(tQBuf,"UPDATE cameras SET `online`=1 WHERE `id`=%d", CamID ); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
#ifdef DEBUG
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
m_pDataStorage->SilentQuery( tQBuf ); |
|
|
|
sprintf(tQBuf,"UPDATE `media_streams` SET `valid`=1 WHERE `source_id`=%d", CamID ); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
#ifdef DEBUG
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
m_pDataStorage->SilentQuery( tQBuf ); |
|
|
|
@ -662,6 +662,77 @@ uint32_t sqliteDBC::addResource( uint8_t type, CSTR devName, uint32_t auxID ){ |
|
|
|
return RetVal; |
|
|
|
}; |
|
|
|
|
|
|
|
DBC_MEDIA_STREAM_DATA *sqliteDBC::getMediaStreamData(uint32_t ID){ |
|
|
|
DBC_MEDIA_STREAM_DATA *tVal = NULL; |
|
|
|
if(m_bIsConnected){ |
|
|
|
char tQBuf[CTEXT]; |
|
|
|
AAssoc *result; |
|
|
|
sprintf(tQBuf, "SELECT * FROM media_streams WHERE `id`=%d", ID ); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
result = m_pDataStorage->Query( tQBuf ); |
|
|
|
if( result!= NULL ) { |
|
|
|
if( result->size() > 0 ) { |
|
|
|
Assoc *cArr; |
|
|
|
tVal = (DBC_MEDIA_STREAM_DATA*) malloc(sizeof(DBC_MEDIA_STREAM_DATA)); |
|
|
|
if( tVal != NULL ) { |
|
|
|
memset( tVal, 0, sizeof(DBC_MEDIA_STREAM_DATA) ); |
|
|
|
Assoc::iterator it; |
|
|
|
cArr = result->at(0); |
|
|
|
tVal->id = ID; |
|
|
|
it = cArr->find("source_id"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
tVal->source_id = atoi( it->second.c_str() ); |
|
|
|
}; |
|
|
|
it = cArr->find("source_type"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
sprintf( tVal->source_type, it->second.c_str() ); |
|
|
|
}; |
|
|
|
it = cArr->find("valid"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
tVal->valid = (bool) atoi( it->second.c_str() ); |
|
|
|
}; |
|
|
|
it = cArr->find("token"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
sprintf( tVal->token, it->second.c_str() ); |
|
|
|
}; |
|
|
|
it = cArr->find("img_width"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
tVal->width = atoi( it->second.c_str() ); |
|
|
|
}; |
|
|
|
it = cArr->find("img_height"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
tVal->height = atoi( it->second.c_str() ); |
|
|
|
}; |
|
|
|
it = cArr->find("fps"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
tVal->fps = atoi( it->second.c_str() ); |
|
|
|
}; |
|
|
|
it = cArr->find("compression_type"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
sprintf(tVal->c_type, it->second.c_str()); |
|
|
|
}; |
|
|
|
it = cArr->find("mrl_proto"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
sprintf( tVal->mrl_proto, it->second.c_str() ); |
|
|
|
}; |
|
|
|
it = cArr->find("mrl_port"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
tVal->mrl_port = atoi( it->second.c_str() ); |
|
|
|
}; |
|
|
|
it = cArr->find("mrl"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
sprintf( tVal->mrl, it->second.c_str() ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
deleteResult( result ); |
|
|
|
}; |
|
|
|
return tVal; |
|
|
|
}; |
|
|
|
|
|
|
|
uint32_t sqliteDBC::getMediaStreamID( uint32_t source_id, CSTR token ){ |
|
|
|
uint32_t RetVal = 0; |
|
|
|
if(m_bIsConnected){ |
|
|
|
@ -1094,6 +1165,82 @@ DBC_INT_LIST *sqliteDBC::listNewModules( DBC_INT_LIST * old_ids ){ |
|
|
|
return tVal; |
|
|
|
}; |
|
|
|
|
|
|
|
DBC_INT_LIST *sqliteDBC::listNewNodes( DBC_INT_LIST * old_ids ){ |
|
|
|
DBC_INT_LIST * tVal = NULL; |
|
|
|
char tParam[CTEXT]; |
|
|
|
//memset( tParam, 0, CTEXT );
|
|
|
|
sprintf(tParam,"0"); |
|
|
|
if( old_ids != NULL ) { |
|
|
|
char tBuffer[CTEXT]; |
|
|
|
for(int i = 0; i< old_ids->size(); i++ ) { |
|
|
|
sprintf( tBuffer, "%s,%d", tParam, old_ids->at(i) ); |
|
|
|
strncpy( tParam, tBuffer, CTEXT ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
if( m_bIsConnected ){ |
|
|
|
char tQBuf[CTEXT]; |
|
|
|
AAssoc *result; |
|
|
|
sprintf(tQBuf, "SELECT id FROM nodes WHERE `type` > 0 AND `id` NOT IN(%s)", tParam ); |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
result = m_pDataStorage->Query( tQBuf ); |
|
|
|
if( result!= NULL ) { |
|
|
|
if( result->size() > 0 ) { |
|
|
|
Assoc *cArr; |
|
|
|
tVal = new DBC_INT_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( atoi( it->second.c_str() )); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
deleteResult( result ); |
|
|
|
}; |
|
|
|
return tVal; |
|
|
|
}; |
|
|
|
|
|
|
|
DBC_INT_LIST *sqliteDBC::listNodes( bool all ){ |
|
|
|
DBC_INT_LIST * tVal = NULL; |
|
|
|
if( m_bIsConnected ){ |
|
|
|
char tQBuf[1024]; |
|
|
|
AAssoc *result; |
|
|
|
if( all ) { |
|
|
|
sprintf(tQBuf, "SELECT `id` FROM `nodes`"); |
|
|
|
} else { |
|
|
|
sprintf(tQBuf, "SELECT `id` FROM `nodes` WHERE `type` > 0" ); |
|
|
|
}; |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
result = m_pDataStorage->Query( tQBuf ); |
|
|
|
if( result!= NULL ) { |
|
|
|
if( result->size() > 0 ) { |
|
|
|
Assoc *cArr; |
|
|
|
tVal = new DBC_INT_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( atoi( it->second.c_str() )); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
deleteResult( result ); |
|
|
|
}; |
|
|
|
return tVal; |
|
|
|
}; |
|
|
|
|
|
|
|
DBC_INT_LIST *sqliteDBC::listResources( uint32_t NodeID ){ |
|
|
|
DBC_INT_LIST * tVal = NULL; |
|
|
|
if(m_bIsConnected){ |
|
|
|
@ -1238,7 +1385,7 @@ bool sqliteDBC::setStreamValid( uint32_t streamID, bool status ){ |
|
|
|
} else { |
|
|
|
sprintf(tQBuf, "UPDATE `media_streams` SET `valid`=0 WHERE `id`=%d", streamID); |
|
|
|
}; |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
#ifdef DEBUG
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
m_pDataStorage->SilentQuery( tQBuf ); |
|
|
|
|