def _sendmsg(self,method,url,headers):
        '''发送消息'''
        msg = '%s %s %s'%(method,url,RTSP_VERSION)
        headers['User-Agent'] = DEFAULT_USERAGENT
        cseq = self._next_seq()
        self._cseq_map[cseq] = method
        headers['CSeq'] = str(cseq)
        if self._session_id: headers['Session'] = self._session_id
        for (k,v) in headers.items():
            msg += LINE_SPLIT_STR + '%s: %s'%(k,str(v))
        msg += HEADER_END_STR # End headers
        if method != 'GET_PARAMETER' or 'x-RetransSeq' in headers:
            PRINT(self._get_time_str() + LINE_SPLIT_STR + msg)
        try:
            self._sock.send(msg)
        except socket.error, e:
            PRINT('Send msg error: %s'%e, RED)
def _sendmsg ( self , method , url , headers ) : msg = '%s %s %s' % ( method , url , RTSP_VERSION ) headers [ 'User-Agent' ] = DEFAULT_USERAGENT cseq = self . _next_seq ( ) self . _cseq_map [ cseq ] = method headers [ 'CSeq' ] = str ( cseq ) if self . _session_id : headers [ 'Session' ] = self . _session_id for ( k , v ) in headers . items ( ) : msg += LINE_SPLIT_STR + '%s: %s' % ( k , str ( v ) ) msg += HEADER_END_STR if method != 'GET_PARAMETER' or 'x-RetransSeq' in headers : PRINT ( self . _get_time_str ( ) + LINE_SPLIT_STR + msg ) try : self . _sock . send ( msg ) except socket . error , e : PRINT ( 'Send msg error: %s' % e , RED )
发送消息