Browse Source

Before LibAV Mem Lickage Debuging

AGP
Evgeny Gagua 5 years ago
parent
commit
7d6d6d054d
  1. 30
      Projects/argus/argus.vpj
  2. 165
      Projects/argus/makefile
  3. 4
      lib/App/argus/ArgusBackend.h
  4. 10
      lib/App/argus/RGoose_Kernel.h
  5. 3
      lib/components/base/basicDualThread.cpp
  6. 8
      lib/components/base/basicLIBAV.h
  7. 3
      lib/components/base/basicMediaDestination.h
  8. 5
      lib/components/base/basicPosition.cpp
  9. 16
      lib/components/base/basicThread.cpp
  10. 2
      lib/components/base/basicTransport.cpp
  11. 4
      lib/components/base/basicTransport.h
  12. 61
      lib/components/base/basicTypes.h
  13. 62
      lib/data/media/video/videoAVLIBSource.cpp
  14. 7
      lib/data/media/video/videoAVLIBSource.h
  15. 6
      lib/data/mysql/database_class.cpp
  16. 4
      lib/data/mysql/database_class.h
  17. 116
      lib/data/ponvif/ponvif.cpp
  18. 17
      lib/data/ponvif/ponvif.h
  19. 2
      lib/data/protocol/onvifMediaObserver.h
  20. 6
      lib/data/protocol/protocol.cpp
  21. 4
      lib/data/protocol/protocol.h
  22. 4
      lib/data/protocol/protocolLGS2D.cpp
  23. 16
      lib/data/protocol/protocolPTZ_ONVIF.cpp
  24. 11
      lib/data/transport/transportSocket.cpp
  25. 2
      lib/data/transport/transportSocket.h
  26. 89
      lib/hardware/uart/serialSOL.cpp
  27. 3
      lib/hardware/uart/serialSOL.h
  28. 235
      lib/rgoose/rgooseCamera.cpp
  29. 33
      lib/rgoose/rgooseCamera.h
  30. 440
      lib/rgoose/rgooseDBConnector.cpp
  31. 16
      lib/rgoose/rgooseDBConnector.h
  32. 43
      lib/rgoose/rgooseFilterAPF.cpp
  33. 185
      lib/rgoose/rgooseHardwareManager.cpp
  34. 5
      lib/rgoose/rgooseHardwareManager.h
  35. 77
      lib/rgoose/rgooseHardwareResource.cpp
  36. 16
      lib/rgoose/rgooseHardwareResource.h
  37. 10
      lib/rgoose/rgooseHardwareResourceDryContactProvider.cpp
  38. 0
      lib/rgoose/rgooseHardwareResourceDryContactProvider.h
  39. 41
      lib/rgoose/rgooseHardwareResourceIpUART.cpp
  40. 17
      lib/rgoose/rgooseHardwareResourceIpUART.h
  41. 25
      lib/rgoose/rgooseHardwareResourceNetwork.cpp
  42. 12
      lib/rgoose/rgooseHardwareResourceNetwork.h
  43. 66
      lib/rgoose/rgooseHardwareResourceNetworkProvider.cpp
  44. 20
      lib/rgoose/rgooseHardwareResourceNetworkProvider.h
  45. 1052
      lib/rgoose/rgooseHardwareResourceSerialProvider.cpp
  46. 60
      lib/rgoose/rgooseHardwareResourceSerialProvider.h
  47. 0
      lib/rgoose/rgooseHardwareResourceVideoProvider.h
  48. 157
      lib/rgoose/rgooseKernel.cpp
  49. 10
      lib/rgoose/rgooseKernel.h
  50. 3
      lib/rgoose/rgooseModule.h
  51. 700
      lib/rgoose/rgooseModuleEmbedVideo.cpp
  52. 153
      lib/rgoose/rgooseModuleEmbedVideo.h
  53. 77
      lib/rgoose/rgooseModuleFactory.cpp
  54. 1
      lib/rgoose/rgooseModuleFactory.h
  55. 97
      lib/rgoose/rgooseModuleOnvifObserver.cpp
  56. 36
      lib/rgoose/rgooseModuleOnvifObserver.h
  57. 4
      lib/rgoose/rgooseModuleZLMedia.cpp
  58. 3
      lib/rgoose/rgooseNode.cpp
  59. 2
      lib/rgoose/rgooseNode.h
  60. 118
      lib/rgoose/rgooseNode2D.cpp
  61. 25
      lib/rgoose/rgooseNode3D.cpp
  62. 75
      lib/rgoose/rgooseNodeFactory.cpp
  63. 61
      lib/rgoose/rgooseNodePTZCamControl.cpp
  64. 2
      lib/rgoose/rgooseNodePTZCamControl.h
  65. 87
      lib/rgoose/rgooseTypes.h

30
Projects/argus/argus.vpj

@ -13,7 +13,7 @@
Version="1"
OutputFile="%bdargus"
CompilerConfigName="Latest Version"
Defines='"/DDEBUG" "/D__STDC_CONSTANT_MACROS" "/D_CLIENT_APPLICATION_"'>
Defines='"/DDEBUG" "/D__STDC_CONSTANT_MACROS" "/D_CLIENT_APPLICATION_" "/D_OPENCV_"'>
<Menu>
<Target
Name="Compile"
@ -26,7 +26,7 @@
RunFromDir="%rw">
<Exec
CmdLine='g++ -c %xup -x c++ %defd -g -ggdb %~other -o "%bd%n%oe" %i %f'
OtherOptions="-std=c++11 -Wno-write-strings -I../../lib/include `pkg-config libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswresample libswscale --cflags`"/>
OtherOptions="-std=c++11 -Wno-write-strings -I../../lib/include `pkg-config opencv4 libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswresample libswscale --cflags`"/>
</Target>
<Target
Name="Link"
@ -129,6 +129,7 @@
<Lib File="-latomic"/>
<Lib File="`pkg-config"/>
<Lib File="--libs"/>
<Lib File="opencv4"/>
<Lib File="rdkafka++`"/>
</Libs>
</Config>
@ -271,8 +272,11 @@
<F N="../../lib/components/base/basicEventHandler.cpp"/>
<F N="../../lib/components/base/basicEventHeap.cpp"/>
<F N="../../lib/components/base/basicFunctionality.cpp"/>
<F N="../../lib/components/base/basicLIBAV.cpp"/>
<F N="../../lib/components/base/basicLogCollection.cpp"/>
<F N="../../lib/components/base/basicLoggingService.cpp"/>
<F N="../../lib/components/base/basicMediaDestination.cpp"/>
<F N="../../lib/components/base/basicMediaSource.cpp"/>
<F N="../../lib/components/base/basicMutex.cpp"/>
<F N="../../lib/components/base/basicObject.cpp"/>
<F N="../../lib/components/base/basicPosition.cpp"/>
@ -321,12 +325,12 @@
<F N="../../lib/rgoose/rgooseFilterAPF.cpp"/>
<F N="../../lib/rgoose/rgooseHardwareManager.cpp"/>
<F N="../../lib/rgoose/rgooseHardwareResource.cpp"/>
<F N="../../lib/rgoose/rgooseHardwareResourceIpUART.cpp"/>
<F N="../../lib/rgoose/rgooseHardwareResourceNetwork.cpp"/>
<F N="../../lib/rgoose/rgooseHardwareResourceUART.cpp"/>
<F N="../../lib/rgoose/rgooseHardwareResourceUSBDCB.cpp"/>
<F N="../../lib/rgoose/rgooseHardwareResourceDryContactProvider.cpp"/>
<F N="../../lib/rgoose/rgooseHardwareResourceNetworkProvider.cpp"/>
<F N="../../lib/rgoose/rgooseHardwareResourceSerialProvider.cpp"/>
<F N="../../lib/rgoose/rgooseKernel.cpp"/>
<F N="../../lib/rgoose/rgooseModule.cpp"/>
<F N="../../lib/rgoose/rgooseModuleEmbedVideo.cpp"/>
<F N="../../lib/rgoose/rgooseModuleFactory.cpp"/>
<F N="../../lib/rgoose/rgooseModuleFlyHunter.cpp"/>
<F N="../../lib/rgoose/rgooseModuleKafka.cpp"/>
@ -352,6 +356,7 @@
<F N="../../lib/data/transport/transportSerial.cpp"/>
<F N="../../lib/data/transport/transportSocket.cpp"/>
<F N="../../lib/alg/generic/utm.cpp"/>
<F N="../../lib/data/media/video/videoAVLIBSource.cpp"/>
<F N="../../lib/data/protocol/xmlParser.cpp"/>
</Folder>
<Folder
@ -362,12 +367,14 @@
<F N="../../lib/components/base/basicEngine.h"/>
<F N="../../lib/components/base/basicEventHandler.h"/>
<F N="../../lib/components/base/basicFunctionality.h"/>
<F N="../../lib/components/base/basicLIBAV.h"/>
<F N="../../lib/components/base/basicObject.h"/>
<F N="../../lib/components/base/basicPosition.h"/>
<F N="../../lib/components/base/basicSettingsProvider.h"/>
<F N="../../lib/components/base/basicThread.h"/>
<F N="../../lib/components/base/basicTransport.h"/>
<F N="../../lib/components/base/basicTypes.h"/>
<F N="../../lib/components/base/basicVideoSource.h"/>
<F N="../../lib/data/net/clientPort.h"/>
<F N="../../lib/data/mysql/database_class.h"/>
<F N="../../lib/alg/generic/heapDebug.h"/>
@ -395,14 +402,13 @@
<F N="../../lib/rgoose/rgooseFilterAPF.h"/>
<F N="../../lib/rgoose/rgooseHardwareManager.h"/>
<F N="../../lib/rgoose/rgooseHardwareResource.h"/>
<F N="../../lib/rgoose/rgooseHardwareResourceIpUART.h"/>
<F N="../../lib/rgoose/rgooseHardwareResourceIpVideoIn.h"/>
<F N="../../lib/rgoose/rgooseHardwareResourceNetwork.h"/>
<F N="../../lib/rgoose/rgooseHardwareResourceUART.h"/>
<F N="../../lib/rgoose/rgooseHardwareResourceUSBDCB.h"/>
<F N="../../lib/rgoose/rgooseHardwareResourceVideoIn.h"/>
<F N="../../lib/rgoose/rgooseHardwareResourceDryContactProvider.h"/>
<F N="../../lib/rgoose/rgooseHardwareResourceNetworkProvider.h"/>
<F N="../../lib/rgoose/rgooseHardwareResourceSerialProvider.h"/>
<F N="../../lib/rgoose/rgooseHardwareResourceVideoProvider.h"/>
<F N="../../lib/rgoose/rgooseKernel.h"/>
<F N="../../lib/rgoose/rgooseModule.h"/>
<F N="../../lib/rgoose/rgooseModuleEmbedVideo.h"/>
<F N="../../lib/rgoose/rgooseModuleFactory.h"/>
<F N="../../lib/rgoose/rgooseModuleFlyHunter.h"/>
<F N="../../lib/rgoose/rgooseModuleKafka.h"/>

165
Projects/argus/makefile

