Skip to content

Commit

Permalink
add onvif interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ruminsam committed Aug 23, 2013
1 parent 64c56d3 commit 0d6ec50
Show file tree
Hide file tree
Showing 221 changed files with 341,531 additions and 2 deletions.
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Section: admin
Priority: optional
Maintainer: Bluecherry <maintainers@bluecherry.net>
Build-Depends: debhelper (>= 7), libmysqlclient-dev, php5-dev,
libidn11-dev, libbsd-dev, yasm, libudev-dev
libidn11-dev, libbsd-dev, yasm, libudev-dev, libxmlrpc-c3-dev
Standards-Version: 3.8.4

Package: bluecherry
Architecture: any
Pre-Depends: adduser
Depends: ${shlibs:Depends}, ssl-cert, dbconfig-common, ucf, mysql-server, curl,
libapache2-mod-php5, sysstat, php5-gd, mkvtoolnix, php-mail, php-mail-mime,
php-net-smtp
php-net-smtp, libxmlrpc-c3-dev
Suggests: solo6010-dkms, monit
Breaks: solo6010-dkms (<< 2.4.7)
Description: Bluecherry DVR Server
Expand Down
24 changes: 24 additions & 0 deletions onvif/DeviceManagement/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
INCLUDE=-I./ -I./gsoap/
CXX=${HOST}-g++
CFLAGS= ${INCLUDE} -DLINUX_NAS -fPIC -c

LIBS= -L/lib -lssl -lcrypto -ldl

all:
$(CXX) $(CFLAGS) gsoap/duration.cpp
$(CXX) $(CFLAGS) gsoap/soapC.cpp
$(CXX) $(CFLAGS) gsoap/soapClient.cpp
$(CXX) $(CFLAGS) gsoap/stdsoap2.cpp
$(CXX) $(CFLAGS) gsoap/dom.cpp
$(CXX) $(CFLAGS) gsoap/mecevp.cpp
$(CXX) $(CFLAGS) gsoap/smdevp.cpp
$(CXX) $(CFLAGS) gsoap/wsseapi.cpp
$(CXX) $(CFLAGS) gsoap/threads.cpp
$(CXX) $(CFLAGS) devmng.cpp
$(CXX) $(LIBS) -shared -o libsoapdevmng.so duration.o soapC.o soapClient.o stdsoap2.o dom.o mecevp.o smdevp.o wsseapi.o threads.o devmng.o -Wl,--version-script=devmng.map

cp -f libsoapdevmng.so /work/bluecherry/bluecherry-apps/onvif/lib
cp -f libsoapdevmng.so /usr/lib
echo Successfully Finished!!!
clean:
rm -rf *.o *.a *.so
134 changes: 134 additions & 0 deletions onvif/DeviceManagement/devmng.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#include "stdafx.h"
#ifdef LINUX_NAS
#include <string>
using namespace std;

#include "devmng.h"
#include "gsoap/soapH.h"
#include "gsoap/DeviceBinding.nsmap"
#include "gsoap/smdevp.h"
#include "gsoap/wsseapi.h"

/************************************************************************************/
/* Function Name : getMediaUrl */
/* Function Desc : get media service url */
/* Author : ruminsam */
/************************************************************************************/
bool getMediaUrl(char* xAddress, char* userId, char* password, char* mediaUrl)
{
int authFlag = 1; // 1 : UsernameTokenDigest, 0: UsernameTokenText

sprintf(mediaUrl, "%s", xAddress);

struct soap* soap = new struct soap;

soap_init2(soap, SOAP_IO_KEEPALIVE, SOAP_IO_KEEPALIVE);
soap->connect_timeout = 7;
soap->recv_timeout = 7;

struct _ns1__GetCapabilities getCapabilitiesRequest;
struct _ns1__GetCapabilitiesResponse getCapabilitiesResponse;

getCapabilitiesRequest.__sizeCategory = 1;

enum ns2__CapabilityCategory category;
category = ns2__CapabilityCategory__All;
getCapabilitiesRequest.Category = &category;

soap_wsse_add_UsernameTokenDigest(soap, NULL, userId, password);
soap_call___ns1__GetCapabilities(soap, xAddress, "", &getCapabilitiesRequest, &getCapabilitiesResponse);

if (soap->error)
{
soap_wsse_add_UsernameTokenText(soap, NULL, userId, password);
soap_call___ns1__GetCapabilities(soap, xAddress, "", &getCapabilitiesRequest, &getCapabilitiesResponse);
if (soap->error)
{
soap_destroy(soap);
soap_end(soap);
soap_done(soap);
delete soap;
return false;
}

authFlag = 0;
}

if (getCapabilitiesResponse.Capabilities == NULL)
{
soap_destroy(soap);
soap_end(soap);
soap_done(soap);
delete soap;
return false;
}

if (getCapabilitiesResponse.Capabilities->Media != NULL && getCapabilitiesResponse.Capabilities->Media->XAddr != NULL)
{
sprintf(mediaUrl, "%s", getCapabilitiesResponse.Capabilities->Media->XAddr);
}

soap_destroy(soap);
soap_end(soap);
soap_done(soap);
delete soap;
return true;
}

