public ISMVideoTrack(ISMVTrackFormat videoFile, ISMVStream stream) { base.TrackFormat = videoFile; // sets payload type and other properties also ParentStream = stream; // set other properties of this track }
public ISMAudioTrack(ISMVTrackFormat audioFile, ISMVStream stream) { base.TrackFormat = audioFile; // this sets the PayloadType and other properties also ParentStream = stream; // set other properties }
public override void Read() { // With Microsoft's ISM, we don't need to read the MP4 headers to figure out how many tracks there are; // we already know at this point because both the .ism and .ismc files have been scanned. foreach (GenericMediaTrack track in MediaTracks) { ISMVTrackFormat trackFormat = track.TrackFormat as ISMVTrackFormat; trackFormat.Read(); } }
public override void WriteSamples(IEnumerable <Slice> slices, CodecTypes codecType) { GenericMediaTrack track = (GenericMediaTrack)this[codecType, 0]; ISMVTrackFormat format = (ISMVTrackFormat)track.TrackFormat; format.CurrentFragment.Write(m_writer); format.CurrentFragment.CheckFilePosition(m_writer); foreach (Slice sample in slices) { m_writer.Write(sample.SliceBytes, 0, sample.SliceBytes.Length); } format.CurrentFragment = null; // release }
public override Slice GetSample(StreamDataBlockInfo SampleInfo) { Slice ans = new Slice(); ans.SliceBytes = new byte[SampleInfo.SliceSize]; //ParentStream.EnterMutex(); ISMVTrackFormat ismvFormat = TrackFormat as ISMVTrackFormat; ismvFormat.boxReader.BaseStream.Position = (long)SampleInfo.StreamOffset; // if this GetSample call follows another one, file should be in position ismvFormat.boxReader.BaseStream.Read(ans.SliceBytes, 0, SampleInfo.SliceSize); //ParentStream.LeaveMutex(); ans.Copy(SampleInfo); return(ans); }
public override string ToString() { const string endXML = @"</MP4Stream>"; StringBuilder xml = new StringBuilder(); xml.Append(base.ToString()); xml.Remove(xml.Length - endXML.Length, endXML.Length); // remove </MP4Stream> foreach (GenericMediaTrack track in this.MediaTracks) { ISMVTrackFormat format = (ISMVTrackFormat)track.TrackFormat; if (format.CurrentFragment != null) { format.CurrentFragment.ToString(); // we can also print track.Fragments, but it can get very, very long } } xml.Append(endXML); return(xml.ToString()); }