@ -24,22 +24,24 @@ CFG_INC=
CFG_LIB=-lpthread -lmysqlclient -lssl -lcurl -lm -lcrypto -lconfig \
-lz -lv4l1 -lv4l2 -lhidapi-libusb `pkg-config libavcodec libavdevice \
libavfilter libavformat libavutil libpostproc libswresample \
libswscale --libs` -lssl -latomic `pkg-config --libs rdkafka++`
libswscale --libs` -lssl -latomic `pkg-config --libs opencv4 \
rdkafka++`
CFG_OBJ=
COMMON_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/basicCameraInfo.o $(OUTDIR)/basicDualThread.o \
$(OUTDIR)/basicEngine.o $(OUTDIR)/basicEvent.o \
$(OUTDIR)/basicEventHandler.o $(OUTDIR)/basicEventHeap.o \
$(OUTDIR)/basicFunctionality.o $(OUTDIR)/basicLogCollection.o \
$(OUTDIR)/basicLoggingService.o $(OUTDIR)/basicMutex.o \
$(OUTDIR)/basicObject.o $(OUTDIR)/basicPosition.o \
$(OUTDIR)/basicRing.o $(OUTDIR)/basicSettings.o \
$(OUTDIR)/basicSettingsProvider.o $(OUTDIR)/basicThread.o \
$(OUTDIR)/basicTimeStamp.o $(OUTDIR)/basicTransport.o \
$(OUTDIR)/basicTypes.o $(OUTDIR)/clientPort.o \
$(OUTDIR)/curlRequest.o $(OUTDIR)/curlRequestsManager.o \
$(OUTDIR)/database_class.o $(OUTDIR)/heapDebug.o \
$(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
$(OUTDIR)/basicFunctionality.o $(OUTDIR)/basicLIBAV.o \
$(OUTDIR)/basicLogCollection.o $(OUTDIR)/basicLoggingService.o \
$(OUTDIR)/basicMediaDestination.o $(OUTDIR)/basicMediaSource.o \
$(OUTDIR)/basicMutex.o $(OUTDIR)/basicObject.o \
$(OUTDIR)/basicPosition.o $(OUTDIR)/basicRing.o \
$(OUTDIR)/basicSettings.o $(OUTDIR)/basicSettingsProvider.o \
$(OUTDIR)/basicThread.o $(OUTDIR)/basicTimeStamp.o \
$(OUTDIR)/basicTransport.o $(OUTDIR)/basicTypes.o \
$(OUTDIR)/clientPort.o $(OUTDIR)/curlRequest.o \
$(OUTDIR)/curlRequestsManager.o $(OUTDIR)/database_class.o \
$(OUTDIR)/heapDebug.o $(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
$(OUTDIR)/json_writer.o $(OUTDIR)/libzip.o $(OUTDIR)/lrf_3d.o \
$(OUTDIR)/mask.o $(OUTDIR)/md5.o \
$(OUTDIR)/mediaNginxStreamingProxyManager.o \
@ -56,11 +58,11 @@ COMMON_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/protocolZLMEDIA.o $(OUTDIR)/rgooseCamera.o \
$(OUTDIR)/rgooseDBConnector.o $(OUTDIR)/rgooseFilterAPF.o \
$(OUTDIR)/rgooseHardwareManager.o $(OUTDIR)/rgooseHardwareResource.o \
$(OUTDIR)/rgooseHardwareResourceIpUART.o \
$(OUTDIR)/rgooseHardwareResourceNetwork.o \
$(OUTDIR)/rgooseHardwareResourceUART.o \
$(OUTDIR)/rgooseHardwareResourceUSBDCB.o $(OUTDIR)/rgooseKernel.o \
$(OUTDIR)/rgooseModule.o $(OUTDIR)/rgooseModuleFactory.o \
$(OUTDIR)/rgooseHardwareResourceDryContactProvider.o \
$(OUTDIR)/rgooseHardwareResourceNetworkProvider.o \
$(OUTDIR)/rgooseHardwareResourceSerialProvider.o \
$(OUTDIR)/rgooseKernel.o $(OUTDIR)/rgooseModule.o \
$(OUTDIR)/rgooseModuleEmbedVideo.o $(OUTDIR)/rgooseModuleFactory.o \
$(OUTDIR)/rgooseModuleFlyHunter.o $(OUTDIR)/rgooseModuleKafka.o \
$(OUTDIR)/rgooseModuleOnvifObserver.o $(OUTDIR)/rgooseModuleSSDP.o \
$(OUTDIR)/rgooseModuleUSBRelay.o $(OUTDIR)/rgooseModuleZLMedia.o \
@ -72,22 +74,24 @@ COMMON_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/servletChannelWS.o $(OUTDIR)/servletClientHandlerWS.o \
$(OUTDIR)/servletWS.o $(OUTDIR)/ssdpAnnouncer.o \
$(OUTDIR)/Transform.o $(OUTDIR)/transportSerial.o \
$(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o $(OUTDIR)/xmlParser.o
$(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \
$(OUTDIR)/videoAVLIBSource.o $(OUTDIR)/xmlParser.o
OBJ=$(COMMON_OBJ) $(CFG_OBJ)
ALL_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/basicCameraInfo.o $(OUTDIR)/basicDualThread.o \
$(OUTDIR)/basicEngine.o $(OUTDIR)/basicEvent.o \
$(OUTDIR)/basicEventHandler.o $(OUTDIR)/basicEventHeap.o \
$(OUTDIR)/basicFunctionality.o $(OUTDIR)/basicLogCollection.o \
$(OUTDIR)/basicLoggingService.o $(OUTDIR)/basicMutex.o \
$(OUTDIR)/basicObject.o $(OUTDIR)/basicPosition.o \
$(OUTDIR)/basicRing.o $(OUTDIR)/basicSettings.o \
$(OUTDIR)/basicSettingsProvider.o $(OUTDIR)/basicThread.o \
$(OUTDIR)/basicTimeStamp.o $(OUTDIR)/basicTransport.o \
$(OUTDIR)/basicTypes.o $(OUTDIR)/clientPort.o \
$(OUTDIR)/curlRequest.o $(OUTDIR)/curlRequestsManager.o \
$(OUTDIR)/database_class.o $(OUTDIR)/heapDebug.o \
$(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
$(OUTDIR)/basicFunctionality.o $(OUTDIR)/basicLIBAV.o \
$(OUTDIR)/basicLogCollection.o $(OUTDIR)/basicLoggingService.o \
$(OUTDIR)/basicMediaDestination.o $(OUTDIR)/basicMediaSource.o \
$(OUTDIR)/basicMutex.o $(OUTDIR)/basicObject.o \
$(OUTDIR)/basicPosition.o $(OUTDIR)/basicRing.o \
$(OUTDIR)/basicSettings.o $(OUTDIR)/basicSettingsProvider.o \
$(OUTDIR)/basicThread.o $(OUTDIR)/basicTimeStamp.o \
$(OUTDIR)/basicTransport.o $(OUTDIR)/basicTypes.o \
$(OUTDIR)/clientPort.o $(OUTDIR)/curlRequest.o \
$(OUTDIR)/curlRequestsManager.o $(OUTDIR)/database_class.o \
$(OUTDIR)/heapDebug.o $(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
$(OUTDIR)/json_writer.o $(OUTDIR)/libzip.o $(OUTDIR)/lrf_3d.o \
$(OUTDIR)/mask.o $(OUTDIR)/md5.o \
$(OUTDIR)/mediaNginxStreamingProxyManager.o \
@ -104,11 +108,11 @@ ALL_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/protocolZLMEDIA.o $(OUTDIR)/rgooseCamera.o \
$(OUTDIR)/rgooseDBConnector.o $(OUTDIR)/rgooseFilterAPF.o \
$(OUTDIR)/rgooseHardwareManager.o $(OUTDIR)/rgooseHardwareResource.o \
$(OUTDIR)/rgooseHardwareResourceIpUART.o \
$(OUTDIR)/rgooseHardwareResourceNetwork.o \
$(OUTDIR)/rgooseHardwareResourceUART.o \
$(OUTDIR)/rgooseHardwareResourceUSBDCB.o $(OUTDIR)/rgooseKernel.o \
$(OUTDIR)/rgooseModule.o $(OUTDIR)/rgooseModuleFactory.o \
$(OUTDIR)/rgooseHardwareResourceDryContactProvider.o \
$(OUTDIR)/rgooseHardwareResourceNetworkProvider.o \
$(OUTDIR)/rgooseHardwareResourceSerialProvider.o \
$(OUTDIR)/rgooseKernel.o $(OUTDIR)/rgooseModule.o \
$(OUTDIR)/rgooseModuleEmbedVideo.o $(OUTDIR)/rgooseModuleFactory.o \
$(OUTDIR)/rgooseModuleFlyHunter.o $(OUTDIR)/rgooseModuleKafka.o \
$(OUTDIR)/rgooseModuleOnvifObserver.o $(OUTDIR)/rgooseModuleSSDP.o \
$(OUTDIR)/rgooseModuleUSBRelay.o $(OUTDIR)/rgooseModuleZLMedia.o \
@ -120,13 +124,14 @@ ALL_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/servletChannelWS.o $(OUTDIR)/servletClientHandlerWS.o \
$(OUTDIR)/servletWS.o $(OUTDIR)/ssdpAnnouncer.o \
$(OUTDIR)/Transform.o $(OUTDIR)/transportSerial.o \
$(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o $(OUTDIR)/xmlParser.o \
-lpthread -lmysqlclient -lssl -lcurl -lm -lcrypto -lconfig -lz \
-lv4l1 -lv4l2 -lhidapi-libusb `pkg-config libavcodec libavdevice \
libavfilter libavformat libavutil libpostproc libswresample \
libswscale --libs` -lssl -latomic `pkg-config --libs rdkafka++`
COMPILE=g++ -c -x c++ "-DDEBUG" "-D__STDC_CONSTANT_MACROS" "-D_CLIENT_APPLICATION_" -g -ggdb -std=c++11 -Wno-write-strings -I../../lib/include `pkg-config libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswresample libswscale --cflags` -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $<
$(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \
$(OUTDIR)/videoAVLIBSource.o $(OUTDIR)/xmlParser.o -lpthread \
-lmysqlclient -lssl -lcurl -lm -lcrypto -lconfig -lz -lv4l1 -lv4l2 \
-lhidapi-libusb `pkg-config libavcodec libavdevice libavfilter \
libavformat libavutil libpostproc libswresample libswscale --libs` \
-lssl -latomic `pkg-config --libs opencv4 rdkafka++`
COMPILE=g++ -c -x c++ "-DDEBUG" "-D__STDC_CONSTANT_MACROS" "-D_CLIENT_APPLICATION_" "-D_OPENCV_" -g -ggdb -std=c++11 -Wno-write-strings -I../../lib/include `pkg-config opencv4 libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswresample libswscale --cflags` -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $<
LINK=g++ -g -ggdb -o "$(OUTFILE)" $(ALL_OBJ)
# Pattern rules
@ -157,6 +162,9 @@ $(OUTDIR)/%.o : ../../lib/alg/generic/%.cpp
$(OUTDIR)/%.o : ../../lib/components/base/%.cpp
$(COMPILE)
$(OUTDIR)/%.o : ../../lib/data/media/video/%.cpp
$(COMPILE)
$(OUTDIR)/%.o : ../../lib/hardware/uart/%.cpp
$(COMPILE)
@ -221,16 +229,17 @@ COMMON_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/basicCameraInfo.o $(OUTDIR)/basicDualThread.o \
$(OUTDIR)/basicEngine.o $(OUTDIR)/basicEvent.o \
$(OUTDIR)/basicEventHandler.o $(OUTDIR)/basicEventHeap.o \
$(OUTDIR)/basicFunctionality.o $(OUTDIR)/basicLogCollection.o \
$(OUTDIR)/basicLoggingService.o $(OUTDIR)/basicMutex.o \
$(OUTDIR)/basicObject.o $(OUTDIR)/basicPosition.o \
$(OUTDIR)/basicRing.o $(OUTDIR)/basicSettings.o \
$(OUTDIR)/basicSettingsProvider.o $(OUTDIR)/basicThread.o \
$(OUTDIR)/basicTimeStamp.o $(OUTDIR)/basicTransport.o \
$(OUTDIR)/basicTypes.o $(OUTDIR)/clientPort.o \
$(OUTDIR)/curlRequest.o $(OUTDIR)/curlRequestsManager.o \
$(OUTDIR)/database_class.o $(OUTDIR)/heapDebug.o \
$(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
$(OUTDIR)/basicFunctionality.o $(OUTDIR)/basicLIBAV.o \
$(OUTDIR)/basicLogCollection.o $(OUTDIR)/basicLoggingService.o \
$(OUTDIR)/basicMediaDestination.o $(OUTDIR)/basicMediaSource.o \
$(OUTDIR)/basicMutex.o $(OUTDIR)/basicObject.o \
$(OUTDIR)/basicPosition.o $(OUTDIR)/basicRing.o \
$(OUTDIR)/basicSettings.o $(OUTDIR)/basicSettingsProvider.o \
$(OUTDIR)/basicThread.o $(OUTDIR)/basicTimeStamp.o \
$(OUTDIR)/basicTransport.o $(OUTDIR)/basicTypes.o \
$(OUTDIR)/clientPort.o $(OUTDIR)/curlRequest.o \
$(OUTDIR)/curlRequestsManager.o $(OUTDIR)/database_class.o \
$(OUTDIR)/heapDebug.o $(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
$(OUTDIR)/json_writer.o $(OUTDIR)/libzip.o $(OUTDIR)/lrf_3d.o \
$(OUTDIR)/mask.o $(OUTDIR)/md5.o \
$(OUTDIR)/mediaNginxStreamingProxyManager.o \
@ -247,11 +256,11 @@ COMMON_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/protocolZLMEDIA.o $(OUTDIR)/rgooseCamera.o \
$(OUTDIR)/rgooseDBConnector.o $(OUTDIR)/rgooseFilterAPF.o \
$(OUTDIR)/rgooseHardwareManager.o $(OUTDIR)/rgooseHardwareResource.o \
$(OUTDIR)/rgooseHardwareResourceIpUART.o \
$(OUTDIR)/rgooseHardwareResourceNetwork.o \
$(OUTDIR)/rgooseHardwareResourceUART.o \
$(OUTDIR)/rgooseHardwareResourceUSBDCB.o $(OUTDIR)/rgooseKernel.o \
$(OUTDIR)/rgooseModule.o $(OUTDIR)/rgooseModuleFactory.o \
$(OUTDIR)/rgooseHardwareResourceDryContactProvider.o \
$(OUTDIR)/rgooseHardwareResourceNetworkProvider.o \
$(OUTDIR)/rgooseHardwareResourceSerialProvider.o \
$(OUTDIR)/rgooseKernel.o $(OUTDIR)/rgooseModule.o \
$(OUTDIR)/rgooseModuleEmbedVideo.o $(OUTDIR)/rgooseModuleFactory.o \
$(OUTDIR)/rgooseModuleFlyHunter.o $(OUTDIR)/rgooseModuleKafka.o \
$(OUTDIR)/rgooseModuleOnvifObserver.o $(OUTDIR)/rgooseModuleSSDP.o \
$(OUTDIR)/rgooseModuleUSBRelay.o $(OUTDIR)/rgooseModuleZLMedia.o \
@ -263,22 +272,24 @@ COMMON_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/servletChannelWS.o $(OUTDIR)/servletClientHandlerWS.o \
$(OUTDIR)/servletWS.o $(OUTDIR)/ssdpAnnouncer.o \
$(OUTDIR)/Transform.o $(OUTDIR)/transportSerial.o \
$(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o $(OUTDIR)/xmlParser.o
$(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \
$(OUTDIR)/videoAVLIBSource.o $(OUTDIR)/xmlParser.o
OBJ=$(COMMON_OBJ) $(CFG_OBJ)
ALL_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/basicCameraInfo.o $(OUTDIR)/basicDualThread.o \
$(OUTDIR)/basicEngine.o $(OUTDIR)/basicEvent.o \
$(OUTDIR)/basicEventHandler.o $(OUTDIR)/basicEventHeap.o \
$(OUTDIR)/basicFunctionality.o $(OUTDIR)/basicLogCollection.o \
$(OUTDIR)/basicLoggingService.o $(OUTDIR)/basicMutex.o \
$(OUTDIR)/basicObject.o $(OUTDIR)/basicPosition.o \
$(OUTDIR)/basicRing.o $(OUTDIR)/basicSettings.o \
$(OUTDIR)/basicSettingsProvider.o $(OUTDIR)/basicThread.o \
$(OUTDIR)/basicTimeStamp.o $(OUTDIR)/basicTransport.o \
$(OUTDIR)/basicTypes.o $(OUTDIR)/clientPort.o \
$(OUTDIR)/curlRequest.o $(OUTDIR)/curlRequestsManager.o \
$(OUTDIR)/database_class.o $(OUTDIR)/heapDebug.o \
$(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
$(OUTDIR)/basicFunctionality.o $(OUTDIR)/basicLIBAV.o \
$(OUTDIR)/basicLogCollection.o $(OUTDIR)/basicLoggingService.o \
$(OUTDIR)/basicMediaDestination.o $(OUTDIR)/basicMediaSource.o \
$(OUTDIR)/basicMutex.o $(OUTDIR)/basicObject.o \
$(OUTDIR)/basicPosition.o $(OUTDIR)/basicRing.o \
$(OUTDIR)/basicSettings.o $(OUTDIR)/basicSettingsProvider.o \
$(OUTDIR)/basicThread.o $(OUTDIR)/basicTimeStamp.o \
$(OUTDIR)/basicTransport.o $(OUTDIR)/basicTypes.o \
$(OUTDIR)/clientPort.o $(OUTDIR)/curlRequest.o \
$(OUTDIR)/curlRequestsManager.o $(OUTDIR)/database_class.o \
$(OUTDIR)/heapDebug.o $(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
$(OUTDIR)/json_writer.o $(OUTDIR)/libzip.o $(OUTDIR)/lrf_3d.o \
$(OUTDIR)/mask.o $(OUTDIR)/md5.o \
$(OUTDIR)/mediaNginxStreamingProxyManager.o \
@ -295,11 +306,11 @@ ALL_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/protocolZLMEDIA.o $(OUTDIR)/rgooseCamera.o \
$(OUTDIR)/rgooseDBConnector.o $(OUTDIR)/rgooseFilterAPF.o \
$(OUTDIR)/rgooseHardwareManager.o $(OUTDIR)/rgooseHardwareResource.o \
$(OUTDIR)/rgooseHardwareResourceIpUART.o \
$(OUTDIR)/rgooseHardwareResourceNetwork.o \
$(OUTDIR)/rgooseHardwareResourceUART.o \
$(OUTDIR)/rgooseHardwareResourceUSBDCB.o $(OUTDIR)/rgooseKernel.o \
$(OUTDIR)/rgooseModule.o $(OUTDIR)/rgooseModuleFactory.o \
$(OUTDIR)/rgooseHardwareResourceDryContactProvider.o \
$(OUTDIR)/rgooseHardwareResourceNetworkProvider.o \
$(OUTDIR)/rgooseHardwareResourceSerialProvider.o \
$(OUTDIR)/rgooseKernel.o $(OUTDIR)/rgooseModule.o \
$(OUTDIR)/rgooseModuleEmbedVideo.o $(OUTDIR)/rgooseModuleFactory.o \
$(OUTDIR)/rgooseModuleFlyHunter.o $(OUTDIR)/rgooseModuleKafka.o \
$(OUTDIR)/rgooseModuleOnvifObserver.o $(OUTDIR)/rgooseModuleSSDP.o \
$(OUTDIR)/rgooseModuleUSBRelay.o $(OUTDIR)/rgooseModuleZLMedia.o \
@ -311,11 +322,12 @@ ALL_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/servletChannelWS.o $(OUTDIR)/servletClientHandlerWS.o \
$(OUTDIR)/servletWS.o $(OUTDIR)/ssdpAnnouncer.o \
$(OUTDIR)/Transform.o $(OUTDIR)/transportSerial.o \
$(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o $(OUTDIR)/xmlParser.o \
-lpthread -lmysqlclient -lssl -lcurl -lm -lcrypto -lconfig -lz \
-lv4l1 -lv4l2 -lhidapi-libusb `pkg-config libavcodec libavdevice \
libavfilter libavformat libavutil libpostproc libswresample \
libswscale --libs` -lssl -latomic `pkg-config --libs rdkafka++`
$(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \
$(OUTDIR)/videoAVLIBSource.o $(OUTDIR)/xmlParser.o -lpthread \
-lmysqlclient -lssl -lcurl -lm -lcrypto -lconfig -lz -lv4l1 -lv4l2 \
-lhidapi-libusb `pkg-config libavcodec libavdevice libavfilter \
libavformat libavutil libpostproc libswresample libswscale --libs` \
-lssl -latomic `pkg-config --libs rdkafka++`
COMPILE=g++ -c -x c++ "-D__STDC_CONSTANT_MACROS" "-D_CLIENT_APPLICATION_" -O3 -std=c++11 -Wno-write-strings -I../../lib/include `pkg-config libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswresample libswscale --cflags` -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $<
LINK=g++ -O3 -o "$(OUTFILE)" $(ALL_OBJ)
@ -348,6 +360,9 @@ $(OUTDIR)/%.o : ../../lib/alg/generic/%.cpp
$(OUTDIR)/%.o : ../../lib/components/base/%.cpp
$(COMPILE)
$(OUTDIR)/%.o : ../../lib/data/media/video/%.cpp
$(COMPILE)
$(OUTDIR)/%.o : ../../lib/hardware/uart/%.cpp
$(COMPILE)

4
lib/App/argus/ArgusBackend.h

@ -24,8 +24,8 @@
#include "../../components/object/objectFileLoggingService.h"
#include "../../components/object/objectConsoleLoggingService.h"
#include "../../data/net/netServer.h"
#include "../../data/ponvif/ponvif.h"
#include "../../data/protocol/onvifMediaObserver.h"
//#include "../../data/ponvif/ponvif.h"
//#include "../../data/protocol/onvifMediaObserver.h"
#include "../../data/mysql/database_class.h"
#include "../../rgoose/rgooseKernel.h"

10
lib/App/argus/RGoose_Kernel.h

@ -59,17 +59,17 @@ struct serial_struct {
#include "../../components/base/basicThread.h"
#include "../../components/base/basicEngine.h"
#include "../../components/base/basicSettingsProvider.h"
#include "../../data/ponvif/ponvif.h"
#include "../../data/protocol/onvifMediaObserver.h"
#include "../../data/ssdp/ssdpAnnouncer.h"
#include "../../data/NginxMediaServer/mediaNginxStreamingProxyManager.h"
//#include "../../data/ponvif/ponvif.h"
//#include "../../data/protocol/onvifMediaObserver.h"
//#include "../../data/ssdp/ssdpAnnouncer.h"
//#include "../../data/NginxMediaServer/mediaNginxStreamingProxyManager.h"
#include "../../components/base/basicEventHeap.h"
#include "../../rgoose/rgooseDBConnector.h"
#include "../../rgoose/rgooseIPCamera.h"
#include "../../rgoose/rgooseNodeFactory.h"
#include "../../rgoose/rgooseModuleFactory.h"
#include "../../data/net/netServer.h"
#include "../../data/servletWS/servletWS.h"
//#include "../../data/servletWS/servletWS.h"
#define SLEEP_KERNEL_INTERVAL 10
#define ONVIF_DISCOVERY_INTERVAL 300 // 5 min

3
lib/components/base/basicDualThread.cpp

@ -180,6 +180,9 @@ bool basicDualThread::uninit( void ){
CloseHandle(m_hThreadAHandle);
CloseHandle(m_hThreadBHandle);
#endif
LOG("UNINIT done!");
m_bThreadAStatus = TH_PRE_INIT;
m_bThreadBStatus = TH_PRE_INIT;
return true;
};

8
lib/components/base/basicLIBAV.h

@ -36,20 +36,23 @@ extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avio.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libswscale/swscale.h>
#include <libswresample/swresample.h>
#include <libavutil/file.h>
#include <libavutil/mathematics.h>
#include <libavutil/error.h>
#include <libavutil/imgutils.h>
};
extern bool _FFD_REGISTER_ALL_FLAG;
//extern bool _FFD_REGISTER_ALL_FLAG;
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,28,1)
#define av_frame_alloc avcodec_alloc_frame
#define av_frame_free avcodec_free_frame
#define avcodec_free_context av_free
#define AV_PIX_FMT_BGR24 PIX_FMT_BGR24
#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P
#define AV_PIX_FMT_YUVJ422P PIX_FMT_YUVJ422P
#endif
#define CLEAR(x) memset(&(x), 0, sizeof(x))
@ -153,6 +156,7 @@ typedef struct VideoState {
AVDictionary *m_pFormatOpts;
AVCodecContext *m_pCodecCtx;
AVCodec *m_pVideoCodec;
SwsContext *m_pSwsCtx;
//VideoPicture m_mPictQ[VIDEO_PICTURE_QUEUE_SIZE];
//int m_iPictQSize;
//int m_iPictQ_rindex;

3
lib/components/base/basicMediaDestination.h

@ -17,7 +17,8 @@ class basicMediaDestination {
basicMediaDestination();
virtual ~basicMediaDestination();
virtual void pushFrame(AVFrame *Frame, void* src = NULL) {};
virtual void pushFrame(cv::Mat* Frame, void* src = NULL) {};
virtual void pushFrame(cv::Mat *Frame, void* src = NULL) {};
virtual void pushFrame(cv::Mat &Frame, void* src = NULL) {};
virtual void setError(bool A, CSTR BOBO = NULL ){};
virtual int startRecord(uint32_t FramesToRecord) { return -1; };
virtual void startRecord(CSTR FileName) {};

5
lib/components/base/basicPosition.cpp

@ -159,23 +159,28 @@ basicPosition& basicPosition::operator=(const basicPosition& src){
};
basicPosition::basicPosition( C3D_WGS84_LOC loc, C3D_SPH_DEGREES orient ): position3D( loc, orient ){
m_pTransform = NULL;
position3D::setSpeed( 0.0f );
updateMatrix();
};
basicPosition::basicPosition( C3D_WGS84_LOC loc, C3D_SPH_RADIANS orient ): position3D( loc, orient ){
m_pTransform = NULL;
position3D::setSpeed( 0.0f );
updateMatrix();
};
basicPosition::basicPosition( int UTM_Zone, C3D_DECART loc, C3D_SPH_DEGREES orient ): position3D( UTM_Zone, loc, orient ){
m_pTransform = NULL;
position3D::setSpeed( 0.0f );
updateMatrix();
};
basicPosition::basicPosition( int UTM_Zone, C3D_DECART loc, C3D_SPH_RADIANS orient ): position3D( UTM_Zone, loc, orient ){
m_pTransform = NULL;
position3D::setSpeed( 0.0f );
updateMatrix();
};
basicPosition::basicPosition( float Lat, float Lon, float Alt, float h_lat, float h_lon, float h_alt, float Speed ) : position3D() {
m_pTransform = NULL;
position3D::setPositionWGS84( Lat, Lon, Alt );
position3D::setOrientationRad( h_lat, h_lon, h_alt );
position3D::setSpeed( Speed );

16
lib/components/base/basicThread.cpp

@ -47,11 +47,13 @@ void basicThread::m_fThreadProc( void ){
basicThread *mThis;
mThis = ( basicThread * ) ptr;
if( mThis->m_bThreadStatus == TH_ARMED ) {
SLOG("Proc Start!");
mThis->m_fThreadProc();
mThis->m_bThreadStatus = TH_EXIT;
SLOG("Proc Exited!");
} else {
SLOG_ERROR("Thread is not ARMED!");
};
mThis->m_bThreadStatus = TH_EXIT;
#ifdef __linux__
pthread_exit( NULL );
return NULL;
@ -61,26 +63,26 @@ void basicThread::m_fThreadProc( void ){
};
void basicThread::waitThreadEnd(bool forced){
LOG("ENDING");
if( m_bThreadStatus > TH_WORKING || m_bThreadStatus < TH_ARMED ) return;
LOG("WAITING");
if( forced ) m_bThreadStatus = TH_ENDED;
while (m_bThreadStatus != TH_EXIT){
SLEEP(DEFAULT_THREAD_SLEEP_TIME);
};
while (m_bThreadStatus != TH_EXIT) SLEEP(1);//DEFAULT_THREAD_SLEEP_TIME);
LOG("DONE -> RIPING");
#if defined( __linux__ ) || defined(WIN_PTHREAD)
pthread_join(m_sThreadHandler, NULL);
#else
WaitForSingleObject(m_hThreadHandle, 2000);
CloseHandle(m_hThreadHandle);
#endif
LOG("FINISH");
};
bool basicThread::uninit( void ){
if( m_bThreadStatus == TH_PRE_INIT ) return true;
while( m_bThreadStatus < TH_WORKING ) SLEEP(1);
m_bThreadStatus = TH_ENDED;
while( m_bThreadStatus < TH_EXIT ) SLEEP(1);
#if defined( __linux__ ) || defined(WIN_PTHREAD)
#if defined( __linux__ ) || defined(WIN_PTHREAD)
pthread_join(m_sThreadHandler, NULL);
#else
WaitForSingleObject(m_hThreadHandle, 2000);

2
lib/components/base/basicTransport.cpp

@ -7,6 +7,7 @@
basicTransport::basicTransport() :m_mQueueProtectorMutex(), m_mBufferProtectorMutex(){
m_pLog = basicLogCollection::getInstance();
m_eConnectionStatus = CS_UNKNOWN;
LOG("C-Done");
//m_bConnected = false;
};
@ -15,6 +16,7 @@ basicTransport::~basicTransport(){
};
bool basicTransport::addRecipient( protocolParser *ProtoParser ){
//LOG("Add Parser");
m_mQueueProtectorMutex.lock();
m_vParsers.push_back( ProtoParser );
ProtoParser->setConnectionStatus( m_eConnectionStatus );

4
lib/components/base/basicTransport.h

@ -18,12 +18,14 @@ class protocolParser;
typedef std::vector<protocolParser *> parseQueue;
class basicTransport{
private:
basicLogCollection * m_pLog;
protected:
//bool m_bConnected;
parseQueue m_vParsers;
basicMutex m_mQueueProtectorMutex;
basicMutex m_mBufferProtectorMutex;
basicLogCollection *m_pLog;
CONNECTION_STATUS m_eConnectionStatus;
public:
basicTransport();

61
lib/components/base/basicTypes.h

@ -32,20 +32,6 @@
#include <string>
#include <vector>
#ifdef __linux__
#include <pthread.h>
#include <unistd.h>
#include <fcntl.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#else
#include <winsock2.h>
#include <winsock.h>
#include <iostream>
#endif
#define MAX_PATH_LEN 1024
#define MAX_CRED_LEN 256
@ -520,53 +506,6 @@ typedef struct S_localIp4Info{
typedef vector<localIp4Info*> localIpAddresses;
#define MAX_BUFF_SIZE 102400 //100K
typedef struct S_OBSERVER_RESULT{
int resultID;
char RefID[CTEXT];
char Type[CTEXT];
char MAC[CTEXT];
char Hardware[CTEXT];
char Name[CTEXT];
char XAddrs[CTEXT];
}OBSERVER_RESULT;
typedef vector<OBSERVER_RESULT*> vectorOBSERVER_RESULT;
class argusModuleOnvifObserver;
typedef struct S_PROBE_CTX{
int AddressID;
char IpAddress[16];
int Port;
int socketFD;
char buff[MAX_BUFF_SIZE + 1];
CSTR send_buff;
CSTR recv_buff;
struct sockaddr_in r_address;
bool bOptVal;
int bOptLen;
int iOptLen;
int RetVal;
int index;
int step;
argusModuleOnvifObserver *observer;
}PROBE_CTX;
typedef struct S_OBSERVER_CTX{
DWORD m_dwThreadID;
#ifdef __linux__
pthread_t m_hThreadHandle;
#else
HANDLE m_hThreadHandle;
#endif
PROBE_CTX * context;
}OBSERVER_CTX;
typedef vector<OBSERVER_CTX*> vectorOBSERVER_CTX;
#ifdef __linux__
#define SLEEP(X) usleep(X*1000)
#else

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

@ -4,12 +4,17 @@
#define LOG( X ) m_pLog->Log( "LibAV_SRC", this, X )
#define LOG_ERROR( X ) m_pLog->Log( "LibAV_SRC", this, _LOG_ERROR, X )
videoAVLIBSource::videoAVLIBSource(): basicMediaSource(), basicThread() {
videoAVLIBSource::videoAVLIBSource( void *opaque ): basicMediaSource(), basicThread() {
m_pLog = basicLogCollection::getInstance();
m_bSizeIsAutomatic = true;
m_nWidth = 640;
m_nHeight = 360;
if( opaque ) {
m_pOpaque = opaque;
} else {
m_pOpaque = (void *)this;
};
if (!initLibAV()) return;
m_pVideoState = (VideoState*)av_mallocz(sizeof(VideoState));
@ -40,12 +45,17 @@ videoAVLIBSource::videoAVLIBSource(): basicMediaSource(), basicThread() {
m_pVideoState->m_bStatus = MS_INIT;
};
videoAVLIBSource::videoAVLIBSource(char *Source) : basicMediaSource(){
videoAVLIBSource::videoAVLIBSource(char *Source, void *opaque ) : basicMediaSource(){
m_pLog = basicLogCollection::getInstance();
m_bStreamingSource = true;
m_bSizeIsAutomatic = true;
m_nWidth = 640;
m_nHeight = 360;
if( opaque ) {
m_pOpaque = opaque;
} else {
m_pOpaque = (void *)this;
};
if( !initLibAV() ) return;
m_pVideoState = (VideoState*)av_mallocz(sizeof(VideoState));
@ -67,7 +77,7 @@ videoAVLIBSource::videoAVLIBSource(char *Source) : basicMediaSource(){
m_pVideoState->m_iAudioStreamID = -1;
#endif
m_pVideoState->m_bStatus = MS_INIT;
_open( Source );
};
@ -490,8 +500,11 @@ int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
#endif
void videoAVLIBSource::m_fThreadProc( void ){
int RetVal;
int bGotPicture = 0;
int RetVal;
int bGotPicture = 0;
#ifdef _OPENCV_
cv::Mat mRGB(m_nHeight, m_nWidth, CV_8UC3);
#endif
m_bThreadStatus = TH_WORKING;
LOG("Reader Thread Started.");
//cv::setBreakOnError( true );
@ -524,7 +537,7 @@ void videoAVLIBSource::m_fThreadProc( void ){
#ifdef PROCESS_YUV420P
sws_scale( img_convert_ctx, (const uint8_t* const*) m_pFrame->data, m_pFrame->linesize, 0, m_pVideoState->m_pCodecCtx->height, m_pFrameYUV->data, m_pFrameYUV->linesize );
//SDL_UpdateYUVTexture(m_pTexture, &m_oRect, m_pFrameYUV->data[0], m_pFrameYUV->linesize[0], m_pFrameYUV->data[1], m_pFrameYUV->linesize[1], m_pFrameYUV->data[2], m_pFrameYUV->linesize[2]);
if (m_pMediaDestination != NULL) m_pMediaDestination->pushFrame( m_pFrameYUV, this);
if (m_pMediaDestination != NULL) m_pMediaDestination->pushFrame( m_pFrameYUV, m_pOpaque );
#else // PROCESS_BGR24
sws_scale(img_convert_ctx, (const uint8_t* const*)m_pFrame->data, m_pFrame->linesize, 0, m_pVideoState->m_pCodecCtx->height, m_pFrameBGR->data, m_pFrameBGR->linesize);
try{
@ -532,12 +545,13 @@ void videoAVLIBSource::m_fThreadProc( void ){
QVideoFrame *tFrame;
tFrame = new QVideoFrame(m_pFrameBGR->linesize[0] * m_nHeight, QSize(m_nHeight, m_nWidth), m_pFrameBGR->linesize[0], QVideoFrame::Format_BGR24);
memcpy(tFrame->bits(), m_pFrameBGR->data[0], m_pFrameBGR->linesize[0] * m_nHeight);
if (m_pMediaDestination != NULL) m_pMediaDestination->pushFrame(tFrame, me );
if (m_pMediaDestination != NULL) m_pMediaDestination->pushFrame(tFrame, m_pOpaque );
# else
#ifdef _OPENCV_
cv::Mat *mRGB;
mRGB = new cv::Mat(m_nHeight, m_nWidth, CV_8UC3);
memcpy(mRGB->data, m_pFrameBGR->data[0], m_pFrameBGR->linesize[0] * m_nHeight);
//cv::Mat *mRGB;
//mRGB = new cv::Mat(m_nHeight, m_nWidth, CV_8UC3);
//memcpy(mRGB->data, m_pFrameBGR->data[0], m_pFrameBGR->linesize[0] * m_nHeight);
memcpy( mRGB.data, m_pFrameBGR->data[0], m_pFrameBGR->linesize[0] * m_nHeight );
#endif
#ifdef _SDL_
SDL_Surface* mRGB;
@ -549,10 +563,9 @@ void videoAVLIBSource::m_fThreadProc( void ){
Uint32 Bmask,
Uint32 Amask);
#endif
if (m_pMediaDestination != NULL) m_pMediaDestination->pushFrame(mRGB, this);
if( m_pMediaDestination != NULL) m_pMediaDestination->pushFrame( mRGB, m_pOpaque );
#ifdef _OPENCV_
delete(mRGB);
//delete(mRGB);
#endif
#ifdef _SDL_
SDL_FreeSurface(mRGB);
@ -587,15 +600,18 @@ void videoAVLIBSource::m_fThreadProc( void ){
#ifdef PROCESS_YUV420P
sws_scale( img_convert_ctx, (const uint8_t* const*)m_pFrame->data, m_pFrame->linesize, 0, m_pVideoState->m_pCodecCtx->height, m_pFrameYUV->data, m_pFrameYUV->linesize);
//SDL_UpdateYUVTexture( m_pTexture, &m_oRect, m_pFrameYUV->data[0], m_pFrameYUV->linesize[0], m_pFrameYUV->data[1], m_pFrameYUV->linesize[1], m_pFrameYUV->data[2], m_pFrameYUV->linesize[2] );
#endif if (m_pMediaDestination != NULL) m_pMediaDestination->pushFrame( m_pFrameYUV, this);
if (m_pMediaDestination != NULL) m_pMediaDestination->pushFrame( m_pFrameYUV, m_pOpaque );
#endif
#ifdef PROCESS_BGR24
sws_scale(img_convert_ctx, (const uint8_t* const*)m_pFrame->data, m_pFrame->linesize, 0, m_pVideoState->m_pCodecCtx->height, m_pFrameBGR->data, m_pFrameBGR->linesize);
try{
cv::Mat *mRGB;
mRGB = new cv::Mat(m_nHeight, m_nWidth, CV_8UC3);
memcpy(mRGB->data, m_pFrameBGR->data[0], m_pFrameBGR->linesize[0] * m_nHeight);
if (m_pMediaDestination != NULL) m_pMediaDestination->pushFrame( mRGB, this );
delete(mRGB);
//cv::Mat *mRGB;
//mRGB = new cv::Mat(m_nHeight, m_nWidth, CV_8UC3);
//memcpy( mRGB->data, m_pFrameBGR->data[0], m_pFrameBGR->linesize[0] * m_nHeight );
cv::Mat mRGB(m_nHeight, m_nWidth, CV_8UC3);
memcpy( mRGB.data, m_pFrameBGR->data[0], m_pFrameBGR->linesize[0] * m_nHeight );
if( m_pMediaDestination != NULL )m_pMediaDestination->pushFrame( mRGB, m_pOpaque );
//delete(mRGB);
} catch (cv::Exception & e) {
LOG_ERROR(e.msg.c_str()); // output exception message
};
@ -612,11 +628,7 @@ void videoAVLIBSource::m_fThreadProc( void ){
};
}else{
m_pVideoState->m_bStatus = MS_CLOSED;
#ifdef __linux__
usleep( 20000 );
#else
Sleep(20);
#endif
SLEEP(5);
};
};
m_pVideoState->m_bStatus = MS_CLOSED;

7
lib/data/media/video/videoAVLIBSource.h

@ -20,6 +20,7 @@ class videoAVLIBSource : public basicMediaSource, public basicThread {
char m_pCookie[33];
VideoState * m_pVideoState;
AVFrame * m_pFrame;
void * m_pOpaque;
#ifdef PROCESS_YUV420P
AVFrame * m_pFrameYUV;
#else
@ -41,9 +42,9 @@ class videoAVLIBSource : public basicMediaSource, public basicThread {
bool _open( CSTR URI, bool ShowDeviceMenu = false, float framerate=-1.f, int inputPin = -1, int width = -1, int height = -1 , bool scaled=false, int s_width=-1, int s_height=-1 );
bool _close( void );
bool _stop( void );
videoAVLIBSource();
videoAVLIBSource( CSTR URI );
videoAVLIBSource( config_setting_t *CFG );
videoAVLIBSource( void *opaque=NULL );
videoAVLIBSource( CSTR URI, void *opaque=NULL );
videoAVLIBSource( config_setting_t *CFG, void *opaque=NULL );
virtual ~videoAVLIBSource();
bool setSize( int Width,
int Height );

6
lib/data/mysql/database_class.cpp

@ -162,7 +162,7 @@ bool MySQL_Connector::ReConnect( void ){
};
AAssoc *MySQL_Connector::Query( CSTR QS, bool useCache ){
AAssoc * RetVal = NULL;
AAssoc * RetVal = NULL;
Assoc * tElement;
unsigned int num_Fields;
MYSQL_RES * Result = NULL;
@ -200,7 +200,7 @@ AAssoc *MySQL_Connector::Query( CSTR QS, bool useCache ){
} else {
Result = mysql_store_result( m_pDBLink );
};*/
while ( mysql_query( m_pDBLink, QS ) ) {
while( mysql_query( m_pDBLink, QS ) ) {
LOG_ERROR( mysql_error( m_pDBLink ));
sprintf( temp, "Error Code: %d", mysql_errno( m_pDBLink ));
LOG_ERROR( temp );
@ -254,7 +254,7 @@ AAssoc *MySQL_Connector::Query( CSTR QS, bool useCache ){
};
} else {
#ifdef DEBUG_MYSQL_QUERIES
LOG( "No Rows" );
LOG( "No Rows" );
#endif
RetVal = NULL;
};

4
lib/data/mysql/database_class.h

@ -6,8 +6,8 @@
#include "../../components/base/basicLogCollection.h"
#include <mysql/mysql.h>
#ifdef DEBUG
//#define DEBUG_MYSQL_QUERIES
#ifdef DEBUG_EXTRA
#define DEBUG_MYSQL_QUERIES
#endif
class MySQL_Connector{

116
lib/data/ponvif/ponvif.cpp

@ -68,11 +68,13 @@ pOnvif::pOnvif(){
m_sCapabilities.Media = NULL;
m_sCapabilities.PTZ = NULL;
m_sCapabilities.Extension = NULL;
LOG("Constructor Done!");
};
pOnvif::~pOnvif(){
#ifdef DEBUG
LOG("Destructor begin");
#endif
if(m_pIpAddress) free(m_pIpAddress);
if(m_pUsername) free(m_pUsername);
if(m_pPassword) free(m_pPassword);
@ -87,10 +89,23 @@ pOnvif::~pOnvif(){
if(m_pLastResponse) free(m_pLastResponse);
if(m_pDiscoveryBindIP) free(m_pDiscoveryBindIP);
if(m_pDiscoveryMCastIP) free(m_pDiscoveryMCastIP);
if( m_pCURL!= NULL ) {
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);
if(m_pCURL){
#ifdef DEBUG
LOG( "Try Cleanup CURL!");
#endif
curl_easy_cleanup(m_pCURL);
m_pCURL = NULL;
};
#ifdef DEBUG
LOG("Destructor Done!");
#endif
};
bool pOnvif::setProxyHost( CSTR proxyHost ){
@ -1310,7 +1325,7 @@ bool pOnvif::ptz_GetStatus( CSTR profileToken, ptzStatus *tStatus ){
XMLResults tParseResults;
XMLNode response = XMLNode::parseString( m_pLastResponse, "root", &tParseResults );
//LOG( m_pLastResponse );
#ifdef DEBUG
#ifdef DEBUG_ONVIF_PRINTOUT_MESSAGES
FILE *fd;
fd = fopen("ONVIF_MSGS.txt","a+");
fprintf(fd, "--------------------\r\n");
@ -1509,8 +1524,6 @@ bool pOnvif::ptz_RelativeMoveZoom( CSTR profileToken, float zoom, float speedZoo
if( _send_request( m_pPTZURI, tBuffer ) ){
XMLResults tParseResults;
XMLNode response = XMLNode::parseString( m_pLastResponse, "root", &tParseResults );
LOG("RCPT:");
LOG( m_pLastResponse );
if( tParseResults.error ){
char tBuf[CTEXT];
sprintf( tBuf, "XML Parse Error %d at %d:%d", tParseResults.error, tParseResults.nLine, tParseResults.nColumn );
@ -1560,18 +1573,41 @@ bool pOnvif::ptz_ContinuousMove( CSTR profileToken, float velocity_pantilt_x, fl
accessToken tTOKEN;
tTOKEN = _makeToken();
sprintf( tBuffer, PONVIF_PACK_CONTINUOUS_MOVE, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken, velocity_pantilt_x, velocity_pantilt_y );
if( _send_request( m_pMediaURI, tBuffer ) ){
/*
#ifdef DEBUG_ONVIF_TRAFFIC
FILE *tf;
tf = fopen("Traffic.txt", "a+");
fprintf( tf, "--------------------\r\n");
fprintf( tf, ">>>>> %s\n", tBuffer );
fprintf( tf, "--------------------\r\n");
#endif
*/
return _send_request( m_pPTZURI, tBuffer );
/*
if( _send_request( m_pPTZURI, tBuffer ) ){
XMLResults tParseResults;
XMLNode response = XMLNode::parseString( m_pLastResponse, "root", &tParseResults );
LOG("RCPT:");
printf(m_pLastResponse);
#ifdef DEBUG_ONVIF_TRAFFIC
fprintf( tf, "--------------------\r\n");
fprintf( tf, "<<<<< %s\n", m_pLastResponse );
fprintf( tf, "--------------------\r\n");
#endif
if( tParseResults.error ){
char tBuf[CTEXT];
sprintf( tBuf, "XML Parse Error %d at %d:%d", tParseResults.error, tParseResults.nLine, tParseResults.nColumn );
LOG_ERROR( tBuf );
} else return true;
} else {
#ifdef DEBUG_ONVIF_TRAFFIC
fclose( tf );
#endif
return true;
};
};
#ifdef DEBUG_ONVIF_TRAFFIC
fclose(tf);
#endif
return false;
//*/
};
bool pOnvif::ptz_ContinuousMoveZoom( CSTR profileToken, float zoom ){
@ -1580,18 +1616,39 @@ bool pOnvif::ptz_ContinuousMoveZoom( CSTR profileToken, float zoom ){
accessToken tTOKEN;
tTOKEN = _makeToken();
sprintf( tBuffer, PONVIF_PACK_CONTINUOUS_ZOOM, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken, zoom );
if( _send_request( m_pMediaURI, tBuffer ) ){
//#ifdef DEBUG_ONVIF_TRAFFIC
// FILE *tf;
// tf = fopen("Traffic.txt", "a+");
// fprintf( tf, "--------------------\r\n");
// fprintf( tf, ">>>>> %s\n", tBuffer );
// fprintf( tf, "--------------------\r\n");
//#endif
return _send_request( m_pPTZURI, tBuffer );
/*
if( _send_request( m_pPTZURI, tBuffer ) ){
XMLResults tParseResults;
XMLNode response = XMLNode::parseString( m_pLastResponse, "root", &tParseResults );
LOG("RCPT:");
printf(m_pLastResponse);
#ifdef DEBUG_ONVIF_TRAFFIC
fprintf( tf, "--------------------\r\n");
fprintf( tf, "<<<<< %s\n", m_pLastResponse );
fprintf( tf, "--------------------\r\n");
#endif
if( tParseResults.error ){
char tBuf[CTEXT];
sprintf( tBuf, "XML Parse Error %d at %d:%d", tParseResults.error, tParseResults.nLine, tParseResults.nColumn );
LOG_ERROR( tBuf );
} else return true;
} else {
#ifdef DEBUG_ONVIF_TRAFFIC
fclose( tf );
#endif
return true;
}
};
#ifdef DEBUG_ONVIF_TRAFFIC
fclose( tf );
#endif
return false;
// */
};
bool pOnvif::ptz_Stop( CSTR profileToken, bool pantilt, bool zoom ){
@ -1599,11 +1656,11 @@ bool pOnvif::ptz_Stop( CSTR profileToken, bool pantilt, bool zoom ){
char tBuffer[DEFAULT_BUFFER_SIZE];
accessToken tTOKEN;
tTOKEN = _makeToken();
sprintf( tBuffer, PONVIF_PACK_PTZ_STOP, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken, pantilt, zoom );
if( _send_request( m_pMediaURI, tBuffer ) ){
sprintf( tBuffer, PONVIF_PACK_PTZ_STOP, tTOKEN.USERNAME, tTOKEN.PASSDIGEST, tTOKEN.NONCE, tTOKEN.TIMESTAMP, profileToken );//, pantilt, zoom );
return _send_request( m_pPTZURI, tBuffer );
/*if( _send_request( m_pPTZURI, tBuffer ) ){
XMLResults tParseResults;
XMLNode response = XMLNode::parseString( m_pLastResponse, "root", &tParseResults );
LOG("RCPT:");
printf(m_pLastResponse);
if( tParseResults.error ){
char tBuf[CTEXT];
@ -1611,7 +1668,8 @@ bool pOnvif::ptz_Stop( CSTR profileToken, bool pantilt, bool zoom ){
LOG_ERROR( tBuf );
} else return true;
};
return false;
return false;
*/
};
/*
@ -1786,17 +1844,26 @@ bool pOnvif::_send_request( CSTR url, CSTR post_string ){
curl_easy_setopt( m_pCURL, CURLOPT_PROXYUSERPWD, tBuffer );
};
};
curl_easy_setopt( m_pCURL, CURLOPT_CONNECTTIMEOUT, 10);
curl_easy_setopt( m_pCURL, CURLOPT_TIMEOUT, 10);
curl_easy_setopt( m_pCURL, CURLOPT_SSL_VERIFYPEER, false );
curl_easy_setopt( m_pCURL, CURLOPT_SSL_VERIFYHOST, false );
curl_easy_setopt( m_pCURL, CURLOPT_POST, true );
curl_easy_setopt( m_pCURL, CURLOPT_WRITEFUNCTION, pOnvif::_writer );
curl_easy_setopt( m_pCURL, CURLOPT_WRITEDATA, this );
curl_easy_setopt( m_pCURL, CURLOPT_CONNECTTIMEOUT, 10);
curl_easy_setopt( m_pCURL, CURLOPT_TIMEOUT, 10);
curl_easy_setopt( m_pCURL, CURLOPT_SSL_VERIFYPEER, 0 );
curl_easy_setopt( m_pCURL, CURLOPT_SSL_VERIFYHOST, 0 );
curl_easy_setopt( m_pCURL, CURLOPT_VERBOSE, 0 );
curl_easy_setopt( m_pCURL, CURLOPT_POST, 1 );
curl_easy_setopt( m_pCURL, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, 0 );
curl_easy_setopt( m_pCURL, CURLOPT_NOPROGRESS, 1 );
curl_easy_setopt( m_pCURL, CURLOPT_NOSIGNAL, 1 );
curl_easy_setopt( m_pCURL, CURLOPT_TCP_FASTOPEN, 1 );
curl_easy_setopt( m_pCURL, CURLOPT_TCP_NODELAY, 1 );
curl_easy_setopt( m_pCURL, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
curl_easy_setopt( m_pCURL, CURLOPT_WRITEFUNCTION, pOnvif::_writer );
curl_easy_setopt( m_pCURL, CURLOPT_WRITEDATA, this );
};
if( m_pCURL != NULL ){
curl_easy_setopt( m_pCURL, CURLOPT_URL, url );
struct curl_slist *sList = NULL;
//Content-Type: application/soap+xml; charset=utf-8; action="http://www.onvif.org/ver20/ptz/wsdl/ContinuousMove"
//Connection: Close
sList = curl_slist_append( sList, "Content-Type: text/xml; charset=utf-8" );
sprintf( tBuffer, "Content-Length: %d", strlen(post_string) );
sList = curl_slist_append( sList, tBuffer );
@ -1818,6 +1885,7 @@ bool pOnvif::_send_request( CSTR url, CSTR post_string ){
int pOnvif::_writer( char *data, size_t size, size_t nmemb, pOnvif *Ptr ){
if( Ptr == NULL ) return 0;
//TLOG("*");
memcpy( (Ptr->m_pLastResponse + Ptr->m_pLastIndex), data, size*nmemb );
Ptr->m_pLastIndex += size*nmemb;
return size*nmemb;

17
lib/data/ponvif/ponvif.h

@ -20,7 +20,7 @@
#define PONVIF_DEFAULT_DISCOVERYMCASTPORT 3702
#define PONVIF_DEFAULT_DISCOVERYTIMEOUT 12
#define PONVIF_PACK_DISCOVERY "<?xml version=\"1.0\" encoding=\"UTF-8\"?><e:Envelope xmlns:e=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:w=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:d=\"http://schemas.xmlsoap.org/ws/2005/04/discovery\" xmlns:dn=\"http://www.onvif.org/ver10/network/wsdl\"><e:Header><w:MessageID>uuid:84ede3de-7dec-11d0-c360-f01234567890</w:MessageID><w:To e:mustUnderstand=\"true\">urn:schemas-xmlsoap-org:ws:2005:04:discovery</w:To><w:Action a:mustUnderstand=\"true\">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</w:Action></e:Header><e:Body><d:Probe><d:Types>dn:NetworkVideoTransmitter</d:Types></d:Probe></e:Body></e:Envelope>"
#define PONVIF_PACK_DISCOVERY "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:w=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:d=\"http://schemas.xmlsoap.org/ws/2005/04/discovery\" xmlns:dn=\"http://www.onvif.org/ver10/network/wsdl\"><s:Header><w:MessageID>uuid:84ede3de-7dec-11d0-c360-f01234567890</w:MessageID><w:To e:mustUnderstand=\"true\">urn:schemas-xmlsoap-org:ws:2005:04:discovery</w:To><w:Action a:mustUnderstand=\"true\">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</w:Action></s:Header><s:Body><d:Probe><d:Types>dn:NetworkVideoTransmitter</d:Types></d:Probe></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_SYS_DTS "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetSystemDateAndTime xmlns=\"http://www.onvif.org/ver10/device/wsdl\"/></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_CAPABILITIES "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetCapabilities xmlns=\"http://www.onvif.org/ver10/device/wsdl\"><Category>All</Category></GetCapabilities></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_VIDEO_SOURCES "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetVideoSources xmlns=\"http://www.onvif.org/ver10/media/wsdl\"/></s:Body></s:Envelope>"
@ -37,10 +37,11 @@
#define PONVIF_PACK_SET_PRESET "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><SetPreset xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><PresetName>%s</PresetName></SetPreset></s:Body></s:Envelope>"
#define PONVIF_PACK_RELATIVE_MOVE "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><RelativeMove xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><Translation><PanTilt x=\"%%TRANSLATIONPANTILTX%%\" y=\"%%TRANSLATIONPANTILTY%%\" space=\"http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Translation><Speed><PanTilt x=\"%%SPEEDPANTILTX%%\" y=\"%%SPEEDPANTILTY%%\" space=\"http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Speed></RelativeMove></s:Body></s:Envelope>"
#define PONVIF_PACK_RELATIVE_ZOOM "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><RelativeMove xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><Translation><Zoom x=\"%%ZOOM%%\" space=\"http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Translation><Speed><Zoom x=\"%%SPEEDZOOM%%\" space=\"http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Speed></RelativeMove></s:Body></s:Envelope>"
#define PONVIF_PACK_ABSOLUTE_MOVE "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><AbsoluteMove xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><Position><PanTilt x=\"%0.5f\" y=\"%0.5f\" space=\"http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/><Zoom x=\"%0.5f\" space=\"http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Position></AbsoluteMove></s:Body></s:Envelope>"
#define PONVIF_PACK_CONTINUOUS_MOVE "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><ContinuousMove xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><Velocity><PanTilt x=\"%%VELOCITYPANTILTX%%\" y=\"%%VELOCITYPANTILTY%%\" space=\"http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Velocity></ContinuousMove></s:Body></s:Envelope>"
#define PONVIF_PACK_CONTINUOUS_ZOOM "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><ContinuousMove xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><Velocity><Zoom x=\"%%ZOOM%%\" space=\"http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Velocity></ContinuousMove></s:Body></s:Envelope>"
#define PONVIF_PACK_PTZ_STOP "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Stop xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><PanTilt>%%PANTILT%%</PanTilt><Zoom>%%ZOOM%%</Zoom></Stop></s:Body></s:Envelope>"
#define PONVIF_PACK_ABSOLUTE_MOVE "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><AbsoluteMove xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><Position><PanTilt x=\"%0.5f\" y=\"%0.5f\" xmlns=\"http://www.onvif.org/ver10/schema\"/><Zoom x=\"%0.5f\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Position></AbsoluteMove></s:Body></s:Envelope>"
#define PONVIF_PACK_CONTINUOUS_MOVE "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><ContinuousMove xmlns=\"http://www.onvif.org/ver10/ptz/wsdl\"><ProfileToken>%s</ProfileToken><Velocity><PanTilt x=\"%0.5f\" y=\"%0.5f\" space=\"http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Velocity></ContinuousMove></s:Body></s:Envelope>"
//#define PONVIF_PACK_CONTINUOUS_MOVE_A "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:tptz=\"http://www.onvif.org/ver20/ptz/wsdl\" xmlns:tt=\"http://www.onvif.org/ver10/schema\"><soap:Body><tptz:ContinuousMove><tptz:ProfileToken>Profile_1</tptz:ProfileToken><tptz:Velocity><tt:PanTilt x=\"1\" y=\"1\"/><tt:Zoom x=\"1\"/></tptz:Velocity></tptz:ContinuousMove></soap:Body></soap:Envelope>"
#define PONVIF_PACK_CONTINUOUS_ZOOM "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><ContinuousMove xmlns=\"http://www.onvif.org/ver10/ptz/wsdl\"><ProfileToken>%s</ProfileToken><Velocity><Zoom x=\"%0.2f\" space=\"http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Velocity></ContinuousMove></s:Body></s:Envelope>"
#define PONVIF_PACK_PTZ_STOP "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Stop xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><PanTilt>true</PanTilt><Zoom>true</Zoom></Stop></s:Body></s:Envelope>"
#define PONVIF_ENVELOPE_EXT "<?xml version=\"1.0\" encoding=\"UTF-8\"?><e:Envelope xmlns:e=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:w=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:d=\"http://schemas.xmlsoap.org/ws/2005/04/discovery\" xmlns:dn=\"http://www.onvif.org/ver10/network/wsdl\">%s%s</e:Envelope>"
#define PONVIF_ENVELOPE_SIM "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">%s%s</s:Envelope>"
@ -427,6 +428,12 @@ class pOnvif{
CSTR m_pDiscoveryMCastIP;
int m_nDiscoveryMCastPort;
bool m_bDiscoveryHideDuplicates;
/*
char UP[128];
char HEADER_STR1[128];
char HEADER_STR2[128];
struct curl_slist * HEADER;
*/
static int _writer( char *data, size_t size, size_t nmemb, pOnvif *Ptr );
public:
pOnvif();

2
lib/data/protocol/onvifMediaObserver.h

@ -28,7 +28,7 @@
#define HTTPMU_HOST_ADDRESS "239.255.255.250"
#define HTTPMU_HOST_PORT 3702
#define DEBUG_ONVIF_PRINTOUT_MESSAGES
//#define DEBUG_ONVIF_PRINTOUT_MESSAGES
/*
#define SEARCH_REQUEST_STRING "M-SEARCH * HTTP/1.1\r\nST:ssdp:all\r\nMX: 3\r\nMAN:\"ssdp:discover\"\r\nHOST: 239.255.255.250:1900\r\n\r\n"

6
lib/data/protocol/protocol.cpp

@ -25,7 +25,7 @@ protocolParser::protocolParser() : m_mBufferProtectorMutex(){
};
protocolParser::~protocolParser(){
# ifdef DEBUG
# ifdef DEBUG_EXTRA
LOG("Destructor Begin");
# endif
m_mBufferProtectorMutex.unlock();
@ -42,7 +42,7 @@ protocolParser::~protocolParser(){
if( m_pParserBuffer != NULL ) {
free( m_pParserBuffer );
};
# ifdef DEBUG
# ifdef DEBUG_EXTRA
LOG("Destructor End");
# endif
};
@ -90,7 +90,9 @@ CONNECTION_STATUS protocolParser::getConnectionStatus( void ){
};
bool protocolParser::setTransport( basicTransport* Transport, bool CAE ){
#ifdef DEBUG_EXTRA
LOG("Set Transport Req");
#endif
if( CAE ){
if (m_oDataTransport != NULL) {
LOG_ERROR("Transport Already Assigned!");

4
lib/data/protocol/protocol.h

@ -29,8 +29,8 @@ typedef std::vector< protocolPackage *> packagePoll;
class protocolParser {
private:
basicLogCollection *m_pLog;
U8 *m_pParserBuffer;
basicLogCollection * m_pLog;
U8 * m_pParserBuffer;
size_t m_nParserDataCount;
bool m_bBufferAltered;
basicMutex m_mBufferProtectorMutex;

4
lib/data/protocol/protocolLGS2D.cpp

@ -22,11 +22,11 @@ protocolLGS_2D::protocolLGS_2D( basicTransport *Transport, U8 DeviceID ):protoco
};
protocolLGS_2D::~protocolLGS_2D(){
# ifdef DEBUG
# ifdef DEBUG_EXTRA
LOG("Destructor Begin");
# endif
m_mInquiryMutex.unlock();
# ifdef DEBUG
# ifdef DEBUG_EXTRA
LOG("Destructor End");
# endif
};

16
lib/data/protocol/protocolPTZ_ONVIF.cpp

@ -49,7 +49,7 @@ bool protocolPTZ_ONVIF::setPassword( CSTR password ){
bool protocolPTZ_ONVIF::create( void ){
if (!protocolPTZ::create()){
LOG("KAKA!");
LOG_ERROR("protocolPTZ::create Failure!");
return false;
};
if( m_pSettings!= NULL ) {
@ -79,8 +79,11 @@ bool protocolPTZ_ONVIF::create( void ){
m_pOnVif->setIPAddress( m_pDeviceURI );
m_pOnVif->setUsername( m_pUser );
m_pOnVif->setPassword( m_pPassword );
LOG("PONVIF BEFORE CREATE");
if( m_pOnVif->create() ){
LOG("CREATE OK -> Get Profile");
m_pProfile = m_pOnVif->getProfiles()->at(0);
LOG("Get Profile OK");
return true;
} else {
LOG("PONVIF CREATION ERROR!");
@ -117,8 +120,15 @@ bool protocolPTZ_ONVIF::move( uint32_t MoveMatrix ){
} else {
Speed_z = -m_dZoomSpeed;
};
if( m_pOnVif->ptz_ContinuousMove( m_pProfile->profiletoken, Speed_x , Speed_y ) ){
return m_pOnVif->ptz_ContinuousMoveZoom( m_pProfile->profiletoken, Speed_z );
bool res = true;
if( ( MoveMatrix & ( PTZ_DRIVE_PAN_MASK | PTZ_DRIVE_TILT_MASK ) ) != 0 ) {
res = m_pOnVif->ptz_ContinuousMove( m_pProfile->profiletoken, Speed_x , Speed_y );
};
if( res ){
if(( MoveMatrix & PTZ_DRIVE_ZOOM_MASK) == 0 ) {
return true;
};
return m_pOnVif->ptz_ContinuousMoveZoom( m_pProfile->profiletoken, Speed_z );
};
} else {
return m_pOnVif->ptz_Stop( m_pProfile->profiletoken, true, true );

11
lib/data/transport/transportSocket.cpp

@ -38,11 +38,13 @@ transportSocket::~transportSocket(){
# endif
};
/*
bool transportSocket::create( void ){
m_bInitComplete = init();
if( m_bInitComplete ) setConnectionStatus( CS_CONNECTED );
return m_bInitComplete;
};
}
;*/
void transportSocket::m_fThreadAProc(void){
int index;
@ -95,12 +97,15 @@ void transportSocket::m_fThreadBProc(void){
do{
m_mQueueProtectorMutex.lock();
if( m_vParsers.size() ){
for (parseQueue::iterator index = m_vParsers.begin(); index != m_vParsers.end(); index++) (*index)->parse(m_pInputBuffer, m_nInputBufferSize);
m_nInputBufferSize = 0;
for (parseQueue::iterator index = m_vParsers.begin(); index != m_vParsers.end(); index++) (*index)->parse(m_pInputBuffer, m_nInputBufferSize);
m_nInputBufferSize = 0;
m_mQueueProtectorMutex.unlock();
} else {
m_nInputBufferSize = 0;
m_mQueueProtectorMutex.unlock();
#ifdef DEBUG_EXTRA
LOG_ERROR("Try to parse data but No Parsers Assigned!");
#endif
SLEEP(100);
};
} while( ( m_vParsers.size() == 0 ) && ( m_bThreadBStatus < TH_ENDED ) && ( m_bThreadBStatus < TH_ENDED ) );

2
lib/data/transport/transportSocket.h

@ -29,7 +29,7 @@ public:
transportSocket();
virtual ~transportSocket();
bool sendData(unsigned char *Data, int DataSize);
virtual bool create( void );
//virtual bool create( void );
};

89
lib/hardware/uart/serialSOL.cpp

@ -31,41 +31,53 @@ serialSOL::serialSOL( SOL_PORT_SETTINGS *PortSettings ): transportSocket(){
};
bool serialSOL::closePort(){
char tBuff[128];
serialSOL::~serialSOL(){
char tBuff[128];
// switch( m_sPortSettings.eConnectionType ){
switch( m_eType ) {
case SOL_UDP_CLIENT:
case SOL_TCP_CLIENT:
case SOL_UDP_SERVER: {
#ifdef __linux__
close( m_nSocketFD );
#else
// When your application is finished receiving datagrams close the socket.
LOG("Server: Finished receiving.Closing the listening socket...");
if( closesocket(m_sSocket) != 0 ){
sprintf(tBuff, "closesocket() failed!Error code : %ld", WSAGetLastError());
LOG_ERROR(tBuff);
} else {
LOG("closesocket() is OK...");
};
// When your application is finished call WSACleanup.
LOG("Server: Cleaning up...");
if (WSACleanup() != 0) {
sprintf(tBuff, "WSACleanup() failed!Error code : %ld", WSAGetLastError());
LOG_ERROR(tBuff);
} else {
LOG("WSACleanup() is OK");
};
#endif
break;
};
case SOL_TCP_SERVER:{
close( m_nSocketFD );
break;
setConnectionStatus( CS_DISCONNECTED );
if( m_bThreadAStatus != TH_PRE_INIT && m_bThreadBStatus != TH_PRE_INIT ){
uninit();
};
if( m_nSocketFD != -1 ) {
switch( m_eType ) {
case SOL_UDP_CLIENT:
case SOL_TCP_CLIENT:
case SOL_UDP_SERVER: {
#ifdef __linux__
close( m_nSocketFD );
#else
// When your application is finished receiving datagrams close the socket.
LOG("Server: Finished receiving.Closing the listening socket...");
if( closesocket(m_sSocket) != 0 ){
sprintf(tBuff, "closesocket() failed!Error code : %ld", WSAGetLastError());
LOG_ERROR(tBuff);
} else {
LOG("closesocket() is OK...");
};
// When your application is finished call WSACleanup.
LOG("Server: Cleaning up...");
if (WSACleanup() != 0) {
sprintf(tBuff, "WSACleanup() failed!Error code : %ld", WSAGetLastError());
LOG_ERROR(tBuff);
} else {
LOG("WSACleanup() is OK");
};
#endif
break;
};
case SOL_TCP_SERVER:{
close( m_nSocketFD );
break;
};
};
};
m_nSocketFD = -1;
};
return true;
};
serialSOL::~serialSOL(){
closePort();
};
#ifdef __linux__
@ -92,6 +104,7 @@ serialSOL::~serialSOL(){
bool serialSOL::create( CSTR address, uint16_t port, int Speed, SOL_TYPE t ){
if( m_eType == SOL_NOT_DEFINED ){
if ( t == SOL_NOT_DEFINED ) {
LOG_ERROR("No Connection Type Defined!");
return false;
};
m_eType = t;
@ -101,7 +114,10 @@ bool serialSOL::create( CSTR address, uint16_t port, int Speed, SOL_TYPE t ){
};
};
if( m_nPort == 0 ){
if( port == 0 ) return false;
if( port == 0 ) {
LOG_ERROR("No Port Defined!");
return false;
};
m_nPort = port;
} else {
if( port != 0 ) {
@ -109,7 +125,10 @@ bool serialSOL::create( CSTR address, uint16_t port, int Speed, SOL_TYPE t ){
};
};
if( m_nSpeed == 0 ){
if( Speed == 0 ) return false;
if( Speed == 0 ){
LOG_ERROR("No Speed Defined!");
return false;
};
m_nSpeed = Speed;
} else {
if( Speed != 0 ) {

3
lib/hardware/uart/serialSOL.h

@ -75,7 +75,8 @@ class serialSOL: public transportSocket {
explicit serialSOL( SOL_TYPE t = SOL_NOT_DEFINED );
explicit serialSOL( SOL_PORT_SETTINGS *PortSettings );
virtual ~serialSOL();
bool create( CSTR address = NULL, uint16_t port = 0, int Speed = 0, SOL_TYPE t = SOL_NOT_DEFINED );
bool create( CSTR address, uint16_t port, int Speed = 0, SOL_TYPE t = SOL_NOT_DEFINED );
bool closePort();
};

235
lib/rgoose/rgooseCamera.cpp

@ -9,6 +9,9 @@
#include "../data/protocol/protocolPTZ_ONVIF.h"
#include "../data/protocol/protocolPTZ_PELCO.h"
#include "rgooseKernel.h"
#include "rgooseModuleEmbedVideo.h"
#define LOG( X ) m_pLog->Log( "RCAM", this, X )
#ifdef DEBUG
@ -32,6 +35,7 @@ static float AC_imager_height[12] = { 3.0f, 3.416f, 3.6f, 3.96f, 4.8f, 5.319f, 6
ARGUS_Camera::ARGUS_Camera(): basicThread(){
m_pLog = basicLogCollection::getInstance();
m_pEvtHeap = basicEventHeap::getInstance();
m_pDBC = argusDBC::getInstance();
m_tTimeTSeconds = 0;
m_pPosition = NULL;
m_pProtocol = NULL;
@ -39,10 +43,19 @@ ARGUS_Camera::ARGUS_Camera(): basicThread(){
m_bState = 0;
m_bBusy = true;
m_fMaxRange = m_fMinHFov = m_fMaxHFov = m_fMinVFov = m_fMaxVFov = .0f;
m_pDBC = argusDBC::getInstance();
m_nRelativeMoveCounter = 0;
m_bRelativeMoveMatrix = 0;
m_fSpeedRise = 0.03f;
m_fRM_Pan = m_fRM_Tilt = m_fRM_Zoom = .0f;
m_bSourceConnected = false;
m_pSource = NULL;
};
ARGUS_Camera::~ARGUS_Camera(){
LOG("Destruct");
m_mQPROTECTOR.unlock();
waitThreadEnd( true );
LOG("Thread Del OK");
if( m_pTransport!= NULL ) {
DBC_UART_DATA *tData = NULL;
tData = m_pDBC->getUartData( m_sCamData.uart_id );
@ -57,6 +70,7 @@ ARGUS_Camera::~ARGUS_Camera(){
};
};
};
LOG("Transport Del OK");
if( m_pProtocol != NULL ) {
switch( m_sCamData.protocol ) {
case CAM_CTRL_PROTO_VISCA:
@ -72,7 +86,16 @@ ARGUS_Camera::~ARGUS_Camera(){
delete( m_pProtocol );
};
};
LOG("Proto Del OK");
if( m_pPosition != NULL ) delete( m_pPosition );
LOG("Pos Del OK");
if( m_bSourceConnected ){
if( m_pSource != NULL ){
m_pSource->_close();
delete( m_pSource );
};
};
LOG("Stream Del OK");
};
@ -96,6 +119,9 @@ bool ARGUS_Camera::create( uint32_t id ){
m_fMaxHFov = calcFOV_mm( AC_imager_width[m_sCamData.imager_type], m_sCamData.max_f );
m_fMinVFov = calcFOV_mm( AC_imager_height[m_sCamData.imager_type], m_sCamData.min_f );
m_fMaxVFov = calcFOV_mm( AC_imager_height[m_sCamData.imager_type], m_sCamData.max_f );
if( m_sCamData.ptz_speed_step > .0f ) {
m_fSpeedRise = m_sCamData.ptz_speed_step;
};
#ifdef DEBUG
char tB[128];
LOG("Camera Info:");
@ -287,8 +313,8 @@ bool ARGUS_Camera::relativeMove( float PanSPD, float TiltSPD, float ZoomSPD ){
MoveMatrix |= PTZ_DRIVE_ZOOM_TELE;
};
};
if( MoveMatrix!= 0 ) {
m_pProtocol->setPTZSpeed( PanSPD, TiltSPD, ZoomSPD );
if( MoveMatrix != 0 ) {
m_pProtocol->setPTZSpeed( fabs(PanSPD), fabs(TiltSPD), fabs(ZoomSPD) );
};
return m_pProtocol->move( MoveMatrix );
};
@ -322,39 +348,138 @@ bool ARGUS_Camera::absoluteMove( float PanPOS, float TiltPOS, float ZoomPOS ){
void ARGUS_Camera::m_fThreadProc( void ){
m_bThreadStatus = TH_WORKING;
while (m_bThreadStatus < TH_ENDED) {
while( m_bThreadStatus < TH_ENDED ) {
//Local Recorder
if( m_bSourceConnected ) {
};
DBC_PUSHED_CMD * PUSHED = m_pDBC->getCamPushedCMD( m_sCamData.id );
if( PUSHED ) {
if( ( PUSHED->CMD & ARGUS_CAM_PCMD_CMD_MASK ) == ARGUS_CAM_PCMD_CMD_MASK ) {
switch( PUSHED->CMD ) {
case 0x80:{
//m_bWM = ANODE_WM_2D_ISSUE_FULL_RESET;
break;
};
case 0x81:{
//m_bWM = ANODE_WM_2D_GET_FAST_DRAW;
break;
};
case 0x82:{
break;
};
};
} else {
//Direct Movment Mode
if( PUSHED->CMD == ARGUS_CAM_PCMD_STOP ) {
m_bState = CAM_WS_STOP_MOVE;
} else {
char tB[64];
if( m_bState!= CAM_WS_AUTOMATED_MOVE ) m_nRelativeMoveCounter = 0;
m_bRelativeMoveMatrix = ( PUSHED->CMD ) >> 1;
m_bState = CAM_WS_AUTOMATED_MOVE;
};
};
free( PUSHED );
};
switch( m_bState ) {
case CAM_WS_INIT:{
// Init Camera - PowerMode
#ifdef DEBUG
LOG("Init Camera - PowerMode");
#endif
if( m_pProtocol->initCamera() ) m_bState = CAM_WS_WHITE_BALLANCE;
break;
};
case CAM_WS_WHITE_BALLANCE:{
// Set Speed
#ifdef DEBUG
LOG("Set WB");
#endif
if( m_pProtocol->setWhiteBalanceMode( WB_AUTO ) ) m_bState = CAM_WS_BACKLIGHT;
break;
};
case CAM_WS_BACKLIGHT:{
// Go 0
#ifdef DEBUG
LOG("Set BLC");
#endif
if( m_pProtocol->setBackLightMode( true ) ) m_bState = CAM_WS_AUTO_FOCUS;
//if( m_pProtocol->goHomePosition() ) m_bState++;
break;
};
case CAM_WS_AUTO_FOCUS:{
#ifdef DEBUG
LOG("Set AF");
#endif
if( m_pProtocol->setAutoFocus( true ) ) m_bState = CAM_WS_INIT_GO_HOME;
break;
};
case CAM_WS_INIT_GO_HOME:{
#ifdef DEBUG
LOG("INIT GO -1 -1 -1");
#endif
if( m_pProtocol->goAbsolute( -1, -1, -1 ) ){
m_bState = CAM_WS_READY;
setBusy( false );
};
break;
};
case CAM_WS_AUTOMATED_MOVE:{
m_nRelativeMoveCounter++;
if( ( m_bRelativeMoveMatrix & 0x03 ) != 0 ) {
//Pan Move
if( ( m_bRelativeMoveMatrix & 0x01 ) == 0 ) {
m_fRM_Pan -= m_fSpeedRise;
} else {
m_fRM_Pan += m_fSpeedRise;
};
};
if( ( m_bRelativeMoveMatrix & 0x0C ) != 0 ) {
//TILT Move
if( ( m_bRelativeMoveMatrix & 0x04 ) == 0 ) {
m_fRM_Tilt -= m_fSpeedRise;
} else {
m_fRM_Tilt += m_fSpeedRise;
}
};
if( ( m_bRelativeMoveMatrix & 0x30 ) != 0 ) {
//ZOOM Move
if( ( m_bRelativeMoveMatrix & 0x10 ) == 0 ) {
//Wide
m_fRM_Zoom -= m_fSpeedRise;
} else {
//Tele
m_fRM_Zoom += m_fSpeedRise;
};
};
if( m_fRM_Pan < -1.0f ) m_fRM_Pan = -1.0f;
if( m_fRM_Pan > 1.0f ) m_fRM_Pan = 1.0f;
if( m_fRM_Tilt < -1.0f ) m_fRM_Tilt = -1.0f;
if( m_fRM_Tilt > 1.0f ) m_fRM_Tilt = 1.0f;
if( m_fRM_Zoom < -1.0f ) m_fRM_Zoom = -1.0f;
if( m_fRM_Zoom > 1.0f ) m_fRM_Zoom = 1.0f;
setBusy( true );
if( !relativeMove( m_fRM_Pan, m_fRM_Tilt, m_fRM_Zoom ) ){
m_bState = CAM_WS_READY;
};
setBusy( false );
break;
};
case CAM_WS_STOP_MOVE:{
m_fRM_Pan = .0f;
m_fRM_Pan = .0f;
m_fRM_Tilt = .0f;
m_fRM_Tilt = .0f;
m_fRM_Zoom = .0f;
m_fRM_Zoom = .0f;
setBusy( true );
if( relativeStop() ){
m_bState = CAM_WS_READY;
};
setBusy( false );
break;
}
case CAM_WS_READY:{
m_mQPROTECTOR.lock();
if( m_qCAM_CMD.size() > 0 ) {
if( m_qCAM_CMD.size() ){
char tB[128];
sprintf( tB,"Queue: %d commands!", m_qCAM_CMD.size() );
LOG( tB );
@ -385,21 +510,34 @@ void ARGUS_Camera::m_fThreadProc( void ){
setBusy( false );
break;
};
case PTZ_RELOAD_CAMERA:{
LOG("Exit Command Rcpt");
m_bThreadStatus = TH_ENDED;
setBusy( true );
};
};
} else m_mQPROTECTOR.unlock();
free( tCMD );
} else {
m_mQPROTECTOR.unlock();
LOG_ERROR("Error Fetching CMD from Queue");
SLEEP( DEFAULT_THREAD_SLEEP_TIME );
};
} else {
m_mQPROTECTOR.unlock();
SLEEP( 5 );
SLEEP( DEFAULT_THREAD_SLEEP_TIME );
};
break;
};
case CAM_WS_END:{
LOG("Exit Command Rcpt");
m_bThreadStatus = TH_ENDED;
setBusy( true );
break;
};
};
SLEEP( DEFAULT_THREAD_SLEEP_TIME );
};
LOG("CTRL Loop End!");
};
bool ARGUS_Camera::inTheFOV( float lat, float lon, float alt ){
@ -594,6 +732,83 @@ bool ARGUS_Camera::lookAtWGS84( uint32_t TargetRefID, float lat, float lon, floa
return false;
};
bool ARGUS_Camera::captureFrame( CSTR fileName, uint8_t compression ){
if( m_bSourceConnected ) {
if( m_pSource != NULL ) {
};
};
return false;
};
bool ARGUS_Camera::connectToStream( uint32_t id ){
if( id ){
argusKernelModule * tKM = NULL;
argusKernel *tKRNL = NULL;
if( m_pDBC == NULL ) {
LOG_ERROR("No Database Connector!");
return false;
};
tKRNL = argusKernel::getInstance();
if( tKRNL ) {
argusModuleFactory *tMF = NULL;
tMF = tKRNL->getModuleFactory();
if( tMF ) {
tKM = tMF->getModule( ARGUS_MODULE_EMBED_VIDEO );
};
};
if( tKM ) {
DBC_MEDIA_STREAM_DATA *tDATA = m_pDBC->getMediaStreamData( id );
LOG("Module && DB OK");
if( tDATA ) {
LOG( tDATA->mrl_proto );
if( strncmp( tDATA->mrl_proto, "v4l2", 4 ) == 0 ){
LOG( tDATA->mrl );
m_pSource = new videoAVLIBSource( tDATA->mrl );
} else {
char tMRL[1024];
DBC_CAM_DATA *tCAM = m_pDBC->getCamData( tDATA->source_id );
if( tCAM ) {
sprintf( tMRL, "%s://%s:%s@%s:%d%s", tDATA->mrl_proto, tCAM->username, tCAM->password, tCAM->ip, tDATA->mrl_port, tDATA->mrl );
free( tCAM );
LOG( tMRL );
m_sMediaSource.mediaStreamId = id;
m_pSource = new videoAVLIBSource( tMRL, &m_sMediaSource );
};
};
if( m_pSource != NULL ) {
LOG("Source OK");
m_pSource->attachDestination( (argusModuleEmbedVideo*) tKM );
LOG("Finish!");
m_bSourceConnected = true;
free( tDATA );
return true;
} else {
LOG_ERROR("Video Source Stream Failure!");
};
free( tDATA );
};
} else {
#ifdef DEBUG
LOG("No Video Module!");
#endif
return true;
};
};
return false;
};
bool ARGUS_Camera::disconnectFromStream( void ){
if( m_bSourceConnected ) {
if( m_pSource ){
delete( m_pSource );
m_pSource = NULL;
};
m_bSourceConnected = false;
};
return !m_bSourceConnected;
};
#undef LOG
#undef LOG_ERROR

33
lib/rgoose/rgooseCamera.h

@ -20,6 +20,7 @@
#include "../components/base/basicThread.h"
#include "../components/base/basicMutex.h"
#include "../data/protocol/protocolPTZ.h"
#include "../data/media/video/videoAVLIBSource.h"
#include "../components/base/basicEventHeap.h"
#include "rgooseDBConnector.h"
@ -37,6 +38,11 @@
#define UART_TYPE_HARDWARE 1
#define UART_TYPE_SOL 2
#define ARGUS_CAM_PCMD_MOVE_MASK 0x7F
#define ARGUS_CAM_PCMD_CMD_MASK 0x80
#define ARGUS_CAM_PCMD_STOP 1
typedef struct S_CAM_PTZ_CMD{
uint8_t CMD;
float PAN;
@ -47,7 +53,8 @@ typedef struct S_CAM_PTZ_CMD{
typedef enum E_CAM_PTZ_CMD{
PTZ_STOP = 0,
PTZ_MOVE = 1,
PTZ_ABSOLUTE = 2
PTZ_ABSOLUTE = 2,
PTZ_RELOAD_CAMERA = 3
}PTZ_CMD;
typedef std::queue<CAM_PTZ_CMD *> CAM_PTZ_CMD_QUEUE;
@ -58,7 +65,8 @@ typedef enum E_CAM_WORKING_STATE{
CAM_WS_BACKLIGHT = 2,
CAM_WS_AUTO_FOCUS = 3,
CAM_WS_INIT_GO_HOME = 4,
CAM_WS_AUTOMATED_MOVE = 10,
CAM_WS_STOP_MOVE = 11,
CAM_WS_READY = 128,
CAM_WS_END = 255
}CAM_WORK_STATE;
@ -66,7 +74,7 @@ typedef enum E_CAM_WORKING_STATE{
class ARGUS_Camera: public basicThread {
private:
basicLogCollection * m_pLog;
DBC_CAM_DATA m_sCamData;
basicPosition * m_pPosition;
basicEventHeap * m_pEvtHeap;
argusDBC * m_pDBC;
@ -74,6 +82,7 @@ class ARGUS_Camera: public basicThread {
uint8_t m_bState;
bool m_bBusy;
float m_fMaxRange;
float m_fMinHFov;
@ -87,6 +96,13 @@ class ARGUS_Camera: public basicThread {
CAM_PTZ_CMD_QUEUE m_qCAM_CMD;
basicMutex m_mQPROTECTOR;
videoAVLIBSource * m_pSource;
uint32_t m_nRelativeMoveCounter;
uint8_t m_bRelativeMoveMatrix;
float m_fSpeedRise;
float m_fRM_Pan;
float m_fRM_Tilt;
float m_fRM_Zoom;
/* Methotds Sutable to Control Camera */
bool relativeMove( float PanSPD, float TiltSPD, float ZoomSPD );
@ -94,17 +110,22 @@ class ARGUS_Camera: public basicThread {
bool absoluteMove( float PanPOS, float TiltPOS, float ZoomPOS );
protected:
DBC_CAM_DATA m_sCamData;
MEDIA_SOURCE_DESC m_sMediaSource;
bool m_bSourceConnected;
bool inTheFOV( float lat, float lon, float alt );
bool lookAtWGS84( uint32_t TargetRefID, float lat, float lon, float alt );
void setBusy( bool Status );
bool captureFrame( CSTR fileName, uint8_t compression = 0 );
void setBusy( bool Status );
bool connectToStream( uint32_t id );
bool disconnectFromStream( void );
virtual void m_fThreadProc( void );
public:
ARGUS_Camera();
~ARGUS_Camera();
bool create( uint32_t id );
};
typedef std::vector<ARGUS_Camera *> vectorARGUS_Cameras;

440
lib/rgoose/rgooseDBConnector.cpp

@ -97,7 +97,7 @@ bool argusDBC::cleanResources( uint32_t SiteID, uint32_t ServerNodeID, bool all
} else {
sprintf( tQBuf, "UPDATE `resources` SET `active`=0 WHERE `site_id`=%d AND `node_id`=%d AND ( `type`=100 OR `type`=101 OR `type`=103 OR `type`=120 )", SiteID, ServerNodeID );
};
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
@ -112,9 +112,7 @@ bool argusDBC::updateIPCam( uint32_t SiteID, CSTR uuid, CSTR Addr ){
char tIpBuf[CTEXT];
char *tPos;
char *tPos2;
#ifdef DEBUG
LOG("Cam Update");
#endif
tPos = strstr(Addr,"//");
if( tPos != NULL ) {
tPos2 = strstr( tPos + 2,"/");
@ -137,7 +135,7 @@ bool argusDBC::updateIPCam( uint32_t SiteID, CSTR uuid, CSTR Addr ){
uuid,
SiteID
);
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
@ -152,9 +150,7 @@ bool argusDBC::updateIPCam( uint32_t SiteID, uint32_t CamID, CSTR Addr ){
char tIpBuf[CTEXT];
char *tPos;
char *tPos2;
#ifdef DEBUG
LOG("Cam Update");
#endif
tPos = strstr(Addr,"//");
if( tPos != NULL ) {
tPos2 = strstr( tPos + 2,"/");
@ -177,12 +173,12 @@ bool argusDBC::updateIPCam( uint32_t SiteID, uint32_t CamID, CSTR Addr ){
CamID,
SiteID
);
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
sprintf(tQBuf,"UPDATE media_streams SET `valid`=1 WHERE source_id=%d AND source_type='D'", CamID );
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
@ -190,7 +186,7 @@ bool argusDBC::updateIPCam( uint32_t SiteID, uint32_t CamID, CSTR Addr ){
};
return false;
};
/*
bool argusDBC::addIPCam( uint32_t SiteID, resultWoWo *tPtr ){
if(m_bIsConnected) {
char tQBuf[1024];
@ -199,9 +195,7 @@ bool argusDBC::addIPCam( uint32_t SiteID, resultWoWo *tPtr ){
char tPath[CTEXT];
char *tPos;
char *tPos2;
#ifdef DEBUG
LOG("Add New Camera Record");
#endif
memcpy( tProto, tPtr->XAddrs, 5 );
tProto[5] = (char)0;
if( tProto[4] == ':') tProto[4] = (char)0;
@ -236,7 +230,7 @@ bool argusDBC::addIPCam( uint32_t SiteID, resultWoWo *tPtr ){
//tPtr->XAddrs,
tIpBuf
);
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
@ -244,7 +238,7 @@ bool argusDBC::addIPCam( uint32_t SiteID, resultWoWo *tPtr ){
};
return false;
};
*/
bool argusDBC::addIPCam( uint32_t SiteID, OBSERVER_RESULT *tPtr ){
if(m_bIsConnected) {
char tQBuf[1024];
@ -253,9 +247,6 @@ bool argusDBC::addIPCam( uint32_t SiteID, OBSERVER_RESULT *tPtr ){
char tPath[CTEXT];
char *tPos;
char *tPos2;
#ifdef DEBUG
LOG("Add New Camera Record");
#endif
memcpy( tProto, tPtr->XAddrs, 5 );
tProto[5] = (char)0;
if( tProto[4] == ':') tProto[4] = (char)0;
@ -290,7 +281,7 @@ bool argusDBC::addIPCam( uint32_t SiteID, OBSERVER_RESULT *tPtr ){
//tPtr->XAddrs,
tIpBuf
);
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
@ -403,7 +394,7 @@ bool argusDBC::getAllCamRecords( uint32_t SiteID, vectorCamRecords &VR ){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT * FROM cameras WHERE `site_id`=%d AND `type`=2 AND `status`=2", SiteID );
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
@ -553,12 +544,12 @@ bool argusDBC::getAllCamRecords( uint32_t SiteID, vectorCamRecords &VR ){
DBC_INT_LIST *argusDBC::listNodes( uint32_t SiteID ){
DBC_INT_LIST * tVal = NULL;
if(m_bIsConnected){
char tQBuf[CTEXT];
if( m_bIsConnected ){
char tQBuf[1024];
AAssoc *result;
sprintf(tQBuf, "SELECT id FROM nodes WHERE `site_id`=%d AND `type` > 0", SiteID );
#ifdef DEBUG
//LOG(tQBuf);
sprintf( tQBuf, "SELECT `id` FROM `nodes` WHERE `site_id`=%d AND `type` > 0", SiteID );
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
if( result!= NULL ) {
@ -567,7 +558,7 @@ DBC_INT_LIST *argusDBC::listNodes( uint32_t SiteID ){
tVal = new DBC_INT_LIST();
if( tVal != NULL ) {
Assoc::iterator it;
for(int i=0;i<result->size();i++) {
for(int i=0; i <result->size();i++) {
cArr = result->at(i);
it = cArr->find("id");
if( it != cArr->end() ){
@ -598,8 +589,8 @@ DBC_INT_LIST *argusDBC::listNewNodes( uint32_t SiteID, DBC_INT_LIST *old_ids ){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT id FROM nodes WHERE `site_id`=%d AND `type` > 0 AND `id` NOT IN(%s)", SiteID, tParam );
#ifdef DEBUG
//LOG(tQBuf);
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
if( result!= NULL ) {
@ -629,7 +620,7 @@ DBC_INT_LIST *argusDBC::listCamMediaStreams( uint32_t CAMID ){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT id FROM media_streams WHERE `source_id`=%d AND `valid`=1", CAMID );
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
@ -654,13 +645,80 @@ DBC_INT_LIST *argusDBC::listCamMediaStreams( uint32_t CAMID ){
return tVal;
};
DBC_NET_IF_DATA *argusDBC::getNetworkInterfaceData( uint32_t ID ){
DBC_NET_IF_DATA * tVal = NULL;
if(m_bIsConnected){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT * FROM `network_interfaces` WHERE `id`=%d", ID );
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
if( result!= NULL ) {
if( result->size() > 0 ) {
Assoc *cArr;
tVal = (DBC_NET_IF_DATA*) malloc(sizeof(DBC_NET_IF_DATA));
if( tVal != NULL ) {
Assoc::iterator it;
cArr = result->at(0);
it = cArr->find("address");
if( it != cArr->end() ){
strncpy( tVal->address, it->second.c_str(), 64 );
};
it = cArr->find("gateway");
if( it != cArr->end() ){
strncpy( tVal->gateway, it->second.c_str(), 64 );
};
it = cArr->find("mask");
if( it != cArr->end() ){
strncpy( tVal->netmask, it->second.c_str(), 64 );
};
it = cArr->find("broadcast");
if( it != cArr->end() ){
strncpy( tVal->broadcast, it->second.c_str(), 64 );
};
};
};
};
deleteResult( result );
};
return tVal;
};
uint32_t argusDBC::getNetworkInterfaceID( CSTR key ){
uint32_t tVal = 0;
if(m_bIsConnected){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT id FROM `network_interfaces` WHERE `key`='%s'", key );
#ifdef DEBUG_EXTRA
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() ){
tVal = atoi( it->second.c_str() );
};
};
};
deleteResult( result );
};
return tVal;
};
DBC_NODE_DATA *argusDBC::getNodeData( uint32_t ID ){
DBC_NODE_DATA * tVal = NULL;
if(m_bIsConnected){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT * FROM nodes WHERE `id`=%d", ID );
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
@ -669,6 +727,7 @@ DBC_NODE_DATA *argusDBC::getNodeData( uint32_t ID ){
Assoc *cArr;
tVal = (DBC_NODE_DATA*) malloc(sizeof(DBC_NODE_DATA));
if( tVal != NULL ) {
memset( tVal, 0, sizeof(DBC_NODE_DATA));
Assoc::iterator it;
cArr = result->at(0);
it = cArr->find("id");
@ -683,6 +742,10 @@ DBC_NODE_DATA *argusDBC::getNodeData( uint32_t ID ){
if( it != cArr->end() ){
tVal->aux_id = atoi( it->second.c_str() );
};
it = cArr->find("aux_parameter");
if( it != cArr->end() ){
tVal->aux_parameter = atoi( it->second.c_str() );
};
it = cArr->find("name");
if( it != cArr->end() ){
sprintf( tVal->name, it->second.c_str() );
@ -1088,41 +1151,50 @@ uint8_t argusDBC::getLRFDataStatus( uint32_t ID ){
return RetVal;
};
uint8_t argusDBC::getLRFPushedCMD( uint32_t ID ){
uint8_t RetVal = 0;
DBC_PUSHED_CMD *argusDBC::getLRFPushedCMD( uint32_t ID ){
DBC_PUSHED_CMD *RetVal = NULL;
if(m_bIsConnected){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT `pushed_cmd` FROM `lrf_sensors` WHERE `id`=%d", ID );
sprintf(tQBuf, "SELECT `pushed_cmd`, `pushed_param` FROM `lrf_sensors` WHERE `id`=%d AND `pushed_cmd` > 0", ID );
#ifdef DEBUG
//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("pushed_cmd");
if( it != cArr->end() ){
RetVal = atoi( it->second.c_str() );
RetVal = (DBC_PUSHED_CMD*)malloc(sizeof(DBC_PUSHED_CMD));
if( RetVal ) {
Assoc *cArr;
Assoc::iterator it;
cArr = result->at(0);
it = cArr->find("pushed_cmd");
if( it != cArr->end() ){
RetVal->CMD = atoi( it->second.c_str() );
};
it = cArr->find("pushed_param");
if( it != cArr->end() ){
RetVal->PARAM = atoi( it->second.c_str() );
};
};
};
//Only If Result is Fetched - Clear Current CMD
sprintf(tQBuf, "UPDATE `lrf_sensors` SET `pushed_cmd`=0, `pushed_param`=0 WHERE `id`=%d", ID );
m_pDatabase->SilentQuery( tQBuf );
};
deleteResult( result );
sprintf(tQBuf, "UPDATE `lrf_sensors` SET `pushed_cmd`=0 WHERE `id`=%d", ID );
m_pDatabase->SilentQuery( tQBuf );
};
return RetVal;
};
DBC_INT_LIST *argusDBC::listModules( uint32_t ServerID ){
DBC_INT_LIST * tVal = NULL;
if(m_bIsConnected){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT id FROM server_modules WHERE `server_id`=%d AND `enabled`=1", ServerID );
sprintf(tQBuf, "SELECT `id` FROM `server_modules` WHERE `server_id`=%d AND `enabled`=1", ServerID );
#ifdef DEBUG
LOG(tQBuf);
//LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
if( result!= NULL ) {
@ -1146,12 +1218,12 @@ DBC_INT_LIST *argusDBC::listModules( uint32_t ServerID ){
return tVal;
};
DBC_INT_LIST *argusDBC::listFilters( uint32_t SiteID, uint32_t ServerID ){
DBC_INT_LIST *argusDBC::listFilters( uint32_t ServerID ){
DBC_INT_LIST * tVal = NULL;
if(m_bIsConnected){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT id FROM server_modules WHERE `server_id`=%d AND `enabled`=1", ServerID );
sprintf(tQBuf, "SELECT `id` FROM `target_filters` WHERE `server_id`=%d AND `enabled`=1", ServerID );
#ifdef DEBUG
LOG(tQBuf);
#endif
@ -1177,7 +1249,7 @@ DBC_INT_LIST *argusDBC::listFilters( uint32_t SiteID, uint32_t ServerID ){
return tVal;
};
DBC_INT_LIST *argusDBC::listMediaStreams( uint32_t SiteId, uint32_t MediaServerID, uint8_t listMode ){
DBC_INT_LIST *argusDBC::listMediaServerStreams( uint32_t SiteId, uint32_t MediaServerID, uint8_t listMode ){
DBC_INT_LIST * tVal = NULL;
if(m_bIsConnected){
char tQBuf[CTEXT];
@ -1212,6 +1284,46 @@ DBC_INT_LIST *argusDBC::listMediaStreams( uint32_t SiteId, uint32_t MediaServerI
return tVal;
};
DBC_INT_LIST *argusDBC::listMediaStreams( uint32_t SiteId, uint8_t listMode ){
DBC_INT_LIST * tVal = NULL;
if(m_bIsConnected){
char tQBuf[CTEXT];
AAssoc *result;
switch( listMode ){
case LIST_VALID_RECORDS:
sprintf(tQBuf, "SELECT id FROM media_streams WHERE `valid`=1 AND `site_id`=%d", SiteId );
break;
case LIST_INVALID_RECORDS:
sprintf(tQBuf, "SELECT id FROM media_streams WHERE `valid`=0 AND `site_id`=%d", SiteId );
break;
default:
sprintf(tQBuf, "SELECT id FROM media_streams WHERE `site_id`=%d", SiteId );
};
#ifdef DEBUG
//LOG(tQBuf);
#endif
result = m_pDatabase->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 *argusDBC::listDetectionProfileIDs( uint32_t nodeID ){
DBC_INT_LIST * tVal = NULL;
if(m_bIsConnected){
@ -1358,9 +1470,9 @@ DBC_INT_LIST *argusDBC::listNewModules( uint32_t ServerID, DBC_INT_LIST * old_id
if(m_bIsConnected){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT id FROM server_modules WHERE `server_id`=%d AND `enabled`=1 AND `id` NOT IN (%s)", ServerID, tParam );
sprintf(tQBuf, "SELECT `id` FROM `server_modules` WHERE `server_id`=%d AND `enabled`=1 AND `id` NOT IN (%s)", ServerID, tParam );
#ifdef DEBUG
LOG(tQBuf);
//LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
if( result!= NULL ) {
@ -1389,7 +1501,7 @@ uint32_t argusDBC::getCamId( CSTR UUID ){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT id FROM cameras WHERE `uuid`='%s'", UUID );
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
@ -1416,7 +1528,7 @@ DBC_CAM_DATA *argusDBC::getCamData( uint32_t ID ){
AAssoc *result;
sprintf(tQBuf, "SELECT * FROM cameras WHERE `id`=%d", ID );
#ifdef DEBUG
LOG(tQBuf);
//LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
if( result!= NULL ) {
@ -1508,6 +1620,10 @@ DBC_CAM_DATA *argusDBC::getCamData( uint32_t ID ){
if( it != cArr->end() ){
tVal->max_f = atof( it->second.c_str() );
};
it = cArr->find("ptz_speed_step");
if( it != cArr->end() ){
tVal->ptz_speed_step = atof( it->second.c_str() );
};
it = cArr->find("pan_model");
if( it != cArr->end() ){
tVal->pan_model = atoi( it->second.c_str() );
@ -1572,13 +1688,49 @@ DBC_CAM_DATA *argusDBC::getCamData( uint32_t ID ){
return tVal;
};
DBC_PUSHED_CMD *argusDBC::getCamPushedCMD( uint32_t ID ){
DBC_PUSHED_CMD *RetVal = NULL;
if(m_bIsConnected){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT `pushed_cmd`, `pushed_param` FROM `cameras` WHERE `id`=%d AND `pushed_cmd` > 0", ID );
#ifdef DEBUG
//LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
if( result!= NULL ) {
if( result->size() > 0 ) {
RetVal = (DBC_PUSHED_CMD*)malloc(sizeof(DBC_PUSHED_CMD));
if( RetVal ) {
Assoc *cArr;
Assoc::iterator it;
cArr = result->at(0);
it = cArr->find("pushed_cmd");
if( it != cArr->end() ){
RetVal->CMD = atoi( it->second.c_str() );
};
it = cArr->find("pushed_param");
if( it != cArr->end() ){
RetVal->PARAM = atoi( it->second.c_str() );
};
};
};
//Only If Result is Fetched - Clear Current CMD
sprintf(tQBuf, "UPDATE `cameras` SET `pushed_cmd`=0, `pushed_param`=0 WHERE `id`=%d", ID );
m_pDatabase->SilentQuery( tQBuf );
};
deleteResult( result );
};
return RetVal;
};
DBC_MODULE_DATA *argusDBC::getModuleData( uint32_t ID ){
DBC_MODULE_DATA *tVal = NULL;
if(m_bIsConnected){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT * FROM server_modules WHERE `id`=%d", ID );
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
@ -1693,6 +1845,14 @@ DBC_MEDIA_STREAM_DATA *argusDBC::getMediaStreamData( uint32_t ID ){
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("mrl_proto");
if( it != cArr->end() ){
sprintf( tVal->mrl_proto, it->second.c_str() );
@ -1901,14 +2061,13 @@ void argusDBC::registerServer(uint32_t SiteID, CSTR identity ){
};
void argusDBC::unregisterServer(uint32_t ServerID, uint32_t NodeID ){
if(m_bIsConnected){
if( setNodeOffline( NodeID ) ){
char tQBuf[CTEXT];
sprintf(tQBuf,"UPDATE servers SET `online`=0 WHERE `id` = %d", ServerID );
sprintf(tQBuf,"UPDATE servers SET `online`=0 WHERE `id`=%d", ServerID );
#ifdef DEBUG
//LOG(tQBuf);
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
setNodeOffline( NodeID );
};
};
@ -1916,14 +2075,14 @@ bool argusDBC::setNodeOnline( uint32_t NodeID, uint8_t status ){
if(m_bIsConnected){
char tQBuf[CTEXT];
if( NodeID ) {
sprintf(tQBuf,"UPDATE nodes SET `online`=%d WHERE `id` = %d", status, NodeID );
sprintf(tQBuf,"UPDATE nodes SET `online`=%d WHERE `id`=%d", status, NodeID );
#ifdef DEBUG
//LOG(tQBuf);
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
sprintf(tQBuf,"UPDATE `resources` SET `active`=1 WHERE `node_id` = %d", NodeID );
sprintf(tQBuf,"UPDATE `resources` SET `active`=1 WHERE `node_id`=%d", NodeID );
#ifdef DEBUG
//LOG(tQBuf);
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
return true;
@ -1938,12 +2097,12 @@ bool argusDBC::setNodeOffline( uint32_t NodeID ){
if( NodeID ) {
sprintf(tQBuf,"UPDATE nodes SET `online`=0 WHERE `id` = %d", NodeID );
#ifdef DEBUG
//LOG(tQBuf);
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
sprintf(tQBuf,"UPDATE `resources` SET `active`=0 WHERE `node_id` = %d", NodeID );
#ifdef DEBUG
//LOG(tQBuf);
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
return true;
@ -2136,7 +2295,7 @@ uint32_t argusDBC::addResource( uint32_t SiteID, uint32_t NodeID, uint8_t type,
char tQBuf[2048];
CSTR tMD5 = MD5String( devName );
if( tMD5 ) {
sprintf( tQBuf, "INSERT INTO `resources` SET `site_id`=%d, `node_id`=%d, `type`=%d, `md5`='%s', `aux_id`=%d, `device`='%s' ON DUPLICATE KEY UPDATE `active`=1", SiteID, NodeID, type, tMD5, auxID, devName );
sprintf( tQBuf, "INSERT INTO `resources` SET `site_id`=%d, `node_id`=%d, `type`=%d, `md5`='%s', `aux_id`=%d, `device`='%s', `active`=1 ON DUPLICATE KEY UPDATE `active`=1, `aux_id`=%d, `device`='%s'", SiteID, NodeID, type, tMD5, auxID, devName, auxID, devName );
free( tMD5 );
#ifdef DEBUG
//LOG(tQBuf);
@ -2511,6 +2670,34 @@ uint32_t argusDBC::addLocalUART( uint32_t ResID, uint8_t utype, uint32_t speed,
return RetVal;
};
uint32_t argusDBC::addLocalNetInterface( CSTR address, CSTR mask, CSTR gateway, CSTR broadcast ){
uint32_t RetVal = 0;
if( m_bIsConnected ) {
char tQBuf[MAX_PATH_LEN];
sprintf( tQBuf, "%s:%s:xxx:%s", address, mask, broadcast );
char * tKey = MD5String( tQBuf );
if( tKey != NULL ) {
sprintf( tQBuf, "INSERT INTO `network_interfaces` SET `key`='%s', `address`='%s', `gateway`='%s', `mask`='%s', `broadcast`='%s' ON DUPLICATE KEY UPDATE `id`=`id`",
tKey,
address,
gateway,
mask,
broadcast
);
#ifdef DEBUG
//LOG(tQBuf);
#endif
RetVal = m_pDatabase->QueryID( tQBuf );
if( RetVal == 0 ) {
RetVal = getNetworkInterfaceID( tKey );
};
free( tKey );
};
};
return RetVal;
};
bool argusDBC::addDraw( uint32_t DBID, uint16_t SIZE, CSTR ID ){
if( m_bIsConnected ) {
char tQBuf[MAX_PATH_LEN];
@ -2785,6 +2972,133 @@ bool argusDBC::updateAFPBox( uint32_t filterID, CSTR Tag, float x, float y, floa
return false;
};
DBC_MODULE_EMBED_VIDEO_DATA *argusDBC::getEmbedVideoData( uint32_t ID ){
DBC_MODULE_EMBED_VIDEO_DATA *tPtr = NULL;
if( m_bIsConnected ) {
char tQBuf[MAX_PATH_LEN];
AAssoc *result;
sprintf( tQBuf, "SELECT * FROM `module_embed_video_settings` WHERE `id`=%d", ID );
#ifdef DEBUG
//LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
if( result!= NULL ) {
if( result->size() > 0 ) {
Assoc *cArr;
tPtr = (DBC_MODULE_EMBED_VIDEO_DATA*)malloc(sizeof(DBC_MODULE_EMBED_VIDEO_DATA));
if( tPtr!= NULL ) {
Assoc::iterator it;
memset(tPtr,0,sizeof(DBC_EVT_DATA));
cArr = result->at(0);
it = cArr->find("web_port");
if( it != cArr->end() ){
tPtr->port = atoi( it->second.c_str() );
};
it = cArr->find("show_ts");
if( it != cArr->end() ){
tPtr->show_ts = (bool)atoi( it->second.c_str() );
};
it = cArr->find("width");
if( it != cArr->end() ){
tPtr->width = atoi( it->second.c_str() );
};
it = cArr->find("height");
if( it != cArr->end() ){
tPtr->height = atoi( it->second.c_str() );
};
it = cArr->find("ts_x");
if( it != cArr->end() ){
tPtr->ts_x = atoi( it->second.c_str() );
};
it = cArr->find("ts_y");
if( it != cArr->end() ){
tPtr->ts_y = atoi( it->second.c_str() );
};
it = cArr->find("ts_font_face");
if( it != cArr->end() ){
tPtr->ts_font_face = atoi( it->second.c_str() );
};
it = cArr->find("ts_font_scale");
if( it != cArr->end() ){
tPtr->ts_font_scale = atof( it->second.c_str() );
};
it = cArr->find("ts_font_thickness");
if( it != cArr->end() ){
tPtr->ts_font_thickness = atoi( it->second.c_str() );
};
it = cArr->find("ts_line_type");
if( it != cArr->end() ){
tPtr->ts_line_type = atoi( it->second.c_str() );
};
it = cArr->find("ts_transperant");
if( it != cArr->end() ){
tPtr->ts_y = (bool)atoi( it->second.c_str() );
};
it = cArr->find("show_label");
if( it != cArr->end() ){
tPtr->show_label = (bool)atoi( it->second.c_str() );
};
it = cArr->find("label_x");
if( it != cArr->end() ){
tPtr->label_x = atoi( it->second.c_str() );
};
it = cArr->find("label_y");
if( it != cArr->end() ){
tPtr->label_y = atoi( it->second.c_str() );
};
it = cArr->find("label_font_face");
if( it != cArr->end() ){
tPtr->label_font_face = atoi( it->second.c_str() );
};
it = cArr->find("label_font_scale");
if( it != cArr->end() ){
tPtr->label_font_scale = atof( it->second.c_str() );
};
it = cArr->find("label_font_thickness");
if( it != cArr->end() ){
tPtr->label_font_thickness = atoi( it->second.c_str() );
};
it = cArr->find("label_line_type");
if( it != cArr->end() ){
tPtr->label_line_type = atoi( it->second.c_str() );
};
it = cArr->find("label_transperant");
if( it != cArr->end() ){
tPtr->label_transperant = (bool) atoi( it->second.c_str() );
};
it = cArr->find("show_logo");
if( it != cArr->end() ){
tPtr->show_logo = (bool) atoi( it->second.c_str() );
};
it = cArr->find("logo_w");
if( it != cArr->end() ){
tPtr->logo_w = atoi( it->second.c_str() );
};
it = cArr->find("logo_h");
if( it != cArr->end() ){
tPtr->logo_h = atoi( it->second.c_str() );
};
it = cArr->find("logo_x");
if( it != cArr->end() ){
tPtr->logo_x = atoi( it->second.c_str() );
};
it = cArr->find("logo_y");
if( it != cArr->end() ){
tPtr->logo_y = atoi( it->second.c_str() );
};
it = cArr->find("logo_md5");
if( it != cArr->end() ){
strncpy( tPtr->logo_md5, it->second.c_str(),32);
tPtr->logo_md5[32]=(char)0;
};
};
};
};
deleteResult( result );
};
return tPtr;
};
DBC_EVT_DATA *argusDBC::getEventByUUID( CSTR UUID ){
DBC_EVT_DATA *tPtr = NULL;
if( m_bIsConnected ) {

16
lib/rgoose/rgooseDBConnector.h

@ -3,7 +3,7 @@
#include "../components/base/basicSettingsProvider.h"
#include "../data/mysql/database_class.h"
#include "../data/protocol/onvifMediaObserver.h"
//#include "../data/protocol/onvifMediaObserver.h"
#include "../alg/generic/md5.h"
#include "rgooseTypes.h"
@ -33,11 +33,12 @@ class argusDBC{
bool addDraw( uint32_t DBID, uint16_t SIZE, CSTR ID );
uint32_t addEvent( uint32_t SRC, CSTR UUID, uint32_t tss, uint32_t tsms, uint8_t evt_type, uint16_t dig_r=0, float AZ=.0f, float EL=.0f, float RANGE=.0f, float AREA=.0f, float lat=.0f, float lon=.0f, float alt=.0f, uint32_t RefID=0, CSTR RefUUID=NULL );
bool addIPCam( uint32_t SiteID, resultWoWo *tPtr );
//bool addIPCam( uint32_t SiteID, resultWoWo *tPtr );
bool addIPCam( uint32_t SiteID, OBSERVER_RESULT *tPtr );
uint32_t addLocalMediaSource( uint32_t SiteID, CSTR path, uint32_t width, uint32_t height );
uint32_t addLocalDCB( uint32_t SiteID, CSTR PATH, CSTR SERIAL, uint8_t CNT, uint32_t status );
uint32_t addLocalUART( uint32_t ResID, uint8_t utype, uint32_t speed, uint8_t bit, char parity, float stop_bit, CSTR PATH, uint8_t mode=0, uint16_t port=0 );
uint32_t addLocalNetInterface( CSTR address, CSTR mask, CSTR gateway, CSTR broadcast );
//uint32_t addNodeSocket( uint32_t NodeID, uint32_t auxID, uint8_t SocketType, uint8_t SocketMode, bool multidrop, CSTR path, CSTR name );
bool addNotification( uint32_t MSG_ID, uint8_t DIS_LVL = 0, uint32_t OBJ_ID=0 );
@ -50,8 +51,9 @@ class argusDBC{
DBC_INT_LIST * listCamMediaStreams( uint32_t CAMID );
DBC_INT_LIST * listDetectionProfileIDs( uint32_t nodeID );
DBC_INT_LIST * listDetectionProfiles( uint32_t nodeID );
DBC_INT_LIST * listFilters( uint32_t m_nSiteID, uint32_t m_nServerID );
DBC_INT_LIST * listMediaStreams( uint32_t SiteId, uint32_t MediaServerID, uint8_t listingType = LIST_ALL_RECORDS );
DBC_INT_LIST * listFilters( uint32_t m_nServerID );
DBC_INT_LIST * listMediaServerStreams( uint32_t SiteId, uint32_t MediaServerID, uint8_t listingType = LIST_ALL_RECORDS );
DBC_INT_LIST * listMediaStreams( uint32_t SiteId, uint8_t listingType = LIST_ALL_RECORDS );
DBC_INT_LIST * listModules( uint32_t SiteID );
DBC_INT_LIST * listNewModules( uint32_t SiteID, DBC_INT_LIST * old_ids );
DBC_INT_LIST * listNewNodes( uint32_t SiteID, DBC_INT_LIST * old_ids );
@ -64,20 +66,24 @@ class argusDBC{
DBC_APF_DATA * getAPFData( uint32_t APFID );
DBC_CAM_DATA * getCamData( uint32_t CamID );
uint32_t getCamId( CSTR UUID );
DBC_PUSHED_CMD * getCamPushedCMD( uint32_t ID );
bool getConnectionStatus(void){return m_bIsConnected;};
DBC_EVT_DATA * getEventByUUID( CSTR UUID );
DBC_MODULE_EMBED_VIDEO_DATA * getEmbedVideoData( uint32_t ID );
DBC_FH_DATA * getFlyHunterData( uint32_t ID );
int getIPCamCount( uint32_t SiteID );
KAFKA_TEMPLATE * getKafkaTemplateForEvent( uint32_t ModuleID, uint32_t ClassID, uint32_t EventID );
bool getLastEvents( vectorEventRecords &VR, uint32_t tss, uint32_t tsms );
DBC_LRF_DATA * getLRFData( uint32_t ID );
uint8_t getLRFDataStatus( uint32_t ID );
uint8_t getLRFPushedCMD( uint32_t ID );
DBC_PUSHED_CMD * getLRFPushedCMD( uint32_t ID );
DBC_MEDIA_STREAM_DATA * getMediaStreamData( uint32_t ID );
DBC_MEDIA_SERVER_DATA * getMediaServerData( uint32_t ID );
DBC_MEDIA_SERVER_STREAM_DATA * getMediaServerStreamData( uint32_t ID );
DBC_MEDIA_SERVER_STREAM_DATA * getMediaServerStreamDataBySource( uint32_t ID );
DBC_MODULE_DATA * getModuleData( uint32_t ID );
uint32_t getNetworkInterfaceID( CSTR key );
DBC_NET_IF_DATA * getNetworkInterfaceData( uint32_t ID );
DBC_NODE_DATA * getNodeData( uint32_t ID );
CSTR getNodeIP4( uint32_t NodeID );
CSTR getNodeIP6( uint32_t NodeID );

43
lib/rgoose/rgooseFilterAPF.cpp

@ -28,6 +28,7 @@ ARGUS_APF::ARGUS_APF( uint32_t id ):ARGUS_TARGET_FILTER( id ), basicThread() {
};
ARGUS_APF::~ARGUS_APF(){
LOG("Stoping Filter!");
stopFilter();
};
@ -68,8 +69,31 @@ bool ARGUS_APF::initFilter(){
};
bool ARGUS_APF::stopFilter(){
m_bActive = false;
if( m_bActive ) {
m_bActive = false;
int tSocketFD = -1;
struct sockaddr_in servaddr;
// Creating socket file descriptor
if(( tSocketFD = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0 ){
LOG_ERROR("socket creation failed");
return false;
};
memset(&servaddr, 0, sizeof(servaddr));
// Filling server information
servaddr.sin_family = AF_INET; // IPv4
servaddr.sin_addr.s_addr = INADDR_ANY;
servaddr.sin_port = htons( m_Settings.port );
char *message="shutdown:";
int slen=sizeof( servaddr );
if( sendto( tSocketFD, message, strlen(message), 0 , (struct sockaddr *) &servaddr, slen) == -1 ){
LOG_ERROR("Failure to Send Shutdown Command!");
};
};
waitThreadEnd( true );
if( m_iSocketFD > -1 ){
shutdown( m_iSocketFD, 2 );
};
@ -125,7 +149,15 @@ void ARGUS_APF::m_fThreadProc( void ){
m_bThreadStatus = TH_WORKING;
while (m_bThreadStatus < TH_ENDED) {
memset( inBuff, 0, 1024 );
dLen = recvfrom( m_iSocketFD, (char *)inBuff, 1024, MSG_WAITALL, ( struct sockaddr *) &CA, &caLen );
if( m_bActive ){
dLen = recvfrom( m_iSocketFD, (char *)inBuff, 1024, MSG_WAITALL, ( struct sockaddr *) &CA, &caLen );
} else {
m_bThreadStatus = TH_ENDED;
#ifdef DEBUG
LOG( "Filter deactivated!");
#endif
continue;
};
if( dLen < 0 ) {
m_bThreadStatus = TH_ENDED;
LOG_ERROR( "RECV error!");
@ -166,6 +198,13 @@ void ARGUS_APF::m_fThreadProc( void ){
delete( Parts );
};
};
if( strstr( inBuff, "shutdown:" ) != NULL ){
m_bThreadStatus = TH_ENDED;
#ifdef DEBUG
LOG( "Shutdown Requested!");
#endif
continue;
};
SLEEP( 2 );
};
};

185
lib/rgoose/rgooseHardwareManager.cpp

@ -1,7 +1,8 @@
#include "rgooseHardwareManager.h"
#include "rgooseKernel.h"
#include "rgooseDBConnector.h"
#include "rgooseHardwareResourceIpUART.h"
#include "rgooseHardwareResourceSerialProvider.h"
#include "rgooseHardwareResourceNetworkProvider.h"
#include "../hardware/hid/hid_dc.h"
#include <hidapi/hidapi.h>
@ -62,6 +63,20 @@ argusHardwareManager::~argusHardwareManager(){
};
void argusHardwareManager::unloadResources( void ){
if( m_vResources.size() ) {
for( VECTOR_HW_RESOURCES::iterator idx = m_vResources.begin(); idx < m_vResources.end(); idx++ ) {
switch( (*idx)->getHardwareType() ) {
case ARGUS_HARDWARE_UART:
case ARGUS_HARDWARE_IP_UART: delete( (argusHardwareResourceSerialProvider*)(*idx) ); break;
case ARGUS_HARDWARE_NETWORK_IPV4:
case ARGUS_HARDWARE_NETWORK_IPV6: delete( (argusHardwareResourceNetwork*)(*idx) ); break;
};
};
m_vResources.clear();
};
};
void argusHardwareManager::loadResources( void ){
if( m_pDBC == NULL ) return;
DBC_INT_LIST *tVal;
@ -73,8 +88,7 @@ void argusHardwareManager::loadResources( void ){
argusHardwareResource *tPtr = NULL;
switch( tData->type ){
case ARGUS_HARDWARE_UART:{
argusHardwareResourceIpUART *tRes;
tRes = new argusHardwareResourceIpUART( tData->id );
argusHardwareResourceSerialProvider *tRes = new argusHardwareResourceSerialProvider( tData->id );
if( tRes != NULL ) {
if( tRes->create() ) {
tPtr = ( argusHardwareResource *) tRes;
@ -84,6 +98,30 @@ void argusHardwareManager::loadResources( void ){
};
break;
};
case ARGUS_HARDWARE_NETWORK_IPV4:
case ARGUS_HARDWARE_NETWORK_IPV6:{
argusHardwareResourceNetwork *tRes = new argusHardwareResourceNetwork( tData->id );
if( tRes != NULL ) {
if( tRes->create() ) {
tPtr = ( argusHardwareResource *) tRes;
} else {
delete( tRes );
};
};
break;
};
case ARGUS_HARDWARE_IP_UART:{
argusHardwareResourceSerialProvider *tRes = new argusHardwareResourceSerialProvider( tData->id );
if( tRes != NULL ) {
//if( tRes->create() ) {
tRes->create();
tPtr = ( argusHardwareResource *) tRes;
//} else {
// delete( tRes );
//};
};
break;
};
};
if( tPtr!= NULL ) {
#ifdef DEBUG
@ -101,6 +139,9 @@ void argusHardwareManager::loadResources( void ){
};
void argusHardwareManager::validate( void ){
#ifdef DEBUG_EXTRA
LOG("Validator");
#endif
if( !m_bHardwareEnumerated ) return;
if( m_vResources.size() ) {
for( VECTOR_HW_RESOURCES::iterator idx = m_vResources.begin(); idx < m_vResources.end(); idx++ ) {
@ -109,10 +150,18 @@ void argusHardwareManager::validate( void ){
LOG_ERROR( "HW Resource Invalid!" );
if( !(*idx)->create()){
LOG_ERROR( "HW Resource Creation Failure!" );
};
};
} else LOG("Re-Created OK");
}
#ifdef DEBUG_EXTRA
else LOG("Resource OK!")
#endif
;
};
};
}
#ifdef DEBUG_EXTRA
else LOG("No Resources!")
#endif
;
};
int xioctl(int fh, int request, void *arg){
@ -133,11 +182,12 @@ void argusHardwareManager::enumerateHardware( void ){
struct dirent * pDR = NULL;
char tBuffer[CTEXT];
struct ifaddrs * ifaddr = NULL;
struct ifaddrs * ifa;
char addr[INET6_ADDRSTRLEN];
if( m_pKernel == NULL ) return;
if( m_pDBC == NULL ) return;
if( m_bHardwareEnumerated ) return;
#ifdef DEBUG
LOG("HW Enumeration Started!");
#endif
@ -152,13 +202,18 @@ void argusHardwareManager::enumerateHardware( void ){
if( -1 == getifaddrs(&ifaddr)) {
LOG_ERROR("No NET INTERFACES?!");
} else {
#ifdef DEBUG
//LOG("NETWORK!");
#ifdef DEBUG_EXTRA
LOG("NETWORK!");
#endif
struct ifaddrs * ifa;
char addr[INET6_ADDRSTRLEN];
char mask[INET6_ADDRSTRLEN];
char gw[INET6_ADDRSTRLEN];
char bc[INET6_ADDRSTRLEN];
for( ifa = ifaddr; ifa; ifa = ifa->ifa_next ){
#ifdef DEBUG
//LOG("NIF ***");
//LOG( ifa->ifa_name );
#ifdef DEBUG_EXTRA
LOG("NIF ***");
LOG( ifa->ifa_name );
#endif
// Filter Loopback if
if( strstr( ifa->ifa_name, "lo" ) != NULL ) continue;
@ -169,16 +224,76 @@ void argusHardwareManager::enumerateHardware( void ){
// create IPv4 string
struct sockaddr_in *in = (struct sockaddr_in*) ifa->ifa_addr;
inet_ntop(AF_INET, &in->sin_addr, addr, sizeof(addr));
sprintf( mask, "%d.%d.%d.%d",
(uint8_t)ifa->ifa_netmask->sa_data[2],
(uint8_t)ifa->ifa_netmask->sa_data[3],
(uint8_t)ifa->ifa_netmask->sa_data[4],
(uint8_t)ifa->ifa_netmask->sa_data[5]
);
sprintf( bc, "%d.%d.%d.%d",
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[2],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[3],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[4],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[5]
);
sprintf( gw, "" );
//sprintf( tBuffer, "NET4:%s", ifa->ifa_name );
//m_pDBC->addNodeSocket( m_nServerNodeID, m_nServerID, ARGUS_NODE_SOCK_TYPE_NETWORK_IPV4, ARGUS_NODE_SOCK_MODE_INOUT, true, ifa->ifa_name, addr );
m_pDBC->addResource( m_nSiteID, m_nServerNodeID, ARGUS_HARDWARE_NETWORK_IPV4, addr );
uint32_t tID = m_pDBC->addLocalNetInterface( addr, mask, gw, bc );
if( tID ) {
m_pDBC->addResource( m_nSiteID, m_nServerNodeID, ARGUS_HARDWARE_NETWORK_IPV4, addr, tID );
};
} else { // AF_INET6
// create IPv6 string
struct sockaddr_in6 *in6 = (struct sockaddr_in6*) ifa->ifa_addr;
inet_ntop(AF_INET6, &in6->sin6_addr, addr, sizeof(addr));
sprintf( mask, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
(uint8_t)ifa->ifa_netmask->sa_data[2],
(uint8_t)ifa->ifa_netmask->sa_data[3],
(uint8_t)ifa->ifa_netmask->sa_data[4],
(uint8_t)ifa->ifa_netmask->sa_data[5],
(uint8_t)ifa->ifa_netmask->sa_data[6],
(uint8_t)ifa->ifa_netmask->sa_data[7],
(uint8_t)ifa->ifa_netmask->sa_data[8],
(uint8_t)ifa->ifa_netmask->sa_data[9],
(uint8_t)ifa->ifa_netmask->sa_data[10],
(uint8_t)ifa->ifa_netmask->sa_data[11],
(uint8_t)ifa->ifa_netmask->sa_data[12],
(uint8_t)ifa->ifa_netmask->sa_data[13],
(uint8_t)ifa->ifa_netmask->sa_data[14],
(uint8_t)ifa->ifa_netmask->sa_data[15],
(uint8_t)ifa->ifa_netmask->sa_data[16],
(uint8_t)ifa->ifa_netmask->sa_data[17]
);
if( ifa->ifa_ifu.ifu_broadaddr != NULL ){
sprintf( bc, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[2],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[3],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[4],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[5],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[6],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[7],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[8],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[9],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[10],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[11],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[12],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[13],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[14],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[15],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[16],
(uint8_t)ifa->ifa_ifu.ifu_broadaddr->sa_data[17]
);
} else {
sprintf( bc, "" );
};
sprintf( gw, "" );
//sprintf( tBuffer, "NET6:%s", ifa->ifa_name );
//m_pDBC->addNodeSocket( m_nServerNodeID, m_nServerID, ARGUS_NODE_SOCK_TYPE_NETWORK_IPV6, ARGUS_NODE_SOCK_MODE_INOUT, true, ifa->ifa_name, addr );
m_pDBC->addResource( m_nSiteID, m_nServerNodeID, ARGUS_HARDWARE_NETWORK_IPV6, addr );
uint32_t tID = m_pDBC->addLocalNetInterface( addr, mask, gw, bc );
if( tID ) {
m_pDBC->addResource( m_nSiteID, m_nServerNodeID, ARGUS_HARDWARE_NETWORK_IPV6, addr, tID );
};
};
#ifdef DEBUG
sprintf( tBuffer, "Network Interface: %s [%s]", ifa->ifa_name, addr );
@ -294,6 +409,7 @@ void argusHardwareManager::enumerateHardware( void ){
};
closedir( dFD );
};
m_bHardwareEnumerated = true;
};
uint32_t argusHardwareManager::createResourceUART( CSTR devName ){
@ -419,11 +535,11 @@ uint32_t argusHardwareManager::createResourceUDCB( CSTR devName ){
return RetVal;
};
argusHardwareResource *argusHardwareManager::requestResource( ARGUS_HARDWARE_TYPE type, uint32_t id ){
argusHardwareResource *argusHardwareManager::requestResource( ARGUS_HARDWARE_PROVIDERS type, uint32_t id ){
argusHardwareResource *RetVal = NULL;
if( m_vResources.size() ) {
for( VECTOR_HW_RESOURCES::iterator idx = m_vResources.begin(); idx < m_vResources.end(); idx++ ) {
if( ((*idx)->getType() == type ) && ( (*idx)->getDbId() == id ) ) {
if( ((*idx)->getProviderType() == type ) && ( (*idx)->getDbId() == id ) ) {
RetVal = (*idx);
break;
};
@ -432,6 +548,41 @@ argusHardwareResource *argusHardwareManager::requestResource( ARGUS_HARDWARE_TYP
return RetVal;
};
DBC_INT_LIST *argusHardwareManager::requestResourcesByType( ARGUS_HARDWARE_PROVIDERS type ){
DBC_INT_LIST *RetVal = NULL;
#ifdef DEBUG_EXTRA
char tBuffer[128];
sprintf( tBuffer, "Requested Resource type: %d", type );
LOG( tBuffer );
#endif
if( m_vResources.size() ) {
#ifdef DEBUG_EXTRA
LOG("Have Some Resources!");
#endif
RetVal = new DBC_INT_LIST();
if( RetVal ) {
#ifdef DEBUG_EXTRA
LOG("RetVal Created!");
#endif
for( VECTOR_HW_RESOURCES::iterator idx = m_vResources.begin(); idx < m_vResources.end(); idx++ ) {
#ifdef DEBUG_EXTRA
sprintf( tBuffer, "Have Resource type: %d", (*idx)->getType() );
LOG( tBuffer );
#endif
if( (*idx)->getProviderType() == type ) {
#ifdef DEBUG_EXTRA
LOG("Matched!");
#endif
RetVal->push_back((*idx)->getDbId());
};
};
} else {
LOG_ERROR("Cannot Create DBC_INT_LIST");
};
};
return RetVal;
};
#undef CLEAR
#undef LOG
#undef LOG_ERROR

5
lib/rgoose/rgooseHardwareManager.h

@ -30,8 +30,9 @@ class argusHardwareManager{
virtual ~argusHardwareManager();
static argusHardwareManager * getInstance( void );
void validate( void );
//argusHardwareResource * getUart( uint32_t SocketId );
argusHardwareResource * requestResource( ARGUS_HARDWARE_TYPE type, uint32_t id );
argusHardwareResource * requestResource( ARGUS_HARDWARE_PROVIDERS type, uint32_t id );
DBC_INT_LIST * requestResourcesByType( ARGUS_HARDWARE_PROVIDERS type );
void unloadResources( void );
private:
static argusHardwareManager * _instance;
argusHardwareManager();

77
lib/rgoose/rgooseHardwareResource.cpp

@ -12,79 +12,112 @@
#define LOG_ERROR( X ) m_pLog->Log( "HWR", this, _LOG_ERROR, X );
#endif
argusHardwareResource::argusHardwareResource( uint32_t id, ARGUS_HARDWARE_TYPE type ): basicObject(){
argusHardwareResource::argusHardwareResource( uint32_t id, ARGUS_HARDWARE_PROVIDERS type ): basicObject(){
m_bValid = false;
m_pDBC = argusDBC::getInstance();
m_pLog = basicLogCollection::getInstance();
m_eProviderType = type;
if( id > 0 ){
if( m_pDBC!=NULL ){
DBC_RESOURCE_DATA *tData = m_pDBC->getResourceData( id );
if( tData != NULL ) {
memcpy( &m_sSettings, tData, sizeof(DBC_RESOURCE_DATA));
memcpy( &m_sResourceSettings, tData, sizeof(DBC_RESOURCE_DATA));
free( tData );
#ifdef DEBUG
char tBuff[256];
switch( m_sSettings.type ) {
#endif
switch( m_sResourceSettings.type ) {
case ARGUS_HARDWARE_USB_DC:{
sprintf( tBuff, "USB Dry Contact [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
#ifdef DEBUG
sprintf( tBuff, "USB Dry Contact [%d] id: %d aux: %d", m_sResourceSettings.type, id, m_sResourceSettings.aux_id );
#endif
m_eProviderType = ARGUS_HARDWARE_PROVIDER_DRY_CONTACT;
break;
};
case ARGUS_HARDWARE_IP_VIDEO_IN:{
sprintf( tBuff, "IP Video IN [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
#ifdef DEBUG
sprintf( tBuff, "IP Video IN [%d] id: %d aux: %d", m_sResourceSettings.type, id, m_sResourceSettings.aux_id );
#endif
m_eProviderType = ARGUS_HARDWARE_PROVIDER_VIDEO;
break;
};
case ARGUS_HARDWARE_IP_VIDEO_OUT:{
sprintf( tBuff, "IP Video IN [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
#ifdef DEBUG
sprintf( tBuff, "IP Video IN [%d] id: %d aux: %d", m_sResourceSettings.type, id, m_sResourceSettings.aux_id );
#endif
m_eProviderType = ARGUS_HARDWARE_PROVIDER_VIDEO;
break;
};
case ARGUS_HARDWARE_IP_UART:{
sprintf( tBuff, "IP UART [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
#ifdef DEBUG
sprintf( tBuff, "IP UART [%d] id: %d aux: %d", m_sResourceSettings.type, id, m_sResourceSettings.aux_id );
#endif
m_eProviderType = ARGUS_HARDWARE_PROVIDER_SERIAL;
break;
};
case ARGUS_HARDWARE_ANALOG_VIDEO_IN:{
sprintf( tBuff, "Analog Video IN [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
#ifdef DEBUG
sprintf( tBuff, "Analog Video IN [%d] id: %d aux: %d", m_sResourceSettings.type, id, m_sResourceSettings.aux_id );
#endif
m_eProviderType = ARGUS_HARDWARE_PROVIDER_VIDEO;
break;
};
case ARGUS_HARDWARE_ANALOG_VIDEO_OUT:{
sprintf( tBuff, "Analog Video IN [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
#ifdef DEBUG
sprintf( tBuff, "Analog Video IN [%d] id: %d aux: %d", m_sResourceSettings.type, id, m_sResourceSettings.aux_id );
#endif
m_eProviderType = ARGUS_HARDWARE_PROVIDER_VIDEO;
break;
};
case ARGUS_HARDWARE_NETWORK_IPV4:{
sprintf( tBuff, "Network Interface [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
#ifdef DEBUG
sprintf( tBuff, "Network Interface [%d] id: %d aux: %d", m_sResourceSettings.type, id, m_sResourceSettings.aux_id );
#endif
m_eProviderType = ARGUS_HARDWARE_PROVIDER_NETWORK;
break;
};
case ARGUS_HARDWARE_NETWORK_IPV6:{
sprintf( tBuff, "Network Interface [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
#ifdef DEBUG
sprintf( tBuff, "Network Interface [%d] id: %d aux: %d", m_sResourceSettings.type, id, m_sResourceSettings.aux_id );
#endif
m_eProviderType = ARGUS_HARDWARE_PROVIDER_NETWORK;
break;
};
case ARGUS_HARDWARE_UART:{
sprintf( tBuff, "HW UART [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
#ifdef DEBUG
sprintf( tBuff, "HW UART [%d] id: %d aux: %d", m_sResourceSettings.type, id, m_sResourceSettings.aux_id );
#endif
m_eProviderType = ARGUS_HARDWARE_PROVIDER_SERIAL;
break;
};
default:{
sprintf( tBuff, "Unknown Resource Type [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
#ifdef DEBUG
sprintf( tBuff, "Unknown Resource Type [%d] id: %d aux: %d", m_sResourceSettings.type, id, m_sResourceSettings.aux_id );
#endif
m_eProviderType = ARGUS_HARDWARE_PROVIDER_UNKNOWN;
break;
};
};
#ifdef DEBUG
LOG( tBuff );
#endif
} else {
LOG_ERROR("Cannot Fetch Hardware Data from DB!");
memset( &m_sSettings, 0, sizeof( DBC_RESOURCE_DATA ));
m_sSettings.id = id;
m_sSettings.type = type;
memset( &m_sResourceSettings, 0, sizeof( DBC_RESOURCE_DATA ));
m_sResourceSettings.id = id;
m_sResourceSettings.type = ARGUS_HARDWARE_UNKNOWN;
};
} else {
LOG_ERROR("No Database Object!");
memset( &m_sSettings, 0, sizeof( DBC_RESOURCE_DATA ));
m_sSettings.id = id;
m_sSettings.type = type;
memset( &m_sResourceSettings, 0, sizeof( DBC_RESOURCE_DATA ));
m_sResourceSettings.id = id;
m_sResourceSettings.type = ARGUS_HARDWARE_UNKNOWN;
};
} else {
LOG_ERROR("Resource ID not set!");
memset( &m_sSettings, 0, sizeof( DBC_RESOURCE_DATA ));
m_sSettings.id = id;
m_sSettings.type = type;
memset( &m_sResourceSettings, 0, sizeof( DBC_RESOURCE_DATA ));
m_sResourceSettings.id = id;
m_sResourceSettings.type = ARGUS_HARDWARE_UNKNOWN;
};
};

16
lib/rgoose/rgooseHardwareResource.h

@ -9,19 +9,21 @@
class argusHardwareResource: public basicObject{
private:
basicLogCollection * m_pLog;
protected:
DBC_RESOURCE_DATA m_sSettings;
basicLogCollection * m_pLog;
argusDBC * m_pDBC;
bool m_bValid;
ARGUS_HARDWARE_PROVIDERS m_eProviderType;
DBC_RESOURCE_DATA m_sResourceSettings;
argusDBC * m_pDBC;
bool m_bValid;
public:
explicit argusHardwareResource( uint32_t id, ARGUS_HARDWARE_TYPE type = ARGUS_HARDWARE_UNKNOWN );
explicit argusHardwareResource( uint32_t id, ARGUS_HARDWARE_PROVIDERS type = ARGUS_HARDWARE_PROVIDER_UNKNOWN );
virtual ~argusHardwareResource();
virtual bool create( void ){ return false; };
virtual bool validate( void ){ return m_bValid; };
bool isValid( void ){ return m_bValid; };
uint32_t getDbId( void ){ return m_sSettings.aux_id; };
ARGUS_HARDWARE_TYPE getType( void ){ return (ARGUS_HARDWARE_TYPE) m_sSettings.type; };
uint32_t getDbId( void ){ return m_sResourceSettings.aux_id; };
ARGUS_HARDWARE_TYPE getHardwareType( void ){ return (ARGUS_HARDWARE_TYPE) m_sResourceSettings.type; };
ARGUS_HARDWARE_PROVIDERS getProviderType( void ){ return m_eProviderType; };
};

lib/rgoose/rgooseHardwareResourceUSBDCB.cpp → lib/rgoose/rgooseHardwareResourceDryContactProvider.cpp

lib/rgoose/rgooseHardwareResourceUSBDCB.h → lib/rgoose/rgooseHardwareResourceDryContactProvider.h

41
lib/rgoose/rgooseHardwareResourceIpUART.cpp

@ -1,41 +0,0 @@
#include "rgooseHardwareResourceIpUART.h"
#define LOG( X ) argusHardwareResource::m_pLog->Log( "HR_IPUART", this, X )
#ifdef DEBUG
#define LOG_ERROR( X ) {\
char _tBfrErrMSG2w34[256];\
sprintf( _tBfrErrMSG2w34, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\
argusHardwareResource::m_pLog->Log( "HR_IPUART", this, _LOG_ERROR, _tBfrErrMSG2w34 );\
}
#else
#define LOG_ERROR( X ) argusHardwareResource::m_pLog->Log( "HR_IPUART", this, _LOG_ERROR, X );
#endif
argusHardwareResourceIpUART::argusHardwareResourceIpUART( uint32_t dbID ) : serialSOL(), argusHardwareResource( dbID, ARGUS_HARDWARE_IP_UART ){
memset( &settingsUART, 0, sizeof(DBC_UART_DATA));
};
argusHardwareResourceIpUART::~argusHardwareResourceIpUART(){
m_pDBC->setNodeOffline( m_sSettings.node_id );
};
bool argusHardwareResourceIpUART::create( void ){
DBC_UART_DATA *tDATA = NULL;
tDATA = m_pDBC->getUartData( m_sSettings.aux_id );
if( tDATA!= NULL ) {
memcpy( &settingsUART, tDATA, sizeof(DBC_UART_DATA));
#ifdef DEBUG
LOG( settingsUART.path );
#endif
free( tDATA );
if( serialSOL::create( settingsUART.path, settingsUART.speed, settingsUART.mode ) ) {
return m_pDBC->setNodeOnline( m_sSettings.node_id );
};
};
return false;
};
#undef LOG
#undef LOG_ERROR

17
lib/rgoose/rgooseHardwareResourceIpUART.h

@ -1,17 +0,0 @@
#ifndef __ARGUS_HARDWARE_UART_HEADER__
#define __ARGUS_HARDWARE_UART_HEADER__
#include "../hardware/uart/serialSOL.h"
#include "rgooseHardwareResource.h"
class argusHardwareResourceIpUART: public serialSOL, argusHardwareResource {
private:
DBC_UART_DATA settingsUART;
public:
explicit argusHardwareResourceIpUART( uint32_t dbID );
virtual ~argusHardwareResourceIpUART();
virtual bool create( void );
};
#endif

25
lib/rgoose/rgooseHardwareResourceNetwork.cpp

@ -1,25 +0,0 @@
#include "rgooseHardwareResourceNetwork.h"
#define LOG( X ) m_pLog->Log( "HW_NET", this, X )
#ifdef DEBUG
#define LOG_ERROR( X ) {\
char _tBfrErrMSG2w34[256];\
sprintf( _tBfrErrMSG2w34, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\
m_pLog->Log( "HW_NET", this, _LOG_ERROR, _tBfrErrMSG2w34 );\
}
#else
#define LOG_ERROR( X ) m_pLog->Log( "HW_NET", this, _LOG_ERROR, X );
#endif
argusHardwareResourceNetwork::argusHardwareResourceNetwork( uint32_t id ):argusHardwareResource( id, ARGUS_HARDWARE_NETWORK_IPV4 ){
};
argusHardwareResourceNetwork::~argusHardwareResourceNetwork(){
};
#undef LOG
#undef LOG_ERROR

12
lib/rgoose/rgooseHardwareResourceNetwork.h

@ -1,12 +0,0 @@
#ifndef __ARGUS_HARDWARE_RESOURCE_NETWORK_HEADER__
#define __ARGUS_HARDWARE_RESOURCE_NETWORK_HEADER__
#include "rgooseHardwareResource.h"
class argusHardwareResourceNetwork: public argusHardwareResource {
public:
explicit argusHardwareResourceNetwork( uint32_t id );
virtual ~argusHardwareResourceNetwork();
};
#endif

66
lib/rgoose/rgooseHardwareResourceNetworkProvider.cpp

@ -0,0 +1,66 @@
#include "rgooseHardwareResourceNetworkProvider.h"
#define LOG( X ) m_pLog->Log( "HWR_NETWORK", this, X )
#ifdef DEBUG
#define LOG_ERROR( X ) {\
char _tBfrErrMSG2w34[256];\
sprintf( _tBfrErrMSG2w34, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\
m_pLog->Log( "HWR_NETWORK", this, _LOG_ERROR, _tBfrErrMSG2w34 );\
}
#else
#define LOG_ERROR( X ) m_pLog->Log( "HWR_NETWORK", this, _LOG_ERROR, X );
#endif
argusHardwareResourceNetwork::argusHardwareResourceNetwork( uint32_t id, ARGUS_HARDWARE_PROVIDERS type ):argusHardwareResource( id, type ){
m_pLog = basicLogCollection::getInstance();
if( m_pDBC!= NULL ){
DBC_NET_IF_DATA *tData = m_pDBC->getNetworkInterfaceData( m_sResourceSettings.aux_id );
if( tData != NULL ) {
memcpy( &m_sNetworkData, tData, sizeof(DBC_NET_IF_DATA));
m_bValid = true;
free( tData );
} else {
memset( &m_sNetworkData, 0, sizeof(DBC_NET_IF_DATA));
};
} else {
memset( &m_sNetworkData, 0, sizeof(DBC_NET_IF_DATA));
};
#ifdef DEBUG
LOG( m_sNetworkData.address );
LOG( m_sNetworkData.netmask );
#endif
};
argusHardwareResourceNetwork::~argusHardwareResourceNetwork(){
};
CSTR argusHardwareResourceNetwork::getAddress(){
if( m_sNetworkData.address[0] != (char)0 ) {
return strdup( m_sNetworkData.address );
};
return NULL;
};
CSTR argusHardwareResourceNetwork::getBroadcast(){
if( m_sNetworkData.broadcast[0] != (char)0 ) {
return strdup( m_sNetworkData.broadcast );
};
return NULL;
};
CSTR argusHardwareResourceNetwork::getMask(){
if( m_sNetworkData.netmask[0] != (char)0 ) {
return strdup( m_sNetworkData.netmask );
};
return NULL;
};
CSTR argusHardwareResourceNetwork::getGateway(){
if( m_sNetworkData.gateway[0] != (char)0 ) {
return strdup( m_sNetworkData.gateway );
};
return NULL;
};
#undef LOG
#undef LOG_ERROR

20
lib/rgoose/rgooseHardwareResourceNetworkProvider.h

@ -0,0 +1,20 @@
#ifndef __ARGUS_HARDWARE_RESOURCE_NETWORK_HEADER__
#define __ARGUS_HARDWARE_RESOURCE_NETWORK_HEADER__
#include "rgooseHardwareResource.h"
class argusHardwareResourceNetwork: public argusHardwareResource {
private:
basicLogCollection * m_pLog;
DBC_NET_IF_DATA m_sNetworkData;
public:
explicit argusHardwareResourceNetwork( uint32_t id, ARGUS_HARDWARE_PROVIDERS type = ARGUS_HARDWARE_PROVIDER_NETWORK );
virtual ~argusHardwareResourceNetwork();
CSTR getAddress();
CSTR getBroadcast();
CSTR getMask();
CSTR getGateway();
virtual bool create( void ){ return true; };
};
#endif

1052
lib/rgoose/rgooseHardwareResourceSerialProvider.cpp
File diff suppressed because it is too large
View File

60
lib/rgoose/rgooseHardwareResourceSerialProvider.h

@ -0,0 +1,60 @@
#ifndef __ARGUS_HARDWARE_SERIAL_PROVIDER_HEADER__
#define __ARGUS_HARDWARE_SERIAL_PROVIDER_HEADER__
#include "rgooseHardwareResource.h"
#include "../components/base/basicTransport.h"
#include "../components/base/basicDualThread.h"
#include <stdio.h> // standard input / output functions
#include <stdlib.h>
#include <string.h> // string function definitions
#include <fcntl.h> // File control definitions
#include <errno.h> // Error number definitions
#ifdef __linux__
#include <unistd.h> // UNIX standard function definitions
#include <termios.h> // POSIX terminal control definitions
#endif
#define MAXIMAL_SOCKET_PACKET_LENGTH 102400
#define MAXIMAL_SERIAL_PACKET_LENGTH MAXIMAL_SOCKET_PACKET_LENGTH
class argusHardwareResourceSerialProvider: public argusHardwareResource, public basicTransport, public basicDualThread {
private:
basicLogCollection * m_pLog;
DBC_UART_DATA m_sUartData;
int m_iDeviceFD;
int m_iMasterFD;
#ifdef __linux__
struct termios m_sTTY;
int m_iInFID;
int m_iOutFID;
#else
DCB PortDCB;
HANDLE m_ioFID;
#endif
bool pingDevice();
bool create_SOL();
bool create_HW();
bool closePort();
int sendBlock(unsigned char *Data, int DataSize);
int recptBlock(unsigned char *Buffer, int *BufferLength);
protected:
U8 m_pInputBuffer[MAXIMAL_SOCKET_PACKET_LENGTH];
U8 m_pOutputBuffer[MAXIMAL_SOCKET_PACKET_LENGTH];
int m_nInputBufferSize;
int m_nOutputBufferSize;
virtual void m_fThreadAProc(void);
virtual void m_fThreadBProc(void);
public:
explicit argusHardwareResourceSerialProvider( uint32_t dbID );
virtual ~argusHardwareResourceSerialProvider();
virtual bool create( void );
virtual bool validate( void );
virtual bool sendData( uint8_t *Data, int DataSize );
virtual bool reconnect( void );
};
#endif

lib/rgoose/rgooseHardwareResourceIpVideoIn.h → lib/rgoose/rgooseHardwareResourceVideoProvider.h

157
lib/rgoose/rgooseKernel.cpp

@ -65,25 +65,28 @@ argusKernel::~argusKernel(){
#ifdef DEBUG
LOG("Destructor");
#endif
WaitFinish(true);
unloadFilters();
if( m_pDBC != NULL ) m_pDBC->unregisterServer( m_nSiteID, m_nServerNodeID );
#ifdef DEBUG
LOG("Deleting Components");
#endif
LOG(" Module Factory...");
#endif
if( m_pModuleFactory != NULL ) delete( m_pModuleFactory );
#ifdef DEBUG
LOG(" Node Factory...");
#endif
if( m_pNodeFactory != NULL ) delete( m_pNodeFactory );
//LOG(" Onvif Observer...");
//if( m_pOnvifMediaObserver != NULL ) delete( m_pOnvifMediaObserver );
//LOG(" Stream Manager...");
//if( m_pStreamManager != NULL ) delete( m_pStreamManager );
//LOG(" SSDP Service Announcer...");
//if( m_pServiceAnnouncer !=NULL ) delete( m_pServiceAnnouncer );
#ifdef DEBUG
LOG("Deleting Filters");
#endif
unloadFilters();
#ifdef DEBUG
LOG("Deleting Resources");
#endif
m_pHardwareManager->unloadResources();
#ifdef DEBUG
LOG("Unregister Server");
#endif
m_pDBC->unregisterServer( m_nSiteID, m_nServerNodeID );
LOG(" DataBase Connection...");
if( m_pDBC != NULL ) delete( m_pDBC );
m_pDBC = NULL;
@ -181,70 +184,54 @@ bool argusKernel::create( void ){
m_pEventHeap = basicEventHeap::getInstance();
//m_pOnvifMediaObserver = onvifMediaObserver::getInstance();
m_pNodeFactory = argusNodeFactory::getInstance();
m_pModuleFactory = argusModuleFactory::getInstance();
//enumerateHardware();
#ifdef DEBUG
LOG( "Load Filters" );
#endif
loadFilters();
//m_pNodeFactory->setDBC( m_pDBC );
m_pNodeFactory->loadNodes( m_nSiteID );
//m_pModuleFactory->setDBC( m_pDBC ); //m_pDBC->getIPCamRecords( m_vCamRecords );
m_pModuleFactory->loadModules( m_nServerID );
#ifdef DEBUG
//LOG( "Start SSDP Beacon" );
LOG( "Filters Loaded" );
#endif
//if( m_pServiceAnnouncer != NULL ) {
// if( !m_pServiceAnnouncer->init() ){
// delete(m_pServiceAnnouncer);
// m_pServiceAnnouncer = NULL;
// };
//};
//m_pStreamManager = NULL;//mediaNginxManager::getInstance();
//if( m_pStreamManager != NULL ) {
// m_pStreamManager->attachStream("rtsp://gagua:4GetMyID@192.168.0.104:554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1", true, 12, "12918" );
//};
/*
#ifdef DEBUG
LOG("Init IP Cameras");
m_pNodeFactory = argusNodeFactory::getInstance();
if( m_pNodeFactory ) {
#ifdef DEBUG
LOG( "Load Nodes" );
#endif
if( m_vCamRecords.size() ) {
ARGUS_Camera *tPtr = NULL;
for( int i=0; i < m_vCamRecords.size(); i++ ) {
tPtr = new ARGUS_Camera();
if( tPtr != NULL ) {
if( tPtr->create( m_vCamRecords.at(i)->ip, m_vCamRecords.at(i)->username, m_vCamRecords.at(i)->password ) ){
if( !m_pNodeFactory->loadNodes( m_nSiteID ) ){
LOG_ERROR("Error While Loading Nodes!");
}
#ifdef DEBUG
LOG("Camera Created!");
else {
LOG( "Nodes Loaded" );
}
#endif
m_vCameras.push_back( tPtr );
tPtr = NULL;
} else {
LOG_ERROR("Camera Creation Failure!");
delete( tPtr );
tPtr = NULL;
};
};
};
;
} else {
LOG_ERROR("Failure to get Node Factory Instance!");
return false;
};
*/
/*
m_pModuleFactory = argusModuleFactory::getInstance();
if( m_pModuleFactory ) {
#ifdef DEBUG
LOG( "Load Modules" );
#endif
if( !m_pModuleFactory->loadModules( m_nServerID ) ){
LOG_ERROR("Error While Loading Modules!");
}
#ifdef DEBUG
LOG("Start OnVIF Discovery");
else {
LOG( "Modules Loaded" );
}
#endif
if( m_pOnvifMediaObserver!= NULL ) {
m_pOnvifMediaObserver->startDiscovery();
m_bDiscoveryStarted = true;
};
*/
;
} else {
LOG_ERROR("Failure to get Module Factory Instance!");
return false;
};
#ifdef DEBUG
LOG( "Kernel Trhead is about to be Created" );
@ -255,22 +242,6 @@ bool argusKernel::create( void ){
};
#ifdef DEBUG
LOG( "Kernel Thread Created" );
#endif
/*
m_pServletWS = new servletWS();
if( m_pServletWS != NULL ) {
LOG("ServletWS Created");
if(m_pServletWS->create(8080)){
LOG("ServletWS Started");
//if( ! m_pServletWS->attachChannel("rtsp://gagua:4GetMyID@192.168.0.109:554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1", false ) ){
// LOG("Error Adding Channel!");
//} else {
// LOG("Channel Attached");
//};
};
};
*/
#ifdef DEBUG
sprintf( tBuffer, "Server is registered as id[%d]", m_nServerID );
LOG( tBuffer );
#endif
@ -280,7 +251,7 @@ bool argusKernel::create( void ){
void argusKernel::loadFilters(){
if( m_pDBC == NULL ) return;
DBC_INT_LIST *tList = m_pDBC->listFilters( m_nSiteID, m_nServerID );
DBC_INT_LIST *tList = m_pDBC->listFilters( m_nServerID );
if( tList != NULL ) {
if( tList->size() > 0 ) {
for( DBC_INT_LIST::iterator idx = tList->begin(); idx < tList->end(); idx++ ) {
@ -310,14 +281,20 @@ void argusKernel::loadFilters(){
void argusKernel::unloadFilters(){
if( m_vTargetFilters.size() > 0 ) {
LOG("Have Filters to Unload");
for( V_TARGET_FILTERS::iterator idx = m_vTargetFilters.begin(); idx < m_vTargetFilters.end(); idx++ ){
switch( (*idx)->getType() ) {
case TF_AUTHORISED_PEOPLE_FILTER:{
delete( (ARGUS_APF*)(*idx) );
break;
};
default:{
char tBuffer[64];
sprintf( tBuffer, "Unknown Filter: %d", (*idx)->getType() );
};
};
};
LOG("Unload Filters Done!");
};
};
@ -345,7 +322,7 @@ void argusKernel::WaitFinish( bool Force ){
};
waitThreadEnd( Force );
#ifdef DEBUG
LOG( "Thread is Detached" );
if( !Force ) LOG( "Thread is Detached" );
#endif
};
@ -432,9 +409,15 @@ void argusKernel::m_fThreadProc( void ){
};
free( tCMD );
};
// Validate Hardware
if( m_pHardwareManager!= NULL ) {
m_pHardwareManager->validate();
};
// Validate Modules
if( m_pModuleFactory != NULL ) {
m_pModuleFactory->validate();
};
// Validate Nodes
if( m_pNodeFactory != NULL ) {
m_pNodeFactory->validate();
};
@ -634,7 +617,7 @@ argusNetNode *argusKernel::getNetNode( int id ){
};
return NULL;
};
/*
int argusKernel::getModules( ARGUS_MODULE_TYPE type, argusKernelModule **&RA ){
RA = NULL;
int cnt = 0;
@ -654,7 +637,7 @@ argusKernelModule *argusKernel::getModule( int id ){
};
return NULL;
};
*/
void argusKernel::dispatchEvent( EVENT_CONTAINER *Evt ){
// Register all events in Database;
//LOG( "New EVENT!!" );

10
lib/rgoose/rgooseKernel.h

@ -60,10 +60,6 @@ struct serial_struct {
#include "../components/base/basicEngine.h"
#include "../components/base/basicSettingsProvider.h"
#include "../components/object/objectSystemAnchor.h"
//#include "../data/ponvif/ponvif.h"
//#include "../data/protocol/onvifMediaObserver.h"
//#include "../data/ssdp/ssdpAnnouncer.h"
//#include "../data/NginxMediaServer/mediaNginxStreamingProxyManager.h"
#include "../components/base/basicEventHeap.h"
#include "rgooseDBConnector.h"
#include "rgooseIPCamera.h"
@ -71,7 +67,6 @@ struct serial_struct {
#include "rgooseModuleFactory.h"
#include "rgooseHardwareManager.h"
#include "../data/net/netServer.h"
//#include "../data/servletWS/servletWS.h"
#include "rgooseTargetFilter.h"
@ -173,8 +168,9 @@ class argusKernel: public basicThread, public basicEventHandler {
uint8_t getExitCause( void ){ return m_bExitCause;};
int getNetNodes( ARGUS_NODE_TYPE type, argusNetNode **&RA );
argusNetNode * getNetNode( int id );
int getModules( ARGUS_MODULE_TYPE type, argusKernelModule **&RA );
argusKernelModule * getModule( int id );
//int getModules( ARGUS_MODULE_TYPE type, argusKernelModule **&RA );
//argusKernelModule * getModule( int id );
argusModuleFactory * getModuleFactory( void ){ return m_pModuleFactory; };
argusHardwareManager * getHardwareManager( void ){ return m_pHardwareManager; };
uint32_t getSiteId( void ){ return m_nSiteID; };
uint32_t getServerId( void ){ return m_nServerID; };

3
lib/rgoose/rgooseModule.h

@ -16,7 +16,8 @@ typedef enum E_ARGUS_MODULE_TYPE{
ARGUS_MODULE_NETWORK = 5,
ARGUS_MODULE_FLYHUNTER = 6,
ARGUS_MODULE_SSDP_ANONCE = 7,
ARGUS_MODULE_ONVIF_OBSERVER = 8
ARGUS_MODULE_ONVIF_OBSERVER = 8,
ARGUS_MODULE_EMBED_VIDEO = 9
}ARGUS_MODULE_TYPE;
class argusKernel;

700
lib/rgoose/rgooseModuleEmbedVideo.cpp

@ -0,0 +1,700 @@
#include "rgooseModuleEmbedVideo.h"
#include "rgooseHardwareResourceNetworkProvider.h"
#include "../alg/generic/base64.h"
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <getopt.h>
#include <ifaddrs.h>
#include <netdb.h>
#include <paths.h>
#include <poll.h>
#include <stdio.h>
#include <signal.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
#include <sys/param.h> /* MIN() */
#include <sys/socket.h>
#include <openssl/sha.h>
#define LOG( X ) argusKernelModule::m_pLog->Log( "MOD_EVIDEO", this, X )
#ifdef DEBUG
#define LOG_ERROR( X ) {\
char _tBfrErrMSG2w34[256];\
sprintf( _tBfrErrMSG2w34, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\
argusKernelModule::m_pLog->Log( "MOD_EVIDEO", this, _LOG_ERROR, _tBfrErrMSG2w34 );\
}
#else
#define LOG_ERROR( X ) argusKernelModule::m_pLog->Log( "MOD_EVIDEO", this, _LOG_ERROR, X );
#endif
#define TLOG( X ) basicLogCollection::getInstance()->Log( "MOD_EVIDEO_T", CTX, X )
#define TLOG_ERROR( X ) basicLogCollection::getInstance()->Log( "MOD_EVIDEO_T", CTX, _LOG_ERROR, X )
enum {
WEBRTC_REQ_SIGNIN = 0,
WEBRTC_REQ_WAIT = 1,
WEBRTC_REQ_SIGNOUT = 2,
WEBRTC_REQ_MESSAGE = 3
};
static const char* kRequestPaths[] = { "/stream", "/sign_in", "/wait", "/sign_out", "/message" };
//buffer_data bd[1]={0};
argusModuleEmbedVideo::argusModuleEmbedVideo( uint32_t moduleID ): argusKernelModule( moduleID, ARGUS_MODULE_EMBED_VIDEO ), basicMediaDestination(), basicThread(){
m_pEventHeap = basicEventHeap::getInstance();
DBC_MODULE_EMBED_VIDEO_DATA *tDATA = m_pDBC->getEmbedVideoData( m_nDBAUXID );
if( tDATA ) {
memcpy( &m_sEmbedVideoData, tDATA, sizeof(DBC_MODULE_EMBED_VIDEO_DATA) );
free( tDATA );
} else {
memset( &m_sEmbedVideoData, 0, sizeof(DBC_MODULE_EMBED_VIDEO_DATA) );
m_sEmbedVideoData.port = 8972;
};
char tB[64];
sprintf( tB, "Web Streams Port: %d", m_sEmbedVideoData.port );
LOG( tB );
sprintf( tB, "Frame: [%dx%d]", m_sEmbedVideoData.width, m_sEmbedVideoData.height );
LOG( tB );
n_pNoSignalData = NULL;
m_nNoSignalSize = 0;
if( m_sEmbedVideoData.show_ts ) LOG("Show TimeStamp");
if( m_sEmbedVideoData.show_label ) LOG("Show Label");
if( m_sEmbedVideoData.show_logo ){
LOG("Show Logo");
LOG( m_sEmbedVideoData.logo_md5 );
};
};
argusModuleEmbedVideo::~argusModuleEmbedVideo(){
if( n_pNoSignalData ) free( n_pNoSignalData );
m_bEnabled = false;
stopService();
};
void *argusModuleEmbedVideo::webClientProc( void *ptr ){
static char *head = "HTTP/1.1 200 OK\r\n"
"Cache-Control: no-store, no-cache, post-check=0, pre-check=0\r\n"
"Pragma: no-cache\r\n"
"MIME-version: 1.0\r\n"
"Connection: close\r\n"
//"Keep-Alive: timeout=5, max=1\r\n"
//"Connection: Keep-Alive\r\n"
//"Content-Type: video/mp4\r\n"
"Content-Transfer-Encoding: BINARY\r\n"
//"Transfer-Encoding: chunked\r\n"
"Content-type: multipart/x-mixed-replace;boundary=MPFrame\r\n"
"\r\n";
static char *abort = "HTTP/1.1 404 OK\r\n"
"Cache-Control: no-store, no-cache, post-check=0, pre-check=0\r\n"
"Pragma: no-cache\r\n"
"Connection: close\r\n\r\n";
static char *no_signal ="HTTP/1.1 200 OK\r\n"
"MIME-version: 1.0\r\n"
"Connection: close\r\n"
"Content-Transfer-Encoding: BINARY\r\n"
//"Content-type: multipart/x-mixed-replace;boundary=MPFrame\r\n\r\n"
"Content-Type: image/jpeg\r\nContent-length: %d\r\n\r\n";
WEB_CLIENT_CTX * CTX = (WEB_CLIENT_CTX *) ptr;
argusModuleEmbedVideo * MODULE = CTX->ModulePtr;
if( CTX ) {
char mesg[1024];
size_t RecvSize;
struct pollfd pfd[1];
char cGetURI[1024];
bool m_bDeflatePerMessage = false;
bool m_pInit;
#ifdef DEBUG_EXTRA
pid_t pid = gettid();
char pidBuf[16];
sprintf( pidBuf, "pid:%d", pid);
TLOG( pidBuf );
#endif
pfd->fd = CTX->m_iSocketFID;
pfd->events = POLLIN | POLLHUP;
while( CTX->bValid ) {
if( !CTX->initDone ){
int RetVal;
char * reqline[256];
RetVal = poll( pfd, 1, 1000 );
if( RetVal <= 0 ){
if ( EINTR == errno ) continue;
TLOG_ERROR("Unrecoverable error");
CTX->bValid = false;
continue;
};
memset( mesg, 0, sizeof(mesg) );
RetVal = recv( CTX->m_iSocketFID, mesg, sizeof(mesg), 0 );
if ( RetVal <= 0 ) {
sprintf( mesg, "web recv() error: %s", strerror(errno));
TLOG_ERROR( mesg );
CTX->bValid = false;
continue;
};
//TLOG( mesg );
uint32_t index = 0;
reqline[index] = strtok( mesg, "\n" );
if( strncmp( reqline[index], "GET", 3 ) == 0 ) {
char * pPartURI;
char * pPartPROTO;
pPartURI = strstr( reqline[index], " " );
if( pPartURI != NULL ) {
pPartURI++;
pPartPROTO = strstr( pPartURI, " " );
pPartPROTO++;
int URILen = pPartPROTO - pPartURI;
strncpy( cGetURI, pPartURI, URILen );
cGetURI[URILen] = (char)0;
if(strncmp( pPartPROTO, "HTTP/1.0", 8) != 0 && strncmp( pPartPROTO, "HTTP/1.1", 8) != 0) {
TLOG_ERROR("No HTTP version supplied in request!");
if( write( CTX->m_iSocketFID, "HTTP/1.1 400 Bad Request\r\n", 26) < 0 ){
sprintf( mesg, "Failed returning status 400 to client: %s", strerror(errno));
TLOG_ERROR(mesg);
};
CTX->bValid = false;
continue;
};
};
TLOG( cGetURI );
};
// parse rest of request
while( ( reqline[++index] = strtok( NULL, "\n" ) )!= NULL ) {
if( strncmp( reqline[index], "Connection:", 11 ) == 0 ) {
char * pPart;
pPart = strcasestr( reqline[index], "Upgrade" );
if( pPart != NULL ) {
TLOG("Upgrade Mode ON");
//bUpgradeMode = true;
};
};
if( strncmp( reqline[index], "Upgrade:", 8 ) == 0 ) {
/*
if( bUpgradeMode ) {
char * pPart;
pPart = strcasestr( reqline[index], "websocket" );
if( pPart != NULL ) {
TLOG("WebSocket Mode ON");
//bWebSocketMode = true;
};
};
*/
};
if( strncmp( reqline[index], "Sec-WebSocket-Version:", 22 ) == 0 ) {
char * pPart;
pPart = strstr( reqline[index], " " );
if( pPart != NULL ) {
char tBuf[CTEXT];
//nWebSocketVersion = atoi(pPart+1);
sprintf( tBuf,"Web Socket Version: %d", 0 );//nWebSocketVersion );
TLOG( tBuf );
};
};
if( strncmp( reqline[index], "Sec-WebSocket-Key:", 18 ) == 0 ) {
/*char * pPart;
pPart = strstr( reqline[index], " " );
if( pPart != NULL ) {
char tGenStr[256];
unsigned char * tBase64;
size_t nBase64;
int kLen;
unsigned char hash[SHA_DIGEST_LENGTH]; // == 20
pPart++;
kLen = strstr(pPart,"\r") - pPart;
strncpy(cWSKey,pPart,kLen);
cWSKey[kLen]=(char)0;
TLOG( cWSKey );
sprintf( tGenStr, "%s%s", cWSKey, ws_guid );
SHA1( (const unsigned char*)tGenStr, strlen(tGenStr), hash );
tBase64 = base64_encode( hash, SHA_DIGEST_LENGTH, &nBase64 );
strncpy( cWSRep, (const char*)tBase64, nBase64 );
free( tBase64 );
cWSRep[nBase64] = (char)0;
TLOG( cWSRep );
};
*/
};
if( strncmp( reqline[index], "Sec-WebSocket-Protocol:", 23 ) == 0 ) {
char * pPart;
pPart = strstr( reqline[index], " " );
if( pPart != NULL ) {
// Check for protos
};
};
if( strncmp( reqline[index], "Sec-WebSocket-Extensions:", 25 ) == 0 ) {
char * pPart;
pPart = strstr( reqline[index], " " );
if( pPart != NULL ) {
pPart++;
if(strncmp( pPart, "permessage-deflate", 18 ) == 0 ) {
m_bDeflatePerMessage = true;
TLOG("Using Deflate");
};
};
};
if( strncmp( reqline[index],"Accept-Encoding:", 16 ) == 0 ){
char * pPart;
pPart = strstr( reqline[index], " " );
if( pPart != NULL ) {
pPart++;
if(strncmp( pPart, "gzip, deflate", 13 ) == 0 ) {
m_bDeflatePerMessage = true;
TLOG("Using Deflate");
};
};
};
};
if( strncmp( cGetURI, "/stream", 7 ) == 0 ) {
uint32_t tStreamID = 0;
CSTR tP;
if( tP = strstr( cGetURI, "?" ) ) {
CSTR tB;
tP++;
if( tB = strstr( tP, "id=" ) ) {
tStreamID = atoi( tB+3 );
};
};
if( tStreamID ) {
char tB[64];
sprintf(tB,"StremID: %d", tStreamID );
TLOG( tB );
if( CTX->ModulePtr->registerForMediaStream( tStreamID, CTX ) ){
// Send Header
if( send( CTX->m_iSocketFID, head, strlen(head), 0 ) < 0 ){
sprintf( mesg, "Failed sending file to client: %s", strerror(errno));
TLOG_ERROR(mesg);
CTX->bValid = false;
};
CTX->initDone = true;
continue;
} else {
TLOG("Stream id Not Online");
};
} else TLOG("No Stream ID");
};
if( CTX->ModulePtr->n_pNoSignalData ) {
sprintf( mesg, no_signal, CTX->ModulePtr->m_nNoSignalSize );
send( CTX->m_iSocketFID, mesg, strlen(mesg), 0 );
send( CTX->m_iSocketFID, CTX->ModulePtr->n_pNoSignalData, CTX->ModulePtr->m_nNoSignalSize, 0 );
send( CTX->m_iSocketFID, "\r\n\r\n", 4, 0 );
TLOG("Sent No Signal Image!");
} else {
// Send 404 Header
send( CTX->m_iSocketFID, abort, strlen(abort), 0 );
TLOG("Aborted!");
};
CTX->bValid = false;
continue;
} else {
uint32_t msgSize;
int retVal;
retVal = read( CTX->m_iEncoderPipe[0], &msgSize, sizeof(uint32_t));
if( retVal == -1 ){
if( errno == EAGAIN || errno == EWOULDBLOCK ){
continue;
};
TLOG_ERROR("Pipe Communication Error[1]!");
CTX->bValid = false;
continue;
};
uint8_t *tBuf = (uint8_t *) malloc(msgSize);
if( tBuf ){
retVal = read( CTX->m_iEncoderPipe[0], tBuf, msgSize );
if( retVal == -1 ){
free( tBuf );
if( errno == EAGAIN || errno == EWOULDBLOCK ){
continue;
};
TLOG_ERROR("Pipe Communication Error[2]!");
CTX->bValid = false;
continue;
};
sprintf( mesg, "--MPFrame\r\nContent-type: image/jpeg\r\nContent-length: %d\r\n\r\n", msgSize );
if( send( CTX->m_iSocketFID, mesg, strlen( mesg ), 0 )< 0 ){
sprintf( mesg, "[1]Failed sending file to client: %s", strerror(errno));
TLOG_ERROR(mesg);
CTX->bValid = false;
continue;
};
if( send( CTX->m_iSocketFID, tBuf, msgSize, 0 ) < 0 ){
sprintf( mesg, "[2]Failed sending file to client: %s", strerror(errno));
TLOG_ERROR(mesg);
CTX->bValid = false;
continue;
};
if( send( CTX->m_iSocketFID, "\r\n\r\n", 4, 0 )< 0 ){
sprintf( mesg, "[3]Failed sending file to client: %s", strerror(errno));
TLOG_ERROR(mesg);
CTX->bValid = false;
continue;
};
free( tBuf );
} else {
TLOG_ERROR("Mem Alloc Error!");
CTX->bValid = false;
};
};
};
};
CTX->bValid = false;
TLOG("WEB Client Handler Ended!");
close( CTX->m_iEncoderPipe[0] );
shutdown( CTX->m_iSocketFID, SHUT_RDWR);
close( CTX->m_iSocketFID );
//pthread_exit( NULL );
return NULL;
};
void argusModuleEmbedVideo::m_fThreadProc( void ){
if( !m_bEnabled ) {
#ifdef DEBUG
LOG("Module is Disabled!");
#endif
return;
};
#ifdef DEBUG
LOG("Module Started!");
#endif
struct pollfd pfd[1];
pfd->fd = m_nSocketDescriptor;
pfd->events = POLLIN | POLLHUP;
m_bThreadStatus = TH_WORKING;
while( m_bThreadStatus < TH_ENDED ) {
if( !m_bEnabled ) {
m_bThreadStatus = TH_ENDED;
continue;
};
int RetVal = poll( pfd, 1, 1000 );
if( RetVal < 0 ){
if( EINTR == errno ) continue;
LOG_ERROR("Unrecoverable error");
m_bThreadStatus = TH_ENDED;
continue;
};
// Handle Connections
if( RetVal != 0 ){
if ( pfd[0].revents & POLLIN ) {
LOG("Handle New Client");
int tSID = accept( pfd[0].fd, NULL, NULL);
if( tSID < 0 ){
char tBuf[CTEXT];
sprintf(tBuf, "Accept() error: %s", strerror(errno));
LOG_ERROR(tBuf);
} else {
LOG("Accept OK");
WEB_CLIENT_CTX *tCTX = (WEB_CLIENT_CTX *) malloc(sizeof(WEB_CLIENT_CTX));
if( tCTX ) {
LOG("CTX OK");
WEB_HANDLER *tHANDLER = (WEB_HANDLER *) malloc(sizeof(WEB_HANDLER));
if( tHANDLER ) {
LOG("HANDLER OK");
memset( tCTX, 0, sizeof(WEB_CLIENT_CTX) );
memset( tHANDLER, 0, sizeof(WEB_HANDLER) );
tCTX->m_iSocketFID = tSID;
tCTX->m_iEncoderPipe[0] = -1;
tCTX->m_iEncoderPipe[1] = -1;
tCTX->mediaStreamId = 0;
tCTX->bValid = true;
tCTX->ModulePtr = this;
LOG("Before Thread Create");
int RetVal = pthread_create( &tHANDLER->m_hThreadHandle, NULL, webClientProc, ( void * ) tCTX );
if( RetVal == -1 ) {
free(tCTX);
free(tHANDLER);
LOG_ERROR("Thread Creation Faled.");
shutdown( tSID, SHUT_RDWR );
close( tSID );
} else {
tHANDLER->CTX = tCTX;
m_mHandlersProtector.lock();
m_vHandlersPool.push_back( tHANDLER );
m_mHandlersProtector.unlock();
LOG("Handler Pushed to a Pool");
};
} else { //https://stackoverflow.com/questions/18545077/image-fullscreen-on-click
free(tCTX);
LOG_ERROR("CL_HANDLER Mem Allocation Failure!");
shutdown( tSID, SHUT_RDWR );
close( tSID );
};
} else {
LOG_ERROR("CL_CTX Mem Allocation Failure!");
shutdown( tSID, SHUT_RDWR );
close( tSID );
};
};
};
};
// Handle Dead Clients
if( m_vHandlersPool.size() ) {
for( vectorHANDLERS::iterator idx = m_vHandlersPool.begin(); idx < m_vHandlersPool.end(); idx++ ) {
if( !( (*idx)->CTX->bValid ) ) {
pthread_join( (*idx)->m_hThreadHandle, NULL );
//close( (*idx)->CTX->m_iEncoderPipe[0] );
close( (*idx)->CTX->m_iEncoderPipe[1] );
free( (*idx)->CTX );
free( (*idx) );
m_mHandlersProtector.lock();
m_vHandlersPool.erase(idx);
m_mHandlersProtector.unlock();
#ifdef DEBUG
LOG("Web Handler Ripped!");
#endif
};
};
};
SLEEP( 50 );
};
};
#define ENABLE_SOCKOPT(sd, level, opt) \
do { \
int val = 1; \
if (setsockopt(sd, level, opt, &val, sizeof(val)) < 0) \
warn("Failed enabling %s for web service", #opt); \
} while (0);
bool argusModuleEmbedVideo::startService(){
LOG("Create");
//Create NoSignal Image
cv::Mat tMat( m_sEmbedVideoData.height, m_sEmbedVideoData.width, CV_8UC3 );
cv::rectangle( tMat, cv::Point( 0, 0 ), cv::Point( m_sEmbedVideoData.width, m_sEmbedVideoData.height ), cv::Scalar( 255, 0, 0 ), cv::FILLED );
cv::putText( tMat, "NO SIGNAL", cv::Point( 10, 30 ), cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar( 0, 255, 255 ), 3 );
if( m_sEmbedVideoData.show_logo ) {
int a_x, a_y;
if( m_sEmbedVideoData.logo_x < 0 ) {
a_x = m_sEmbedVideoData.width + m_sEmbedVideoData.logo_x - m_sEmbedVideoData.logo_w;
if( a_x < 0 ) a_x = 0;
} else a_x = m_sEmbedVideoData.logo_x;
if( ( a_x + m_sEmbedVideoData.logo_w ) > m_sEmbedVideoData.width ) a_x = m_sEmbedVideoData.width - m_sEmbedVideoData.logo_w;
if( m_sEmbedVideoData.logo_y < 0 ) {
a_y = m_sEmbedVideoData.height + m_sEmbedVideoData.logo_y - m_sEmbedVideoData.logo_h;
if( a_y < 0 ) a_y = 0;
} else a_y = m_sEmbedVideoData.logo_y;
if( ( a_y + m_sEmbedVideoData.logo_h ) > m_sEmbedVideoData.height ) a_y = m_sEmbedVideoData.height - m_sEmbedVideoData.logo_h;
if( ( a_x > -1 ) && ( a_y > -1 ) ) {
char tName[256];
m_sEmbedVideoData.logo_x = a_x;
m_sEmbedVideoData.logo_y = a_y;
sprintf( tName, "data/assets/images/%s.png", m_sEmbedVideoData.logo_md5 );
cv::Mat T = cv::imread( tName, cv::IMREAD_UNCHANGED );
if( T.cols > 0 ) {
cv::Mat mask;
vector<cv::Mat> layers;
cv::split( T, layers); // seperate channels
cv::Mat rgb[3] = { layers[0], layers[1], layers[2] };
mask = layers[3]; // png's alpha channel used as mask
cv::merge( rgb, 3, T ); // put together the RGB channels, now transp insn't transparent
cv::resize( T, m_mLogoPic, cv::Size( m_sEmbedVideoData.logo_w, m_sEmbedVideoData.logo_h ), cv::INTER_CUBIC );
cv::resize( mask, m_mLogoMask, cv::Size( m_sEmbedVideoData.logo_w, m_sEmbedVideoData.logo_h ), cv::INTER_CUBIC );
cv::Rect roi(cv::Point( m_sEmbedVideoData.logo_x, m_sEmbedVideoData.logo_y ), cv::Size( m_sEmbedVideoData.logo_w, m_sEmbedVideoData.logo_h ));
cv::Mat destinationROI = tMat( roi );
m_mLogoPic.copyTo( destinationROI, m_mLogoMask );
//m_sEmbedVideoData.show_logo = false;
} else {
LOG("Logo Disabled - No Picture is Loaded");
m_sEmbedVideoData.show_logo = false;
};
} else {
LOG("Logo Disabled - Wrong Coords");
m_sEmbedVideoData.show_logo = false;
};
};
vector<int> compression_params;
//compression_params.push_back(CV_IMWRITE_PNG_COMPRESSION);
//compression_params.push_back(9);
compression_params.push_back(cv::IMWRITE_JPEG_QUALITY);
compression_params.push_back(75);
vector<uchar> buf;
cv::imencode( ".jpg", tMat, buf, compression_params );
m_nNoSignalSize = buf.size();
n_pNoSignalData = (uint8_t *) malloc( m_nNoSignalSize );
if( n_pNoSignalData ) {
memcpy( n_pNoSignalData, buf.data(), m_nNoSignalSize );
} else m_nNoSignalSize =0;
buf.clear();
struct sockaddr sa;
struct sockaddr_in *sin;
memset(&sa, 0, sizeof(struct sockaddr));
sa.sa_family = AF_INET;
sin = (struct sockaddr_in *)&sa;
sin->sin_addr.s_addr = htonl( INADDR_ANY );
sin->sin_port = htons( m_sEmbedVideoData.port );
m_nSocketDescriptor = socket( sa.sa_family, SOCK_STREAM | SOCK_NONBLOCK, 0);
if( m_nSocketDescriptor == -1 ){
LOG_ERROR("Failed creating ACC socket");
return false;
};
ENABLE_SOCKOPT( m_nSocketDescriptor, SOL_SOCKET, SO_REUSEADDR);
#ifdef SO_REUSEPORT
ENABLE_SOCKOPT( m_nSocketDescriptor, SOL_SOCKET, SO_REUSEPORT);
#endif
if( bind( m_nSocketDescriptor, &sa, sizeof(sa)) < 0 ){
LOG_ERROR("Failed binding Socket");
close( m_nSocketDescriptor );
return false;
} else {
LOG("Bind Socessfull");
};
if( listen( m_nSocketDescriptor, 10) != 0 ){
LOG_ERROR("Failed setting web listen backlog");
close( m_nSocketDescriptor );
return false;
} else {
LOG("Listen OK");
};
return init();
};
bool argusModuleEmbedVideo::stopService(){
waitThreadEnd( true );
/*
if( m_vThreads.size() ) { // Kill-Wait Started Probes
#ifdef DEBUG
LOG("Have to Wait Probes!");
#endif
for( vectorOBSERVER_CTX::iterator index = m_vThreads.begin(); index < m_vThreads.end(); index++ ) {
pthread_join( (*index)->m_hThreadHandle, NULL );
};
m_vThreads.clear();
};
#ifdef DEBUG
LOG("No More Probes!");
#endif
if (m_vResultPool.size()){ // Clear structures
for( vectorOBSERVER_RESULT::iterator index = m_vResultPool.begin(); index < m_vResultPool.end(); index++){
free(*index);
};
m_vResultPool.clear();
};
#ifdef DEBUG
LOG("Data is Cleared!");
#endif
*/
return true;
};
bool argusModuleEmbedVideo::reloadSettings(){
return true;
};
void argusModuleEmbedVideo::dispatchEvent(EVENT_CONTAINER *Evt){
};
bool argusModuleEmbedVideo::validate(){
return true;
};
void argusModuleEmbedVideo::pushFrame( AVFrame *Frame, void* src){
MEDIA_SOURCE_DESC * tMD = (MEDIA_SOURCE_DESC *) src;
if( tMD ) {
};
};
void argusModuleEmbedVideo::pushFrame( cv::Mat &Frame, void* src ){
MEDIA_SOURCE_DESC * tMD = (MEDIA_SOURCE_DESC *) src;
if( tMD ) {
if( m_vHandlersPool.size() ) {
cv::Mat RD;
cv::resize( Frame, RD, cv::Size( m_sEmbedVideoData.width, m_sEmbedVideoData.height ), cv::INTER_LINEAR );
if( m_sEmbedVideoData.show_ts ){
char DateStr[200];
time_t t = time( NULL );
struct tm * tmp = gmtime( &t );
if( tmp ){
if( strftime( DateStr, sizeof(DateStr), "%F %T GMT", tmp )!=0 ){
cv::rectangle( RD, cv::Point( 10, 10 ), cv::Point( 490, 60 ), cv::Scalar( 0, 0, 0 ), cv::FILLED );
cv::putText( RD, DateStr, cv::Point( 30, 45 ),
(cv::HersheyFonts) m_sEmbedVideoData.ts_font_face,
m_sEmbedVideoData.ts_font_scale, cv::Scalar( 0, 255, 255 ),
m_sEmbedVideoData.ts_font_thickness,
m_sEmbedVideoData.ts_line_type
);
};
};
};
if( m_sEmbedVideoData.show_logo ){
cv::Rect roi( cv::Point( m_sEmbedVideoData.logo_x, m_sEmbedVideoData.logo_y ), cv::Size( m_sEmbedVideoData.logo_w, m_sEmbedVideoData.logo_h ));
cv::Mat destinationROI = RD( roi );
m_mLogoPic.copyTo( destinationROI, m_mLogoMask );
};
vector<int> compression_params;
//compression_params.push_back(CV_IMWRITE_PNG_COMPRESSION);
//compression_params.push_back(9);
compression_params.push_back(cv::IMWRITE_JPEG_QUALITY);
compression_params.push_back(75);
vector<uchar> buf;
uint32_t DataSize;
cv::imencode( ".jpg", RD, buf, compression_params );
DataSize = buf.size();
uint8_t *pData = buf.data();
for( vectorHANDLERS::iterator idx = m_vHandlersPool.begin(); idx < m_vHandlersPool.end(); idx++ ) {
if( (*idx)->CTX->mediaStreamId == tMD->mediaStreamId ) {
write( (*idx)->CTX->m_iEncoderPipe[1], &DataSize, sizeof(uint32_t));
write( (*idx)->CTX->m_iEncoderPipe[1], pData, DataSize );
};
};
};
};
};
bool argusModuleEmbedVideo::registerForMediaStream( uint32_t id, WEB_CLIENT_CTX *&CTX ){
if( CTX ){
if( id ){
//Check if its Valid!
DBC_MEDIA_STREAM_DATA *tSD = m_pDBC->getMediaStreamData( id );
if( tSD ) {
if( ! tSD->valid ) {
free( tSD );
return false;
};
free( tSD );
if( pipe( CTX->m_iEncoderPipe ) == -1 ){
CTX->bValid = false;
return false;
};
CTX->mediaStreamId = id;
return true;
};
};
} else LOG_ERROR("Client Context error!");
return false;
};
#undef LOG
#undef LOG_ERROR
#undef TLOG
#undef TLOG_ERROR

153
lib/rgoose/rgooseModuleEmbedVideo.h

@ -0,0 +1,153 @@
#ifndef __ARGUS_MODULE_EMBED_VIDEO_HEADER__
#define __ARGUS_MODULE_EMBED_VIDEO_HEADER__
#include "rgooseModule.h"
#include "../components/base/basicMutex.h"
#include "../components/base/basicThread.h"
#include "../components/base/basicEventHeap.h"
//#include "../data/media/video/videoAVLIBDestination.h"
#include "../components/base/basicMediaDestination.h"
class argusModuleEmbedVideo;
#define FILESTREAMBUFFERSZ 1048576
/* Video CODECS */
#define VC_VPX 0
#define VC_X264 1
#define VC_MP4 2
#define VC_MJPEG 3
#define VC_FLV 4
/* Video FORMATS */
#define VF_WEBM 0
#define VF_MP4 1
#define VF_MP3 2
#define VF_AAC 3
#define VF_OGG 4
#define VF_MJPEG 5
#define VF_FLV 6
/* Encoder PROFILES */
#define VP_ULTRAFAST 0
#define VP_VERYFAST 1
#define VP_FAST 2
#define VP_MEDIUM 3
#define VP_SLOW 4
#define VP_VERYSLOW 5
#define VP_ULTRASLOW 6
#define VIDEO_OUTPUT VO_MJPEG
//#define VIDEO_OUTPUT VO_MPEG4
//#define VIDEO_OUTPUT VO_H264
//#define VIDEO_OUTPUT VO_FLV
#define VIDEO_OUTPUT_WIDTH 640 //1920
#define VIDEO_OUTPUT_HEIGHT 480 //1080
#define VIDEO_OUTPUT_FPS 10
#define VIDEO_OUTPUT_GOP 30
#if( LIBAVCODEC_VERSION_MAJOR < 54 )
//#define VIDEO_OUTPUT_CODEC CODEC_ID_MJPEG
//#define VIDEO_OUTPUT_PIX_FMT PIX_FMT_YUVJ422P
#else
//#if( VIDEO_OUTPUT == VO_MJPEG )
#define VIDEO_OUTPUT_CODEC AV_CODEC_ID_MJPEG
#define VIDEO_OUTPUT_PIX_FMT AV_PIX_FMT_YUVJ422P
#define VIDEO_OUTPUT_CONTAINER_LONG "mjpeg"
#define VIDEO_OUTPUT_BITRATE 4000000
#define VIDEO_OUTPUT_CONTAINER "mjpeg"
/*
#endif
#if( VIDEO_OUTPUT == VO_MPEG4 )
#define VIDEO_OUTPUT_CODEC AV_CODEC_ID_MPEG4
#define VIDEO_OUTPUT_PIX_FMT AV_PIX_FMT_YUV420P
#define VIDEO_OUTPUT_CONTAINER_LONG "mp4"
#define VIDEO_OUTPUT_BITRATE 100000000
#define VIDEO_OUTPUT_CONTAINER "mp4"
//*
#endif
#if( VIDEO_OUTPUT == VO_H264 )
//* /
#define VIDEO_OUTPUT_CODEC AV_CODEC_ID_H264
#define VIDEO_OUTPUT_PIX_FMT AV_PIX_FMT_YUV420P
#define VIDEO_OUTPUT_BITRATE 100000000
#define VIDEO_OUTPUT_CONTAINER_LONG "matroska"
#define VIDEO_OUTPUT_CONTAINER "mkv"
/*
#endif
#if( VIDEO_OUTPUT == VO_FLV )
#define VIDEO_OUTPUT_CODEC AV_CODEC_ID_FLV1
#define VIDEO_OUTPUT_PIX_FMT AV_PIX_FMT_YUV420P
#define VIDEO_OUTPUT_BITRATE 4000000
#define VIDEO_OUTPUT_CONTAINER "flv"
#endif
*/
#endif
typedef struct S_buffer_data {
uint8_t * buf;
int size;
uint8_t * ptr;
size_t room; ///< size left in the buffer
} buffer_data;
#define NR_COLORS 4
#define AVIO_BUFFER_SIZE 4096
#define BD_BUFFER_SIZE 1024
typedef struct S_WEB_CLIENT_CTX{
int m_iSocketFID;
int m_iEncoderPipe[2];
bool bValid;
bool initDone;
bool headerIsSent;
uint32_t mediaStreamId;
argusModuleEmbedVideo * ModulePtr;
}WEB_CLIENT_CTX;
typedef struct S_WEB_HANDLER{
DWORD m_dwThreadID;
#ifdef __linux__
pthread_t m_hThreadHandle;
#else
HANDLE m_hThreadHandle;
#endif
WEB_CLIENT_CTX * CTX;
}WEB_HANDLER;
typedef vector<WEB_HANDLER*> vectorHANDLERS;
//typedef vector<STREAM_CTX*> vectorSTREAMS;
class argusModuleEmbedVideo: public argusKernelModule, public basicMediaDestination, public basicThread {
private:
basicEventHeap * m_pEventHeap;
static void * webClientProc( void *ptr );
int m_nSocketDescriptor;
basicMutex m_mHandlersProtector;
vectorHANDLERS m_vHandlersPool;
DBC_MODULE_EMBED_VIDEO_DATA m_sEmbedVideoData;
uint8_t * n_pNoSignalData;
uint32_t m_nNoSignalSize;
cv::Mat m_mLogoPic;
cv::Mat m_mLogoMask;
bool registerForMediaStream( uint32_t id, WEB_CLIENT_CTX *&CTX );
protected:
/* From Basic Thread */
virtual void m_fThreadProc( void );
public:
explicit argusModuleEmbedVideo( uint32_t moduleID );
~argusModuleEmbedVideo();
/* From Kernel Module */
virtual bool reloadSettings();
virtual bool startService();
virtual bool stopService();
virtual void dispatchEvent(EVENT_CONTAINER *Evt);
virtual bool validate();
/* from Media Destination */
virtual void pushFrame(AVFrame *Frame, void* src = NULL);
//virtual void pushFrame(cv::Mat* Frame, void* src = NULL);
virtual void pushFrame( cv::Mat &Frame, void* src = NULL);
};
#endif

77
lib/rgoose/rgooseModuleFactory.cpp

@ -5,6 +5,7 @@
#include "rgooseModuleFlyHunter.h"
#include "rgooseModuleSSDP.h"
#include "rgooseModuleOnvifObserver.h"
#include "rgooseModuleEmbedVideo.h"
#ifdef MEM_DEBUG
#include "../alg/generic/heapDebug.h"
@ -44,19 +45,17 @@ bool argusModuleFactory::loadModules( uint32_t ServerID ){
if(m_pDBC == NULL) return false;
m_nServerID = ServerID;
DBC_INT_LIST *tList = NULL;
LOG("Query Modules from DB");
tList = m_pDBC->listModules( m_nServerID );
if( tList != NULL ) {
if( tList->size()>0 ) {
LOG("Modules Fetched from DB");
for( int index=0; index< tList->size(); index++) {
createModule( tList->at(index) );
};
if( tList->size() ) {
for( DBC_INT_LIST::iterator idx = tList->begin(); idx < tList->end(); idx++ ) createModule( *idx );
tList->clear();
LOG("Modules Loadded");
} else {
}
#ifdef DEBUG
else {
LOG("No Modules Defined");
};
}
#endif
delete( tList );
return true;
} else {
@ -67,9 +66,6 @@ bool argusModuleFactory::loadModules( uint32_t ServerID ){
argusKernelModule *argusModuleFactory::createModule( int id ){
argusKernelModule *tVal = NULL;
#ifdef DEBUG
LOG("Create Module");
#endif
if( m_pDBC != NULL ){
DBC_MODULE_DATA *tData = NULL;
@ -113,6 +109,12 @@ argusKernelModule *argusModuleFactory::createModule( int id ){
#endif
tVal = new argusModuleOnvifObserver( tData->module_id );
break;
case ARGUS_MODULE_EMBED_VIDEO:
#ifdef DEBUG
LOG("Creating Embed Video Module");
#endif
tVal = new argusModuleEmbedVideo( tData->module_id );
break;
};
free(tData);
} else {
@ -124,9 +126,6 @@ argusKernelModule *argusModuleFactory::createModule( int id ){
if( tVal != NULL ){
tVal->startService();
m_vKernelModules.push_back( tVal );
#ifdef DEBUG
LOG("Module Created And Loadded");
#endif
};
return tVal;
};
@ -134,10 +133,13 @@ argusKernelModule *argusModuleFactory::createModule( int id ){
void argusModuleFactory::deleteModule( argusKernelModule *M ){
if( M ) {
switch( M->getType() ) {
case ARGUS_MODULE_ZLMEDIA: delete((argusModuleZLMedia *) M ); break;
case ARGUS_MODULE_DCBUSB: delete( (argusModuleUSBRelay*) M ); break;
case ARGUS_MODULE_KAFKA: delete( (argusModuleKafka*) M ); break;
case ARGUS_MODULE_FLYHUNTER: delete( (argusModuleFlyHunter*) M ); break;
case ARGUS_MODULE_ZLMEDIA: delete( (argusModuleZLMedia *) M ); break;
case ARGUS_MODULE_DCBUSB: delete( (argusModuleUSBRelay*) M ); break;
case ARGUS_MODULE_KAFKA: delete( (argusModuleKafka*) M ); break;
case ARGUS_MODULE_FLYHUNTER: delete( (argusModuleFlyHunter*) M ); break;
case ARGUS_MODULE_SSDP_ANONCE: delete( (argusModuleSSDPAnnouncer*) M ); break;
case ARGUS_MODULE_ONVIF_OBSERVER: delete( (argusModuleOnvifObserver*) M ); break;
case ARGUS_MODULE_EMBED_VIDEO: delete( (argusModuleEmbedVideo*) M ); break;
};
};
};
@ -181,10 +183,36 @@ uint32_t argusModuleFactory::fetchModules( ARGUS_MODULE_TYPE t, argusKernelModul
};
argusKernelModule *argusModuleFactory::getModule( uint32_t id ){
if( m_vKernelModules.size() > id ) {
argusKernelModule *RetVal = NULL;
if( m_vKernelModules.size() ) {
for( vectorKernelModules::iterator idx = m_vKernelModules.begin(); idx < m_vKernelModules.end(); idx++ ){
if( (*idx)->getId() == id ) {
RetVal = (*idx);
break;
};
};
};
return RetVal;
};
argusKernelModule *argusModuleFactory::getModule( ARGUS_MODULE_TYPE t, uint32_t id ){
argusKernelModule *RetVal = NULL;
if( m_vKernelModules.size() ) {
for( vectorKernelModules::iterator idx = m_vKernelModules.begin(); idx < m_vKernelModules.end(); idx++ ){
if( id ){
if( ( (*idx)->getType() == t ) && ( (*idx)->getId() == id ) ){
RetVal = (*idx);
break;
};
} else {
if( (*idx)->getType() == t ){
RetVal = (*idx);
break;
};
};
};
};
return NULL;
return RetVal;
};
void argusModuleFactory::validate( void ){
@ -239,6 +267,9 @@ void argusModuleFactory::validate( void ){
m_vKernelModules.at( cm )->validate();
cm++;
} else {
#ifdef DEBUG
LOG("Delete Module!");
#endif
deleteModule( cm );
};
};
@ -250,6 +281,10 @@ void argusModuleFactory::validate( void ){
#endif
while( m_vKernelModules.size() ) deleteModule( 0 );
};
} else {
#ifdef DEBUG
LOG("No Modules to Validate!");
#endif
};
#ifdef MEM_DEBUG
memEnd = getCurrentRSS();

1
lib/rgoose/rgooseModuleFactory.h

@ -19,6 +19,7 @@ class argusModuleFactory{
void deleteModule( argusKernelModule * );
void deleteModule( int id );
argusKernelModule * getModule( uint32_t id );
argusKernelModule * getModule( ARGUS_MODULE_TYPE t, uint32_t id = 0 );
uint32_t getModulesCount( ARGUS_MODULE_TYPE t );
uint32_t fetchModules( ARGUS_MODULE_TYPE, argusKernelModule**&RA );
bool loadModules( uint32_t ServerID = 0 );

97
lib/rgoose/rgooseModuleOnvifObserver.cpp

@ -1,5 +1,6 @@
#include "rgooseModuleOnvifObserver.h"
#include "rgooseKernel.h"
#include "rgooseHardwareResourceNetworkProvider.h"
#define SEARCH_REQUEST_STRING "<?xml version=\"1.0\" encoding=\"UTF-8\"?><e:Envelope xmlns:e=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:w=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:d=\"http://schemas.xmlsoap.org/ws/2005/04/discovery\" xmlns:dn=\"http://www.onvif.org/ver10/network/wsdl\"><e:Header><w:MessageID>uuid:84ede3de-7dec-11d0-c360-f01234567890</w:MessageID><w:To e:mustUnderstand=\"true\">urn:schemas-xmlsoap-org:ws:2005:04:discovery</w:To><w:Action a:mustUnderstand=\"true\">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</w:Action></e:Header><e:Body><d:Probe><d:Types>dn:NetworkVideoTransmitter</d:Types></d:Probe></e:Body></e:Envelope>"
#define SEARCH_REQUEST_STRING2323 "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" \
@ -143,44 +144,63 @@ void argusModuleOnvifObserver::m_fThreadProc(){
LOG("Module Started!");
#endif
while( m_bThreadStatus < TH_ENDED ) {
if( m_pIpAddresses != NULL ){
id = 0;
if( m_pKernel != NULL ){
#ifdef DEBUG_EXTRA
LOG("Check IPS");
if( m_pIpAddresses->size() > 0 ){
LOG("Have IPS");
//Start Reaper thread
dStep = 30.0 / (m_pIpAddresses->size() + 1);
// Start Discoverers on each broadcast IP
id = 0;
for( localIpAddresses::iterator index = m_pIpAddresses->begin(); index < m_pIpAddresses->end(); index++ ){
if (strlen((*index)->broadcast)){
LOG("Have BC Address");
startProbe((*index)->broadcast, id, (int) dStep );
LOG("Probe Started");
#endif
argusHardwareManager *tHWM = m_pKernel->getHardwareManager();
if( tHWM != NULL ) {
DBC_INT_LIST *rIDS = tHWM->requestResourcesByType( ARGUS_HARDWARE_PROVIDER_NETWORK );
if( rIDS != NULL ) {
dStep = 30.0 / (rIDS->size() + 1);
for( DBC_INT_LIST::iterator idx = rIDS->begin(); idx < rIDS->end(); idx++ ){
argusHardwareResourceNetwork *tRES = (argusHardwareResourceNetwork *) tHWM->requestResource( ARGUS_HARDWARE_PROVIDER_NETWORK, *idx );
if( tRES != NULL ) {
CSTR BC = tRES->getBroadcast();
if( BC!= NULL ) {
#ifdef DEBUG_EXTRA
LOG("Have BC Address");
#endif
startProbe( BC, id, (int) dStep );
#ifdef DEBUG_EXTRA
LOG("Probe Started");
#endif
dStatus += dStep;
m_nStatus = (int)dStatus;
id++;
free( BC );
}
#ifdef DEBUG_EXTRA
else {
LOG("NO BC Address");
}
#endif
;
} else {
LOG_ERROR("Cannot Get Resource!");
};
};
dStatus += dStep;
m_nStatus = (int)dStatus;
id++;
};
// default probe was here
} else {
LOG_ERROR("No Networks Detected!");
#ifdef DEBUG
LOG("Start Default Probe");
delete( rIDS );
}
#ifdef DEBUG_EXTRA
else {
LOG("No Networks Detected!");
}
#endif
startProbe(HTTPMU_HOST_ADDRESS, id, (int)dStep);
dStatus += dStep;
m_nStatus = (int)dStatus;
;
} else {
LOG_ERROR("No HW Manager");
};
} else {
LOG_ERROR("ERROR FETCHING IP ADDRESSES!" );
#ifdef DEBUG
LOG("Start Default Probe");
#endif
startProbe(HTTPMU_HOST_ADDRESS, id, (int)dStep);
dStatus += dStep;
m_nStatus = (int)dStatus;
LOG_ERROR("Kernel Not Assigned!" );
};
#ifdef DEBUG_EXTRA
LOG("Start Default Probe");
#endif
startProbe(HTTPMU_HOST_ADDRESS, id, (int)dStep);
dStatus += dStep;
m_nStatus = (int)dStatus;
SLEEP( 30000 );
};
};
@ -365,7 +385,7 @@ void *argusModuleOnvifObserver::probeThreadProc( void *ptr ){
};
};
me->observer->m_nStatus += me->step;
#ifdef DEBUG
#ifdef DEBUG_EXTRA
TLOG("Probe Finished");
#endif
#ifdef __linux__
@ -378,8 +398,9 @@ void *argusModuleOnvifObserver::probeThreadProc( void *ptr ){
};
bool argusModuleOnvifObserver::startProbe(CSTR IP, int ID, int stp){
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG("Starting Probe!");
LOG( IP );
#endif
PROBE_CTX *tVal = init_PROBE_CTX(IP, ID, stp);
if( tVal == NULL ) return false;
@ -413,7 +434,7 @@ bool argusModuleOnvifObserver::startProbe(CSTR IP, int ID, int stp){
#endif
tThread->context = tVal;
m_vThreads.push_back(tThread);
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG("Probe Created");
#endif
return true;
@ -427,21 +448,21 @@ bool argusModuleOnvifObserver::startProbe(CSTR IP, int ID, int stp){
bool argusModuleOnvifObserver::validate(){
if( m_vResultPool.size() ){ // Clear structures
for( vectorOBSERVER_RESULT::iterator index = m_vResultPool.begin(); index < m_vResultPool.end(); index++){
#ifdef DEBUG
#ifdef DEBUG_EXTRA
char tBuffer[256];
sprintf( tBuffer, "Found Camwera [%s] %s", (*index)->XAddrs, (*index)->RefID );
LOG( tBuffer );
#endif
uint32_t cid = m_pDBC->getCamId( (*index)->RefID ); //isCameraListed( DiscoverResults->at(index)->RefID );
if( cid ) {
#ifdef DEBUG
#ifdef DEBUG_EXTRA
sprintf( tBuffer, "Camera is Listed as %d", cid );
LOG( tBuffer );
#endif
m_pDBC->updateIPCam( m_pKernel->getSiteId(), cid, (*index)->XAddrs );// DiscoverResults->at(index));
} else {
// Uncknown camera - no checking
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG("Camera is Not Listed");
#endif
m_pDBC->addIPCam( m_pKernel->getSiteId(), (*index) );

36
lib/rgoose/rgooseModuleOnvifObserver.h

@ -12,10 +12,46 @@
#define HTTPMU_HOST_ADDRESS "239.255.255.250"
#define HTTPMU_HOST_PORT 3702
//#define DEBUG_ONVIF_PRINTOUT_MESSAGES
#define DEFAULT_HTTP_PORT 80
typedef vector<OBSERVER_RESULT*> vectorOBSERVER_RESULT;
class argusModuleOnvifObserver;
typedef struct S_PROBE_CTX{
int AddressID;
char IpAddress[16];
int Port;
int socketFD;
char buff[MAX_BUFF_SIZE + 1];
CSTR send_buff;
CSTR recv_buff;
struct sockaddr_in r_address;
bool bOptVal;
int bOptLen;
int iOptLen;
int RetVal;
int index;
int step;
argusModuleOnvifObserver *observer;
}PROBE_CTX;
typedef struct S_OBSERVER_CTX{
DWORD m_dwThreadID;
#ifdef __linux__
pthread_t m_hThreadHandle;
#else
HANDLE m_hThreadHandle;
#endif
PROBE_CTX * context;
}OBSERVER_CTX;
typedef vector<OBSERVER_CTX*> vectorOBSERVER_CTX;
class argusModuleOnvifObserver: public argusKernelModule, public basicThread {
private:
basicEventHeap * m_pEventHeap;

4
lib/rgoose/rgooseModuleZLMedia.cpp

@ -111,7 +111,7 @@ bool argusModuleZLMedia::validate(){
if( !m_pProtocol->requestIsFinished() ) return true;
DBC_INT_LIST *tStreams;
tStreams = m_pDBC->listMediaStreams( m_pKernel->getSiteId(), m_sSettings.id, LIST_VALID_RECORDS );
tStreams = m_pDBC->listMediaServerStreams( m_pKernel->getSiteId(), m_sSettings.id, LIST_VALID_RECORDS );
if( tStreams != NULL ){
for( int index = 0; index < tStreams->size(); index++ ) {
DBC_MEDIA_SERVER_STREAM_DATA * tData;
@ -138,7 +138,7 @@ bool argusModuleZLMedia::validate(){
case ZLM_STAGE_COLLECT_DATA:{
// Validate Invalid Streams
DBC_INT_LIST *tStreams;
tStreams = m_pDBC->listMediaStreams( m_pKernel->getSiteId(), m_sSettings.id, LIST_INVALID_RECORDS );
tStreams = m_pDBC->listMediaServerStreams( m_pKernel->getSiteId(), m_sSettings.id, LIST_INVALID_RECORDS );
if( tStreams!= NULL ) {
DBC_MEDIA_SERVER_STREAM_DATA *tData;
for( int index = 0; index < tStreams->size(); index++ ) {

3
lib/rgoose/rgooseNode.cpp

@ -20,6 +20,7 @@ argusNetNode::argusNetNode( uint32_t id ):basicObject(){
m_pTargetFilter = NULL;
if( m_pDBC != NULL ) {
DBC_NODE_DATA *tData = NULL;
m_pDBC->setNodeOnline( m_nDBID );
tData = m_pDBC->getNodeData( m_nDBID );
if( tData != NULL ) {
memcpy( &m_sNodeData , tData, sizeof(DBC_NODE_DATA));
@ -34,14 +35,12 @@ argusNetNode::argusNetNode( uint32_t id ):basicObject(){
m_sNodeData.type = ARGUS_UNKNOWN;
m_sNodeData.node_id = id;
};
LOG("FULL CONSTRUCTOR DONE!");
};
argusNetNode::argusNetNode( DBC_NODE_DATA *Data ):basicObject(){
m_nDBID = Data->node_id;
m_pDBC = argusDBC::getInstance();
memcpy( &m_sNodeData , Data, sizeof(DBC_NODE_DATA));
LOG("DATA CONSTRUCTOR DONE!");
};
argusNetNode::~argusNetNode(){

2
lib/rgoose/rgooseNode.h

@ -24,7 +24,7 @@ class argusNetNode: public basicObject{
NODE_CMD_Q m_qCommands;
basicMutex m_mCommandProtector;
protected:
argusDBC * m_pDBC;
argusDBC * m_pDBC;
uint32_t m_nDBID;
DBC_NODE_DATA m_sNodeData;
basicPosition * m_pPosition;

118
lib/rgoose/rgooseNode2D.cpp

@ -1,6 +1,5 @@
#include "rgooseNode2D.h"
#include "../hardware/uart/serialPort.h"
#include "../hardware/uart/serialSOL.h"
#include "rgooseHardwareResourceSerialProvider.h"
#include "rgooseKernel.h"
#define LOG( X ) m_pLog->Log( "2DNODE", this, X )
@ -18,7 +17,6 @@
ARGUS_2DSensor::ARGUS_2DSensor( uint32_t id ):argusNetNode( id ), basicThread(), protocolLGS_2D(){
m_bWM = ANODE_WM_2D_BEFORE_START;
m_pLog = basicLogCollection::getInstance();
m_pPosition = new basicPosition();
m_pEventHeap = basicEventHeap::getInstance();
@ -58,17 +56,24 @@ void ARGUS_2DSensor::cleanupDeviceStructures( void ){
m_bVersionStringValid = false;
};
ARGUS_2DSensor::~ARGUS_2DSensor(){
ARGUS_2DSensor::~ARGUS_2DSensor(){
#ifdef DEBUG
LOG("Stoping Service");
#endif
stopService();
#ifdef DEBUG
LOG("Service is Stoped");
#endif
if( m_pPosition ) delete( m_pPosition );
if( m_pPort != NULL ) {
switch( m_bPortType ) {
case 1: delete( (serialPort*) m_pPort ); break;
case 2: delete( (serialSOL*) m_pPort ); break;
};
} else {
// Do Nothing here - HW manager handles resources
}
#ifdef DEBUG_EXTRA
else {
LOG_ERROR("No Transport Assigned!");
};
}
#endif
;
};
bool ARGUS_2DSensor::startService() {
@ -111,10 +116,9 @@ bool ARGUS_2DSensor::validate(){
switch( m_bWM ){
case ANODE_WM_2D_PING:{
// In Idle Mode
uint8_t tCMD = 0;
tCMD = m_pDBC->getLRFPushedCMD( m_sLRF_DATA.id );
if( tCMD ) {
switch( tCMD ) {
DBC_PUSHED_CMD * PUSHED = m_pDBC->getLRFPushedCMD( m_sLRF_DATA.id );
if( PUSHED ) {
switch( PUSHED->CMD ) {
case ARGUS_LRF_PCMD_FULL_RESET:{
#ifdef DEBUG
LOG("Full Reset Push CMD!");
@ -133,6 +137,7 @@ bool ARGUS_2DSensor::validate(){
break;
};
};
free( PUSHED );
};
};
};
@ -150,66 +155,39 @@ void ARGUS_2DSensor::m_fThreadProc( void ){
switch( getWM() ) {
// Physical Connection Channel
case ANODE_WM_2D_CREATE_PORT:{
if( m_pPort != NULL ) {
switch( m_bPortType ) {
case 1: delete( (serialPort*) m_pPort ); break;
case 2: delete( (serialSOL*) m_pPort ); break;
};
m_pPort = NULL;
setTransport( m_pPort, false );
//Update Node -> Offline
m_pDBC->setNodeOffline( m_nDBID );
m_bInitialFlips = LGS_INITIAL_FLIPS;
} else {
DBC_UART_DATA *tData = NULL;
tData = m_pDBC->getUartData( m_sLRF_DATA.uart_id );
if( tData != NULL ) {
switch( m_bPortType ) {
case 1: {
#ifdef DEBUG
LOG("HW Port");
#endif
serialPort *tT = NULL;
tT = new serialPort();
if( tT!= NULL ){
if( tT->create( tData->path, tData->speed ) ){
m_pPort = (basicTransport *) tT;
} else {
delete( tT );
};
};
break;
};
case 2: {
#ifdef DEBUG
LOG("SOL Port");
#endif
serialSOL *tT = NULL;
tT = new serialSOL( (SOL_TYPE)tData->mode );
if( tT!= NULL ){
if( tT->create( tData->path, tData->port, tData->speed ) ){
m_pPort = (basicTransport *) tT;
} else {
delete( tT );
};
argusKernel *AK = argusKernel::getInstance();
if( AK != NULL ) {
argusHardwareManager *tHM = AK->getHardwareManager();
if( tHM != NULL ) {
argusHardwareResource *tRES = tHM->requestResource( ARGUS_HARDWARE_PROVIDER_SERIAL, m_sLRF_DATA.uart_id );
if( tRES != NULL ) {
if( tRES->isValid()) {
m_pPort = static_cast<basicTransport *>(static_cast<argusHardwareResourceSerialProvider *>(tRES));
//m_pPort = (basicTransport *)((argusHardwareResourceIpUART *) tRES );
//Bind To Proto
char tB[64];
sprintf( tB, "PortOBJ: %p", m_pPort );
LOG( tB );
if( !setTransport( m_pPort, false )){
LOG_ERROR("Binding Port Failure!");
} else {
LOG("Port Bind Sucessfully Done");
m_bDeviceWM = 0x00;
setWM( ANODE_WM_2D_CONNECT );
break;
};
break;
};
};
free( tData );
} else {
LOG_ERROR("Can not access Hardware Manager");
};
if( m_pPort!= NULL ) {
//Bind To Proto
if( !setTransport( m_pPort, false )){
LOG_ERROR("Binding Port Failure!");
} else {
//Node will be online uppon receive ack to getStatus
//m_pDBC->setNodeOnline( m_nDBID, ARGUS_NODE_STATUS_INIT );
m_bDeviceWM = 0x00;
setWM( ANODE_WM_2D_CONNECT );
};
} else SLEEP( 500 );
} else {
LOG_ERROR("Can not access Kernel");
};
setTransport( NULL, false );
m_pDBC->setNodeOffline( m_nDBID );
m_bInitialFlips = LGS_INITIAL_FLIPS;
SLEEP( 500 );
break;
};
// Logical Connection Checking
@ -486,7 +464,7 @@ void ARGUS_2DSensor::setWM( uint8_t MD ){
bool ARGUS_2DSensor::packetHandler( protocolPackage *Package ){
uint8_t cDeviceID = Package->m_pData[DEV_ID_IDX];
if( ( cDeviceID == m_sLRF_DATA.device_id ) || ( cDeviceID == 0 ) ) {
if( ( cDeviceID == m_sLRF_DATA.device_id ) || ( m_sLRF_DATA.device_id == 0 ) ) {
#ifdef DEBUG
char tBuff[256];
//LOG("Device Reply");

25
lib/rgoose/rgooseNode3D.cpp

@ -8,7 +8,14 @@ argus3DLIDAR::argus3DLIDAR( uint32_t ID ): argusNetNode( ID ){
m_pMasterNode = NULL;
m_pSlaveNode = NULL;
m_pEventHeap = basicEventHeap::getInstance();
memset( &m_sDATA, 0, sizeof(DBC_LRF_DATA) );
DBC_LRF_DATA *tDATA = m_pDBC->getLRFData( m_sNodeData.aux_id );
if( tDATA != NULL ) {
memcpy( &m_sDATA, tDATA, sizeof(DBC_LRF_DATA));
free( tDATA );
} else {
memset( &m_sDATA, 0, sizeof(DBC_LRF_DATA));
};
};
argus3DLIDAR::~argus3DLIDAR(){
@ -23,14 +30,14 @@ bool argus3DLIDAR::startService(){
LOG_ERROR("No Database Connector Defined!");
return false;
};
DBC_LRF_DATA *tData;
tData = m_pDBC->getLRFData( m_sNodeData.aux_id );
if( tData == NULL ) {
LOG_ERROR("No Database Data!!");
return false;
};
memcpy( &m_sDATA, tData, sizeof(DBC_LRF_DATA));
free( tData );
// DBC_LRF_DATA *tData;
// tData = m_pDBC->getLRFData( m_sNodeData.aux_id );
// if( tData == NULL ) {
// LOG_ERROR("No Database Data!!");
// return false;
// };
// memcpy( &m_sDATA, tData, sizeof(DBC_LRF_DATA));
// free( tData );
m_pMasterNode = new sensorLGS3D( m_sNodeData.node_id, true );
if( m_pMasterNode != NULL ) {
#ifdef DEBUG

75
lib/rgoose/rgooseNodeFactory.cpp

@ -28,6 +28,7 @@ argusNodeFactory* argusNodeFactory::getInstance() {
argusNodeFactory::argusNodeFactory(){
m_pLog = basicLogCollection::getInstance();
m_pDBC = argusDBC::getInstance();
LOG("CONSTRUCTION");
};
argusNodeFactory::~argusNodeFactory(){
@ -80,14 +81,35 @@ bool argusNodeFactory::unloadNodes( void ){
};
return true;
};
/*
bool argusNodeFactory::loadNodes( uint32_t SiteID ){
LOG("Node Loader");
if(m_pDBC == NULL) return false;
m_nSiteID = SiteID;
DBC_INT_LIST *tList = NULL;
tList = m_pDBC->listNodes( SiteID );
DBC_INT_LIST *tList = m_pDBC->listNodes( SiteID );
if( tList != NULL ) {
for( DBC_INT_LIST::iterator idx = tList->begin(); idx < tList->end(); idx++ ){
uint32_t id = *idx;
char msg[64];
sprintf( msg, "Creating Node[%d]", id );
createNode( id );
};
tList->clear();
delete( tList );
return true;
};
return false;
};
*/
bool argusNodeFactory::loadNodes( uint32_t SiteID ){
if( m_pDBC == NULL ) return false;
LOG("DB OK");
m_nSiteID = SiteID;
DBC_INT_LIST *tList = m_pDBC->listNodes( SiteID );
if( tList != NULL ) {
LOG("Have Nodes");
for( int index=0; index< tList->size(); index++ ) {
LOG("Have to Create");
createNode( tList->at(index) );
};
tList->clear();
@ -120,6 +142,7 @@ bool argusNodeFactory::reloadNode( uint32_t NodeID ){
argusNetNode *argusNodeFactory::createNode( uint32_t id ){
argusNetNode *tVal = NULL;
LOG("Create Node!");
if( m_pDBC != NULL ){
DBC_NODE_DATA *tData = NULL;
tData = m_pDBC->getNodeData( id );
@ -142,9 +165,10 @@ argusNetNode *argusNodeFactory::createNode( uint32_t id ){
ARGUS_PTZCAM *tCamera;
tCamera = new ARGUS_PTZCAM( id );
if( tCamera ) {
LOG("Success");
LOG("Starting Service");
tCamera->startService();
tVal = ( argusNetNode *) tCamera;
LOG("Success");
};
break;
};
@ -156,9 +180,10 @@ argusNetNode *argusNodeFactory::createNode( uint32_t id ){
ARGUS_PTZCAM *tCamera;
tCamera = new ARGUS_PTZCAM( id );
if( tCamera ) {
LOG("Success");
LOG("Starting Service");
tCamera->startService();
tVal = ( argusNetNode *) tCamera;
LOG("Success");
};
break;
};
@ -290,13 +315,19 @@ void argusNodeFactory::deleteNode( argusNetNode *ptr ){
#ifdef DEBUG
LOG("Destroying Network Static Camera");
#endif
delete((ARGUS_Camera *) ptr );
SLEEP(2000);
LOG("Actual Destroying Network Static Camera");
delete((ARGUS_PTZCAM *) ptr );
break;
case ARGUS_IP_PTZ_CAMERA:
#ifdef DEBUG
LOG("Destroying Network PTZ Camera");
#endif
delete((ARGUS_Camera *) ptr );
SLEEP(2000);
delete((ARGUS_PTZCAM *) ptr );
#ifdef DEBUG
LOG("Done Successfuly");
#endif
break;
case ARGUS_IP_UART_GATEWAY:
#ifdef DEBUG
@ -381,7 +412,7 @@ void argusNodeFactory::validate( void ){
#endif
if( m_vNetNodes.size() ) {
DBC_INT_LIST tL;
for( int cm = 0; cm < m_vNetNodes.size(); cm++ ) tL.push_back( m_vNetNodes.at(cm)->getDbId() );
for( vectorNetNodes::iterator idx = m_vNetNodes.begin(); idx < m_vNetNodes.end(); idx++ ) tL.push_back( (*idx)->getDbId() );
tList = m_pDBC->listNewNodes( m_nSiteID, &tL );
tL.clear();
} else {
@ -389,7 +420,7 @@ void argusNodeFactory::validate( void ){
};
if( tList != NULL ) {
LOG("New Nodes Added!");
for( int index=0; index< tList->size(); index++) createNode(tList->at(index));
for( DBC_INT_LIST::iterator idx = tList->begin(); idx < tList->end(); idx++ ) createNode( *idx );
tList->clear();
delete( tList );
};
@ -403,29 +434,21 @@ void argusNodeFactory::validate( void ){
//Get Full List
tList = m_pDBC->listNodes( m_nSiteID );
if( tList != NULL ) {
int cm = 0;
while( cm < m_vNetNodes.size() ) {
//check if module removed
for( vectorNetNodes::iterator idx = m_vNetNodes.begin(); idx < m_vNetNodes.end(); idx++ ){
bool tRemoved = true;
for( int lm = 0; lm < tList->size(); lm++ ) {
if( tList->at(lm) == m_vNetNodes.at(cm)->getDbId() ) {
tRemoved = false;
break;
};
};
if( !tRemoved ) {
// validate module
m_vNetNodes.at(cm)->validate();
cm++;
} else {
deleteNode( cm );
for( DBC_INT_LIST::iterator idz = tList->begin(); idz < tList->end(); idz++ ) if( (*idz) == (*idx)->getDbId() ) tRemoved = false;
tRemoved = !(*idx)->validate();
if( tRemoved ) {
deleteNode((*idx));
};
};
};
tList->clear();
delete( tList );
} else {
LOG("All Modules Must be Deleted!");
while( m_vNetNodes.size() ) deleteNode( (uint32_t) 0 );
for( vectorNetNodes::iterator idx = m_vNetNodes.begin(); idx < m_vNetNodes.end(); idx++ ) deleteNode((*idx));
m_vNetNodes.clear();
m_mNetNodesIDS.clear();
};
};
#ifdef MEM_DEBUG

61
lib/rgoose/rgooseNodePTZCamControl.cpp

@ -40,11 +40,13 @@ ARGUS_PTZCAM::ARGUS_PTZCAM( DBC_NODE_DATA *Data ): basicEventHandler(), argusNet
ARGUS_PTZCAM::ARGUS_PTZCAM( uint32_t id ): basicEventHandler(), argusNetNode( id ), ARGUS_Camera(){
m_pLog = basicLogCollection::getInstance();
memset( &m_sCtrlData, 0, sizeof(CAMERA_CTRL_DATA) );
m_sMediaSource.mediaSourceId = m_sNodeData.aux_id;
memset( &m_sCtrlData, 0, sizeof( CAMERA_CTRL_DATA ));
};
ARGUS_PTZCAM::~ARGUS_PTZCAM(){
LOG("Destructor");
stopService();
};
bool ARGUS_PTZCAM::startService(){
@ -142,7 +144,60 @@ void ARGUS_PTZCAM::dispatchEvent( EVENT_CONTAINER *E ){
};
};
};
bool ARGUS_PTZCAM::validate(){
//LOG("VALIDATE");
if( m_bThreadStatus == TH_ENDED ) return false;
if( !argusNetNode::m_pDBC ) return false;
//Validate Node Settings
{
DBC_NODE_DATA *tDATA = argusNetNode::m_pDBC->getNodeData( m_nDBID );
if( tDATA ) {
if( memcmp( &m_sNodeData, tDATA, sizeof(DBC_NODE_DATA)) != 0 ){
free( tDATA );
LOG("Node Settings Changed!");
return false;
};
free( tDATA );
} else {
LOG("Node Deleted!");
return false;
};
}
// Validate Camera Settings
/*{
DBC_CAM_DATA *tDATA = argusNetNode::m_pDBC->getCamData( m_sNodeData.aux_id );
if( tDATA ) {
if( memcmp( &m_sCamData, tDATA, sizeof(DBC_CAM_DATA)) != 0 ){
free( tDATA );
LOG("Cam Settings Changed!");
return false;
};
free( tDATA );
} else{
LOG("Cam Deleted!");
return false;
};
}*/
// Validate Stream
{
if( m_sNodeData.aux_parameter ) { // Has Choosed Stream
DBC_MEDIA_STREAM_DATA *tDATA = argusNetNode::m_pDBC->getMediaStreamData( m_sNodeData.aux_parameter );
if( tDATA ){
if( tDATA->valid ) {
if( !m_bSourceConnected ) {
if(!connectToStream( m_sNodeData.aux_parameter ) ) return false;
};
} else {
if( m_bSourceConnected ) {
if( disconnectFromStream() ) return false;
};
};
free( tDATA );
};
};
}
return true;
};
#undef LOG
#undef LOG_ERROR

2
lib/rgoose/rgooseNodePTZCamControl.h

@ -45,7 +45,7 @@ class ARGUS_PTZCAM: public ARGUS_Camera, public argusNetNode, public basicEventH
virtual void dispatchEvent( EVENT_CONTAINER *Evt );
virtual bool startService();
virtual bool stopService();
virtual bool validate();
};
#endif

87
lib/rgoose/rgooseTypes.h

@ -1,7 +1,20 @@
#ifndef __ARGUSE_DATA_TYPES_HEADERS__
#define __ARGUSE_DATA_TYPES_HEADERS__
#include <vector>
#ifdef __linux__
#include <pthread.h>
#include <unistd.h>
#include <fcntl.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#else
#include <winsock2.h>
#include <winsock.h>
#include <iostream>
#endif
#define ONE_DAY_HISTORY 86400
#define ONE_HOUR_HISTORY 3600
@ -35,6 +48,25 @@
#define ARGUS_DS_VALID 3
#define ARGUS_DS_CONF_MISTMATCH 4
#define MAX_BUFF_SIZE 102400 //100K
typedef struct S_OBSERVER_RESULT{
int resultID;
char RefID[CTEXT];
char Type[CTEXT];
char MAC[CTEXT];
char Hardware[CTEXT];
char Name[CTEXT];
char XAddrs[CTEXT];
}OBSERVER_RESULT;
typedef struct S_MEDIA_SOURCE_DESC{
uint32_t mediaStreamId;
uint32_t mediaSourceId;
}MEDIA_SOURCE_DESC;
typedef enum E_ARGUS_NODE_TYPE{
ARGUS_SERVER = 0,
ARGUS_ALS_SENSOR = 1,
@ -78,6 +110,14 @@ typedef enum E_ARGUS_SOCKET_TYPE{
}ARGUS_SOCKET_TYPE;
*/
typedef enum E_ARGUS_HARDWARE_PROVIDERS{
ARGUS_HARDWARE_PROVIDER_UNKNOWN = 0,
ARGUS_HARDWARE_PROVIDER_SERIAL = 1,
ARGUS_HARDWARE_PROVIDER_NETWORK = 2,
ARGUS_HARDWARE_PROVIDER_VIDEO = 3,
ARGUS_HARDWARE_PROVIDER_DRY_CONTACT = 4
} ARGUS_HARDWARE_PROVIDERS;
typedef enum E_ARGUS_HARDWARE_TYPE{
ARGUS_HARDWARE_UNKNOWN = 0,
ARGUS_HARDWARE_UART = 1,
@ -93,6 +133,7 @@ typedef enum E_ARGUS_HARDWARE_TYPE{
ARGUS_HARDWARE_IP_VIDEO_IN = 131
} ARGUS_HARDWARE_TYPE;
typedef struct S_DBC_CAM_DATA{
uint32_t id;
uint32_t site_id;
@ -116,6 +157,7 @@ typedef struct S_DBC_CAM_DATA{
float min_f;
float max_f;
float max_range;
float ptz_speed_step;
uint8_t pan_model;
uint16_t pan_angles;
uint8_t tilt_model;
@ -131,9 +173,17 @@ typedef struct S_DBC_CAM_DATA{
char ptz_token[65];
}DBC_CAM_DATA;
typedef struct S_DBC_NET_IF_DATA{
char address[64];
char netmask[64];
char broadcast[64];
char gateway[64];
}DBC_NET_IF_DATA;
typedef struct S_DBC_NODE_DATA{
uint32_t node_id;
uint32_t aux_id;
uint32_t aux_parameter;
ARGUS_NODE_TYPE type;
bool online;
uint32_t tss;
@ -149,6 +199,34 @@ typedef struct S_DBC_MODULE_DATA{
char name[128];
}DBC_MODULE_DATA;
typedef struct S_DBC_MODULE_EMBED_VIDEO_DATA{
uint16_t port;
bool show_ts;
bool show_label;
bool show_logo;
uint16_t width;
uint16_t height;
int ts_x;
int ts_y;
uint8_t ts_font_face;
float ts_font_scale;
int8_t ts_font_thickness;
int ts_line_type;
bool ts_transperant;
int label_x;
int label_y;
uint8_t label_font_face;
float label_font_scale;
int8_t label_font_thickness;
int label_line_type;
bool label_transperant;
uint8_t logo_w;
uint8_t logo_h;
int logo_x;
int logo_y;
char logo_md5[33];
}DBC_MODULE_EMBED_VIDEO_DATA;
/*
typedef struct S_DBC_SOCKET_DATA{
uint32_t socket_id;
@ -171,6 +249,11 @@ typedef struct S_DBC_RESOURCE_DATA{
char device[64];
}DBC_RESOURCE_DATA;
typedef struct S_DBC_PUSHED_CMD{
uint8_t CMD;
int PARAM;
}DBC_PUSHED_CMD;
typedef struct S_DBC_MEDIA_STREAM_DATA{
uint32_t id;
uint32_t source_id;
@ -178,6 +261,8 @@ typedef struct S_DBC_MEDIA_STREAM_DATA{
char source_type[2];
bool valid;
char token[65];
uint32_t width;
uint32_t height;
char mrl_proto[6];
uint16_t mrl_port;
char mrl[251];

Loading…
Cancel
Save