#NEWLINE# def on_data( self , ts , type_ , data ) : #NEWLINE# #INDENT# stream = self . _tracks . get ( type_ , None ) #NEWLINE# if ( not stream ) : #NEWLINE# #INDENT# d = self . _make_stream ( ts , type_ ) #NEWLINE# if ( not d ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# d . addCallback ( ( lambda _ : self . on_data ( ts , type_ , data ) ) ) #NEWLINE# return #NEWLINE# #UNINDENT# flags = 0 #NEWLINE# if ( type_ == chunks . MSG_VIDEO ) : #NEWLINE# #INDENT# bytes = len ( data ) #NEWLINE# ( frame_type , codec_id , h264_type ) = ( None , None , None ) #NEWLINE# if ( bytes > 1 ) : #NEWLINE# #INDENT# ( ft_codec , h264_type ) = _s_double_uchar . unpack ( data . peek ( 2 ) ) #NEWLINE# ( frame_type , codec_id ) = ( ( ft_codec >> 4 ) , ( ft_codec & 15 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( bytes > 0 ) : #NEWLINE# #INDENT# ( ft_codec , ) = _s_uchar . unpack ( data . peek ( 1 ) ) #NEWLINE# ( frame_type , codec_id ) = ( ( ft_codec >> 4 ) , ( ft_codec & 15 ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ( frame_type == 1 ) and ( codec_id == 7 ) and ( h264_type == 0 ) ) : #NEWLINE# #INDENT# d = stream . write_headers ( data ) #NEWLINE# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( frame_type is not None ) : #NEWLINE# #INDENT# if ( frame_type == 1 ) : #NEWLINE# #INDENT# flags = FF_KEYFRAME #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# flags = FF_INTERFRAME #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( type_ == chunks . MSG_AUDIO ) : #NEWLINE# #INDENT# bytes = len ( data ) #NEWLINE# ( codec_id , aac_type ) = ( None , None ) #NEWLINE# if ( bytes > 1 ) : #NEWLINE# #INDENT# ( ft_codec , aac_type ) = _s_double_uchar . unpack ( data . peek ( 2 ) ) #NEWLINE# codec_id = ( ft_codec >> 4 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( bytes > 0 ) : #NEWLINE# #INDENT# ( ft_codec , ) = _s_uchar . unpack ( data . peek ( 1 ) ) #NEWLINE# codec_id = ( ft_codec >> 4 ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ( codec_id == 10 ) and ( aac_type == 0 ) ) : #NEWLINE# #INDENT# self . _audio_headers += 1 #NEWLINE# d = stream . write_headers ( data ) #NEWLINE# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( codec_id != 10 ) and ( self . _audio_headers == 0 ) ) : #NEWLINE# #INDENT# self . _audio_headers += 1 #NEWLINE# d = stream . write_headers ( vb ( data . peek ( 1 ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( codec_id is not None ) : #NEWLINE# #INDENT# flags = FF_KEYFRAME #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# log . error ( 'Unsupported data type: %r' , type_ ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# d = stream . write ( ts , flags , data )