1
/***************************************************************************
2
copyright : (C) 2005 by Brian Nickel
3
email : brian.nickel@gmail.com
4
based on : mpcproperties.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
***************************************************************************/
27
public class Properties : TagLib.AudioProperties
29
//////////////////////////////////////////////////////////////////////////
31
//////////////////////////////////////////////////////////////////////////
32
private TimeSpan duration;
33
//private short codec_id;
34
private short channels;
35
private uint sample_rate;
36
private uint bytes_per_second;
38
//////////////////////////////////////////////////////////////////////////
40
//////////////////////////////////////////////////////////////////////////
41
public Properties (HeaderObject header, ReadStyle style) : base (style)
43
duration = TimeSpan.Zero;
49
foreach (Object obj in header.Children)
51
if (obj is FilePropertiesObject)
52
duration = ((FilePropertiesObject) obj).PlayDuration;
54
if (obj is StreamPropertiesObject && bytes_per_second == 0)
56
StreamPropertiesObject stream = (StreamPropertiesObject) obj;
58
if (!stream.StreamType.Equals (Guid.AsfAudioMedia))
61
ByteVector data = stream.TypeSpecificData;
63
//codec_id = data.Mid (0, 2).ToShort (false);
64
channels = data.Mid (2, 2).ToShort (false);
65
sample_rate = data.Mid (4, 4).ToUInt (false);
66
bytes_per_second = data.Mid (8, 4).ToUInt (false);
71
public Properties (HeaderObject header) : this (header, ReadStyle.Average)
76
//////////////////////////////////////////////////////////////////////////
78
//////////////////////////////////////////////////////////////////////////
79
public override TimeSpan Duration {get {return duration;}}
80
public override int Bitrate {get {return (int) (bytes_per_second * 8 / 1000);}}
81
public override int SampleRate {get {return (int) sample_rate;}}
82
public override int Channels {get {return channels;}}