Initial commit
This commit is contained in:
commit
262601edb8
2025 files changed
+218754
No files matched your search
@@ -0,0 +1,263 @@
|
||||
//
|
||||
// ContentDescriptionObject.cs: Provides a representation of an ASF Content
|
||||
// Description object which can be read from and written to disk.
|
||||
//
|
||||
// Author:
|
||||
// Brian Nickel (brian.nickel@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2006-2007 Brian Nickel
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License version
|
||||
// 2.1 as published by the Free Software Foundation.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace TagLib.Asf
|
||||
{
|
||||
/// <summary>
|
||||
/// This class extends <see cref="Object" /> to provide a
|
||||
/// representation of an ASF Content Description object which can be
|
||||
/// read from and written to disk.
|
||||
/// </summary>
|
||||
public class ContentDescriptionObject : Object
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Contains the media title.
|
||||
/// </summary>
|
||||
string title = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the author/performer.
|
||||
/// </summary>
|
||||
string author = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the copyright information.
|
||||
/// </summary>
|
||||
string copyright = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the description of the media.
|
||||
/// </summary>
|
||||
string description = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the rating of the media.
|
||||
/// </summary>
|
||||
string rating = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="ContentDescriptionObject" /> by reading the
|
||||
/// contents from a specified position in a specified file.
|
||||
/// </summary>
|
||||
/// <param name="file">
|
||||
/// A <see cref="Asf.File" /> object containing the file from
|
||||
/// which the contents of the new instance are to be read.
|
||||
/// </param>
|
||||
/// <param name="position">
|
||||
/// A <see cref="long" /> value specify at what position to
|
||||
/// read the object.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="file" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// <paramref name="position" /> is less than zero or greater
|
||||
/// than the size of the file.
|
||||
/// </exception>
|
||||
/// <exception cref="CorruptFileException">
|
||||
/// The object read from disk does not have the correct GUID
|
||||
/// or smaller than the minimum size.
|
||||
/// </exception>
|
||||
public ContentDescriptionObject (File file, long position)
|
||||
: base (file, position)
|
||||
{
|
||||
if (Guid != Asf.Guid.AsfContentDescriptionObject)
|
||||
throw new CorruptFileException ("Object GUID incorrect.");
|
||||
|
||||
if (OriginalSize < 34)
|
||||
throw new CorruptFileException ("Object size too small.");
|
||||
|
||||
ushort title_length = file.ReadWord ();
|
||||
ushort author_length = file.ReadWord ();
|
||||
ushort copyright_length = file.ReadWord ();
|
||||
ushort description_length = file.ReadWord ();
|
||||
ushort rating_length = file.ReadWord ();
|
||||
|
||||
title = file.ReadUnicode (title_length);
|
||||
author = file.ReadUnicode (author_length);
|
||||
copyright = file.ReadUnicode (copyright_length);
|
||||
description = file.ReadUnicode (description_length);
|
||||
rating = file.ReadUnicode (rating_length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="ContentDescriptionObject" /> with no contents.
|
||||
/// </summary>
|
||||
public ContentDescriptionObject ()
|
||||
: base (Asf.Guid.AsfContentDescriptionObject)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Region
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the title of the media described by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="string" /> object containing the title of
|
||||
/// the media or <see langword="null" /> if it is not set.
|
||||
/// </value>
|
||||
public string Title {
|
||||
get { return title.Length == 0 ? null : title; }
|
||||
set {
|
||||
title = string.IsNullOrEmpty (value) ? string.Empty : value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the author or performer of the media
|
||||
/// described by the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="string" /> object containing the author of
|
||||
/// the media or <see langword="null" /> if it is not set.
|
||||
/// </value>
|
||||
public string Author {
|
||||
get { return author.Length == 0 ? null : author; }
|
||||
set {
|
||||
author = string.IsNullOrEmpty (value) ? string.Empty : value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the copyright information for the media
|
||||
/// described by the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="string" /> object containing the copyright
|
||||
/// information for the media or <see langword="null" /> if
|
||||
/// it is not set.
|
||||
/// </value>
|
||||
public string Copyright {
|
||||
get { return copyright.Length == 0 ? null : copyright; }
|
||||
set {
|
||||
copyright = string.IsNullOrEmpty (value) ? string.Empty : value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the description of the media described by
|
||||
/// the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="string" /> object containing a description
|
||||
/// of the media or <see langword="null" /> if it is not set.
|
||||
/// </value>
|
||||
public string Description {
|
||||
get {
|
||||
return description.Length == 0 ? null : description;
|
||||
}
|
||||
set {
|
||||
description = string.IsNullOrEmpty (value) ? string.Empty : value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the rating of the media described by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="string" /> object containing a rating of the
|
||||
/// media or <see langword="null" /> if it is not set.
|
||||
/// </value>
|
||||
public string Rating {
|
||||
get { return rating.Length == 0 ? null : rating; }
|
||||
set {
|
||||
rating = string.IsNullOrEmpty (value) ? string.Empty : value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the current instance is empty.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <see langword="true" /> if all the values are cleared.
|
||||
/// Otherwise <see langword="false" />.
|
||||
/// </value>
|
||||
public bool IsEmpty {
|
||||
get {
|
||||
return title.Length == 0 &&
|
||||
author.Length == 0 &&
|
||||
copyright.Length == 0 &&
|
||||
description.Length == 0 &&
|
||||
rating.Length == 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Region
|
||||
|
||||
/// <summary>
|
||||
/// Renders the current instance as a raw ASF object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered version of the current instance.
|
||||
/// </returns>
|
||||
public override ByteVector Render ()
|
||||
{
|
||||
ByteVector title_bytes = RenderUnicode (title);
|
||||
ByteVector author_bytes = RenderUnicode (author);
|
||||
ByteVector copyright_bytes = RenderUnicode (copyright);
|
||||
ByteVector description_bytes =
|
||||
RenderUnicode (description);
|
||||
ByteVector rating_bytes = RenderUnicode (rating);
|
||||
|
||||
ByteVector output = RenderWord ((ushort)
|
||||
title_bytes.Count);
|
||||
output.Add (RenderWord ((ushort)author_bytes.Count));
|
||||
output.Add (RenderWord ((ushort)copyright_bytes.Count));
|
||||
output.Add (RenderWord ((ushort)
|
||||
description_bytes.Count));
|
||||
output.Add (RenderWord ((ushort)rating_bytes.Count));
|
||||
output.Add (title_bytes);
|
||||
output.Add (author_bytes);
|
||||
output.Add (copyright_bytes);
|
||||
output.Add (description_bytes);
|
||||
output.Add (rating_bytes);
|
||||
|
||||
return Render (output);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f526cfb69af160d3c9edf6227f73e985
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,474 @@
|
||||
//
|
||||
// ContentDescriptor.cs: Provides a representation of an ASF Content Descriptor
|
||||
// to be used in combination with ExtendedContentDescriptionObject.
|
||||
//
|
||||
// Author:
|
||||
// Brian Nickel (brian.nickel@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2006-2007 Brian Nickel
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License version
|
||||
// 2.1 as published by the Free Software Foundation.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace TagLib.Asf
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the type of data stored in a <see
|
||||
/// cref="ContentDescriptor" /> or <see cref="DescriptionRecord" />
|
||||
/// object.
|
||||
/// </summary>
|
||||
public enum DataType
|
||||
{
|
||||
/// <summary>
|
||||
/// The descriptor contains Unicode (UTF-16LE) text.
|
||||
/// </summary>
|
||||
Unicode = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The descriptor contains binary data.
|
||||
/// </summary>
|
||||
Bytes = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The descriptor contains a boolean value.
|
||||
/// </summary>
|
||||
Bool = 2,
|
||||
|
||||
/// <summary>
|
||||
/// The descriptor contains a 4-byte DWORD value.
|
||||
/// </summary>
|
||||
DWord = 3,
|
||||
|
||||
/// <summary>
|
||||
/// The descriptor contains a 8-byte QWORD value.
|
||||
/// </summary>
|
||||
QWord = 4,
|
||||
|
||||
/// <summary>
|
||||
/// The descriptor contains a 2-byte WORD value.
|
||||
/// </summary>
|
||||
Word = 5,
|
||||
|
||||
/// <summary>
|
||||
/// The descriptor contains a 16-byte GUID value.
|
||||
/// </summary>
|
||||
Guid = 6
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This class provides a representation of an ASF Content
|
||||
/// Descriptor to be used in combination with <see
|
||||
/// cref="ExtendedContentDescriptionObject" />.
|
||||
/// </summary>
|
||||
public class ContentDescriptor
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Contains the string value.
|
||||
/// </summary>
|
||||
string strValue;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the byte value.
|
||||
/// </summary>
|
||||
ByteVector byteValue;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the long value.
|
||||
/// </summary>
|
||||
ulong longValue;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="ContentDescriptor" /> with a specified name and
|
||||
/// and value.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// new instance.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A <see cref="string" /> object containing the value for
|
||||
/// the new instance.
|
||||
/// </param>
|
||||
public ContentDescriptor (string name, string value)
|
||||
{
|
||||
Name = name;
|
||||
strValue = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="ContentDescriptor" /> with a specified name and
|
||||
/// and value.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// new instance.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A <see cref="ByteVector" /> object containing the value
|
||||
/// for the new instance.
|
||||
/// </param>
|
||||
public ContentDescriptor (string name, ByteVector value)
|
||||
{
|
||||
Name = name;
|
||||
Type = DataType.Bytes;
|
||||
byteValue = new ByteVector (value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="ContentDescriptor" /> with a specified name and
|
||||
/// and value.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// new instance.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A <see cref="uint" /> value containing the value
|
||||
/// for the new instance.
|
||||
/// </param>
|
||||
public ContentDescriptor (string name, uint value)
|
||||
{
|
||||
Name = name;
|
||||
Type = DataType.DWord;
|
||||
longValue = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="ContentDescriptor" /> with a specified name and
|
||||
/// and value.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// new instance.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A <see cref="ulong" /> value containing the value
|
||||
/// for the new instance.
|
||||
/// </param>
|
||||
public ContentDescriptor (string name, ulong value)
|
||||
{
|
||||
Name = name;
|
||||
Type = DataType.QWord;
|
||||
longValue = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="ContentDescriptor" /> with a specified name and
|
||||
/// and value.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// new instance.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A <see cref="ushort" /> value containing the value
|
||||
/// for the new instance.
|
||||
/// </param>
|
||||
public ContentDescriptor (string name, ushort value)
|
||||
{
|
||||
Name = name;
|
||||
Type = DataType.Word;
|
||||
longValue = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="ContentDescriptor" /> with a specified name and
|
||||
/// and value.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// new instance.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A <see cref="bool" /> value containing the value
|
||||
/// for the new instance.
|
||||
/// </param>
|
||||
public ContentDescriptor (string name, bool value)
|
||||
{
|
||||
Name = name;
|
||||
Type = DataType.Bool;
|
||||
longValue = value ? 1uL : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="ContentDescriptor" /> by reading its contents from
|
||||
/// a file.
|
||||
/// </summary>
|
||||
/// <param name="file">
|
||||
/// A <see cref="Asf.File" /> object to read the raw ASF
|
||||
/// Description Record from.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="file" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <exception cref="CorruptFileException">
|
||||
/// A valid descriptor could not be read.
|
||||
/// </exception>
|
||||
/// <remarks>
|
||||
/// <paramref name="file" /> must be at a seek position at
|
||||
/// which the descriptor can be read.
|
||||
/// </remarks>
|
||||
protected internal ContentDescriptor (File file)
|
||||
{
|
||||
if (file == null)
|
||||
throw new ArgumentNullException (nameof (file));
|
||||
|
||||
if (!Parse (file))
|
||||
throw new CorruptFileException ("Failed to parse content descriptor.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// current instance.
|
||||
/// </value>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of data contained in the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="DataType" /> value indicating type of data
|
||||
/// contained in the current instance.
|
||||
/// </value>
|
||||
public DataType Type { get; private set; } = DataType.Unicode;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string representation of the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="string" /> object containing the value of
|
||||
/// the current instance.
|
||||
/// </returns>
|
||||
public override string ToString ()
|
||||
{
|
||||
if (Type == DataType.Unicode)
|
||||
return strValue;
|
||||
|
||||
if (Type == DataType.Bytes)
|
||||
return byteValue.ToString (StringType.UTF16LE);
|
||||
|
||||
return longValue.ToString ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the binary contents of the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// contents of the current instance, or <see langword="null"
|
||||
/// /> if <see cref="Type" /> is unequal to <see
|
||||
/// cref="DataType.Bytes" />.
|
||||
/// </returns>
|
||||
public ByteVector ToByteVector ()
|
||||
{
|
||||
return byteValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the boolean value contained in the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="bool" /> value containing the value of the
|
||||
/// current instance.
|
||||
/// </returns>
|
||||
public bool ToBool ()
|
||||
{
|
||||
return longValue != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DWORD value contained in the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="uint" /> value containing the value of the
|
||||
/// current instance.
|
||||
/// </returns>
|
||||
public uint ToDWord ()
|
||||
{
|
||||
if (Type == DataType.Unicode && strValue != null && uint.TryParse (strValue, out var value))
|
||||
return value;
|
||||
|
||||
return (uint)longValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the QWORD value contained in the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ulong" /> value containing the value of the
|
||||
/// current instance.
|
||||
/// </returns>
|
||||
public ulong ToQWord ()
|
||||
{
|
||||
if (Type == DataType.Unicode && strValue != null && ulong.TryParse (strValue, out var value))
|
||||
return value;
|
||||
|
||||
return longValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the WORD value contained in the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ushort" /> value containing the value of the
|
||||
/// current instance.
|
||||
/// </returns>
|
||||
public ushort ToWord ()
|
||||
{
|
||||
if (Type == DataType.Unicode && strValue != null && ushort.TryParse (strValue, out var value))
|
||||
return value;
|
||||
|
||||
return (ushort)longValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the current instance as a raw ASF Description
|
||||
/// Record.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered version of the current instance.
|
||||
/// </returns>
|
||||
public ByteVector Render ()
|
||||
{
|
||||
ByteVector value;
|
||||
|
||||
switch (Type) {
|
||||
case DataType.Unicode:
|
||||
value = Object.RenderUnicode (strValue);
|
||||
break;
|
||||
case DataType.Bytes:
|
||||
value = byteValue;
|
||||
break;
|
||||
case DataType.Bool:
|
||||
case DataType.DWord:
|
||||
value = Object.RenderDWord ((uint)longValue);
|
||||
break;
|
||||
case DataType.QWord:
|
||||
value = Object.RenderQWord (longValue);
|
||||
break;
|
||||
case DataType.Word:
|
||||
value = Object.RenderWord ((ushort)longValue);
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
ByteVector name = Object.RenderUnicode (Name);
|
||||
|
||||
var output = new ByteVector {
|
||||
Object.RenderWord ((ushort)name.Count),
|
||||
name,
|
||||
Object.RenderWord ((ushort)Type),
|
||||
Object.RenderWord ((ushort)value.Count),
|
||||
value
|
||||
};
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Populates the current instance by reading in the contents
|
||||
/// from a file.
|
||||
/// </summary>
|
||||
/// <param name="file">
|
||||
/// A <see cref="Asf.File" /> object to read the raw ASF
|
||||
/// Content Descriptor from.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// <see langword="true" /> if the data was read correctly.
|
||||
/// Otherwise <see langword="false" />.
|
||||
/// </returns>
|
||||
protected bool Parse (File file)
|
||||
{
|
||||
int name_count = file.ReadWord ();
|
||||
Name = file.ReadUnicode (name_count);
|
||||
|
||||
Type = (DataType)file.ReadWord ();
|
||||
|
||||
int value_count = file.ReadWord ();
|
||||
switch (Type) {
|
||||
case DataType.Word:
|
||||
longValue = file.ReadWord ();
|
||||
break;
|
||||
|
||||
case DataType.Bool:
|
||||
longValue = file.ReadDWord ();
|
||||
break;
|
||||
|
||||
case DataType.DWord:
|
||||
longValue = file.ReadDWord ();
|
||||
break;
|
||||
|
||||
case DataType.QWord:
|
||||
longValue = file.ReadQWord ();
|
||||
break;
|
||||
|
||||
case DataType.Unicode:
|
||||
strValue = file.ReadUnicode (value_count);
|
||||
break;
|
||||
|
||||
case DataType.Bytes:
|
||||
byteValue = file.ReadBlock (value_count);
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12848f0d0cefe0dd3864fc18248f7482
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,568 @@
|
||||
//
|
||||
// DescriptionRecord.cs: Provides a representation of an ASF Description Record
|
||||
// to be used in combination with MetadataLibaryObject.
|
||||
//
|
||||
// Author:
|
||||
// Brian Nickel (brian.nickel@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2006-2007 Brian Nickel
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License version
|
||||
// 2.1 as published by the Free Software Foundation.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace TagLib.Asf
|
||||
{
|
||||
/// <summary>
|
||||
/// This class provides a representation of an ASF Description Record
|
||||
/// to be used in combination with <see cref="MetadataLibraryObject"
|
||||
/// />.
|
||||
/// </summary>
|
||||
public class DescriptionRecord
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Contains the string value.
|
||||
/// </summary>
|
||||
string strValue;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the byte value.
|
||||
/// </summary>
|
||||
ByteVector byteValue;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the long value.
|
||||
/// </summary>
|
||||
ulong longValue;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the GUID value.
|
||||
/// </summary>
|
||||
System.Guid guidValue = System.Guid.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="DescriptionRecord" /> with a specified language,
|
||||
/// stream, name, and value.
|
||||
/// </summary>
|
||||
/// <param name="languageListIndex">
|
||||
/// A <see cref="ushort" /> value containing the language
|
||||
/// list index of the new instance.
|
||||
/// </param>
|
||||
/// <param name="streamNumber">
|
||||
/// A <see cref="ushort" /> value containing the stream
|
||||
/// number of the new instance.
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// new instance.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A <see cref="string" /> object containing the value for
|
||||
/// the new instance.
|
||||
/// </param>
|
||||
public DescriptionRecord (ushort languageListIndex, ushort streamNumber, string name, string value)
|
||||
{
|
||||
LanguageListIndex = languageListIndex;
|
||||
StreamNumber = streamNumber;
|
||||
Name = name;
|
||||
strValue = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="DescriptionRecord" /> with a specified language,
|
||||
/// stream, name, and value.
|
||||
/// </summary>
|
||||
/// <param name="languageListIndex">
|
||||
/// A <see cref="ushort" /> value containing the language
|
||||
/// list index of the new instance.
|
||||
/// </param>
|
||||
/// <param name="streamNumber">
|
||||
/// A <see cref="ushort" /> value containing the stream
|
||||
/// number of the new instance.
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// new instance.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A <see cref="ByteVector" /> object containing the value
|
||||
/// for the new instance.
|
||||
/// </param>
|
||||
public DescriptionRecord (ushort languageListIndex, ushort streamNumber, string name, ByteVector value)
|
||||
{
|
||||
LanguageListIndex = languageListIndex;
|
||||
StreamNumber = streamNumber;
|
||||
Name = name;
|
||||
Type = DataType.Bytes;
|
||||
byteValue = new ByteVector (value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="DescriptionRecord" /> with a specified language,
|
||||
/// stream, name, and value.
|
||||
/// </summary>
|
||||
/// <param name="languageListIndex">
|
||||
/// A <see cref="ushort" /> value containing the language
|
||||
/// list index of the new instance.
|
||||
/// </param>
|
||||
/// <param name="streamNumber">
|
||||
/// A <see cref="ushort" /> value containing the stream
|
||||
/// number of the new instance.
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// new instance.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A <see cref="uint" /> value containing the value
|
||||
/// for the new instance.
|
||||
/// </param>
|
||||
public DescriptionRecord (ushort languageListIndex, ushort streamNumber, string name, uint value)
|
||||
{
|
||||
LanguageListIndex = languageListIndex;
|
||||
StreamNumber = streamNumber;
|
||||
Name = name;
|
||||
Type = DataType.DWord;
|
||||
longValue = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="DescriptionRecord" /> with a specified language,
|
||||
/// stream, name, and value.
|
||||
/// </summary>
|
||||
/// <param name="languageListIndex">
|
||||
/// A <see cref="ushort" /> value containing the language
|
||||
/// list index of the new instance.
|
||||
/// </param>
|
||||
/// <param name="streamNumber">
|
||||
/// A <see cref="ushort" /> value containing the stream
|
||||
/// number of the new instance.
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// new instance.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A <see cref="ulong" /> value containing the value
|
||||
/// for the new instance.
|
||||
/// </param>
|
||||
public DescriptionRecord (ushort languageListIndex, ushort streamNumber, string name, ulong value)
|
||||
{
|
||||
LanguageListIndex = languageListIndex;
|
||||
StreamNumber = streamNumber;
|
||||
Name = name;
|
||||
Type = DataType.QWord;
|
||||
longValue = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="DescriptionRecord" /> with a specified language,
|
||||
/// stream, name, and value.
|
||||
/// </summary>
|
||||
/// <param name="languageListIndex">
|
||||
/// A <see cref="ushort" /> value containing the language
|
||||
/// list index of the new instance.
|
||||
/// </param>
|
||||
/// <param name="streamNumber">
|
||||
/// A <see cref="ushort" /> value containing the stream
|
||||
/// number of the new instance.
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// new instance.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A <see cref="ushort" /> value containing the value
|
||||
/// for the new instance.
|
||||
/// </param>
|
||||
public DescriptionRecord (ushort languageListIndex, ushort streamNumber, string name, ushort value)
|
||||
{
|
||||
LanguageListIndex = languageListIndex;
|
||||
StreamNumber = streamNumber;
|
||||
Name = name;
|
||||
Type = DataType.Word;
|
||||
longValue = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="DescriptionRecord" /> with a specified language,
|
||||
/// stream, name, and value.
|
||||
/// </summary>
|
||||
/// <param name="languageListIndex">
|
||||
/// A <see cref="ushort" /> value containing the language
|
||||
/// list index of the new instance.
|
||||
/// </param>
|
||||
/// <param name="streamNumber">
|
||||
/// A <see cref="ushort" /> value containing the stream
|
||||
/// number of the new instance.
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// new instance.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A <see cref="bool" /> value containing the value
|
||||
/// for the new instance.
|
||||
/// </param>
|
||||
public DescriptionRecord (ushort languageListIndex, ushort streamNumber, string name, bool value)
|
||||
{
|
||||
LanguageListIndex = languageListIndex;
|
||||
StreamNumber = streamNumber;
|
||||
Name = name;
|
||||
Type = DataType.Bool;
|
||||
longValue = value ? 1uL : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="DescriptionRecord" /> with a specified language,
|
||||
/// stream, name, and value.
|
||||
/// </summary>
|
||||
/// <param name="languageListIndex">
|
||||
/// A <see cref="ushort" /> value containing the language
|
||||
/// list index of the new instance.
|
||||
/// </param>
|
||||
/// <param name="streamNumber">
|
||||
/// A <see cref="ushort" /> value containing the stream
|
||||
/// number of the new instance.
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// new instance.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A <see cref="System.Guid" /> value containing the value
|
||||
/// for the new instance.
|
||||
/// </param>
|
||||
public DescriptionRecord (ushort languageListIndex, ushort streamNumber, string name, System.Guid value)
|
||||
{
|
||||
LanguageListIndex = languageListIndex;
|
||||
StreamNumber = streamNumber;
|
||||
Name = name;
|
||||
Type = DataType.Guid;
|
||||
guidValue = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="DescriptionRecord" /> by reading its contents from
|
||||
/// a file.
|
||||
/// </summary>
|
||||
/// <param name="file">
|
||||
/// A <see cref="Asf.File" /> object to read the raw ASF
|
||||
/// Description Record from.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="file" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <exception cref="CorruptFileException">
|
||||
/// A valid record could not be read.
|
||||
/// </exception>
|
||||
/// <remarks>
|
||||
/// <paramref name="file" /> must be at a seek position at
|
||||
/// which the record can be read.
|
||||
/// </remarks>
|
||||
protected internal DescriptionRecord (File file)
|
||||
{
|
||||
if (file == null)
|
||||
throw new ArgumentNullException (nameof (file));
|
||||
|
||||
if (!Parse (file))
|
||||
throw new CorruptFileException ("Failed to parse description record.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the language associated with the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="ushort" /> value containing the index of the
|
||||
/// language associated with the current instance.
|
||||
/// </value>
|
||||
public ushort LanguageListIndex { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the stream associated with the current
|
||||
/// instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="ushort" /> value containing the index of the
|
||||
/// stream associated with the current instance.
|
||||
/// </value>
|
||||
public ushort StreamNumber { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// current instance.
|
||||
/// </value>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of data contained in the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="DataType" /> value indicating type of data
|
||||
/// contained in the current instance.
|
||||
/// </value>
|
||||
public DataType Type { get; private set; } = DataType.Unicode;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string representation of the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="string" /> object containing the value of
|
||||
/// the current instance.
|
||||
/// </returns>
|
||||
public override string ToString ()
|
||||
{
|
||||
if (Type == DataType.Unicode)
|
||||
return strValue;
|
||||
|
||||
if (Type == DataType.Bytes)
|
||||
return byteValue.ToString (StringType.UTF16LE);
|
||||
|
||||
return longValue.ToString ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the binary contents of the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// contents of the current instance, or <see langword="null"
|
||||
/// /> if <see cref="Type" /> is unequal to <see
|
||||
/// cref="DataType.Bytes" />.
|
||||
/// </returns>
|
||||
public ByteVector ToByteVector ()
|
||||
{
|
||||
return byteValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the boolean value contained in the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="bool" /> value containing the value of the
|
||||
/// current instance.
|
||||
/// </returns>
|
||||
public bool ToBool ()
|
||||
{
|
||||
return longValue != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DWORD value contained in the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="uint" /> value containing the value of the
|
||||
/// current instance.
|
||||
/// </returns>
|
||||
public uint ToDWord ()
|
||||
{
|
||||
if (Type == DataType.Unicode && strValue != null && uint.TryParse (strValue, out var value))
|
||||
return value;
|
||||
|
||||
return (uint)longValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the QWORD value contained in the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ulong" /> value containing the value of the
|
||||
/// current instance.
|
||||
/// </returns>
|
||||
public ulong ToQWord ()
|
||||
{
|
||||
if (Type == DataType.Unicode && strValue != null && ulong.TryParse (strValue, out var value))
|
||||
return value;
|
||||
|
||||
return longValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the WORD value contained in the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ushort" /> value containing the value of the
|
||||
/// current instance.
|
||||
/// </returns>
|
||||
public ushort ToWord ()
|
||||
{
|
||||
if (Type == DataType.Unicode && strValue != null && ushort.TryParse (strValue, out var value))
|
||||
return value;
|
||||
|
||||
return (ushort)longValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the GUID value contained in the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="System.Guid" /> value containing the value
|
||||
/// of the current instance.
|
||||
/// </returns>
|
||||
public System.Guid ToGuid ()
|
||||
{
|
||||
return guidValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the current instance as a raw ASF Description
|
||||
/// Record.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered version of the current instance.
|
||||
/// </returns>
|
||||
public ByteVector Render ()
|
||||
{
|
||||
ByteVector value;
|
||||
|
||||
switch (Type) {
|
||||
case DataType.Unicode:
|
||||
value = Object.RenderUnicode (strValue);
|
||||
break;
|
||||
case DataType.Bytes:
|
||||
value = byteValue;
|
||||
break;
|
||||
case DataType.Bool:
|
||||
case DataType.DWord:
|
||||
value = Object.RenderDWord ((uint)longValue);
|
||||
break;
|
||||
case DataType.QWord:
|
||||
value = Object.RenderQWord (longValue);
|
||||
break;
|
||||
case DataType.Word:
|
||||
value = Object.RenderWord ((ushort)longValue);
|
||||
break;
|
||||
case DataType.Guid:
|
||||
value = guidValue.ToByteArray ();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
ByteVector name = Object.RenderUnicode (Name);
|
||||
|
||||
var output = new ByteVector {
|
||||
Object.RenderWord (LanguageListIndex),
|
||||
Object.RenderWord (StreamNumber),
|
||||
Object.RenderWord ((ushort)name.Count),
|
||||
Object.RenderWord ((ushort)Type),
|
||||
Object.RenderDWord ((uint)value.Count),
|
||||
name,
|
||||
value
|
||||
};
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Populates the current instance by reading in the contents
|
||||
/// from a file.
|
||||
/// </summary>
|
||||
/// <param name="file">
|
||||
/// A <see cref="Asf.File" /> object to read the raw ASF
|
||||
/// Description Record from.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// <see langword="true" /> if the data was read correctly.
|
||||
/// Otherwise <see langword="false" />.
|
||||
/// </returns>
|
||||
protected bool Parse (File file)
|
||||
{
|
||||
// Field name Field type Size (bits)
|
||||
// Language List Index WORD 16
|
||||
// Stream Number WORD 16
|
||||
// Name Length WORD 16
|
||||
// Data Type WORD 16
|
||||
// Data Length DWORD 32
|
||||
// Name WCHAR varies
|
||||
// Data See below varies
|
||||
|
||||
LanguageListIndex = file.ReadWord ();
|
||||
StreamNumber = file.ReadWord ();
|
||||
ushort name_length = file.ReadWord ();
|
||||
Type = (DataType)file.ReadWord ();
|
||||
int data_length = (int)file.ReadDWord ();
|
||||
Name = file.ReadUnicode (name_length);
|
||||
|
||||
switch (Type) {
|
||||
case DataType.Word:
|
||||
longValue = file.ReadWord ();
|
||||
break;
|
||||
case DataType.Bool:
|
||||
case DataType.DWord:
|
||||
longValue = file.ReadDWord ();
|
||||
break;
|
||||
case DataType.QWord:
|
||||
longValue = file.ReadQWord ();
|
||||
break;
|
||||
case DataType.Unicode:
|
||||
strValue = file.ReadUnicode (data_length);
|
||||
break;
|
||||
case DataType.Bytes:
|
||||
byteValue = file.ReadBlock (data_length);
|
||||
break;
|
||||
case DataType.Guid:
|
||||
guidValue = file.ReadGuid ();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b240cea38450eb09286babb6fd6d82c7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,270 @@
|
||||
//
|
||||
// ExtendedContentDescriptionObject.cs: Provides a representation of an ASF
|
||||
// Extended Content Description object which can be read from and written to
|
||||
// disk.
|
||||
//
|
||||
// Author:
|
||||
// Brian Nickel (brian.nickel@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2006-2007 Brian Nickel
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License version
|
||||
// 2.1 as published by the Free Software Foundation.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TagLib.Asf
|
||||
{
|
||||
/// <summary>
|
||||
/// This class extends <see cref="Object" /> to provide a
|
||||
/// representation of an ASF Extended Content Description object
|
||||
/// which can be read from and written to disk.
|
||||
/// </summary>
|
||||
public class ExtendedContentDescriptionObject : Object, IEnumerable<ContentDescriptor>
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Contains the content descriptors.
|
||||
/// </summary>
|
||||
readonly List<ContentDescriptor> descriptors = new List<ContentDescriptor> ();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="ExtendedContentDescriptionObject" /> by reading the
|
||||
/// contents from a specified position in a specified file.
|
||||
/// </summary>
|
||||
/// <param name="file">
|
||||
/// A <see cref="Asf.File" /> object containing the file from
|
||||
/// which the contents of the new instance are to be read.
|
||||
/// </param>
|
||||
/// <param name="position">
|
||||
/// A <see cref="long" /> value specify at what position to
|
||||
/// read the object.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="file" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// <paramref name="position" /> is less than zero or greater
|
||||
/// than the size of the file.
|
||||
/// </exception>
|
||||
/// <exception cref="CorruptFileException">
|
||||
/// The object read from disk does not have the correct GUID
|
||||
/// or smaller than the minimum size.
|
||||
/// </exception>
|
||||
public ExtendedContentDescriptionObject (File file, long position)
|
||||
: base (file, position)
|
||||
{
|
||||
if (!Guid.Equals (Asf.Guid.AsfExtendedContentDescriptionObject))
|
||||
throw new CorruptFileException ("Object GUID incorrect.");
|
||||
|
||||
if (OriginalSize < 26)
|
||||
throw new CorruptFileException ("Object size too small.");
|
||||
|
||||
ushort count = file.ReadWord ();
|
||||
|
||||
for (ushort i = 0; i < count; i++)
|
||||
AddDescriptor (new ContentDescriptor (file));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="ExtendedContentDescriptionObject" /> with no
|
||||
/// contents.
|
||||
/// </summary>
|
||||
public ExtendedContentDescriptionObject ()
|
||||
: base (Asf.Guid.AsfExtendedContentDescriptionObject)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the current instance is empty.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <see langword="true" /> if the current instance doesn't
|
||||
/// contain any <see cref="ContentDescriptor" /> objects.
|
||||
/// Otherwise <see langword="false" />.
|
||||
/// </value>
|
||||
public bool IsEmpty {
|
||||
get { return descriptors.Count == 0; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Renders the current instance as a raw ASF object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered version of the current instance.
|
||||
/// </returns>
|
||||
public override ByteVector Render ()
|
||||
{
|
||||
ByteVector output = new ByteVector ();
|
||||
ushort count = 0;
|
||||
|
||||
foreach (ContentDescriptor desc in descriptors) {
|
||||
count++;
|
||||
output.Add (desc.Render ());
|
||||
}
|
||||
|
||||
return Render (RenderWord (count) + output);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all descriptors with a given name from the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// descriptors to be removed.
|
||||
/// </param>
|
||||
public void RemoveDescriptors (string name)
|
||||
{
|
||||
for (int i = descriptors.Count - 1; i >= 0; i--)
|
||||
if (name == descriptors[i].Name)
|
||||
descriptors.RemoveAt (i);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all descriptors with any of a collection of names
|
||||
/// from the current instance.
|
||||
/// </summary>
|
||||
/// <param name="names">
|
||||
/// A <see cref="T:string[]" /> containing the names of the
|
||||
/// descriptors to be retrieved.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="names" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <returns>
|
||||
/// A <see cref="T:System.Collections.Generic.IEnumerable`1" /> object enumerating
|
||||
/// through the <see cref="ContentDescriptor" /> objects
|
||||
/// retrieved from the current instance.
|
||||
/// </returns>
|
||||
public IEnumerable<ContentDescriptor> GetDescriptors (params string[] names)
|
||||
{
|
||||
if (names == null)
|
||||
throw new ArgumentNullException (nameof (names));
|
||||
|
||||
foreach (string name in names)
|
||||
foreach (ContentDescriptor desc in descriptors)
|
||||
if (desc.Name == name)
|
||||
yield return desc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a descriptor to the current instance.
|
||||
/// </summary>
|
||||
/// <param name="descriptor">
|
||||
/// A <see cref="ContentDescriptor" /> object to add to the
|
||||
/// current instance.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="descriptor" /> is <see langword="null"
|
||||
/// />.
|
||||
/// </exception>
|
||||
public void AddDescriptor (ContentDescriptor descriptor)
|
||||
{
|
||||
if (descriptor == null)
|
||||
throw new ArgumentNullException (nameof (descriptor));
|
||||
|
||||
descriptors.Add (descriptor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the a collection of desciptors for a given name,
|
||||
/// removing the existing matching records.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// descriptors to be added.
|
||||
/// </param>
|
||||
/// <param name="descriptors">
|
||||
/// A <see cref="T:ContentDescriptor[]" /> containing
|
||||
/// descriptors to add to the new instance.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="name" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <remarks>
|
||||
/// All added entries in <paramref name="descriptors" />
|
||||
/// should match <paramref name="name" /> but it is not
|
||||
/// verified by the method. The descriptors will be added
|
||||
/// with their own names and not the one provided in this
|
||||
/// method, which are used for removing existing values and
|
||||
/// determining where to position the new objects.
|
||||
/// </remarks>
|
||||
public void SetDescriptors (string name, params ContentDescriptor[] descriptors)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException (nameof (name));
|
||||
|
||||
int position = this.descriptors.Count;
|
||||
for (int i = this.descriptors.Count - 1; i >= 0; i--) {
|
||||
if (name == this.descriptors[i].Name) {
|
||||
this.descriptors.RemoveAt (i);
|
||||
position = i;
|
||||
}
|
||||
}
|
||||
this.descriptors.InsertRange (position, descriptors);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region IEnumerable
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerator for enumerating through the content
|
||||
/// descriptors.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="T:System.Collections.IEnumerator`1" /> for
|
||||
/// enumerating through the content descriptors.
|
||||
/// </returns>
|
||||
public IEnumerator<ContentDescriptor> GetEnumerator ()
|
||||
{
|
||||
return descriptors.GetEnumerator ();
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator
|
||||
System.Collections.IEnumerable.GetEnumerator ()
|
||||
{
|
||||
return descriptors.GetEnumerator ();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d284fb627fd9b464a993ff8f4769b52c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,436 @@
|
||||
//
|
||||
// File.cs: Provides tagging and properties support for Microsoft's ASF files.
|
||||
//
|
||||
// Author:
|
||||
// Brian Nickel (brian.nickel@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2006-2007 Brian Nickel
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License version
|
||||
// 2.1 as published by the Free Software Foundation.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TagLib.Asf
|
||||
{
|
||||
/// <summary>
|
||||
/// This class extends <see cref="TagLib.File" /> to provide tagging
|
||||
/// and properties support for Microsoft's ASF files.
|
||||
/// </summary>
|
||||
[SupportedMimeType ("taglib/wma", "wma")]
|
||||
[SupportedMimeType ("taglib/wmv", "wmv")]
|
||||
[SupportedMimeType ("taglib/asf", "asf")]
|
||||
[SupportedMimeType ("audio/x-ms-wma")]
|
||||
[SupportedMimeType ("audio/x-ms-asf")]
|
||||
[SupportedMimeType ("video/x-ms-asf")]
|
||||
public class File : TagLib.File
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Contains the file's tag.
|
||||
/// </summary>
|
||||
Tag asf_tag;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the file's properties.
|
||||
/// </summary>
|
||||
Properties properties;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="File" /> for a specified path in the local file
|
||||
/// system and specified read style.
|
||||
/// </summary>
|
||||
/// <param name="path">
|
||||
/// A <see cref="string" /> object containing the path of the
|
||||
/// file to use in the new instance.
|
||||
/// </param>
|
||||
/// <param name="propertiesStyle">
|
||||
/// A <see cref="ReadStyle" /> value specifying at what level
|
||||
/// of accuracy to read the media properties, or <see
|
||||
/// cref="ReadStyle.None" /> to ignore the properties.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="path" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
public File (string path, ReadStyle propertiesStyle)
|
||||
: base (path)
|
||||
{
|
||||
Read (propertiesStyle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="File" /> for a specified path in the local file
|
||||
/// system with an average read style.
|
||||
/// </summary>
|
||||
/// <param name="path">
|
||||
/// A <see cref="string" /> object containing the path of the
|
||||
/// file to use in the new instance.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="path" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
public File (string path)
|
||||
: this (path, ReadStyle.Average)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="File" /> for a specified file abstraction and
|
||||
/// specified read style.
|
||||
/// </summary>
|
||||
/// <param name="abstraction">
|
||||
/// A <see cref="TagLib.File.IFileAbstraction" /> object to use when
|
||||
/// reading from and writing to the file.
|
||||
/// </param>
|
||||
/// <param name="propertiesStyle">
|
||||
/// A <see cref="ReadStyle" /> value specifying at what level
|
||||
/// of accuracy to read the media properties, or <see
|
||||
/// cref="ReadStyle.None" /> to ignore the properties.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="abstraction" /> is <see langword="null"
|
||||
/// />.
|
||||
/// </exception>
|
||||
public File (IFileAbstraction abstraction, ReadStyle propertiesStyle)
|
||||
: base (abstraction)
|
||||
{
|
||||
Read (propertiesStyle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="File" /> for a specified file abstraction with an
|
||||
/// average read style.
|
||||
/// </summary>
|
||||
/// <param name="abstraction">
|
||||
/// A <see cref="TagLib.File.IFileAbstraction" /> object to use when
|
||||
/// reading from and writing to the file.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="abstraction" /> is <see langword="null"
|
||||
/// />.
|
||||
/// </exception>
|
||||
public File (IFileAbstraction abstraction)
|
||||
: this (abstraction, ReadStyle.Average)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets a abstract representation of all tags stored in the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="TagLib.Tag" /> object representing all tags
|
||||
/// stored in the current instance.
|
||||
/// </value>
|
||||
public override TagLib.Tag Tag {
|
||||
get { return asf_tag; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the media properties of the file represented by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="TagLib.Properties" /> object containing the
|
||||
/// media properties of the file represented by the current
|
||||
/// instance.
|
||||
/// </value>
|
||||
public override Properties Properties {
|
||||
get { return properties; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Saves the changes made in the current instance to the
|
||||
/// file it represents.
|
||||
/// </summary>
|
||||
public override void Save ()
|
||||
{
|
||||
// Boilerplate
|
||||
PreSave ();
|
||||
|
||||
Mode = AccessMode.Write;
|
||||
try {
|
||||
var header = new HeaderObject (this, 0);
|
||||
|
||||
if (asf_tag == null) {
|
||||
header.RemoveContentDescriptors ();
|
||||
TagTypesOnDisk &= ~TagTypes.Asf;
|
||||
} else {
|
||||
TagTypesOnDisk |= TagTypes.Asf;
|
||||
header.AddUniqueObject (
|
||||
asf_tag.ContentDescriptionObject);
|
||||
header.AddUniqueObject (
|
||||
asf_tag.ExtendedContentDescriptionObject);
|
||||
header.Extension.AddUniqueObject (
|
||||
asf_tag.MetadataLibraryObject);
|
||||
}
|
||||
|
||||
var output = header.Render ();
|
||||
long diff = output.Count - (long)header.OriginalSize;
|
||||
Insert (output, 0, (long)header.OriginalSize);
|
||||
|
||||
InvariantStartPosition += diff;
|
||||
InvariantEndPosition += diff;
|
||||
} finally {
|
||||
Mode = AccessMode.Closed;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a tag of a specified type from the current instance,
|
||||
/// optionally creating a new tag if possible.
|
||||
/// </summary>
|
||||
/// <param name="type">
|
||||
/// A <see cref="TagLib.TagTypes" /> value indicating the
|
||||
/// type of tag to read.
|
||||
/// </param>
|
||||
/// <param name="create">
|
||||
/// A <see cref="bool" /> value specifying whether or not to
|
||||
/// try and create the tag if one is not found.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A <see cref="Tag" /> object containing the tag that was
|
||||
/// found in or added to the current instance. If no
|
||||
/// matching tag was found and none was created, <see
|
||||
/// langword="null" /> is returned.
|
||||
/// </returns>
|
||||
public override TagLib.Tag GetTag (TagTypes type, bool create)
|
||||
{
|
||||
if (type == TagTypes.Asf)
|
||||
return asf_tag;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a set of tag types from the current instance.
|
||||
/// </summary>
|
||||
/// <param name="types">
|
||||
/// A bitwise combined <see cref="TagLib.TagTypes" /> value
|
||||
/// containing tag types to be removed from the file.
|
||||
/// </param>
|
||||
/// <remarks>
|
||||
/// In order to remove all tags from a file, pass <see
|
||||
/// cref="TagTypes.AllTags" /> as <paramref name="types" />.
|
||||
/// </remarks>
|
||||
public override void RemoveTags (TagTypes types)
|
||||
{
|
||||
if ((types & TagTypes.Asf) == TagTypes.Asf)
|
||||
asf_tag.Clear ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 2-byte WORD from the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ushort" /> value containing the WORD read
|
||||
/// from the current instance.
|
||||
/// </returns>
|
||||
public ushort ReadWord ()
|
||||
{
|
||||
return ReadBlock (2).ToUShort (false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 4-byte DWORD from the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="uint" /> value containing the DWORD read
|
||||
/// from the current instance.
|
||||
/// </returns>
|
||||
public uint ReadDWord ()
|
||||
{
|
||||
return ReadBlock (4).ToUInt (false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 8-byte QWORD from the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ulong" /> value containing the QWORD read
|
||||
/// from the current instance.
|
||||
/// </returns>
|
||||
public ulong ReadQWord ()
|
||||
{
|
||||
return ReadBlock (8).ToULong (false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 16-byte GUID from the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="System.Guid" /> value containing the GUID
|
||||
/// read from the current instance.
|
||||
/// </returns>
|
||||
public System.Guid ReadGuid ()
|
||||
{
|
||||
return new System.Guid (ReadBlock (16).Data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a Unicode (UTF-16LE) string of specified length
|
||||
/// from the current instance.
|
||||
/// </summary>
|
||||
/// <param name="length">
|
||||
/// A <see cref="int" /> value specifying the number of bytes
|
||||
/// to read. This should always be an even number.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A <see cref="string" /> object containing the Unicode
|
||||
/// string read from the current instance.
|
||||
/// </returns>
|
||||
public string ReadUnicode (int length)
|
||||
{
|
||||
ByteVector data = ReadBlock (length);
|
||||
string output = data.ToString (StringType.UTF16LE);
|
||||
int i = output.IndexOf ('\0');
|
||||
return (i >= 0) ? output.Substring (0, i) : output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a collection of objects from the current instance.
|
||||
/// </summary>
|
||||
/// <param name="count">
|
||||
/// A <see cref="uint" /> value specifying the number of
|
||||
/// objects to read.
|
||||
/// </param>
|
||||
/// <param name="position">
|
||||
/// A <see cref="long" /> value specifying the seek position
|
||||
/// at which to start reading.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A new <see cref="T:System.Collections.Generic.IEnumerable`1" /> object enumerating
|
||||
/// through the <see cref="Object" /> objects read from the
|
||||
/// current instance.
|
||||
/// </returns>
|
||||
public IEnumerable<Object> ReadObjects (uint count,
|
||||
long position)
|
||||
{
|
||||
for (int i = 0; i < (int)count; i++) {
|
||||
Object obj = ReadObject (position);
|
||||
position += (long)obj.OriginalSize;
|
||||
yield return obj;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a <see cref="Object" /> from the current instance.
|
||||
/// </summary>
|
||||
/// <param name="position">
|
||||
/// A <see cref="long" /> value specifying the seek position
|
||||
/// at which to start reading.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A new <see cref="Object" /> object of appropriate type as
|
||||
/// read from the current instance.
|
||||
/// </returns>
|
||||
public Object ReadObject (long position)
|
||||
{
|
||||
Seek (position);
|
||||
System.Guid id = ReadGuid ();
|
||||
|
||||
if (id.Equals (Guid.AsfFilePropertiesObject))
|
||||
return new FilePropertiesObject (this,
|
||||
position);
|
||||
|
||||
if (id.Equals (Guid.AsfStreamPropertiesObject))
|
||||
return new StreamPropertiesObject (this,
|
||||
position);
|
||||
|
||||
if (id.Equals (Guid.AsfContentDescriptionObject))
|
||||
return new ContentDescriptionObject (this,
|
||||
position);
|
||||
|
||||
if (id.Equals (
|
||||
Guid.AsfExtendedContentDescriptionObject))
|
||||
return new ExtendedContentDescriptionObject (
|
||||
this, position);
|
||||
|
||||
if (id.Equals (Guid.AsfPaddingObject))
|
||||
return new PaddingObject (this, position);
|
||||
|
||||
if (id.Equals (Guid.AsfHeaderExtensionObject))
|
||||
return new HeaderExtensionObject (this,
|
||||
position);
|
||||
|
||||
if (id.Equals (Guid.AsfMetadataLibraryObject))
|
||||
return new MetadataLibraryObject (this,
|
||||
position);
|
||||
|
||||
return new UnknownObject (this, position);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the current instance.
|
||||
/// </summary>
|
||||
/// <param name="propertiesStyle">
|
||||
/// A <see cref="ReadStyle" /> value specifying at what level
|
||||
/// of accuracy to read the media properties, or <see
|
||||
/// cref="ReadStyle.None" /> to ignore the properties.
|
||||
/// </param>
|
||||
void Read (ReadStyle propertiesStyle)
|
||||
{
|
||||
Mode = AccessMode.Read;
|
||||
try {
|
||||
HeaderObject header = new HeaderObject (this, 0);
|
||||
|
||||
if (header.HasContentDescriptors)
|
||||
TagTypesOnDisk |= TagTypes.Asf;
|
||||
|
||||
asf_tag = new Tag (header);
|
||||
|
||||
InvariantStartPosition = (long)header.OriginalSize;
|
||||
InvariantEndPosition = Length;
|
||||
|
||||
if ((propertiesStyle & ReadStyle.Average) != 0)
|
||||
properties = header.Properties;
|
||||
} finally {
|
||||
Mode = AccessMode.Closed;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 230597e1f22d7c4048805f50836d30b1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,275 @@
|
||||
//
|
||||
// FilePropertiesObject.cs: Provides a representation of an ASF File Properties
|
||||
// object which can be read from and written to disk.
|
||||
//
|
||||
// Author:
|
||||
// Brian Nickel (brian.nickel@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2006-2007 Brian Nickel
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License version
|
||||
// 2.1 as published by the Free Software Foundation.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace TagLib.Asf
|
||||
{
|
||||
/// <summary>
|
||||
/// This class extends <see cref="Object" /> to provide a
|
||||
/// representation of an ASF File Properties object which can be read
|
||||
/// from and written to disk.
|
||||
/// </summary>
|
||||
public class FilePropertiesObject : Object
|
||||
{
|
||||
#region Constant Values
|
||||
|
||||
static readonly DateTime FileTimeOffset = new DateTime (1601, 1, 1);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Contains the GUID for the file.
|
||||
/// </summary>
|
||||
System.Guid file_id;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the creation date.
|
||||
/// </summary>
|
||||
readonly ulong creation_date;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the play duration.
|
||||
/// </summary>
|
||||
readonly ulong play_duration;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the send duration.
|
||||
/// </summary>
|
||||
readonly ulong send_duration;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="FilePropertiesObject" /> by reading the contents
|
||||
/// from a specified position in a specified file.
|
||||
/// </summary>
|
||||
/// <param name="file">
|
||||
/// A <see cref="Asf.File" /> object containing the file from
|
||||
/// which the contents of the new instance are to be read.
|
||||
/// </param>
|
||||
/// <param name="position">
|
||||
/// A <see cref="long" /> value specify at what position to
|
||||
/// read the object.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="file" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// <paramref name="position" /> is less than zero or greater
|
||||
/// than the size of the file.
|
||||
/// </exception>
|
||||
/// <exception cref="CorruptFileException">
|
||||
/// The object read from disk does not have the correct GUID
|
||||
/// or smaller than the minimum size.
|
||||
/// </exception>
|
||||
public FilePropertiesObject (File file, long position)
|
||||
: base (file, position)
|
||||
{
|
||||
if (!Guid.Equals (Asf.Guid.AsfFilePropertiesObject))
|
||||
throw new CorruptFileException ("Object GUID incorrect.");
|
||||
|
||||
if (OriginalSize < 104)
|
||||
throw new CorruptFileException ("Object size too small.");
|
||||
|
||||
file_id = file.ReadGuid ();
|
||||
FileSize = file.ReadQWord ();
|
||||
creation_date = file.ReadQWord ();
|
||||
DataPacketsCount = file.ReadQWord ();
|
||||
play_duration = file.ReadQWord ();
|
||||
send_duration = file.ReadQWord ();
|
||||
Preroll = file.ReadQWord ();
|
||||
Flags = file.ReadDWord ();
|
||||
MinimumDataPacketSize = file.ReadDWord ();
|
||||
MaximumDataPacketSize = file.ReadDWord ();
|
||||
MaximumBitrate = file.ReadDWord ();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the GUID for the file described by the current
|
||||
/// instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="System.Guid" /> value containing the GUID
|
||||
/// for the file described by the current instance.
|
||||
/// </value>
|
||||
public System.Guid FileId {
|
||||
get { return file_id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the file described by the current
|
||||
/// instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="ulong" /> value containing the size of the
|
||||
/// file described by the current instance.
|
||||
/// </value>
|
||||
public ulong FileSize { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the creation date of the file described by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="DateTime" /> value containing the creation
|
||||
/// date of the file described by the current instance.
|
||||
/// </value>
|
||||
public DateTime CreationDate {
|
||||
get { return new DateTime ((long)creation_date + FileTimeOffset.Ticks); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of data packets in the file described by
|
||||
/// the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="ulong" /> value containing the number of
|
||||
/// data packets in the file described by the current
|
||||
/// instance.
|
||||
/// </value>
|
||||
public ulong DataPacketsCount { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the play duration of the file described by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="TimeSpan" /> value containing the play
|
||||
/// duration of the file described by the current instance.
|
||||
/// </value>
|
||||
public TimeSpan PlayDuration {
|
||||
get { return new TimeSpan ((long)play_duration); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the send duration of the file described by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="TimeSpan" /> value containing the send
|
||||
/// duration of the file described by the current instance.
|
||||
/// </value>
|
||||
public TimeSpan SendDuration {
|
||||
get { return new TimeSpan ((long)send_duration); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the pre-roll of the file described by the current
|
||||
/// instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="ulong" /> value containing the pre-roll of
|
||||
/// the file described by the current instance.
|
||||
/// </value>
|
||||
public ulong Preroll { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the flags of the file described by the current
|
||||
/// instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="uint" /> value containing the flags of the
|
||||
/// file described by the current instance.
|
||||
/// </value>
|
||||
public uint Flags { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the minimum data packet size of the file described
|
||||
/// by the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="uint" /> value containing the minimum data
|
||||
/// packet size of the file described by the current
|
||||
/// instance.
|
||||
/// </value>
|
||||
public uint MinimumDataPacketSize { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the maximum data packet size of the file described
|
||||
/// by the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="uint" /> value containing the maximum data
|
||||
/// packet size of the file described by the current
|
||||
/// instance.
|
||||
/// </value>
|
||||
public uint MaximumDataPacketSize { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the maximum bitrate of the file described by the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="uint" /> value containing the maximum
|
||||
/// bitrate of the file described by the current instance.
|
||||
/// </value>
|
||||
public uint MaximumBitrate { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Renders the current instance as a raw ASF object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered version of the current instance.
|
||||
/// </returns>
|
||||
public override ByteVector Render ()
|
||||
{
|
||||
ByteVector output = file_id.ToByteArray ();
|
||||
output.Add (RenderQWord (FileSize));
|
||||
output.Add (RenderQWord (creation_date));
|
||||
output.Add (RenderQWord (DataPacketsCount));
|
||||
output.Add (RenderQWord (play_duration));
|
||||
output.Add (RenderQWord (send_duration));
|
||||
output.Add (RenderQWord (Preroll));
|
||||
output.Add (RenderDWord (Flags));
|
||||
output.Add (RenderDWord (MinimumDataPacketSize));
|
||||
output.Add (RenderDWord (MaximumDataPacketSize));
|
||||
output.Add (RenderDWord (MaximumBitrate));
|
||||
|
||||
return Render (output);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aadef2fcac80345fe8d8d585ba22aed5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,110 @@
|
||||
//
|
||||
// Guid.cs: Provides common GUID values used by ASF Objects.
|
||||
//
|
||||
// Author:
|
||||
// Brian Nickel (brian.nickel@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2006-2007 Brian Nickel
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License version
|
||||
// 2.1 as published by the Free Software Foundation.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA
|
||||
//
|
||||
|
||||
namespace TagLib.Asf
|
||||
{
|
||||
/// <summary>
|
||||
/// This static class contains common <see cref="System.Guid" />
|
||||
/// values used by ASF Objects.
|
||||
/// </summary>
|
||||
public static class Guid
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that an object is a <see
|
||||
/// cref="ContentDescriptionObject" />.
|
||||
/// </summary>
|
||||
public static readonly System.Guid AsfContentDescriptionObject =
|
||||
new System.Guid ("75B22633-668E-11CF-A6D9-00AA0062CE6C");
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that an object is a <see
|
||||
/// cref="ExtendedContentDescriptionObject" />.
|
||||
/// </summary>
|
||||
public static readonly System.Guid AsfExtendedContentDescriptionObject =
|
||||
new System.Guid ("D2D0A440-E307-11D2-97F0-00A0C95EA850");
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that an object is a <see
|
||||
/// cref="FilePropertiesObject" />.
|
||||
/// </summary>
|
||||
public static readonly System.Guid AsfFilePropertiesObject =
|
||||
new System.Guid ("8CABDCA1-A947-11CF-8EE4-00C00C205365");
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that an object is a <see
|
||||
/// cref="HeaderExtensionObject" />.
|
||||
/// </summary>
|
||||
public static readonly System.Guid AsfHeaderExtensionObject =
|
||||
new System.Guid ("5FBF03B5-A92E-11CF-8EE3-00C00C205365");
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that an object is a <see
|
||||
/// cref="HeaderObject" />.
|
||||
/// </summary>
|
||||
public static readonly System.Guid AsfHeaderObject =
|
||||
new System.Guid ("75B22630-668E-11CF-A6D9-00AA0062CE6C");
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that an object is a <see
|
||||
/// cref="MetadataLibraryObject" />.
|
||||
/// </summary>
|
||||
public static readonly System.Guid AsfMetadataLibraryObject =
|
||||
new System.Guid ("44231C94-9498-49D1-A141-1D134E457054");
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that an object is a <see
|
||||
/// cref="PaddingObject" />.
|
||||
/// </summary>
|
||||
public static readonly System.Guid AsfPaddingObject =
|
||||
new System.Guid ("1806D474-CADF-4509-A4BA-9AABCB96AAE8");
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that an object is a <see
|
||||
/// cref="StreamPropertiesObject" />.
|
||||
/// </summary>
|
||||
public static readonly System.Guid AsfStreamPropertiesObject =
|
||||
new System.Guid ("B7DC0791-A9B7-11CF-8EE6-00C00C205365");
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that a <see cref="StreamPropertiesObject" />
|
||||
/// contains information about an audio stream.
|
||||
/// </summary>
|
||||
public static readonly System.Guid AsfAudioMedia =
|
||||
new System.Guid ("F8699E40-5B4D-11CF-A8FD-00805F5C442B");
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that a <see cref="StreamPropertiesObject" />
|
||||
/// contains information about an video stream.
|
||||
/// </summary>
|
||||
public static readonly System.Guid AsfVideoMedia =
|
||||
new System.Guid ("BC19EFC0-5B4D-11CF-A8FD-00805F5C442B");
|
||||
|
||||
/// <summary>
|
||||
/// Indicates a placeholder portion of a file is correctly
|
||||
/// encoded.
|
||||
/// </summary>
|
||||
public static readonly System.Guid AsfReserved1 =
|
||||
new System.Guid ("ABD3D211-A9BA-11cf-8EE6-00C00C205365");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 106d81de03690f00d9a5574b209c688b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,174 @@
|
||||
//
|
||||
// HeaderExtensionObject.cs: Provides a representation of an ASF Header
|
||||
// Extension object which can be read from and written to disk.
|
||||
//
|
||||
// Author:
|
||||
// Brian Nickel (brian.nickel@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2006-2007 Brian Nickel
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License version
|
||||
// 2.1 as published by the Free Software Foundation.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TagLib.Asf
|
||||
{
|
||||
/// <summary>
|
||||
/// This class extends <see cref="Object" /> to provide a
|
||||
/// representation of an ASF Header Extension object which can be
|
||||
/// read from and written to disk.
|
||||
/// </summary>
|
||||
public class HeaderExtensionObject : Object
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Contains the child objects.
|
||||
/// </summary>
|
||||
readonly List<Object> children = new List<Object> ();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="HeaderExtensionObject" /> by reading the contents
|
||||
/// from a specified position in a specified file.
|
||||
/// </summary>
|
||||
/// <param name="file">
|
||||
/// A <see cref="Asf.File" /> object containing the file from
|
||||
/// which the contents of the new instance are to be read.
|
||||
/// </param>
|
||||
/// <param name="position">
|
||||
/// A <see cref="long" /> value specify at what position to
|
||||
/// read the object.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="file" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// <paramref name="position" /> is less than zero or greater
|
||||
/// than the size of the file.
|
||||
/// </exception>
|
||||
/// <exception cref="CorruptFileException">
|
||||
/// The object read from disk does not have the correct GUID
|
||||
/// or contents.
|
||||
/// </exception>
|
||||
public HeaderExtensionObject (File file, long position)
|
||||
: base (file, position)
|
||||
{
|
||||
if (!Guid.Equals (Asf.Guid.AsfHeaderExtensionObject))
|
||||
throw new CorruptFileException ("Object GUID incorrect.");
|
||||
|
||||
if (file.ReadGuid () != Asf.Guid.AsfReserved1)
|
||||
throw new CorruptFileException ("Reserved1 GUID expected.");
|
||||
|
||||
if (file.ReadWord () != 6)
|
||||
throw new CorruptFileException ("Invalid reserved WORD. Expected '6'.");
|
||||
|
||||
uint size_remaining = file.ReadDWord ();
|
||||
position += 0x170 / 8;
|
||||
|
||||
while (size_remaining > 0) {
|
||||
Object obj = file.ReadObject (position);
|
||||
position += (long)obj.OriginalSize;
|
||||
size_remaining -= (uint)obj.OriginalSize;
|
||||
children.Add (obj);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the child objects contained in the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="T:System.Collections.Generic.IEnumerable`1" /> object enumerating
|
||||
/// through the children of the current instance.
|
||||
/// </value>
|
||||
public IEnumerable<Object> Children {
|
||||
get { return children; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Renders the current instance as a raw ASF object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered version of the current instance.
|
||||
/// </returns>
|
||||
public override ByteVector Render ()
|
||||
{
|
||||
ByteVector output = new ByteVector ();
|
||||
|
||||
foreach (var child in children)
|
||||
output.Add (child.Render ());
|
||||
|
||||
output.Insert (0, RenderDWord ((uint)output.Count));
|
||||
output.Insert (0, RenderWord (6));
|
||||
output.Insert (0, Asf.Guid.AsfReserved1.ToByteArray ());
|
||||
|
||||
return Render (output);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a child object to the current instance.
|
||||
/// </summary>
|
||||
/// <param name="obj">
|
||||
/// A <see cref="Object" /> object to add to the current
|
||||
/// instance.
|
||||
/// </param>
|
||||
public void AddObject (Object obj)
|
||||
{
|
||||
children.Add (obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a child unique child object to the current instance,
|
||||
/// replacing and existing child if present.
|
||||
/// </summary>
|
||||
/// <param name="obj">
|
||||
/// A <see cref="Object" /> object to add to the current
|
||||
/// instance.
|
||||
/// </param>
|
||||
public void AddUniqueObject (Object obj)
|
||||
{
|
||||
for (int i = 0; i < children.Count; i++)
|
||||
if (children[i].Guid == obj.Guid) {
|
||||
children[i] = obj;
|
||||
return;
|
||||
}
|
||||
|
||||
children.Add (obj);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc8a5039b8de0c71c9af979086ce9378
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,265 @@
|
||||
//
|
||||
// HeaderObject.cs: Provides a representation of an ASF Header object which can
|
||||
// be read from and written to disk.
|
||||
//
|
||||
// Author:
|
||||
// Brian Nickel (brian.nickel@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2006-2007 Brian Nickel
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License version
|
||||
// 2.1 as published by the Free Software Foundation.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TagLib.Asf
|
||||
{
|
||||
/// <summary>
|
||||
/// This class extends <see cref="Object" /> to provide a
|
||||
/// representation of an ASF Header object which can be read from and
|
||||
/// written to disk.
|
||||
/// </summary>
|
||||
public class HeaderObject : Object
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Contains the reserved header data.
|
||||
/// </summary>
|
||||
readonly ByteVector reserved;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the child objects.
|
||||
/// </summary>
|
||||
readonly List<Object> children;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="HeaderObject" /> by reading the contents from a
|
||||
/// specified position in a specified file.
|
||||
/// </summary>
|
||||
/// <param name="file">
|
||||
/// A <see cref="Asf.File" /> object containing the file from
|
||||
/// which the contents of the new instance are to be read.
|
||||
/// </param>
|
||||
/// <param name="position">
|
||||
/// A <see cref="long" /> value specify at what position to
|
||||
/// read the object.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="file" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// <paramref name="position" /> is less than zero or greater
|
||||
/// than the size of the file.
|
||||
/// </exception>
|
||||
/// <exception cref="CorruptFileException">
|
||||
/// The object read from disk does not have the correct GUID
|
||||
/// or smaller than the minimum size.
|
||||
/// </exception>
|
||||
public HeaderObject (File file, long position)
|
||||
: base (file, position)
|
||||
{
|
||||
if (!Guid.Equals (Asf.Guid.AsfHeaderObject))
|
||||
throw new CorruptFileException ("Object GUID incorrect.");
|
||||
|
||||
if (OriginalSize < 26)
|
||||
throw new CorruptFileException ("Object size too small.");
|
||||
|
||||
children = new List<Object> ();
|
||||
|
||||
uint child_count = file.ReadDWord ();
|
||||
|
||||
reserved = file.ReadBlock (2);
|
||||
|
||||
children.AddRange (file.ReadObjects (child_count,
|
||||
file.Tell));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the header extension object contained in the
|
||||
/// current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="HeaderExtensionObject" /> object containing
|
||||
/// the header extension object.
|
||||
/// </value>
|
||||
public HeaderExtensionObject Extension {
|
||||
get {
|
||||
foreach (Object child in children)
|
||||
if (child is HeaderExtensionObject)
|
||||
return child as HeaderExtensionObject;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the child objects contained in the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="T:System.Collections.Generic.IEnumerable`1" /> object enumerating
|
||||
/// through the children of the current instance.
|
||||
/// </value>
|
||||
public IEnumerable<Object> Children {
|
||||
get { return children; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the media properties contained within the current
|
||||
/// instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="Properties" /> object containing the media
|
||||
/// properties of the current instance.
|
||||
/// </value>
|
||||
public Properties Properties {
|
||||
get {
|
||||
TimeSpan duration = TimeSpan.Zero;
|
||||
var codecs = new List<ICodec> ();
|
||||
|
||||
foreach (var obj in Children) {
|
||||
if (obj is FilePropertiesObject fpobj) {
|
||||
duration = fpobj.PlayDuration - TimeSpan.FromMilliseconds (fpobj.Preroll);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (obj is StreamPropertiesObject spobj) {
|
||||
codecs.Add (spobj.Codec);
|
||||
}
|
||||
}
|
||||
|
||||
return new Properties (duration, codecs);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the current instance contains either
|
||||
/// type of content descriptiors.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <see langword="true" /> if the current instance contains
|
||||
/// a <see cref="ContentDescriptionObject" /> or a <see
|
||||
/// cref="ExtendedContentDescriptionObject" />. Otherwise
|
||||
/// <see langword="false" />.
|
||||
/// </value>
|
||||
public bool HasContentDescriptors {
|
||||
get {
|
||||
foreach (Object child in children)
|
||||
if (child.Guid == Asf.Guid.AsfContentDescriptionObject ||
|
||||
child.Guid == Asf.Guid.AsfExtendedContentDescriptionObject)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Renders the current instance as a raw ASF object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered version of the current instance.
|
||||
/// </returns>
|
||||
public override ByteVector Render ()
|
||||
{
|
||||
var output = new ByteVector ();
|
||||
uint child_count = 0;
|
||||
|
||||
foreach (var child in children)
|
||||
if (child.Guid != Asf.Guid.AsfPaddingObject) {
|
||||
output.Add (child.Render ());
|
||||
child_count++;
|
||||
}
|
||||
|
||||
long size_diff = (long)output.Count + 30 -
|
||||
(long)OriginalSize;
|
||||
|
||||
if (size_diff != 0) {
|
||||
var obj = new PaddingObject ((uint)(size_diff > 0 ? 4096 : -size_diff));
|
||||
|
||||
output.Add (obj.Render ());
|
||||
child_count++;
|
||||
}
|
||||
|
||||
output.Insert (0, reserved);
|
||||
output.Insert (0, RenderDWord (child_count));
|
||||
return Render (output);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a child object to the current instance.
|
||||
/// </summary>
|
||||
/// <param name="obj">
|
||||
/// A <see cref="Object" /> object to add to the current
|
||||
/// instance.
|
||||
/// </param>
|
||||
public void AddObject (Object obj)
|
||||
{
|
||||
children.Add (obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a child unique child object to the current instance,
|
||||
/// replacing and existing child if present.
|
||||
/// </summary>
|
||||
/// <param name="obj">
|
||||
/// A <see cref="Object" /> object to add to the current
|
||||
/// instance.
|
||||
/// </param>
|
||||
public void AddUniqueObject (Object obj)
|
||||
{
|
||||
for (int i = 0; i < children.Count; i++)
|
||||
if (children[i].Guid == obj.Guid) {
|
||||
children[i] = obj;
|
||||
return;
|
||||
}
|
||||
|
||||
children.Add (obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the content description objects from the current
|
||||
/// instance.
|
||||
/// </summary>
|
||||
public void RemoveContentDescriptors ()
|
||||
{
|
||||
for (int i = children.Count - 1; i >= 0; i--)
|
||||
if (children[i].Guid == Asf.Guid.AsfContentDescriptionObject ||
|
||||
children[i].Guid == Asf.Guid.AsfExtendedContentDescriptionObject)
|
||||
children.RemoveAt (i);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28f74c9348168792da3d31feb083107a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,288 @@
|
||||
//
|
||||
// MetadataLibraryObject.cs: Provides a representation of an ASF Metadata
|
||||
// Library object which can be read from and written to disk.
|
||||
//
|
||||
// Author:
|
||||
// Brian Nickel (brian.nickel@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2006-2007 Brian Nickel
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License version
|
||||
// 2.1 as published by the Free Software Foundation.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TagLib.Asf
|
||||
{
|
||||
/// <summary>
|
||||
/// This class extends <see cref="Object" /> to provide a
|
||||
/// representation of an ASF Metadata Library object which can be
|
||||
/// read from and written to disk.
|
||||
/// </summary>
|
||||
public class MetadataLibraryObject : Object, IEnumerable<DescriptionRecord>
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Contains the description records.
|
||||
/// </summary>
|
||||
readonly List<DescriptionRecord> records = new List<DescriptionRecord> ();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="MetadataLibraryObject" /> by reading the contents
|
||||
/// from a specified position in a specified file.
|
||||
/// </summary>
|
||||
/// <param name="file">
|
||||
/// A <see cref="Asf.File" /> object containing the file from
|
||||
/// which the contents of the new instance are to be read.
|
||||
/// </param>
|
||||
/// <param name="position">
|
||||
/// A <see cref="long" /> value specify at what position to
|
||||
/// read the object.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="file" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// <paramref name="position" /> is less than zero or greater
|
||||
/// than the size of the file.
|
||||
/// </exception>
|
||||
/// <exception cref="CorruptFileException">
|
||||
/// The object read from disk does not have the correct GUID
|
||||
/// or smaller than the minimum size.
|
||||
/// </exception>
|
||||
public MetadataLibraryObject (File file, long position)
|
||||
: base (file, position)
|
||||
{
|
||||
if (!Guid.Equals (Asf.Guid.AsfMetadataLibraryObject))
|
||||
throw new CorruptFileException ("Object GUID incorrect.");
|
||||
|
||||
if (OriginalSize < 26)
|
||||
throw new CorruptFileException ("Object size too small.");
|
||||
|
||||
ushort count = file.ReadWord ();
|
||||
|
||||
for (ushort i = 0; i < count; i++) {
|
||||
var rec = new DescriptionRecord (file);
|
||||
AddRecord (rec);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="MetadataLibraryObject" /> with no contents.
|
||||
/// </summary>
|
||||
public MetadataLibraryObject ()
|
||||
: base (Asf.Guid.AsfMetadataLibraryObject)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the current instance is empty.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <see langword="true" /> if the current instance doesn't
|
||||
/// contain any <see cref="DescriptionRecord" /> objects.
|
||||
/// Otherwise <see langword="false" />.
|
||||
/// </value>
|
||||
public bool IsEmpty {
|
||||
get { return records.Count == 0; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Renders the current instance as a raw ASF object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered version of the current instance.
|
||||
/// </returns>
|
||||
public override ByteVector Render ()
|
||||
{
|
||||
ByteVector output = new ByteVector ();
|
||||
ushort count = 0;
|
||||
|
||||
foreach (DescriptionRecord rec in records) {
|
||||
count++;
|
||||
output.Add (rec.Render ());
|
||||
}
|
||||
|
||||
return Render (RenderWord (count) + output);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all records with a given language, stream, and
|
||||
/// name from the current instance.
|
||||
/// </summary>
|
||||
/// <param name="languageListIndex">
|
||||
/// A <see cref="ushort" /> value containing the language
|
||||
/// list index of the records to be removed.
|
||||
/// </param>
|
||||
/// <param name="streamNumber">
|
||||
/// A <see cref="ushort" /> value containing the stream
|
||||
/// number of the records to be removed.
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// records to be removed.
|
||||
/// </param>
|
||||
public void RemoveRecords (ushort languageListIndex, ushort streamNumber, string name)
|
||||
{
|
||||
for (int i = records.Count - 1; i >= 0; i--) {
|
||||
DescriptionRecord rec = records[i];
|
||||
if (rec.LanguageListIndex == languageListIndex &&
|
||||
rec.StreamNumber == streamNumber &&
|
||||
rec.Name == name)
|
||||
records.RemoveAt (i);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all records with a given language, stream, and any
|
||||
/// of a collection of names from the current instance.
|
||||
/// </summary>
|
||||
/// <param name="languageListIndex">
|
||||
/// A <see cref="ushort" /> value containing the language
|
||||
/// list index of the records to be retrieved.
|
||||
/// </param>
|
||||
/// <param name="streamNumber">
|
||||
/// A <see cref="ushort" /> value containing the stream
|
||||
/// number of the records to be retrieved.
|
||||
/// </param>
|
||||
/// <param name="names">
|
||||
/// A <see cref="T:string[]" /> containing the names of the
|
||||
/// records to be retrieved.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A <see cref="T:System.Collections.Generic.IEnumerable`1" /> object enumerating
|
||||
/// through the <see cref="DescriptionRecord" /> objects
|
||||
/// retrieved from the current instance.
|
||||
/// </returns>
|
||||
public IEnumerable<DescriptionRecord> GetRecords (ushort languageListIndex, ushort streamNumber, params string[] names)
|
||||
{
|
||||
foreach (DescriptionRecord rec in records) {
|
||||
if (rec.LanguageListIndex != languageListIndex ||
|
||||
rec.StreamNumber != streamNumber)
|
||||
continue;
|
||||
|
||||
foreach (string name in names)
|
||||
if (rec.Name == name)
|
||||
yield return rec;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a record to the current instance.
|
||||
/// </summary>
|
||||
/// <param name="record">
|
||||
/// A <see cref="DescriptionRecord" /> object to add to the
|
||||
/// current instance.
|
||||
/// </param>
|
||||
public void AddRecord (DescriptionRecord record)
|
||||
{
|
||||
records.Add (record);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the a collection of records for a given language,
|
||||
/// stream, and name, removing the existing matching records.
|
||||
/// </summary>
|
||||
/// <param name="languageListIndex">
|
||||
/// A <see cref="ushort" /> value containing the language
|
||||
/// list index of the records to be added.
|
||||
/// </param>
|
||||
/// <param name="streamNumber">
|
||||
/// A <see cref="ushort" /> value containing the stream
|
||||
/// number of the records to be added.
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// A <see cref="string" /> object containing the name of the
|
||||
/// records to be added.
|
||||
/// </param>
|
||||
/// <param name="records">
|
||||
/// A <see cref="T:DescriptionRecord[]" /> containing records
|
||||
/// to add to the new instance.
|
||||
/// </param>
|
||||
/// <remarks>
|
||||
/// All added entries in <paramref name="records" /> should
|
||||
/// match <paramref name="languageListIndex" />, <paramref
|
||||
/// name="streamNumber" /> and <paramref name="name" /> but
|
||||
/// it is not verified by the method. The records will be
|
||||
/// added with their own values and not those provided in
|
||||
/// this method, which are used for removing existing values
|
||||
/// and determining where to position the new object.
|
||||
/// </remarks>
|
||||
public void SetRecords (ushort languageListIndex, ushort streamNumber, string name, params DescriptionRecord[] records)
|
||||
{
|
||||
int position = this.records.Count;
|
||||
for (int i = this.records.Count - 1; i >= 0; i--) {
|
||||
DescriptionRecord rec = this.records[i];
|
||||
if (rec.LanguageListIndex == languageListIndex &&
|
||||
rec.StreamNumber == streamNumber &&
|
||||
rec.Name == name) {
|
||||
this.records.RemoveAt (i);
|
||||
position = i;
|
||||
}
|
||||
}
|
||||
this.records.InsertRange (position, records);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region IEnumerable
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerator for enumerating through the
|
||||
/// description records.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="T:System.Collections.IEnumerator`1" /> for
|
||||
/// enumerating through the description records.
|
||||
/// </returns>
|
||||
public IEnumerator<DescriptionRecord> GetEnumerator ()
|
||||
{
|
||||
return records.GetEnumerator ();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator ()
|
||||
{
|
||||
return records.GetEnumerator ();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60b732db7695db75682664625a7c9288
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,244 @@
|
||||
//
|
||||
// Object.cs: Provides a basic representation of an ASF object which can be read
|
||||
// from and written to disk.
|
||||
//
|
||||
// Author:
|
||||
// Brian Nickel (brian.nickel@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2006-2007 Brian Nickel
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License version
|
||||
// 2.1 as published by the Free Software Foundation.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace TagLib.Asf
|
||||
{
|
||||
/// <summary>
|
||||
/// This abstract class provides a basic representation of an ASF
|
||||
/// object which can be read from and written to disk.
|
||||
/// </summary>
|
||||
public abstract class Object
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Contains the GUID of the object.
|
||||
/// </summary>
|
||||
readonly System.Guid id;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="Object" /> by reading the contents from a
|
||||
/// specified position in a specified file.
|
||||
/// </summary>
|
||||
/// <param name="file">
|
||||
/// A <see cref="Asf.File" /> object containing the file from
|
||||
/// which the contents of the new instance are to be read.
|
||||
/// </param>
|
||||
/// <param name="position">
|
||||
/// A <see cref="long" /> value specify at what position to
|
||||
/// read the object.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="file" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// <paramref name="position" /> is less than zero or greater
|
||||
/// than the size of the file.
|
||||
/// </exception>
|
||||
protected Object (File file, long position)
|
||||
{
|
||||
if (file == null)
|
||||
throw new ArgumentNullException (nameof (file));
|
||||
|
||||
if (position < 0 ||
|
||||
position > file.Length - 24)
|
||||
throw new ArgumentOutOfRangeException (nameof (position));
|
||||
|
||||
file.Seek (position);
|
||||
id = file.ReadGuid ();
|
||||
OriginalSize = file.ReadQWord ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="Object" /> with a specified GUID.
|
||||
/// </summary>
|
||||
/// <param name="guid">
|
||||
/// A <see cref="System.Guid" /> value containing the GUID to
|
||||
/// use for the new instance.
|
||||
/// </param>
|
||||
protected Object (System.Guid guid)
|
||||
{
|
||||
id = guid;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the GUID for the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="System.Guid" /> object containing the GUID
|
||||
/// of the current instance.
|
||||
/// </value>
|
||||
public System.Guid Guid {
|
||||
get { return id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the original size of the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="ulong" /> value containing the size of the
|
||||
/// current instance as it originally appeared on disk.
|
||||
/// </value>
|
||||
public ulong OriginalSize { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Renders the current instance as a raw ASF object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered version of the current instance.
|
||||
/// </returns>
|
||||
/// <seealso cref="Render(ByteVector)" />
|
||||
public abstract ByteVector Render ();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Static Methods
|
||||
|
||||
/// <summary>
|
||||
/// Renders a Unicode (wide) string.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// A <see cref="string" /> object containing the text to
|
||||
/// render.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered value.
|
||||
/// </returns>
|
||||
public static ByteVector RenderUnicode (string value)
|
||||
{
|
||||
ByteVector v = ByteVector.FromString (value, StringType.UTF16LE);
|
||||
v.Add (RenderWord (0));
|
||||
return v;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders a 4-byte DWORD.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// A <see cref="uint" /> value containing the DWORD to
|
||||
/// render.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered value.
|
||||
/// </returns>
|
||||
public static ByteVector RenderDWord (uint value)
|
||||
{
|
||||
return ByteVector.FromUInt (value, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders a 8-byte QWORD.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// A <see cref="ulong" /> value containing the QWORD to
|
||||
/// render.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered value.
|
||||
/// </returns>
|
||||
public static ByteVector RenderQWord (ulong value)
|
||||
{
|
||||
return ByteVector.FromULong (value, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders a 2-byte WORD.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// A <see cref="ushort" /> value containing the WORD to
|
||||
/// render.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered value.
|
||||
/// </returns>
|
||||
public static ByteVector RenderWord (ushort value)
|
||||
{
|
||||
return ByteVector.FromUShort (value, false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Renders the current instance as a raw ASF object
|
||||
/// containing specified data.
|
||||
/// </summary>
|
||||
/// <param name="data">
|
||||
/// A <see cref="ByteVector" /> object containing the data to
|
||||
/// contained in the rendered version of the current
|
||||
/// instance.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered version of the current instance.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// Child classes implementing <see cref="Render()" /> should
|
||||
/// render their contents and then send the data through this
|
||||
/// method to produce the final output.
|
||||
/// </remarks>
|
||||
protected ByteVector Render (ByteVector data)
|
||||
{
|
||||
ulong length = (ulong)((data != null ? data.Count : 0) + 24);
|
||||
ByteVector v = id.ToByteArray ();
|
||||
v.Add (RenderQWord (length));
|
||||
v.Add (data);
|
||||
return v;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de6647e25247fb396826cf683998e204
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,125 @@
|
||||
//
|
||||
// PaddingObject.cs: Provides a representation of an ASF Padding object which
|
||||
// can be read from and written to disk.
|
||||
//
|
||||
// Author:
|
||||
// Brian Nickel (brian.nickel@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2006-2007 Brian Nickel
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License version
|
||||
// 2.1 as published by the Free Software Foundation.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace TagLib.Asf
|
||||
{
|
||||
/// <summary>
|
||||
/// This class extends <see cref="Object" /> to provide a
|
||||
/// representation of an ASF Padding object which can be read from
|
||||
/// and written to disk.
|
||||
/// </summary>
|
||||
public class PaddingObject : Object
|
||||
{
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="PaddingObject" /> by reading the contents from a
|
||||
/// specified position in a specified file.
|
||||
/// </summary>
|
||||
/// <param name="file">
|
||||
/// A <see cref="Asf.File" /> object containing the file from
|
||||
/// which the contents of the new instance are to be read.
|
||||
/// </param>
|
||||
/// <param name="position">
|
||||
/// A <see cref="long" /> value specify at what position to
|
||||
/// read the object.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="file" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// <paramref name="position" /> is less than zero or greater
|
||||
/// than the size of the file.
|
||||
/// </exception>
|
||||
/// <exception cref="CorruptFileException">
|
||||
/// The object read from disk does not have the correct GUID
|
||||
/// or smaller than the minimum size.
|
||||
/// </exception>
|
||||
public PaddingObject (File file, long position)
|
||||
: base (file, position)
|
||||
{
|
||||
if (!Guid.Equals (Asf.Guid.AsfPaddingObject))
|
||||
throw new CorruptFileException ("Object GUID incorrect.");
|
||||
|
||||
if (OriginalSize < 24)
|
||||
throw new CorruptFileException ("Object size too small.");
|
||||
|
||||
Size = OriginalSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="PaddingObject" /> of a specified size.
|
||||
/// </summary>
|
||||
/// <param name="size">
|
||||
/// A <see cref="uint" /> value specifying the number of
|
||||
/// bytes the new instance is to take up on disk.
|
||||
/// </param>
|
||||
public PaddingObject (uint size)
|
||||
: base (Asf.Guid.AsfPaddingObject)
|
||||
{
|
||||
Size = size;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Prublic Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the number of bytes the current instance
|
||||
/// will take up on disk.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="ulong" /> value containing the size of the
|
||||
/// current instance on disk.
|
||||
/// </value>
|
||||
public ulong Size { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Renders the current instance as a raw ASF object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered version of the current instance.
|
||||
/// </returns>
|
||||
public override ByteVector Render ()
|
||||
{
|
||||
return Render (new ByteVector ((int)(Size - 24)));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57cc0edc0b79695a69d3f10c7d65944f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,226 @@
|
||||
//
|
||||
// StreamPropertiesObject.cs: Provides a representation of an ASF Stream
|
||||
// Properties object which can be read from and written to disk.
|
||||
//
|
||||
// Author:
|
||||
// Brian Nickel (brian.nickel@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2006-2007 Brian Nickel
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License version
|
||||
// 2.1 as published by the Free Software Foundation.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace TagLib.Asf
|
||||
{
|
||||
/// <summary>
|
||||
/// This class extends <see cref="Object" /> to provide a
|
||||
/// representation of an ASF Stream Properties object which can be
|
||||
/// read from and written to disk.
|
||||
/// </summary>
|
||||
public class StreamPropertiesObject : Object
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Contains the time offset of the stream.
|
||||
/// </summary>
|
||||
readonly ulong time_offset;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the reserved data.
|
||||
/// </summary>
|
||||
readonly uint reserved;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="PaddingObject" /> by reading the contents from a
|
||||
/// specified position in a specified file.
|
||||
/// </summary>
|
||||
/// <param name="file">
|
||||
/// A <see cref="Asf.File" /> object containing the file from
|
||||
/// which the contents of the new instance are to be read.
|
||||
/// </param>
|
||||
/// <param name="position">
|
||||
/// A <see cref="long" /> value specify at what position to
|
||||
/// read the object.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="file" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// <paramref name="position" /> is less than zero or greater
|
||||
/// than the size of the file.
|
||||
/// </exception>
|
||||
/// <exception cref="CorruptFileException">
|
||||
/// The object read from disk does not have the correct GUID
|
||||
/// or smaller than the minimum size.
|
||||
/// </exception>
|
||||
public StreamPropertiesObject (File file, long position)
|
||||
: base (file, position)
|
||||
{
|
||||
if (!Guid.Equals (Asf.Guid.AsfStreamPropertiesObject))
|
||||
throw new CorruptFileException ("Object GUID incorrect.");
|
||||
|
||||
if (OriginalSize < 78)
|
||||
throw new CorruptFileException ("Object size too small.");
|
||||
|
||||
StreamType = file.ReadGuid ();
|
||||
ErrorCorrectionType = file.ReadGuid ();
|
||||
time_offset = file.ReadQWord ();
|
||||
|
||||
int type_specific_data_length = (int)file.ReadDWord ();
|
||||
int error_correction_data_length = (int)file.ReadDWord ();
|
||||
|
||||
Flags = file.ReadWord ();
|
||||
reserved = file.ReadDWord ();
|
||||
TypeSpecificData = file.ReadBlock (type_specific_data_length);
|
||||
ErrorCorrectionData = file.ReadBlock (error_correction_data_length);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the codec information contained in the current
|
||||
/// instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="ICodec" /> object containing the codec
|
||||
/// information read from <see cref="TypeSpecificData" /> or
|
||||
/// <see langword="null" /> if the data could not be decoded.
|
||||
/// </value>
|
||||
public ICodec Codec {
|
||||
get {
|
||||
if (StreamType == Asf.Guid.AsfAudioMedia)
|
||||
return new Riff.WaveFormatEx (TypeSpecificData, 0);
|
||||
|
||||
if (StreamType == Asf.Guid.AsfVideoMedia)
|
||||
return new Riff.BitmapInfoHeader (TypeSpecificData, 11);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the stream type GUID of the current instance.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// A <see cref="System.Guid" /> object containing the stream
|
||||
/// type GUID of the current instance.
|
||||
/// </summary>
|
||||
public System.Guid StreamType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the error correction type GUID of the current
|
||||
/// instance.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// A <see cref="System.Guid" /> object containing the error
|
||||
/// correction type GUID of the current instance.
|
||||
/// </summary>
|
||||
public System.Guid ErrorCorrectionType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the time offset at which the stream described by the
|
||||
/// current instance begins.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="TimeSpan" /> value containing the time
|
||||
/// offset at which the stream described by the current
|
||||
/// instance begins.
|
||||
/// </value>
|
||||
public TimeSpan TimeOffset {
|
||||
get { return new TimeSpan ((long)time_offset); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the flags that apply to the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="ushort" /> value containing the flags that
|
||||
/// apply to the current instance.
|
||||
/// </value>
|
||||
public ushort Flags { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type specific data contained in the current
|
||||
/// instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="ByteVector" /> object containing the type
|
||||
/// specific data contained in the current instance.
|
||||
/// </value>
|
||||
/// <remarks>
|
||||
/// The contents of this value are dependant on the type
|
||||
/// contained in <see cref="StreamType" />.
|
||||
/// </remarks>
|
||||
public ByteVector TypeSpecificData { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the error correction data contained in the current
|
||||
/// instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="ByteVector" /> object containing the error
|
||||
/// correction data contained in the current instance.
|
||||
/// </value>
|
||||
/// <remarks>
|
||||
/// The contents of this value are dependant on the type
|
||||
/// contained in <see cref="ErrorCorrectionType" />.
|
||||
/// </remarks>
|
||||
public ByteVector ErrorCorrectionData { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Renders the current instance as a raw ASF object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered version of the current instance.
|
||||
/// </returns>
|
||||
public override ByteVector Render ()
|
||||
{
|
||||
ByteVector output = StreamType.ToByteArray ();
|
||||
output.Add (ErrorCorrectionType.ToByteArray ());
|
||||
output.Add (RenderQWord (time_offset));
|
||||
output.Add (RenderDWord ((uint)TypeSpecificData.Count));
|
||||
output.Add (RenderDWord ((uint)ErrorCorrectionData.Count));
|
||||
output.Add (RenderWord (Flags));
|
||||
output.Add (RenderDWord (reserved));
|
||||
output.Add (TypeSpecificData);
|
||||
output.Add (ErrorCorrectionData);
|
||||
|
||||
return Render (output);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4fa10f38049b3e2499e7f713daf6b9a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d734ffb9edf169961b4e181c03effffd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// UnknownObject.cs: Provides a simple and generic representation of an object
|
||||
// not identified by TagLib# so that its contents may be preserved.
|
||||
//
|
||||
// Author:
|
||||
// Brian Nickel (brian.nickel@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2006-2007 Brian Nickel
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License version
|
||||
// 2.1 as published by the Free Software Foundation.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace TagLib.Asf
|
||||
{
|
||||
/// <summary>
|
||||
/// This class extends <see cref="Object" /> to provide a
|
||||
/// representation of an unknown object which can be read from and
|
||||
/// written to disk.
|
||||
/// </summary>
|
||||
public class UnknownObject : Object
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and initializes a new instance of <see
|
||||
/// cref="UnknownObject" /> by reading the contents from a
|
||||
/// specified position in a specified file.
|
||||
/// </summary>
|
||||
/// <param name="file">
|
||||
/// A <see cref="Asf.File" /> object containing the file from
|
||||
/// which the contents of the new instance are to be read.
|
||||
/// </param>
|
||||
/// <param name="position">
|
||||
/// A <see cref="long" /> value specify at what position to
|
||||
/// read the object.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="file" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// <paramref name="position" /> is less than zero or greater
|
||||
/// than the size of the file.
|
||||
/// </exception>
|
||||
public UnknownObject (File file, long position)
|
||||
: base (file, position)
|
||||
{
|
||||
Data = file.ReadBlock ((int)(OriginalSize - 24));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the data contained in the current instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="ByteVector" /> object containing the data
|
||||
/// contained in the current instance.
|
||||
/// </value>
|
||||
public ByteVector Data { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Renders the current instance as a raw ASF object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="ByteVector" /> object containing the
|
||||
/// rendered version of the current instance.
|
||||
/// </returns>
|
||||
public override ByteVector Render ()
|
||||
{
|
||||
return Render (Data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91aaa7eb7ea3bc7638ef1a9a9bb9f898
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user