2005-04-19 Gabor Kelemen <kelemeng@gnome.hu>
[beagle.git] / Filters / FilterMp3.cs
blobd957b393159c9b9110f94b89b02b78d60676d688
1 //
2 // FilterMp3.cs : Register for reading of mp3 files, id3v2 is read, then missing
3 // infos are filled with id3v1 values.
4 //
5 // Author:
6 // Raphaël Slinckx <raf.raf@wol.be>
7 //
8 // Copyright 2004 (C) Raphaël Slinckx
9 //
12 // Permission is hereby granted, free of charge, to any person obtaining a
13 // copy of this software and associated documentation files (the "Software"),
14 // to deal in the Software without restriction, including without limitation
15 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 // and/or sell copies of the Software, and to permit persons to whom the
17 // Software is furnished to do so, subject to the following conditions:
19 // The above copyright notice and this permission notice shall be included in
20 // all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 // DEALINGS IN THE SOFTWARE.
31 using System;
32 using System.IO;
33 using Beagle.Util.AudioUtil;
35 namespace Beagle.Filters {
37 public class FilterMp3 : FilterMusic {
39 private Id3v1TagReader Id3v1Reader = new Id3v1TagReader ();
40 private Id3v2TagReader Id3v2Reader = new Id3v2TagReader ();
43 protected override Tag GetTag(Stream s)
45 Tag v2 = Id3v2Reader.Read ((FileStream)s);
46 Tag v1 = Id3v1Reader.Read ((FileStream)s);
48 v2.Merge (v1);
49 return v2;
52 protected override void RegisterSupportedTypes()
54 AddSupportedMimeType ("audio/x-mp3");
55 AddSupportedMimeType ("audio/mpeg");