Compute lucene-style scores for our hits.
[beagle.git] / Filters / FilterMp3.cs
blob3bfe17d188dd001ae935d568c2d2a07e2dbc77c9
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;
34 using Beagle.Daemon;
35 using Beagle.Util.AudioUtil;
37 namespace Beagle.Filters {
39 public class FilterMp3 : FilterMusic {
41 private Id3v1TagReader Id3v1Reader = new Id3v1TagReader ();
42 private Id3v2TagReader Id3v2Reader = new Id3v2TagReader ();
45 protected override Tag GetTag(Stream s)
47 Tag v2 = Id3v2Reader.Read ((FileStream)s);
48 Tag v1 = Id3v1Reader.Read ((FileStream)s);
50 v2.Merge (v1);
51 return v2;
54 protected override void RegisterSupportedTypes()
56 AddSupportedFlavor (FilterFlavor.NewFromMimeType ("audio/x-mp3"));
57 AddSupportedFlavor (FilterFlavor.NewFromMimeType ("audio/mpeg"));