Skip to content

Commit

Permalink
Rename pull and push
Browse files Browse the repository at this point in the history
  • Loading branch information
roleoroleo committed Sep 9, 2024
1 parent e7c4761 commit aa04e0c
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Brief explanation of some parameters:
| ptz | 1 if onvif_simple_server can control PTZ, 0 otherwise |
| max_step_* | max values of x and y movements reported by the cam (min = 0) |
| move_* | the binary that moves the PTZ controls, onvif_simple_server will run it with a system call |
| events | set to 1 to enable ONVIF PullPoint, 2 to enable WS Base Notification or 3 to enable both |
| events | set to 1 to enable PullPoint, 2 to enable Base Subscription or 3 to enable both |
| topic | the topic of the event |
| source_name | the source name inside the Notify message |
| source_value | the source value inside the Notify message |
Expand Down
6 changes: 3 additions & 3 deletions conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,11 @@ int process_conf_file(char *file)
//Events Profile for ONVIF Events Service
} else if (strcasecmp(param, "events") == 0) {
if (strcasecmp(value, "1") == 0) {
service_ctx.events_enable = EVENTS_PULL; // Pull
service_ctx.events_enable = EVENTS_PULLPOINT; // PullPoint
} else if (strcasecmp(value, "2") == 0) {
service_ctx.events_enable = EVENTS_PUSH; // WS Base
service_ctx.events_enable = EVENTS_BASESUBSCRIPTION; // Base Subscription
} else if (strcasecmp(value, "3") == 0) {
service_ctx.events_enable = EVENTS_BOTH; // Pull and WS Base
service_ctx.events_enable = EVENTS_BOTH; // PullPoint and Base Subscription
}
} else if (strcasecmp(param, "topic") == 0) {
if (service_ctx.events_enable != EVENTS_NONE) {
Expand Down
68 changes: 34 additions & 34 deletions device_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int device_get_services()
char port[8];
const char *cap;

char epush[8], epull[8];
char ebasesubscription[8], epullpoint[8];

port[0] = '\0';
if (service_ctx.port != 80)
Expand All @@ -53,15 +53,15 @@ int device_get_services()
sprintf(ptz_service_address, "http://%s%s/onvif/ptz_service", address, port);
sprintf(events_service_address, "http://%s%s/onvif/events_service", address, port);

if ((service_ctx.events_enable == EVENTS_PULL) || (service_ctx.events_enable == EVENTS_BOTH)) {
strcpy(epull, "true");
if ((service_ctx.events_enable == EVENTS_PULLPOINT) || (service_ctx.events_enable == EVENTS_BOTH)) {
strcpy(epullpoint, "true");
} else {
strcpy(epull, "false");
strcpy(epullpoint, "false");
}
if ((service_ctx.events_enable == EVENTS_PUSH) || (service_ctx.events_enable == EVENTS_BOTH)) {
strcpy(epush, "true");
if ((service_ctx.events_enable == EVENTS_BASESUBSCRIPTION) || (service_ctx.events_enable == EVENTS_BOTH)) {
strcpy(ebasesubscription, "true");
} else {
strcpy(epush, "false");
strcpy(ebasesubscription, "false");
}

cap = get_element("IncludeCapability", "Body");
Expand All @@ -71,8 +71,8 @@ int device_get_services()
"%DEVICE_SERVICE_ADDRESS%", device_service_address,
"%MEDIA_SERVICE_ADDRESS%", media_service_address,
"%EVENTS_SERVICE_ADDRESS%", events_service_address,
"%EVENTS_PUSH%", epush,
"%EVENTS_PULL%", epull);
"%EVENTS_BASESUBSCRIPTION%", ebasesubscription,
"%EVENTS_PULLPOINT%", epullpoint);

fprintf(stdout, "Content-type: application/soap+xml\r\n");
fprintf(stdout, "Content-Length: %ld\r\n\r\n", size);
Expand All @@ -81,16 +81,16 @@ int device_get_services()
"%DEVICE_SERVICE_ADDRESS%", device_service_address,
"%MEDIA_SERVICE_ADDRESS%", media_service_address,
"%EVENTS_SERVICE_ADDRESS%", events_service_address,
"%EVENTS_PUSH%", epush,
"%EVENTS_PULL%", epull);
"%EVENTS_BASESUBSCRIPTION%", ebasesubscription,
"%EVENTS_PULLPOINT%", epullpoint);
} else {
long size = cat(NULL, "device_service_files/GetServices_with_capabilities_ptz.xml", 12,
"%DEVICE_SERVICE_ADDRESS%", device_service_address,
"%MEDIA_SERVICE_ADDRESS%", media_service_address,
"%PTZ_SERVICE_ADDRESS%", ptz_service_address,
"%EVENTS_SERVICE_ADDRESS%", events_service_address,
"%EVENTS_PUSH%", epush,
"%EVENTS_PULL%", epull);
"%EVENTS_BASESUBSCRIPTION%", ebasesubscription,
"%EVENTS_PULLPOINT%", epullpoint);

