@@ -66,7 +66,7 @@ class ONVIFService(object):
6666 @safe_func
6767 def __init__ (self , xaddr , user , passwd , url ,
6868 cache_location = '/tmp/suds' , cache_duration = None ,
69- encrypt = True , daemon = False , ws_client = None , no_cache = False ):
69+ encrypt = True , daemon = False , ws_client = None , no_cache = False , portType = None ):
7070
7171 if not os .path .isfile (url ):
7272 raise ONVIFError ('%s doesn`t exist!' % url )
@@ -91,6 +91,7 @@ def __init__(self, xaddr, user, passwd, url,
9191 self .ws_client = Client (url = self .url ,
9292 location = self .xaddr ,
9393 cache = cache ,
94+ port = portType ,
9495 headers = {'Content-Type' : 'application/soap+xml' })
9596 else :
9697 self .ws_client = ws_client
@@ -240,6 +241,14 @@ def update_xaddrs(self):
240241 except Exception :
241242 logger .exception ('Unexcept service type' )
242243
244+ with self .services_lock :
245+ try :
246+ self .event = self .create_events_service ()
247+ self .xaddrs ['http://www.onvif.org/ver10/events/wsdl/PullPointSubscription' ] = self .event .CreatePullPointSubscription ().SubscriptionReference .Address
248+ except :
249+ pass
250+
251+
243252 def update_url (self , host = None , port = None ):
244253 changed = False
245254 if host and self .host != host :
@@ -295,7 +304,7 @@ def get_definition(self, name):
295304 if not os .path .isfile (wsdlpath ):
296305 raise ONVIFError ('No such file: %s' % wsdlpath )
297306
298- # XAddr for devicemgmt is fixd :
307+ # XAddr for devicemgmt is fixed :
299308 if name == 'devicemgmt' :
300309 xaddr = 'http://%s:%s/onvif/device_service' % (self .host , self .port )
301310 return xaddr , wsdlpath
@@ -307,7 +316,7 @@ def get_definition(self, name):
307316
308317 return xaddr , wsdlpath
309318
310- def create_onvif_service (self , name , from_template = True ):
319+ def create_onvif_service (self , name , from_template = True , portType = None ):
311320 '''Create ONVIF service client'''
312321
313322 name = name .lower ()
@@ -323,14 +332,14 @@ def create_onvif_service(self, name, from_template=True):
323332 self .cache_duration ,
324333 self .encrypt ,
325334 self .daemon ,
326- no_cache = self .no_cache )
335+ no_cache = self .no_cache , portType = portType )
327336 # No template, create new service from wsdl document.
328337 # A little time-comsuming
329338 else :
330339 service = ONVIFService (xaddr , self .user , self .passwd ,
331340 wsdl_file , self .cache_location ,
332341 self .cache_duration , self .encrypt ,
333- self .daemon , no_cache = self .no_cache )
342+ self .daemon , no_cache = self .no_cache , portType = portType )
334343
335344 self .services [name ] = service
336345
@@ -369,4 +378,7 @@ def create_search_service(self, from_template=True):
369378 return self .create_onvif_service ('search' , from_template )
370379
371380 def create_replay_service (self , from_template = True ):
372- return self .create_onvif_service ('search' , from_template )
381+ return self .create_onvif_service ('replay' , from_template )
382+
383+ def create_pullpoint_service (self , from_template = True ):
384+ return self .create_onvif_service ('pullpoint' , from_template , portType = 'PullPointSubscription' )
0 commit comments