1
/***************************************************************************
2
copyright : (C) 2005 by Brian Nickel
3
email : brian.nickel@gmail.com
4
based on : oggfile.cpp from TagLib
5
***************************************************************************/
7
/***************************************************************************
8
* This library is free software; you can redistribute it and/or modify *
9
* it under the terms of the GNU Lesser General Public License version *
10
* 2.1 as published by the Free Software Foundation. *
12
* This library is distributed in the hope that it will be useful, but *
13
* WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15
* Lesser General Public License for more details. *
17
* You should have received a copy of the GNU Lesser General Public *
18
* License along with this library; if not, write to the Free Software *
19
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
21
***************************************************************************/
23
using System.Collections;
26
namespace TagLib.Ogg.Vorbis
28
[SupportedMimeType("taglib/ogg", "ogg")]
29
[SupportedMimeType("application/ogg")]
30
[SupportedMimeType("application/x-ogg")]
31
[SupportedMimeType("audio/vorbis")]
32
[SupportedMimeType("audio/x-vorbis")]
33
[SupportedMimeType("audio/x-vorbis+ogg")]
34
[SupportedMimeType("audio/ogg")]
35
[SupportedMimeType("audio/x-ogg")]
36
public class File : Ogg.File
38
//////////////////////////////////////////////////////////////////////////
40
//////////////////////////////////////////////////////////////////////////
41
private Ogg.XiphComment comment;
42
private Properties properties;
44
private static byte [] vorbis_comment_header_id = {0x03, (byte)'v', (byte)'o', (byte)'r', (byte)'b', (byte)'i', (byte)'s'};
47
//////////////////////////////////////////////////////////////////////////
49
//////////////////////////////////////////////////////////////////////////
50
public File (string file, Properties.ReadStyle properties_style) : base (file)
55
try {Mode = AccessMode.Read;}
58
Read (properties_style);
60
Mode = AccessMode.Closed;
63
public File (string file) : this (file, Properties.ReadStyle.Average)
67
public override void Save ()
69
ClearPageData (); // Force re-reading of the file.
71
ByteVector v = vorbis_comment_header_id;
73
GetTag (TagTypes.Xiph, true);
75
v.Add (comment.Render ());
82
public override TagLib.Tag GetTag (TagTypes type, bool create)
84
if (type == TagTypes.Xiph)
86
if (comment == null && create)
87
comment = new Ogg.XiphComment ();
96
//////////////////////////////////////////////////////////////////////////
98
//////////////////////////////////////////////////////////////////////////
99
public override Tag Tag {get {return GetTag (TagTypes.Xiph, true);}}
101
public override AudioProperties AudioProperties {get {return properties;}}
103
//////////////////////////////////////////////////////////////////////////
105
//////////////////////////////////////////////////////////////////////////
106
private void Read (Properties.ReadStyle properties_style)
108
ByteVector comment_header_data = GetPacket (1);
110
if (comment_header_data.Mid (0, 7) != vorbis_comment_header_id)
111
throw new CorruptFileException ("Could not find the Vorbis Comment header.");
113
comment = new Ogg.XiphComment (comment_header_data.Mid (7));
115
if(properties_style != Properties.ReadStyle.None)
116
properties = new Properties (this, properties_style);