Example #1
0
        protected override void SaveToStream(Stream stream)
        {
            base.SaveToStream(stream);

            if (Version == 1)
            {
                stream.WriteBEUInt64(MovieHeaderBox.Convert1904Time(CreationTime));
                stream.WriteBEUInt64(MovieHeaderBox.Convert1904Time(ModificationTime));
                stream.WriteBEUInt32(TrackID);
                stream.WriteBEUInt32(_Reserved1);
                stream.WriteBEUInt64(Duration);
            }
            else // if (Version == 0)
            {
                stream.WriteBEUInt32((uint)MovieHeaderBox.Convert1904Time(CreationTime));
                stream.WriteBEUInt32((uint)MovieHeaderBox.Convert1904Time(ModificationTime));
                stream.WriteBEUInt32(TrackID);
                stream.WriteBEUInt32(_Reserved1);
                stream.WriteBEUInt32((uint)Duration);
            }
            for(int i=0; i<2; i++) stream.WriteBEUInt32(_Reserved2[i]);
            stream.WriteBEInt16(Layer);
            stream.WriteBEInt16(AlternateGroup);
            stream.WriteBEInt16(Volume);
            stream.WriteBEUInt16(_Reserved3);
            for (int i = 0; i < 9; i++) stream.WriteBEInt32(_Matrix[i]);
            stream.WriteBEUInt32(Width);
            stream.WriteBEUInt32(Height);
        }
Example #2
0
        protected override void SaveToStream(Stream stream)
        {
            if (Version==0 && 
                (_CreationTime > uint.MaxValue || 
                _ModificationTime > uint.MaxValue || 
                Duration > uint.MaxValue)) Version = 1;

            base.SaveToStream(stream);

            if (Version == 1)
            {
                stream.WriteBEUInt64(_CreationTime);
                stream.WriteBEUInt64(_ModificationTime);
                stream.WriteBEUInt32(TimeScale);
                stream.WriteBEUInt64(Duration);
            }
            else // if(Version == 0)
            {
                stream.WriteBEUInt32(checked((uint)_CreationTime));
                stream.WriteBEUInt32(checked((uint)_ModificationTime));
                stream.WriteBEUInt32(TimeScale);
                stream.WriteBEUInt32(checked((uint)Duration));
            }
            stream.WriteBEInt32(_Rate);
            stream.WriteBEInt16(_Volume);
            stream.WriteBytes(Reserved);
            for (int i = 0; i < 9; i++) stream.WriteBEInt32(Matrix[i]);
            stream.WriteBytes(PreDefined);
            stream.WriteBEUInt32(NextTrackID);
        }
Example #3
0
        protected override void SaveToStream(Stream stream)
        {
            if(FragmentDuration > UInt32.MaxValue) Version = 1;

            base.SaveToStream(stream);

            if (Version == 1) stream.WriteBEUInt64(FragmentDuration);
            else stream.WriteBEUInt32((uint)FragmentDuration);
        }
Example #4
0
        protected override void SaveToStream(Stream stream)
        {
            base.SaveToStream(stream);

            if (Version == 1)
            {
                stream.WriteBEUInt64(MovieHeaderBox.Convert1904Time(CreationTime));
                stream.WriteBEUInt64(MovieHeaderBox.Convert1904Time(ModificationTime));
                stream.WriteBEUInt32(TimeScale);
                stream.WriteBEUInt64(Duration);
            }
            else // if (Version == 0)
            {
                stream.WriteBEUInt32((uint)MovieHeaderBox.Convert1904Time(CreationTime));
                stream.WriteBEUInt32((uint)MovieHeaderBox.Convert1904Time(ModificationTime));
                stream.WriteBEUInt32(TimeScale);
                stream.WriteBEUInt32((uint)Duration);
            }

            stream.WriteBEUInt16(ConvertThreeLetterLanguageCode(Language));
            stream.WriteBEUInt16(Predefined);
        }
Example #5
0
        protected override void SaveToStream(Stream stream)
        {
            TrackFragmentFlags newFlags = 0;
            if (BaseDataOffset.HasValue) newFlags |= TrackFragmentFlags.BaseDataOffsetPresent;
            if (SampleDescriptionIndex.HasValue) newFlags |= TrackFragmentFlags.SampleDrescriptionIndexPresent;
            if (DefaultSampleDuration.HasValue) newFlags |= TrackFragmentFlags.DefaultSampleDurationPresent;
            if (DefaultSampleSize.HasValue) newFlags |= TrackFragmentFlags.DefaultSampleSizePresent;
            if (DefaultSampleFlags != null) newFlags |= TrackFragmentFlags.DefaultSampleFlagsPresent;
            if (DurationIsEmpty) newFlags |= TrackFragmentFlags.DurationIsEmpty;

            Flags = newFlags;

            base.SaveToStream(stream);

            stream.WriteBEUInt32(TrackID);
            if (BaseDataOffset.HasValue) stream.WriteBEUInt64(BaseDataOffset.Value);
            if (SampleDescriptionIndex.HasValue) stream.WriteBEUInt32(SampleDescriptionIndex.Value);
            if (DefaultSampleDuration.HasValue) stream.WriteBEUInt32(DefaultSampleDuration.Value);
            if (DefaultSampleSize.HasValue) stream.WriteBEUInt32(DefaultSampleSize.Value);
            if (DefaultSampleFlags!=null) stream.WriteBEUInt32(DefaultSampleFlags._flags);
        }
Example #6
0
            /// <summary>
            /// Serialize the frame to the given stream returning the byte size of the frame
            /// </summary>
            public int Serialize(Stream stream)
            {
                //MAGIC
                stream.WriteBEUShort(MAGIC);
                
                //VERSION
                stream.WriteByte( VERSION );

                //TYPE
                stream.WriteByte( (byte)m_Type );

                //FORMAT
                stream.WriteBEInt32( m_Format );

                //ONEWAY
                stream.WriteByte( m_OneWay ? (byte)1 : (byte)0 ); 

                //REQUEST GUID
                stream.WriteBEUInt64( m_RequestID.ID );

                //HEADERSCONTENT
                stream.WriteBEInt32(m_HeadersContentLength);
                if (m_HeadersContentLength>0)
                {
                    var hbuf = HEADERS_ENCODING.GetBytes( m_HeadersContent );
                    stream.Write( hbuf, 0, hbuf.Length );
                }

                return Length;
            }
Example #7
0
 public static void WriteTimeStamp(Stream stream, DateTime ts)
 {
     var nix = ts.ToMicrosecondsSinceUnixEpochStart();
       stream.WriteBEUInt64((ulong)nix);
 }
Example #8
0
 public static void WritePageHeader(Stream stream, DateTime ts)
 {
     stream.WriteBEUInt64(PAGE_HEADER);
       WriteTimeStamp(stream, ts);
 }