bool DataBuffer::Test( ) { bool ok = true; cout << "Testing DataBuffer" << endl; DataBuffer buff; TESTCHECK( buff.Data() == 0, true, &ok ); TESTCHECK( buff.Size(), 0, &ok ); char sIn[ 10 ] = "123456789"; Foo fIn = { 127, 2.5f }; cout << "Add( char *, 10 )" << endl; buff.Add( sIn, 10 ); TESTCHECK( *buff.Data(), '1', &ok ); TESTCHECK( buff.Size(), 10, &ok ); cout << "Add( Foo )" << endl; buff.Add( fIn ); cout << "Read( 10 )" << endl; const char * sOut = buff.Read( 10 ); TESTCHECK( (string( sIn ) == string( sOut )), true, &ok ); cout << "Read< Foo >()" << endl; const Foo * pFoo = buff.Read< Foo >( ); TESTCHECK( pFoo->i, 127, &ok ); TESTCHECK( pFoo->f, 2.5f, &ok ); if ( ok ) cout << "DataBuffer PASSED." << endl << endl; else cout << "DataBuffer FAILED." << endl << endl; return ok; }
/*! \todo handle flags \todo hardcoded limit of the number of frames in a lace should be a parameter \return true if more frames can be added to this Block */ bool KaxInternalBlock::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, LacingType lacing, bool invisible) { SetValueIsSet(); if (myBuffers.size() == 0) { // first frame Timecode = timecode; TrackNumber = track.TrackNumber(); mInvisible = invisible; mLacing = lacing; } myBuffers.push_back(&buffer); // we don't allow more than 8 frames in a Block because the overhead improvement is minimal if (myBuffers.size() >= 8 || lacing == LACING_NONE) return false; if (lacing == LACING_XIPH) // decide wether a new frame can be added or not // a frame in a lace is not efficient when the place necessary to code it in a lace is bigger // than the size of a simple Block. That means more than 6 bytes (4 in struct + 2 for EBML) to code the size return (buffer.Size() < 6*0xFF); else return true; }