コード例 #1
0
ファイル: parser.c プロジェクト: romaipart/vdr-plugin-xvdr
void cParser::Parse(unsigned char *data, int datasize, bool pusi)
{
  // get available data
  int length = 0;
  uint8_t* buffer = Get(length);

  // do we have a sync ?
  int framesize = 0;
  if(length > m_headersize && buffer != NULL && CheckAlignmentHeader(buffer, framesize))
  {
    if(framesize > 0 && length >= framesize)
    {
      ParsePayload(buffer, framesize);
      SendPayload(buffer, framesize);

      m_curPTS = PtsAdd(m_curPTS, m_duration);
      m_curDTS = PtsAdd(m_curDTS, m_duration);

      Del(framesize);
    }

    PutData(data, datasize, pusi);
    return;
  }

  // try to find sync
  int offset = FindAlignmentOffset(buffer, length, 0, framesize);
  if(offset != -1)
  {
    INFOLOG("sync found at offset %i (streamtype: %s / %i bytes in buffer / framesize: %i bytes)", offset, m_demuxer->TypeName(), Available(), framesize);
    Del(offset);
  }

  PutData(data, datasize, pusi);
}
コード例 #2
0
ファイル: asf.c プロジェクト: 5sw/stuff
void ParsePayloadHeader( uint8_t flags )
{
	printf( "\tParsing payload parsing information...\n" );
	bool multiplePayloads = (flags & BIT( 0 )) != 0;
	int sequenceType = (flags & (BIT( 1 ) | BIT( 2 ))) >> 1;
	int paddingLengthType = (flags & (BIT( 3 ) | BIT( 4 ))) >> 3;
	int packetLengthType = (flags & (BIT( 5 ) | BIT( 6 ))) >> 5;
	bool ecPresent = (flags & BIT( 7 )) != 0;
	
	printf( "\tMultiple Payloads                    %s\n", multiplePayloads ? "yes" : "no" );
	printf( "\tSequence type:                       %d\n", sequenceType );
	printf( "\tPadding length type:                 %d\n", paddingLengthType );
	printf( "\tPacket length type:                  %d\n", packetLengthType );
	printf( "\tEC present:                          %s\n", ecPresent ? "yes" : "no" );
	
	uint8_t propertyFlags = ReadByte();
	
	ParseInfo info;
	info.repDataLengthType = propertyFlags & (BIT( 0 ) | BIT( 1 ));
	info.offsetLengthType = (propertyFlags & (BIT( 2 ) | BIT( 3 ))) >> 2;
	info.objectNumberLengthType = (propertyFlags & (BIT( 4 ) | BIT( 5 ))) >> 4;
	int streamNumberLengthType = (propertyFlags & (BIT( 6 ) | BIT( 7 ))) >> 6;
	
	printf( "\tRepl. data length type               %d\n", info.repDataLengthType );
	printf( "\tOffset into media object length type %d\n", info.offsetLengthType );
	printf( "\tMedia object number lengtht type     %d\n", info.objectNumberLengthType );
	printf( "\tStream Number Length Type            %d\n", streamNumberLengthType );
	
	uint32_t packetLength = ReadNumber( packetLengthType );
	printf( "\tPacket length:                       %d\n", packetLength );
	
	uint32_t sequence = ReadNumber( sequenceType );
	printf( "\tSequence number:                     %d\n", sequence );
	
	uint32_t paddingLength = ReadNumber( paddingLengthType );
	printf( "\tPadding length:                      %d\n", paddingLength );
	
	uint32_t sendTime = ReadDWord();
	printf( "\tSend time:                           %d\n", sendTime );
	
	uint16_t duration = ReadWord();
	printf( "\tDuration:                            %d\n", duration );
	
	if (multiplePayloads) ParseMultiplePayloads( &info );
	else ParsePayload( &info );
}