freeMXF.org
http://freemxf.org/forum/

Problem with ReadFromFile()
http://freemxf.org/forum/viewtopic.php?f=2&t=109
Page 1 of 1

Author:  LY [ Thu Oct 04, 2007 2:41 pm ]
Post subject:  Problem with ReadFromFile()

Hi,

I use BodyReader to get video frames and wrote the code to test:
Code:
 
   VideoDataHandler *pHandler = new VideoDataHandler(BodySID);

   BodyReaderPtr BodyParser = new BodyReader(theFile);
   BodyParser->MakeGCReader(BodySID);
   GCReaderPtr ThisReader = BodyParser->GetGCReader(BodySID);
   ThisReader->SetDataHandler(TrackNumber_v, pHandler);// I've got the video track number
   for(;;)
   {
        cout<<"BodyParser->Tell(): "<<BodyParser->Tell()<<endl;
      bool Result = BodyParser->ReadFromFile();
      if(!Result)
      {
          if( BodyParser->Eof())
         {
            cout<<"End of file."<<endl;
            break;
         }
         BodyParser->ReSync();
      }
   }



The HandleData() is simple:
Code:
bool VideoDataHandler::HandleData(GCReaderPtr Caller, KLVObjectPtr Object)
{
        cout<<"In VideoDataHandler::HandleData"<<endl;
      return true;
}


The problem is:
Using BodyParser->ReadFromFile() all video frame would be parsed.
Using BodyParser->ReadFromFile(true) the HandleData() will be called only once. Than "End of file."
Who can tell me why? Was the ReadFromFile(true) wrongly used here?

Author:  LY [ Thu Oct 04, 2007 2:44 pm ]
Post subject: 

I use ReadFromFile(true) because I want to stop the process after a certain video frame has been found.

Using ReadFromFile() all KLVs in a partition will be parsed, how can I stop it after the wanted video frame has been found?

Author:  LY [ Fri Oct 05, 2007 10:21 am ]
Post subject: 

I made it.
Just add Caller->StopReading() into VideoDataHandler::HandleData() than the process can be stopped.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/