/// <summary> /// Add a frame to this traf /// </summary> public void AddFrame(GenericMediaFrame frame) { if (_children.Last() is trun) { // looking at .ismv files in a hex editor, they use multiple frames/trun. trun ot = _children.Last() as trun; ot.AddFrame(frame); } else { var t = new trun(); t.AddFrame(frame); AddChild(t); } Header.AddFrame(frame); }
/// <summary> /// Called by 'AgregatePayload()' as soon as a frame has been completed. /// Adds a GenericMediaFrame to the WaitingFrames queue if possible. /// </summary> private void DecodeFrame(int PES_PID, MemoryStream StreamData, double MinimumTime) { if (StreamData == null || StreamData.Length <= 9) { return; // no useful data. } byte[] payload = StreamData.ToArray(); PES pes = new PES(payload); long new_timestamp = pes.PTS; long minimum_timestamp = (long)(MinimumTime * 90000.0); while (new_timestamp < minimum_timestamp) // fix for 32-bit issues: { new_timestamp += 0xFFFFFFFFL; // compensate for overflow } // **** EVERYTHING ABOVE THIS LINE IS 90kHz CLOCK **** new_timestamp = MpegToNetTime(new_timestamp); // **** EVERYTHING BELOW THIS LINE IS 10MHz CLOCK **** long old_timestamp = Timestamps[PES_PID]; if (new_timestamp > old_timestamp) { Timestamps[PES_PID] = new_timestamp; } if (old_timestamp < 0) { old_timestamp = new_timestamp; // prevent very long frames if clock is not zero-based. } GenericMediaFrame frame = new GenericMediaFrame(); frame.FrameData = pes.FrameData; frame.DataLength = frame.FrameData.Length; frame.FramePresentationTime = Timestamps[PES_PID]; frame.FrameDuration = Timestamps[PES_PID] - old_timestamp; // First frame duration = 0 WaitingFrames[PES_PID].Enqueue(frame); // try to fix first frame: if (WaitingFrames[PES_PID].Count == 2) { var first = WaitingFrames[PES_PID].Peek(); // if bad duration, guess that it'll be the same as the next. if (first.FrameDuration <= 1) { first.FrameDuration = frame.FrameDuration; } } }
/// <summary> /// Add a frame to this traf /// </summary> public void AddFrame(GenericMediaFrame frame) { if (_children.Last() is trun) // looking at .ismv files in a hex editor, they use multiple frames/trun. { trun ot = _children.Last() as trun; ot.AddFrame(frame); } else { var t = new trun(); t.AddFrame(frame); AddChild(t); } Header.AddFrame(frame); }
/// <summary> /// Add a frame to the track /// </summary> public void AddFrame(UInt32 TrackID, GenericMediaFrame frame) { // Ensure correct boxes if (Tracks == null) { Tracks = new traf(TrackID); AddChild(Tracks); } if (TrackID != Tracks.TrackId) throw new Exception("Fragments should only contain a single track"); if (Dependencies == null) { Dependencies = new sdtp(); AddChild(Dependencies); } // Add this frame Tracks.AddFrame(frame); Dependencies.AddFrame(frame); // Add duration Duration += frame.FrameDuration; }
/// <summary> /// Add a frame to the track /// </summary> public void AddFrame(UInt32 TrackID, GenericMediaFrame frame) { // Ensure correct boxes if (Tracks == null) { Tracks = new traf(TrackID); AddChild(Tracks); } if (TrackID != Tracks.TrackId) { throw new Exception("Fragments should only contain a single track"); } if (Dependencies == null) { Dependencies = new sdtp(); AddChild(Dependencies); } // Add this frame Tracks.AddFrame(frame); Dependencies.AddFrame(frame); // Add duration Duration += frame.FrameDuration; }
/// <summary> /// Add a frame to this trun /// </summary> public void AddFrame(GenericMediaFrame f) { FrameCount++; }
public void AddFrame(GenericMediaFrame gmf) { DataSize += (uint)gmf.FrameData.Length; FrameCount++; }
/// <summary> /// Add a frame to the track /// </summary> public void AddFrame(UInt32 TrackID, GenericMediaFrame frame) { _data.Write(frame.FrameData, 0, frame.FrameData.Length); }
/// <summary> /// Add frames to this fragment. /// GOPs should be closed inside a fragment (no external refs) /// </summary> /// <param name="TrackID">Track ID (should be associated with 'moov' headers)</param> /// <param name="frame">Frame data</param> public void AddFrame(UInt32 TrackID, GenericMediaFrame frame) { FragmentInfo.AddFrame(TrackID, frame); MovieData.AddFrame(TrackID, frame); }
/// <summary> /// Add a frame to this trun /// </summary> public void AddFrame(GenericMediaFrame f) { _frames.Add(f); }