Browse Source

SCADA TCC functionality + OnVif fixes

pull/7/head
Evgeny Gagua 2 months ago
parent
commit
a1cafbe14f
  1. 2
      Projects/la_mojo/build
  2. 3
      lib/App/common/serverDataBinder.h
  3. 9
      lib/App/common/serverMySQL_dataBinder.cpp
  4. 14
      lib/App/common/streamHandler.cpp
  5. 287
      lib/App/serva/servaModBusManager.cpp
  6. 85
      lib/App/serva/servaSessionManager.cpp
  7. 20
      lib/data/media/video/videoAVLIBSource.cpp
  8. 172
      lib/data/ponvif/ponvif.cpp
  9. 2
      lib/data/ponvif/ponvif.h

2
Projects/la_mojo/build

@ -7,7 +7,7 @@
#make clean -e "CFG=LRF_Proxy_ONLY"
#make -e "CFG=LRF_Proxy_ONLY" -j$(nproc)
#make clean -e "CFG=Debug86"
make clean -e "CFG=Debug86"
make -e "CFG=Debug86" -j$(nproc)
#cd Debug86
#strip ./mojo_d

3
lib/App/common/serverDataBinder.h

@ -71,7 +71,7 @@ typedef struct S_SESSION_DATA
uint32_t sts;
uint32_t sms;
uint32_t lts;
uint8_t src;
char src;
char final;
bool skeep_validation;
char reportVaultPath[MAX_PATH];
@ -104,6 +104,7 @@ typedef struct S_MODBUS_RTU_INFO
uint8_t c_OutBits;
uint8_t status;
uint64_t ts;
uint8_t func;
} MODBUS_RTU_INFO;
typedef struct S_SCADA_TRACK_INFO

9
lib/App/common/serverMySQL_dataBinder.cpp

@ -431,6 +431,11 @@ MODBUS_RTU_INFO * servaMySQLDBC::getModBusRTU(uint64_t id)
RetVal->crossbar[3] = bb & 0x0F;
RetVal->crossbar[7] = ( bb & 0xF0 ) >> 4;
};
it = cArr->find("func");
if (it != cArr->end())
{
RetVal->func= atoi(it->second.c_str());
};
};
};
deleteResult(result);
@ -987,6 +992,10 @@ SESSION_DATA * servaMySQLDBC::getSessionData(uint64_t id)
if( it != cArr->end() ){
RetVal->lts = atoi( it->second.c_str() );
};
it = cArr->find("src");
if( it != cArr->end() ){
RetVal->src = it->second.c_str()[0];
};
//RetVal->lts = time(NULL); //? Why ?
it = cArr->find("uuid");
if (it != cArr->end())

14
lib/App/common/streamHandler.cpp

@ -211,25 +211,21 @@ bool streamHandler::create(dataBinder * ptr, uint32_t stremID)
case 'A': m_pSource = (basicMediaSource *) new videoAVLIBSource(&m_sSourceDesc); break;
case 'D':
{
/*
// Check Auth mode if basic - Override and use AVLIB
// To Debug LIVE555 ONLY
if (1 || tCAM->auth_mode == 0)
{
if( tCAM->auth_mode == 0){
m_cSourceType = 'A';
m_pSource = (basicMediaSource *) new videoAVLIBSource(&m_sSourceDesc);
break;
}
else
{
} else{
m_pSource = (basicMediaSource *) new videoLIVE555Source(&m_sSourceDesc);
break;
};
*/
//m_pSource = (basicMediaSource *) new videoLIVE555Source(&m_sSourceDesc);
m_cSourceType = 'A'; // To use corect Destructor!
m_pSource = (basicMediaSource *) new videoAVLIBSource(&m_sSourceDesc);
//m_cSourceType = 'A'; // To use corect Destructor!
//m_pSource = (basicMediaSource *) new videoAVLIBSource(&m_sSourceDesc);
break;
};
};

287
lib/App/serva/servaModBusManager.cpp

