1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
namespace TagLib.Mpeg4
{
public abstract class FullBox : Box
{
//////////////////////////////////////////////////////////////////////////
// private properties
//////////////////////////////////////////////////////////////////////////
private byte version;
private uint flags;
//////////////////////////////////////////////////////////////////////////
// public methods
//////////////////////////////////////////////////////////////////////////
public FullBox (BoxHeader header, Box parent) : base (header, parent)
{
File.Seek (base.DataPosition);
// First 4 bytes contain version and flag data.
version = File.ReadBlock (1) [0];
flags = File.ReadBlock (3).ToUInt ();
}
// We can create our own box.
public FullBox (ByteVector type, uint flags, Box parent) : base (new BoxHeader (type), parent)
{
version = 0;
this.flags = flags;
}
public FullBox (ByteVector type, uint flags) : this (type, flags, null)
{
}
public FullBox (ByteVector type, Box parent) : this (type, 0, parent)
{
}
public FullBox (ByteVector type) : this (type, 0)
{
}
// Render this box with the extra data at the beginning.
protected override ByteVector Render (ByteVector data)
{
ByteVector output = new ByteVector ();
output += (byte) version;
output += ByteVector.FromUInt (flags).Mid (1,3);
output += data;
return base.Render (output);
}
//////////////////////////////////////////////////////////////////////////
// public properties
//////////////////////////////////////////////////////////////////////////
public uint Version {get {return version;} set {version = (byte)value;}}
public uint Flags {get {return flags;} set {flags = value;}}
// Offset for those foru bytes.
protected override long DataPosition {get {return base.DataPosition + 4;}}
protected override ulong DataSize {get {return base.DataSize - 4;}}
}
}
|