bool getDeviceInfo(char* xAddress, char* userId, char* password, char* make, char* model, char* firmware)
{
int authFlag = 1; // 1 : UsernameTokenDigest, 0: UsernameTokenText

sprintf(make, "%s", "");
sprintf(model, "%s", "");
sprintf(firmware, "%s", "");

struct soap* soap = new struct soap;

char serverUri[100];

sprintf(serverUri, "%s", xAddress);

soap_init2(soap, SOAP_IO_KEEPALIVE, SOAP_IO_KEEPALIVE);

soap_wsse_add_UsernameTokenDigest(soap, NULL, userId, password);
soap->connect_timeout = 7;
soap->recv_timeout = 7;

struct _ns1__GetDeviceInformation request;
struct _ns1__GetDeviceInformationResponse result;

soap_call___ns1__GetDeviceInformation(soap, serverUri, "", &request, &result);

if (soap->error)
{
soap_wsse_add_UsernameTokenText(soap, NULL, userId, password);
soap_call___ns1__GetDeviceInformation(soap, serverUri, "", &request, &result);
if (soap->error)
{
soap_destroy(soap);
soap_end(soap);
soap_done(soap);
delete soap;
return false;
}

authFlag = 0;
}

if (result.Manufacturer != NULL)
sprintf(make, "%s", result.Manufacturer);
if (result.Model != NULL)
sprintf(model, "%s", result.Model);
if (result.FirmwareVersion != NULL)
sprintf(firmware, "%s", result.FirmwareVersion);

soap_destroy(soap);
soap_end(soap);
soap_done(soap);
delete soap;

return true;
}

#endif
4 changes: 4 additions & 0 deletions onvif/DeviceManagement/devmng.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extern "C" {
bool getMediaUrl(char* xAddress, char* userId, char* password, char* mediaUrl);
bool getDeviceInfo(char* xAddress, char* userId, char* password, char* make, char* model, char* firmware);
}
4 changes: 4 additions & 0 deletions onvif/DeviceManagement/devmng.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
global: getMediaUrl;getDeviceInfo;
local: *;
};
19 changes: 19 additions & 0 deletions onvif/DeviceManagement/gsoap/DeviceBinding.nsmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

#include "soapH.h"
SOAP_NMAC struct Namespace namespaces[] =
{
{"SOAP-ENV", "http://www.w3.org/2003/05/soap-envelope", "http://www.w3.org/2003/05/soap-envelope", NULL},
{"SOAP-ENC", "http://www.w3.org/2003/05/soap-encoding", "http://www.w3.org/2003/05/soap-encoding", NULL},
{"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},
{"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},
{"c14n", "http://www.w3.org/2001/10/xml-exc-c14n#", NULL, NULL},
{"wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", NULL, NULL},
{"xenc", "http://www.w3.org/2001/04/xmlenc#", NULL, NULL},
{"ds", "http://www.w3.org/2000/09/xmldsig#", NULL, NULL},
{"wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd", NULL},
{"xmime", "http://tempuri.org/xmime.xsd", NULL, NULL},
{"xop", "http://www.w3.org/2004/08/xop/include", NULL, NULL},
{"ns2", "http://www.onvif.org/ver10/schema", NULL, NULL},
{"ns1", "http://www.onvif.org/ver10/device/wsdl", NULL, NULL},
{NULL, NULL, NULL, NULL}
};
Loading

0 comments on commit 0d6ec50

Please sign in to comment.