@ -222,61 +222,264 @@ void servaModBusManager::m_fThreadProc( void ){
if ( ((*idx)->c_InBits & ( 1 << bi ) ) == ( 1 << bi ) ) {
//Bit is set
if ( (*idx)->crossbar[4+bi] ) { // Assigned Action For Bit
uint64_t cTID = 0;
SCADA_TRACK_INFO tData;
tData.platform_id = (*idx)->platform_id;
if ( (*idx)->crossbar[4+bi] == 1 || (*idx)->crossbar[4+bi] == 3 ) tData.side = 'U';
if ( (*idx)->crossbar[4+bi] == 2 || (*idx)->crossbar[4+bi] == 3 ) tData.side = 'B';
cTID = m_pDBC->getTrackIdByPlatform((*idx)->platform_id, tData.side );
if ( cTID ) {
SESSION_DATA *tSData = servaSessionManager::getInstance()->getActiveSessionByTrack( cTID );
if ( tSData ) {
//Rate Session
m_pDBC->updateSessionStatus( tSData->db_id, 1 );
// Create Event?? or just Disable Scada Signal
DBC_UINT64_LIST *tIDS = m_pDBC->listPlatformModBusRTU( tData.platform_id );
// check functionality
switch ( (*idx)->crossbar[4 + bi] ) {
case 1:{//Upper Track
uint64_t cTID = m_pDBC->getTrackIdByPlatform( (*idx)->platform_id, 'U' );
if ( cTID ) {
SESSION_DATA *tSData = servaSessionManager::getInstance()->getActiveSessionByTrack( cTID );
if ( tSData ) {
//Rate Session
m_pDBC->updateSessionStatus( tSData->db_id, 1 );
// Create Event?? or just Disable Scada Signal
DBC_UINT64_LIST *tIDS = m_pDBC->listPlatformModBusRTU( (*idx)->platform_id );
if ( tIDS ) {
for ( DBC_UINT64_LIST::iterator idd=tIDS->begin(); idd != tIDS->end(); idd++ ) {
MODBUS_RTU_INFO *tRTU = m_pDBC->getModBusRTU( *idd );
if ( tRTU ) {
uint8_t bON = ( 1 << tRTU->crossbar[MBUS_CROSSBAR_UPPER_TRACK] );
uint8_t bOFF = ~( 1 << tRTU->crossbar[MBUS_CROSSBAR_UPPER_TRACK] );
//Remove Scheduled Signal change
m_mProtector.lock();
for ( V_MODBUS_ACION_ITEMS::iterator idz=m_vActioItems.begin(); idz!=m_vActioItems.end(); ){
if( (*idz)->module_id == tRTU->id ) {
//check if shceduled signal is current
if( (((*idz)->value & bON ) == bON ) || (((*idz)->mask & bOFF ) == bOFF ) ){
free((*idx));
m_vActioItems.erase( idz );
} else idz++;
//break;
} else idz++;
};
m_mProtector.unlock();
//Mitigate Signal if sent
if ( (tRTU->c_OutBits & bON ) == bON ) {
tRTU->c_OutBits &= bOFF;
int rv = modbus_set_rtu( tRTU->ip, tRTU->port, tRTU->output_base_addr, tRTU->c_OutBits );
if ( rv < 0 ) {
m_pDBC->updateModBusRTU( tRTU->id, MBUS_STATUS_OFFLINE, 0, 0 );
} else {
m_pDBC->updateModBusRTU( tRTU->id, MBUS_STATUS_ONLINE, tRTU->c_InBits, tRTU->c_OutBits );
};
};
free( tRTU );
};
};
delete( tIDS );
};
free( tSData );
};
};
break;
};
case 2:{//Bottom Track
uint64_t cTID = m_pDBC->getTrackIdByPlatform( (*idx)->platform_id, 'B' );
if ( cTID ) {
SESSION_DATA *tSData = servaSessionManager::getInstance()->getActiveSessionByTrack( cTID );
if ( tSData ) {
//Rate Session
m_pDBC->updateSessionStatus( tSData->db_id, 1 );
// Create Event?? or just Disable Scada Signal
DBC_UINT64_LIST *tIDS = m_pDBC->listPlatformModBusRTU( (*idx)->platform_id );
if ( tIDS ) {
for ( DBC_UINT64_LIST::iterator idd=tIDS->begin(); idd != tIDS->end(); idd++ ) {
MODBUS_RTU_INFO *tRTU = m_pDBC->getModBusRTU( *idd );
if ( tRTU ) {
uint8_t bON = ( 1 << tRTU->crossbar[MBUS_CROSSBAR_BOTTOM_TRACK] );
uint8_t bOFF = ~( 1 << tRTU->crossbar[MBUS_CROSSBAR_BOTTOM_TRACK] );
//Remove Scheduled Signal change
m_mProtector.lock();
for ( V_MODBUS_ACION_ITEMS::iterator idz=m_vActioItems.begin(); idz!=m_vActioItems.end(); ){
if( (*idz)->module_id == tRTU->id ) {
//check if shceduled signal is current
if( (((*idz)->value & bON ) == bON ) || (((*idz)->mask & bOFF ) == bOFF ) ){
free((*idx));
m_vActioItems.erase( idz );
} else idz++;
//break;
} else idz++;
};
m_mProtector.unlock();
//Mitigate Signal if sent
if ( (tRTU->c_OutBits & bON ) == bON ) {
tRTU->c_OutBits &= bOFF;
int rv = modbus_set_rtu( tRTU->ip, tRTU->port, tRTU->output_base_addr, tRTU->c_OutBits );
if ( rv < 0 ) {
m_pDBC->updateModBusRTU( tRTU->id, MBUS_STATUS_OFFLINE, 0, 0 );
} else {
m_pDBC->updateModBusRTU( tRTU->id, MBUS_STATUS_ONLINE, tRTU->c_InBits, tRTU->c_OutBits );
};
};
free( tRTU );
};
};
delete( tIDS );
};
free( tSData );
};
};
break;
};
case 3:{//Both Tracks
uint64_t cTID = m_pDBC->getTrackIdByPlatform( (*idx)->platform_id, 'U' );
if ( cTID ) {
SESSION_DATA *tSData = servaSessionManager::getInstance()->getActiveSessionByTrack( cTID );
if ( tSData ) {
//Rate Session
m_pDBC->updateSessionStatus( tSData->db_id, 1 );
// Create Event?? or just Disable Scada Signal
DBC_UINT64_LIST *tIDS = m_pDBC->listPlatformModBusRTU( (*idx)->platform_id );
if ( tIDS ) {
for ( DBC_UINT64_LIST::iterator idd=tIDS->begin(); idd != tIDS->end(); idd++ ) {
MODBUS_RTU_INFO *tRTU = m_pDBC->getModBusRTU( *idd );
if ( tRTU ) {
uint8_t bON = ( 1 << tRTU->crossbar[MBUS_CROSSBAR_UPPER_TRACK] );
uint8_t bOFF = ~( 1 << tRTU->crossbar[MBUS_CROSSBAR_UPPER_TRACK] );
//Remove Scheduled Signal change
m_mProtector.lock();
for ( V_MODBUS_ACION_ITEMS::iterator idz=m_vActioItems.begin(); idz!=m_vActioItems.end(); ){
if( (*idz)->module_id == tRTU->id ) {
//check if shceduled signal is current
if( (((*idz)->value & bON ) == bON ) || (((*idz)->mask & bOFF ) == bOFF ) ){
free((*idx));
m_vActioItems.erase( idz );
} else idz++;
//break;
} else idz++;
};
m_mProtector.unlock();
//Mitigate Signal if sent
if ( (tRTU->c_OutBits & bON ) == bON ) {
tRTU->c_OutBits &= bOFF;
int rv = modbus_set_rtu( tRTU->ip, tRTU->port, tRTU->output_base_addr, tRTU->c_OutBits );
if ( rv < 0 ) {
m_pDBC->updateModBusRTU( tRTU->id, MBUS_STATUS_OFFLINE, 0, 0 );
} else {
m_pDBC->updateModBusRTU( tRTU->id, MBUS_STATUS_ONLINE, tRTU->c_InBits, tRTU->c_OutBits );
};
};
free( tRTU );
};
};
delete( tIDS );
};
free( tSData );
};
};
cTID = m_pDBC->getTrackIdByPlatform( (*idx)->platform_id, 'B' );
if ( cTID ) {
SESSION_DATA *tSData = servaSessionManager::getInstance()->getActiveSessionByTrack( cTID );
if ( tSData ) {
//Rate Session
m_pDBC->updateSessionStatus( tSData->db_id, 1 );
// Create Event?? or just Disable Scada Signal
DBC_UINT64_LIST *tIDS = m_pDBC->listPlatformModBusRTU( (*idx)->platform_id );
if ( tIDS ) {
for ( DBC_UINT64_LIST::iterator idd=tIDS->begin(); idd != tIDS->end(); idd++ ) {
MODBUS_RTU_INFO *tRTU = m_pDBC->getModBusRTU( *idd );
if ( tRTU ) {
uint8_t bON = ( 1 << tRTU->crossbar[MBUS_CROSSBAR_BOTTOM_TRACK] );
uint8_t bOFF = ~( 1 << tRTU->crossbar[MBUS_CROSSBAR_BOTTOM_TRACK] );
//Remove Scheduled Signal change
m_mProtector.lock();
for ( V_MODBUS_ACION_ITEMS::iterator idz=m_vActioItems.begin(); idz!=m_vActioItems.end(); ){
if( (*idz)->module_id == tRTU->id ) {
//check if shceduled signal is current
if( (((*idz)->value & bON ) == bON ) || (((*idz)->mask & bOFF ) == bOFF ) ){
free((*idx));
m_vActioItems.erase( idz );
} else idz++;
//break;
} else idz++;
};
m_mProtector.unlock();
//Mitigate Signal if sent
if ( (tRTU->c_OutBits & bON ) == bON ) {
tRTU->c_OutBits &= bOFF;
int rv = modbus_set_rtu( tRTU->ip, tRTU->port, tRTU->output_base_addr, tRTU->c_OutBits );
if ( rv < 0 ) {
m_pDBC->updateModBusRTU( tRTU->id, MBUS_STATUS_OFFLINE, 0, 0 );
} else {
m_pDBC->updateModBusRTU( tRTU->id, MBUS_STATUS_ONLINE, tRTU->c_InBits, tRTU->c_OutBits );
};
};
free( tRTU );
};
};
delete( tIDS );
};
free( tSData );
};
};
break;
};
case 4:{ // Set TCC AUX signal
// ?? and create Scheduled mitigation of the signal ??
DBC_UINT64_LIST *tIDS = m_pDBC->listPlatformModBusRTU( (*idx)->platform_id );
if ( tIDS ) {
for ( DBC_UINT64_LIST::iterator idd=tIDS->begin(); idd != tIDS->end(); idd++ ) {
MODBUS_RTU_INFO *tRTU = m_pDBC->getModBusRTU( *idd );
if ( tRTU ) {
uint8_t bON = ( 1 << tRTU->crossbar[((tData.side == 'U')?MBUS_CROSSBAR_UPPER_TRACK:MBUS_CROSSBAR_BOTTOM_TRACK)] );
uint8_t bOFF = ~( 1 << tRTU->crossbar[((tData.side == 'U')?MBUS_CROSSBAR_UPPER_TRACK:MBUS_CROSSBAR_BOTTOM_TRACK)] );
//Remove Scheduled Signal change
m_mProtector.lock();
for ( V_MODBUS_ACION_ITEMS::iterator idz=m_vActioItems.begin(); idz!=m_vActioItems.end(); ){
if( (*idz)->module_id == tRTU->id ) {
//check if shceduled signal is current
if( (((*idz)->value & bON ) == bON ) || (((*idz)->mask & bOFF ) == bOFF ) ){
free((*idx));
m_vActioItems.erase( idz );
// check if TCC Module
if ( tRTU->func == 3 ) {
uint8_t bON = (1 << tRTU->crossbar[MBUS_CROSSBAR_AUX]);
uint8_t bOFF = ~( 1 << tRTU->crossbar[MBUS_CROSSBAR_AUX] );
//Remove Scheduled Signal change
m_mProtector.lock();
for ( V_MODBUS_ACION_ITEMS::iterator idz=m_vActioItems.begin(); idz!=m_vActioItems.end(); ){
if( (*idz)->module_id == tRTU->id ) {
//check if shceduled signal is current
if( (((*idz)->value & bON ) == bON ) || (((*idz)->mask & bOFF ) == bOFF ) ){
free((*idx));
m_vActioItems.erase( idz );
} else idz++;
//break;
} else idz++;
//break;
} else idz++;
};
m_mProtector.unlock();
//Mitigate Signal if sent
if ( (tRTU->c_OutBits & bON ) == bON ) {
tRTU->c_OutBits &= bOFF;
int rv = modbus_set_rtu( tRTU->ip, tRTU->port, tRTU->output_base_addr, tRTU->c_OutBits );
if ( rv < 0 ) {
m_pDBC->updateModBusRTU( tRTU->id, MBUS_STATUS_OFFLINE, 0, 0 );
};
m_mProtector.unlock();
//Skeep Signal if Allready Set
if ( (tRTU->c_OutBits & bON ) == 0 ) {
tRTU->c_OutBits |= bON;
int rv = modbus_set_rtu( tRTU->ip, tRTU->port, tRTU->output_base_addr, tRTU->c_OutBits );
if ( rv < 0 ) {
m_pDBC->updateModBusRTU( tRTU->id, MBUS_STATUS_OFFLINE, 0, 0 );
} else {
m_pDBC->updateModBusRTU( tRTU->id, MBUS_STATUS_ONLINE, tRTU->c_InBits, tRTU->c_OutBits );
//Create Action Item Do disable Signal
MODBUS_ACION_ITEM *tAI = (MODBUS_ACION_ITEM *)malloc(sizeof(MODBUS_ACION_ITEM));
if ( tAI ) {
memset( tAI, 0, sizeof(MODBUS_ACION_ITEM) );
//?? How long
tAI->scheduled_on = getMilliseconds() + ( m_sManagerData.automaticAlarmRisingTO * 1000 );
tAI->module_id = tRTU->id;
tAI->value = ( 1 << tRTU->crossbar[MBUS_CROSSBAR_AUX] );
m_mProtector.lock();
m_vActioItems.push_back( tAI );
m_mProtector.unlock();
};
};
} else {
m_pDBC->updateModBusRTU( tRTU->id, MBUS_STATUS_ONLINE, tRTU->c_InBits, tRTU->c_OutBits );
// Only Create New Action Item to Mitigate
// That will propogate delay because old Mitigation item was deleted
MODBUS_ACION_ITEM *tAI = (MODBUS_ACION_ITEM *)malloc(sizeof(MODBUS_ACION_ITEM));
if ( tAI ) {
memset( tAI, 0, sizeof(MODBUS_ACION_ITEM) );
//?? How long
tAI->scheduled_on = getMilliseconds() + ( m_sManagerData.automaticAlarmRisingTO * 1000 );
tAI->module_id = tRTU->id;
tAI->value = ( 1 << tRTU->crossbar[MBUS_CROSSBAR_AUX] );
m_mProtector.lock();
m_vActioItems.push_back( tAI );
m_mProtector.unlock();
};
};
};
free( tRTU );
};
};
delete( tIDS );
};
free( tSData );
break;
};
};
};

85
lib/App/serva/servaSessionManager.cpp

@ -444,6 +444,30 @@ SESSION_DATA *servaSessionManager::updateSession( uint64_t tack_id, uint64_t mod
tData->sms = cms%1000;
tData->track_id = tack_id;
getUniqID_UUID( tData->uuid );
// Set Side of event
tData->src = ' ';
DBC_IS_MODULE_DATA *tMData = m_pDBC->getModuleData( module_id );
if ( tMData ) {
DBC_IS_TRACK_DATA *tTData = m_pDBC->getTrackData( tack_id );
if ( tTData ) {
if (tTData->side == 'U') {
if (tMData->side == 'F') {
tData->src = 'L';
} else {
tData->src = 'R';
};
} else {
if (tMData->side == 'F') {
tData->src = 'R';
} else {
tData->src = 'L';
};
};
free(tTData);
};
free(tMData);
};
// Create History Database if not exists
char tBase[MAX_PATH];
sprintf( tBase, "%s/%" PRIu64, m_pDbReportBase, tack_id );
@ -523,20 +547,57 @@ SESSION_DATA *servaSessionManager::updateSession( uint64_t tack_id, uint64_t mod
LOG_ERROR("Cannot Allocate Session Data [malloc]!");
};
if ( tData ) {
//LOG("All Seems to be good!");
tData->db_id = m_pDBC->sessionCreate( tData->track_id, tData->sts, tData->sms, tData->uuid, 'A' );
// Session is New
if ( tData->db_id == 0 ) {
LOG_ERROR("Cannot Create Session!");
delete( tData->m_pDataReport );
free( tData );
tData = NULL;
//LOG("All Seems to be good!");
tData->db_id = m_pDBC->sessionCreate( tData->track_id, tData->sts, tData->sms, tData->uuid, tData->src );
if ( tData->db_id == 0 ) {
LOG_ERROR("Cannot Create Session!");
delete( tData->m_pDataReport );
free( tData );
tData = NULL;
} else {
m_mSessionProtector.lock();
m_mSessions[tack_id] = tData;
m_mSessionProtector.unlock();
//Propogate Event ->Session Start
EVENT_CONTAINER *tEvt = createBasicEvent( tack_id, EVT_CLASS_SYSTEM, EVT_SRV_SESSION_STARTED );
if ( tEvt ) basicEventHeap::getInstance()->broadcast( tEvt );
};
} else {
m_mSessionProtector.lock();
m_mSessions[tack_id] = tData;
m_mSessionProtector.unlock();
//Propogate Event ->Session Start
EVENT_CONTAINER *tEvt = createBasicEvent( tack_id, EVT_CLASS_SYSTEM, EVT_SRV_SESSION_STARTED );
if ( tEvt ) basicEventHeap::getInstance()->broadcast( tEvt );
char cSRC = ' ';
DBC_IS_MODULE_DATA *tMData = m_pDBC->getModuleData( module_id );
if ( tMData ) {
DBC_IS_TRACK_DATA *tTData = m_pDBC->getTrackData( tack_id );
if ( tTData ) {
if (tTData->side == 'U') {
if (tMData->side == 'F') {
cSRC = 'L';
} else {
cSRC = 'R';
};
} else {
if (tMData->side == 'F') {
cSRC = 'R';
} else {
cSRC = 'L';
};
};
free(tTData);
};
free(tMData);
};
if ( cSRC != ' ' ) {
// Have side info
if ( ( tData->src != 'B' ) && ( tData->src != cSRC ) ) {
tData->src = 'B';
m_pDBC->updateSessionSource( tData->db_id, tData->src );
// Create Event for other side
EVENT_CONTAINER *tEvt = createBasicEvent( tack_id, EVT_CLASS_SYSTEM, EVT_SRV_SESSION_STARTED );
if ( tEvt ) basicEventHeap::getInstance()->broadcast( tEvt );
};
};
};
};
};

20
lib/data/media/video/videoAVLIBSource.cpp

@ -286,8 +286,13 @@ bool videoAVLIBSource::_restart(void)
{
case AVLIB_SOURCE_DDSHOW:
{
#if (LIBAVCODEC_VERSION_MAJOR >= 60 )
//const added for ffmpeg 60
const AVInputFormat * iformat = av_find_input_format("dshow");
const AVInputFormat * iformat = av_find_input_format("dshow");
#else
AVInputFormat * iformat = av_find_input_format("dshow");
#endif
if ((RetVal = avformat_open_input(&m_pVideoState->m_pFormatCtx, m_pVideoState->m_pFileName, iformat, &m_pVideoState->m_pFormatOpts)) != 0)
{
char tB[2048];
@ -380,9 +385,12 @@ bool videoAVLIBSource::_restart(void)
LOG("YABABA-2!");
#endif
/* find the video stream information */
#if (LIBAVCODEC_VERSION_MAJOR >= 60 )
//cast ffmpeg 60
m_pVideoState->m_iVideoStreamID = av_find_best_stream(m_pVideoState->m_pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, const_cast<const AVCodec**>(&m_pVideoState->m_pVideoCodec), 0);
#else
m_pVideoState->m_iVideoStreamID = av_find_best_stream(m_pVideoState->m_pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, &m_pVideoState->m_pVideoCodec, 0);
#endif
if (m_pVideoState->m_iVideoStreamID == -1)
{
LOG_ERROR("Didn't find a video stream.");
@ -554,7 +562,11 @@ bool videoAVLIBSource::_open(char * URI, bool ShowDeviceMenu, float framerate, i
// av_dict_set(&m_pVideoState->m_pFormatOpts, "show_video_crossbar_connection_dialog", "true", 0);
// AVInputFormat * is Internal Const in CoDec Lib
#if (LIBAVCODEC_VERSION_MAJOR >= 60 )
const AVInputFormat * iformat = av_find_input_format("dshow");
#else
AVInputFormat * iformat = av_find_input_format("dshow");
#endif
// av_dict_set(&options, "pixel_format", "bgr24", 0);
av_dict_set(&m_pVideoState->m_pFormatOpts, "timeout", "5000", 0);
// AVDeviceInfoList *device_list;
@ -747,7 +759,11 @@ bool videoAVLIBSource::_open(char * URI, bool ShowDeviceMenu, float framerate, i
LOG("YABABA-2!");
#endif
/* find the video stream information */
#if (LIBAVCODEC_VERSION_MAJOR >= 60 )
m_pVideoState->m_iVideoStreamID = av_find_best_stream(m_pVideoState->m_pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, const_cast<const AVCodec**>(&m_pVideoState->m_pVideoCodec), 0);
#else
m_pVideoState->m_iVideoStreamID = av_find_best_stream(m_pVideoState->m_pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, &m_pVideoState->m_pVideoCodec, 0);
#endif
if (m_pVideoState->m_iVideoStreamID == -1)
{

172
lib/data/ponvif/ponvif.cpp

@ -80,17 +80,97 @@ pOnvif::pOnvif()
m_nDiscoveryMCastPort = PONVIF_DEFAULT_DISCOVERYMCASTPORT;
m_bDiscoveryHideDuplicates = true;
m_pHttpAccessManager = NULL;
m_sCapabilities.Analytics = NULL;
m_sCapabilities.Device = NULL;
m_sCapabilities.Events = NULL;
m_sCapabilities.Imaging = NULL;
m_sCapabilities.Media = NULL;
m_sCapabilities.PTZ = NULL;
m_sCapabilities.Extension = NULL;
memset( &m_sCapabilities, 0, sizeof( nodeCapability ) );
m_bAuthMode = 0;
LOG("Constructor Done!");
}
void pOnvif::cleanNodeCapability( nodeCapability *ptr ){
LOG("A");
if ( ptr->Analytics ) free( ptr->Analytics );
LOG("B");
if ( ptr->Device ){
LOG("1");
if ( ptr->Device->Network ){
LOG("1a");
if ( ptr->Device->Network->Extension) {
if ( ptr->Device->Network->Extension->Extension ) free ( ptr->Device->Network->Extension->Extension );
free( ptr->Device->Network->Extension );
};
free( ptr->Device->Network );
};
LOG("2");
if ( ptr->Device->System ){
LOG("2a");
if( ptr->Device->System->SupportedVersions ) free( ptr->Device->System->SupportedVersions );
if ( ptr->Device->System->Extension) {
if ( ptr->Device->System->Extension->Extension ) free ( ptr->Device->System->Extension->Extension );
free( ptr->Device->System->Extension );
};
free( ptr->Device->System );
};
LOG("3");
if ( ptr->Device->IO ){
LOG("3a");
if ( ptr->Device->IO->Extension) {
if( ptr->Device->IO->Extension->AuxiliaryCommands ) free( ptr->Device->IO->Extension->AuxiliaryCommands );
if ( ptr->Device->IO->Extension->Extension ) free ( ptr->Device->IO->Extension->Extension );
free( ptr->Device->IO->Extension );
};
free( ptr->Device->IO );
};
LOG("4");
if ( ptr->Device->Security ){
LOG("4a");
if ( ptr->Device->Security->Extension) {
if ( ptr->Device->Security->Extension->Extension ) free ( ptr->Device->Security->Extension->Extension );
free( ptr->Device->Security->Extension );
};
free( ptr->Device->Security );
};
LOG("5");
if ( ptr->Device->Extension ) {
LOG("5a");
free( ptr->Device->Extension );
}
LOG("6");
free( ptr->Device );
LOG("62");
};
LOG("C");
if ( ptr->Events ) free( ptr->Events );
LOG("D");
if ( ptr->Imaging ) free( ptr->Imaging );
LOG("E");
if ( ptr->Media ){
if ( ptr->Media->StreamingCapabilities ) {
if ( ptr->Media->StreamingCapabilities->Extension ) free( ptr->Media->StreamingCapabilities->Extension );
free( ptr->Media->StreamingCapabilities );
};
if ( ptr->Media->Extension ) {
if ( ptr->Media->Extension->ProfileCapabilities ) free( ptr->Media->Extension->ProfileCapabilities );
free( ptr->Media->Extension );
};
};
LOG("F");
if ( ptr->PTZ ) free( ptr->PTZ );
LOG("G");
if ( ptr->Extension ){
if ( ptr->Extension->DeviceIO ) free( ptr->Extension->DeviceIO );
if ( ptr->Extension->Display ) free( ptr->Extension->Display );
if ( ptr->Extension->Recording ) free( ptr->Extension->Recording );
if ( ptr->Extension->Search ) free( ptr->Extension->Search );
if ( ptr->Extension->Replay ) free( ptr->Extension->Replay );
if ( ptr->Extension->Receiver ) free( ptr->Extension->Receiver );
if ( ptr->Extension->AnalyticsDevice ) {
if ( ptr->Extension->AnalyticsDevice->Extension ) free( ptr->Extension->AnalyticsDevice->Extension );
free(ptr->Extension->AnalyticsDevice);
};
if ( ptr->Extension->Extensions ) free( ptr->Extension->Extensions );
free(ptr->Extension);
};
};
pOnvif::~pOnvif()
{
#ifdef DEBUG
@ -98,88 +178,76 @@ pOnvif::~pOnvif()
#endif
if (m_pIpAddress)
{
LOG("1");
free(m_pIpAddress);
}
if (m_pUsername)
{
LOG("2");
free(m_pUsername);
}
if (m_pPassword)
{
LOG("3");
free(m_pPassword);
}
if (m_pMediaURI)
{
free(m_pMediaURI);
}
//if (m_pMediaURI)
//{
// LOG("4");
// free(m_pMediaURI);
//}
if (m_pSnapshotURI)
{
LOG("5");
free(m_pSnapshotURI);
}
if (m_pDeviceURI)
{
free(m_pDeviceURI);
}
if (m_pPTZURI)
{
free(m_pPTZURI);
}
//if (m_pDeviceURI)
//{
// LOG("6");
// free(m_pDeviceURI);
//}
//if (m_pPTZURI)
//{
// LOG("7");
// free(m_pPTZURI);
//}
if (m_pBaseURI)
{
LOG("8");
free(m_pBaseURI);
}
if (m_pProxyHost)
{
LOG("9");
free(m_pProxyHost);
}
if (m_pProxyUsername)
{
LOG("10");
free(m_pProxyUsername);
}
if (m_pProxyPassword)
{
LOG("11");
free(m_pProxyPassword);
}
if (m_pLastResponse)
{
LOG("12");
free(m_pLastResponse);
}
if (m_pDiscoveryBindIP)
{
LOG("13");
free(m_pDiscoveryBindIP);
}
if (m_pDiscoveryMCastIP)
{
LOG("14");
free(m_pDiscoveryMCastIP);
}
if (m_sCapabilities.Analytics)
{
free(m_sCapabilities.Analytics);
}
if (m_sCapabilities.Device)
{
free(m_sCapabilities.Device);
}
if (m_sCapabilities.Events)
{
free(m_sCapabilities.Events);
}
if (m_sCapabilities.Imaging)
{
free(m_sCapabilities.Imaging);
}
if (m_sCapabilities.Media)
{
free(m_sCapabilities.Media);
}
if (m_sCapabilities.PTZ)
{
free(m_sCapabilities.PTZ);
}
if (m_sCapabilities.Extension)
{
free(m_sCapabilities.Extension);
}
cleanNodeCapability( &m_sCapabilities );
LOG("CNC Done!");
if (m_pCURL)
{
#ifdef DEBUG
@ -445,7 +513,7 @@ void pOnvif::getSupportedVersion(void) {}
nodeCapability * pOnvif::getCapabilities(void)
{
return &m_sCapabilities;
return &m_sCapabilities;
}
bool pOnvif::setBreakOnError(bool intransingent)
@ -695,16 +763,14 @@ bool pOnvif::create(void){
// Update some Vars Online!
// preg_match("/^http(.*)onvif\//",$this->mediauri,$matches);
// m_pBaseURI = $matches[0];
if (media_GetVideoSources())
{
if (media_GetProfiles())
{
if (media_GetVideoSources()){
if (media_GetProfiles()){
//_getActiveSources( m_vVideoSources, m_vVideoProfiles);
return true;
};
};
LOG_ERROR("Error Profiles!");
return true;
return false;
}
/*

2
lib/data/ponvif/ponvif.h

@ -478,7 +478,7 @@ typedef std::vector<discoveryNodeInfo *> discoveryResults;
class pOnvif
{
private:
void cleanNodeCapability( nodeCapability *ptr );
curlRequestsManager * m_pHttpAccessManager;
basicMutex m_mResponseProtector;
CURL * m_pCURL;

Loading…
Cancel
Save