コード例 #1
0
ファイル: Box.cs プロジェクト: mcguirepr/bmff
        public static Box FromStream(Stream stream, BaseMediaOptions options = BaseMediaOptions.LoadChildren)
        {
            Box box = null;

            try
            {
                ulong offset = (ulong)stream.Position;

                uint  size      = stream.ReadBEUInt32();
                uint  type      = stream.ReadBEUInt32();
                ulong?largeSize = null;

                if (size == 1)
                {
                    largeSize = stream.ReadBEUInt64();
                }

                BoxType boxType = (type == uuidType)
                    ? new BoxType(new Guid(stream.ReadBytes(16)))
                    : new BoxType(type);

                AvailableBoxTypes.TryGetValue(boxType, out Type t);

                box = t != null ? (Box)Activator.CreateInstance(t) : new Boxes.UnknownBox(boxType);

                box.Size      = size;
                box.LargeSize = largeSize;
                box.Offset    = offset;
                box.Initialize(ConstrainedStream.WrapStream(stream), options);
            }
            catch (EndOfStreamException) { }

            return(box);
        }
コード例 #2
0
 public BaseMediaReader(Stream stream, BaseMediaOptions options = BaseMediaOptions.None)
 {
     if (stream.CanSeek && stream.Position != 0)
     {
         stream.Seek(0, SeekOrigin.Begin);
     }
     BaseStream = stream;
     Options    = options;
 }
コード例 #3
0
ファイル: Box.cs プロジェクト: evgeniylevakhin/bmff
        internal void Initialize(Stream stream, BaseMediaOptions options = BaseMediaOptions.LoadChildren)
        {
            Trace.WriteLine(Type, "Loading");
            _SourceStream = stream;

            ConstrainedStream constrainedStream = ConstrainedStream.WrapStream(stream);

            constrainedStream.PushConstraint((long)Offset.Value, (long)EffectiveSize);

            LoadFromStream(stream);

            ContentOffset = (ulong)stream.Position;

            if (((options & BaseMediaOptions.LoadChildren) == BaseMediaOptions.LoadChildren) && this is ISuperBox)
            {
                LoadChildrenFromStream(stream);
            }

            Sync(stream, !(this is IContentBox));

            constrainedStream.PopConstraint();
        }
コード例 #4
0
ファイル: BaseMediaReader.cs プロジェクト: heksesang/bmff
 public BaseMediaReader(Stream stream, BaseMediaOptions options = BaseMediaOptions.None)
 {
     if (stream.CanSeek && stream.Position!=0) stream.Seek(0, SeekOrigin.Begin);
     BaseStream = stream;
     Options = options;
 }