[Live-devel] some problems with ByteStreamMultiFileSource

Karlov Andrey kan at pisem.net
Mon Sep 10 00:15:29 PDT 2007


Then one file is over, ByteStreamFileSource switch us to another file,
for this purpoise it has method:


    "void ByteStreamMultiFileSource::onSourceClosure1() {
      // This routine was called because the currently-read source was 
closed
      // (probably due to EOF).  Close this source down, and move to the
      // next one: ...
       ....


this method called from here, as I understand:

    void ByteStreamFileSource::doGetNextFrame() {
          if (feof(fFid) || ferror(fFid)) {
          handleClosure(this);
          return;
      }
       ...

but there are exists some cases, when the file is over , but it doesn't 
handled correctly
I see the next reasons of this problem here:

       void ByteStreamFileSource::doReadFromFile() {
          // Try to read as many bytes as will fit in the buffer provide
          // (or "fPreferredFrameSize" if less)
          if (fPreferredFrameSize > 0 && fPreferredFrameSize < fMaxSize) {
              fMaxSize = fPreferredFrameSize;
          }
      fFrameSize = fread(fTo, 1, fMaxSize, fFid);
        ....

1. usually fMaxSize = (7*188)=1316 and then in file remain in exact 1316 
unreaded bytes,
     then EOF don't happens
2. if in file remain little then 188 bytes (TS packet) EOF dont't 
happens too

These two cases handled here:

void MPEG2TransportStreamFramer::afterGettingFrame1(unsigned frameSize,
                            struct timeval presentationTime) {
      fFrameSize += frameSize;
      unsigned const numTSPackets = fFrameSize/TRANSPORT_PACKET_SIZE;
      fFrameSize = numTSPackets*TRANSPORT_PACKET_SIZE; // an integral # 
of TS packets
      if (fFrameSize == 0) {
        // We didn't read a complete TS packet; assume that the input 
source has closed.
        handleClosure(this);
        return;
      }


but calling "handleClosure(this)" don't rezult for switching to another 
file there,
instead of this it call function "afterPlaying", which defined here:

    videoSink->startPlaying(*videoSource, afterPlaying, videoSink);


What correct way switch to another file in these cases?
I try to do folowing:

    void ByteStreamFileSource::doReadFromFile() {
      // Try to read as many bytes as will fit in the buffer provided
      // (or "fPreferredFrameSize" if less)
      if (fPreferredFrameSize > 0 && fPreferredFrameSize < fMaxSize) {
        fMaxSize = fPreferredFrameSize;
      }
      fFrameSize = fread(fTo, 1, fMaxSize, fFid);

      if (fFrameSize < 188) {     
           handleClosure(this);   //  < --------------- switch t another 
file here
           return;
      }
    .....


But I think that it isn't the most right way
What can you adwise?


I'm very thankfull to your help!

Sorry for awful English =)

 

Karlov Andrey.



More information about the live-devel mailing list