fprintf(stdout, "Content-type: application/soap+xml\r\n");
fprintf(stdout, "Content-Length: %ld\r\n\r\n", size);
Expand All @@ -100,8 +100,8 @@ int device_get_services()
"%MEDIA_SERVICE_ADDRESS%", media_service_address,
"%PTZ_SERVICE_ADDRESS%", ptz_service_address,
"%EVENTS_SERVICE_ADDRESS%", events_service_address,
"%EVENTS_PUSH%", epush,
"%EVENTS_PULL%", epull);
"%EVENTS_BASESUBSCRIPTION%", ebasesubscription,
"%EVENTS_PULLPOINT%", epullpoint);
}
} else {
if (service_ctx.ptz_node.enable == 0) {
Expand Down Expand Up @@ -292,7 +292,7 @@ int device_get_capabilities()
int icategory;
const char *category;

char epush[8], epull[8];
char ebasesubscription[8], epullpoint[8];

category = get_element("Category", "Body");
if (category != NULL) {
Expand Down Expand Up @@ -322,15 +322,15 @@ int device_get_capabilities()
sprintf(ptz_service_address, "http://%s%s/onvif/ptz_service", address, port);
sprintf(events_service_address, "http://%s%s/onvif/events_service", address, port);

if ((service_ctx.events_enable == EVENTS_PULL) || (service_ctx.events_enable == EVENTS_BOTH)) {
strcpy(epull, "true");
if ((service_ctx.events_enable == EVENTS_PULLPOINT) || (service_ctx.events_enable == EVENTS_BOTH)) {
strcpy(epullpoint, "true");
} else {
strcpy(epull, "false");
strcpy(epullpoint, "false");
}
if ((service_ctx.events_enable == EVENTS_PUSH) || (service_ctx.events_enable == EVENTS_BOTH)) {
strcpy(epush, "true");
if ((service_ctx.events_enable == EVENTS_BASESUBSCRIPTION) || (service_ctx.events_enable == EVENTS_BOTH)) {
strcpy(ebasesubscription, "true");
} else {
strcpy(epush, "false");
strcpy(ebasesubscription, "false");
}

if (icategory == 1) {
Expand Down Expand Up @@ -368,24 +368,24 @@ int device_get_capabilities()
} else if (icategory == 8) {
long size = cat(NULL, "device_service_files/GetEventsCapabilities.xml", 6,
"%EVENTS_SERVICE_ADDRESS%", events_service_address,
"%EVENTS_PUSH%", epush,
"%EVENTS_PULL%", epull);
"%EVENTS_BASESUBSCRIPTION%", ebasesubscription,
"%EVENTS_PULLPOINT%", epullpoint);

fprintf(stdout, "Content-type: application/soap+xml\r\n");
fprintf(stdout, "Content-Length: %ld\r\n\r\n", size);

return cat("stdout", "device_service_files/GetEventsCapabilities.xml", 6,
"%EVENTS_SERVICE_ADDRESS%", events_service_address,
"%EVENTS_PUSH%", epush,
"%EVENTS_PULL%", epull);
"%EVENTS_BASESUBSCRIPTION%", ebasesubscription,
"%EVENTS_PULLPOINT%", epullpoint);
} else {
if (service_ctx.ptz_node.enable == 0) {
long size = cat(NULL, "device_service_files/GetCapabilities_no_ptz.xml", 10,
"%DEVICE_SERVICE_ADDRESS%", device_service_address,
"%MEDIA_SERVICE_ADDRESS%", media_service_address,
"%EVENTS_SERVICE_ADDRESS%", events_service_address,
"%EVENTS_PUSH%", epush,
"%EVENTS_PULL%", epull);
"%EVENTS_BASESUBSCRIPTION%", ebasesubscription,
"%EVENTS_PULLPOINT%", epullpoint);

fprintf(stdout, "Content-type: application/soap+xml\r\n");
fprintf(stdout, "Content-Length: %ld\r\n\r\n", size);
Expand All @@ -394,16 +394,16 @@ int device_get_capabilities()
"%DEVICE_SERVICE_ADDRESS%", device_service_address,
"%MEDIA_SERVICE_ADDRESS%", media_service_address,
"%EVENTS_SERVICE_ADDRESS%", events_service_address,
"%EVENTS_PUSH%", epush,
"%EVENTS_PULL%", epull);
"%EVENTS_BASESUBSCRIPTION%", ebasesubscription,
"%EVENTS_PULLPOINT%", epullpoint);
} else {
long size = cat(NULL, "device_service_files/GetCapabilities_ptz.xml", 12,
"%DEVICE_SERVICE_ADDRESS%", device_service_address,
"%MEDIA_SERVICE_ADDRESS%", media_service_address,
"%PTZ_SERVICE_ADDRESS%", ptz_service_address,
"%EVENTS_SERVICE_ADDRESS%", events_service_address,
"%EVENTS_PUSH%", epush,
"%EVENTS_PULL%", epull);
"%EVENTS_BASESUBSCRIPTION%", ebasesubscription,
"%EVENTS_PULLPOINT%", epullpoint);

fprintf(stdout, "Content-type: application/soap+xml\r\n");
fprintf(stdout, "Content-Length: %ld\r\n\r\n", size);
Expand All @@ -413,8 +413,8 @@ int device_get_capabilities()
"%MEDIA_SERVICE_ADDRESS%", media_service_address,
"%PTZ_SERVICE_ADDRESS%", ptz_service_address,
"%EVENTS_SERVICE_ADDRESS%", events_service_address,
"%EVENTS_PUSH%", epush,
"%EVENTS_PULL%", epull);
"%EVENTS_BASESUBSCRIPTION%", ebasesubscription,
"%EVENTS_PULLPOINT%", epullpoint);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions device_service_files/GetCapabilities_no_ptz.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
</tt:Device>
<tt:Events>
<tt:XAddr>%EVENTS_SERVICE_ADDRESS%</tt:XAddr>
<tt:WSSubscriptionPolicySupport>%EVENTS_PUSH%</tt:WSSubscriptionPolicySupport>
<tt:WSPullPointSupport>%EVENTS_PULL%</tt:WSPullPointSupport>
<tt:WSSubscriptionPolicySupport>%EVENTS_BASESUBSCRIPTION%</tt:WSSubscriptionPolicySupport>
<tt:WSPullPointSupport>%EVENTS_PULLPOINT%</tt:WSPullPointSupport>
<tt:WSPausableSubscriptionManagerInterfaceSupport>false</tt:WSPausableSubscriptionManagerInterfaceSupport>
</tt:Events>
<tt:Media>
Expand Down
4 changes: 2 additions & 2 deletions device_service_files/GetCapabilities_ptz.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
</tt:Device>
<tt:Events>
<tt:XAddr>%EVENTS_SERVICE_ADDRESS%</tt:XAddr>
<tt:WSSubscriptionPolicySupport>%EVENTS_PUSH%</tt:WSSubscriptionPolicySupport>
<tt:WSPullPointSupport>%EVENTS_PULL%</tt:WSPullPointSupport>
<tt:WSSubscriptionPolicySupport>%EVENTS_BASESUBSCRIPTION%</tt:WSSubscriptionPolicySupport>
<tt:WSPullPointSupport>%EVENTS_PULLPOINT%</tt:WSPullPointSupport>
<tt:WSPausableSubscriptionManagerInterfaceSupport>false</tt:WSPausableSubscriptionManagerInterfaceSupport>
</tt:Events>
<tt:Media>
Expand Down
4 changes: 2 additions & 2 deletions device_service_files/GetEventsCapabilities.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<tds:Capabilities>
<tt:Events>
<tt:XAddr>%EVENTS_SERVICE_ADDRESS%</tt:XAddr>
<tt:WSSubscriptionPolicySupport>%EVENTS_PUSH%</tt:WSSubscriptionPolicySupport>
<tt:WSPullPointSupport>%EVENTS_PULL%</tt:WSPullPointSupport>
<tt:WSSubscriptionPolicySupport>%EVENTS_BASESUBSCRIPTION%</tt:WSSubscriptionPolicySupport>
<tt:WSPullPointSupport>%EVENTS_PULLPOINT%</tt:WSPullPointSupport>
<tt:WSPausableSubscriptionManagerInterfaceSupport>false</tt:WSPausableSubscriptionManagerInterfaceSupport>
</tt:Events>
</tds:Capabilities>
Expand Down
4 changes: 2 additions & 2 deletions device_service_files/GetServices_with_capabilities_no_ptz.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
WSSubscriptionPolicySupport="%EVENTS_PUSH%"
WSPullPointSupport="%EVENTS_PULL%"
WSSubscriptionPolicySupport="%EVENTS_BASESUBSCRIPTION%"
WSPullPointSupport="%EVENTS_PULLPOINT%"
WSPausableSubscriptionManagerInterfaceSupport="false">
</tev:Capabilities>
</tds:Capabilities>
Expand Down
4 changes: 2 additions & 2 deletions device_service_files/GetServices_with_capabilities_ptz.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
WSSubscriptionPolicySupport="%EVENTS_PUSH%"
WSPullPointSupport="%EVENTS_PULL%"
WSSubscriptionPolicySupport="%EVENTS_BASESUBSCRIPTION%"
WSPullPointSupport="%EVENTS_PULLPOINT%"
WSPausableSubscriptionManagerInterfaceSupport="false">
</tev:Capabilities>
</tds:Capabilities>
Expand Down
22 changes: 11 additions & 11 deletions events_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,29 @@ shm_t *subs_evts;

