Debug commit

This commit is contained in:
Erik Zandvliet 2011-07-31 16:28:14 +02:00
parent 8364b187e9
commit 9369f5f08f

View file

@ -21,6 +21,8 @@ class Transport_Packet {
void SetPesHeader( );
void Write( );
void Write( Socket::Connection conn );
void SetContinuityCounter( int Counter );
void SetMessageLength( int MsgLen );
private:
int PID;
char Buffer[188];
@ -34,6 +36,15 @@ Transport_Packet::Transport_Packet( bool NALUStart, int PID ) {
Buffer[3] = (char)0x00;
}
void Transport_Packet::SetMessageLength( int MsgLen ) {
Buffer[8] = ( MsgLen & 0xFF00 ) >> 8;
Buffer[9] = ( MsgLen & 0xFF );
}
void Transport_Packet::SetContinuityCounter( int Counter ) {
Buffer[3] = (char)0x00 + ( Counter & 0x0F );
}
void Transport_Packet::SetPesHeader( ) {
Buffer[4] = (char)0x00;
Buffer[5] = (char)0x00;
@ -52,19 +63,24 @@ void Transport_Packet::SetPayload( char * Payload, int PayloadLen, int Offset )
}
std::vector<Transport_Packet> WrapNalus( FLV::Tag tag ) {
static int ContinuityCounter = 0;
Transport_Packet TS;
int PacketAmount = ( ( tag.len - (188 - 17 ) ) / 184 ) + 2;
std::cerr << "Wrapping a tag of length " << tag.len << " into " << PacketAmount << " TS Packet(s)\n";
std::vector<Transport_Packet> Result;
char LeadIn[4] = { (char)0x00, (char)0x00, (char)0x00, (char)0x01 };
TS = Transport_Packet( true );
TS.SetContinuityCounter( ContinuityCounter );
ContinuityCounter = ( ( ContinuityCounter + 1 ) & 0x0F );
TS.SetPesHeader( );
TS.SetMessageLength( tag.len - 16 );
TS.SetPayload( LeadIn, 4, 13 );
TS.SetPayload( &tag.data[16], 171, 17 );
Result.push_back( TS );
for( int i = 0; i < (PacketAmount - 1); i++ ) {
// std::cerr << i << "<" << (PacketAmount - 1) << "? " << ( i < ( PacketAmount - 1 ) ) << "\n";
TS = Transport_Packet( false );
TS.SetContinuityCounter( ContinuityCounter );
ContinuityCounter = ( ( ContinuityCounter + 1 ) & 0x0F );
TS.SetPayload( &tag.data[187+(184*i)], 184, 4 );
Result.push_back( TS );
}
@ -99,6 +115,7 @@ int TS_Handler( Socket::Connection conn ) {
#endif
inited = true;
}
switch (ss.ready()){
case -1:
conn.close();
@ -124,7 +141,9 @@ int TS_Handler( Socket::Connection conn ) {
}
}
if( tag.data[ 0 ] == 0x08 ) {
fprintf(stderr, "Audio Tag Read\n");
if( ( tag.data[ 11 ] == 0xAF ) && ( tag.data[ 12 ] == 0x01 ) ) {
fprintf(stderr, "Audio Contains Raw AAC\n");
}
}
}
break;