@@ -39,7 +39,7 @@ class RTSPURLError(RTSPError): pass
3939class  RTSPNetError (RTSPError ): pass 
4040
4141class  RTSPClient (threading .Thread ):
42-     TRANSPORT_TYPE_LIST  =  ['rtp_over_tcp' ]
42+     TRANSPORT_TYPE_LIST  =  ['ts_over_tcp'  , ' rtp_over_tcp' , 'ts_over_udp' , 'rtp_over_udp '
4343    NAT_IP_PORT          =  '' 
4444    ENABLE_ARQ           =  False 
4545    ENABLE_FEC           =  False 
@@ -188,16 +188,23 @@ def _parse_msg(self):
188188        '''Read through the cache and pull out a complete 
189189           response or ANNOUNCE notification message''' 
190190        msg  =  '' 
191-         if   self .cache (): 
192-              tmp   =   self . cache () 
191+         tmp   =   self .cache ()
192+         if   tmp : 
193193            try :
194-                 (msg , tmp ) =  tmp .split (HEADER_END_STR , 1 )
194+                 # Check here for a header, if the cache isn't empty and there 
195+                 #  isn't a HEADER_END_STR, then there isn't a proper header in 
196+                 #  the response. For now this will generate an error and fail. 
197+                 (header , body ) =  tmp .split (HEADER_END_STR , 1 )
195198            except  ValueError  as  e :
196199                self ._callback (self ._get_time_str () +  '\n '  +  tmp )
197200                raise  RTSPError ('Response did not contain double CRLF' )
198-             content_length  =  self ._get_content_length (msg )
199-             msg  +=  HEADER_END_STR  +  tmp [:content_length ]
200-             self .set_cache (tmp [content_length :])
201+             content_length  =  self ._get_content_length (header )
202+             # If the body of the message is less than the given content_length 
203+             #  then the full message hasn't been received so bail. 
204+             if  (len (body ) <  content_length ):
205+                 return  '' 
206+             msg  =  header  +  HEADER_END_STR  +  body [:content_length ]
207+             self .set_cache (body [content_length :])
201208        return  msg 
202209
203210    """ 
@@ -413,13 +420,14 @@ def do_describe(self, headers={}):
413420        self ._sendmsg ('DESCRIBE' , self ._orig_url , headers )
414421
415422    def  do_setup (self , track_id_str = None , headers = {}):
423+         #TODO: Currently issues SETUP for all tracks but doesn't keep track  
424+         # of all sessions or teardown all of them. 
416425        if  self ._auth :
417426            headers ['Authorization' ] =  self ._auth 
418427        headers ['Transport' ] =  self ._get_transport_type ()
419-         #TODO: Currently issues SETUP for all tracks but doesn't keep track  
420-         # of all sessions or teardown all of them. 
428+         # If a string is supplied, it must contain the proceeding '/' 
421429        if  isinstance (track_id_str ,str ):
422-             self ._sendmsg ('SETUP' , self ._orig_url + '/' + track_id_str , headers )
430+             self ._sendmsg ('SETUP' , self ._orig_url   +   track_id_str , headers )
423431        elif  isinstance (track_id_str , int ):
424432            self ._sendmsg ('SETUP' , self ._orig_url  + 
425433                                   '/'  + 
0 commit comments