int events_get_service_capabilities()
{
char epush[8], epull[8];
char ebasesubscription[8], epullpoint[8];

if ((service_ctx.events_enable == EVENTS_PULL) || (service_ctx.events_enable == EVENTS_BOTH)) {
strcpy(epull, "true");
if ((service_ctx.events_enable == EVENTS_PULLPOINT) || (service_ctx.events_enable == EVENTS_BOTH)) {
strcpy(epullpoint, "true");
} else {
strcpy(epull, "false");
strcpy(epullpoint, "false");
}
if ((service_ctx.events_enable == EVENTS_PUSH) || (service_ctx.events_enable == EVENTS_BOTH)) {
strcpy(epush, "true");
if ((service_ctx.events_enable == EVENTS_BASESUBSCRIPTION) || (service_ctx.events_enable == EVENTS_BOTH)) {
strcpy(ebasesubscription, "true");
} else {
strcpy(epush, "false");
strcpy(ebasesubscription, "false");
}

long size = cat(NULL, "events_service_files/GetServiceCapabilities.xml", 4,
"%EVENTS_PUSH%", epush,
"%EVENTS_PULL%", epull);
"%EVENTS_BASESUBSCRIPTION%", ebasesubscription,
"%EVENTS_PULLPOINT%", epullpoint);

fprintf(stdout, "Content-type: application/soap+xml\r\n");
fprintf(stdout, "Content-Length: %ld\r\n\r\n", size);

return cat("stdout", "events_service_files/GetServiceCapabilities.xml", 4,
"%EVENTS_PUSH%", epush,
"%EVENTS_PULL%", epull);
"%EVENTS_BASESUBSCRIPTION%", ebasesubscription,
"%EVENTS_PULLPOINT%", epullpoint);
}

int events_create_pull_point_subscription()
Expand Down
4 changes: 2 additions & 2 deletions events_service_files/GetServiceCapabilities.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
WSSubscriptionPolicySupport="%EVENTS_PUSH%"
WSPullPointSupport="%EVENTS_PULL%"
WSSubscriptionPolicySupport="%EVENTS_BASESUBSCRIPTION%"
WSPullPointSupport="%EVENTS_PULLPOINT%"
WSPausableSubscriptionManagerInterfaceSupport="false">
</tev:Capabilities>
</tev:GetServiceCapabilitiesResponse>
Expand Down
6 changes: 3 additions & 3 deletions utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
#define CONSUMER_REFERENCE_MAX_SIZE 256

#define EVENTS_NONE 0
#define EVENTS_PULL 1
#define EVENTS_PUSH 2
#define EVENTS_BOTH 3
#define EVENTS_PULLPOINT 1 // PullPoint
#define EVENTS_BASESUBSCRIPTION 2 // Base Subscription
#define EVENTS_BOTH 3 // PullPoint and Base Subscription

typedef enum {
SUB_UNUSED,
Expand Down

0 comments on commit aa04e0c

Please sign in to comment.