// assumption this can ONLY be called when we know the next box is a fragment... private void ScanForAudioOrVideo() { long pos = boxReader.BaseStream.Position; do { long fragPos = boxReader.BaseStream.Position; Fragment frag = new Fragment(); int trakID = (int)frag.GetTrackID(boxReader); if (GetFragmentHandlerType(trakID) == _handlerType) { if (_handlerType.Equals("soun")) { audioFound = true; nextAudioFragPosition = fragPos; audioTrackID = trakID; } else if (_handlerType.Equals("vide")) { videoFound = true; nextVideoFragPosition = fragPos; videoTrackID = trakID; } break; } } while (this.boxReader.PeekNextBoxType() == BoxTypes.MovieFragment); boxReader.BaseStream.Position = pos; audiovideoScanCompleted = true; }
private Fragment GetNextVideoFrag() { if (nextVideoFragPosition < 0) return (null); // there are no more!! boxReader.BaseStream.Position = nextVideoFragPosition; // we know where at least the next frag is as we prepared this prior to the call of this function... Fragment answer = new Fragment(GetTimeScale(videoTrackID), GetPayloadType(videoTrackID)); answer.Read(boxReader); nextVideoFragPosition = -1; while (this.boxReader.PeekNextBoxType() == BoxTypes.MovieFragment) { long fragPos = boxReader.BaseStream.Position; Fragment tmp = new Fragment(); int trakID = (int)tmp.GetTrackID(boxReader); if (GetFragmentHandlerType(trakID) == "vide") { nextVideoFragPosition = fragPos; break; } } return (answer); }