~ubuntu-branches/debian/sid/hipo/sid

« back to all changes in this revision

Viewing changes to taglib-sharp/TagLib/Asf/Properties.cs

  • Committer: Bazaar Package Importer
  • Author(s): Arthur Loiret
  • Date: 2008-04-02 15:37:34 UTC
  • mfrom: (1.1.3 upstream) (2.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080402153734-hnz2ia2tj3zox4z8
Tags: 0.6.1-2
* 0001-Remove-deprecated-Encoding-field-from-hipo.desktop.i.patch: Add,
  taken from Ubuntu.
* Let's hope Ubuntu maintainer Miguel Ruiz will send its patches back to
  Debian next time.
* debian/copyright: Rewrite.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
    copyright            : (C) 2005 by Brian Nickel
3
 
    email                : brian.nickel@gmail.com
4
 
    based on             : mpcproperties.cpp from TagLib
5
 
 ***************************************************************************/
6
 
 
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.                     *
11
 
 *                                                                         *
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.                       *
16
 
 *                                                                         *
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  *
20
 
 *   USA                                                                   *
21
 
 ***************************************************************************/
22
 
 
23
 
using System;
24
 
 
25
 
namespace TagLib.Asf
26
 
{
27
 
   public class Properties : TagLib.AudioProperties
28
 
   {
29
 
      //////////////////////////////////////////////////////////////////////////
30
 
      // private properties
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;
37
 
      
38
 
      //////////////////////////////////////////////////////////////////////////
39
 
      // public methods
40
 
      //////////////////////////////////////////////////////////////////////////
41
 
      public Properties (HeaderObject header, ReadStyle style) : base (style)
42
 
      {
43
 
         duration         = TimeSpan.Zero;
44
 
         //codec_id         = 0;
45
 
         channels         = 0;
46
 
         sample_rate      = 0;
47
 
         bytes_per_second = 0;
48
 
         
49
 
         foreach (Object obj in header.Children)
50
 
         {
51
 
            if (obj is FilePropertiesObject)
52
 
               duration = ((FilePropertiesObject) obj).PlayDuration;
53
 
            
54
 
            if (obj is StreamPropertiesObject && bytes_per_second == 0)
55
 
            {
56
 
               StreamPropertiesObject stream = (StreamPropertiesObject) obj;
57
 
               
58
 
               if (!stream.StreamType.Equals (Guid.AsfAudioMedia))
59
 
                  continue;
60
 
               
61
 
               ByteVector data = stream.TypeSpecificData;
62
 
               
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);
67
 
            }
68
 
         }
69
 
      }
70
 
      
71
 
      public Properties (HeaderObject header) : this (header, ReadStyle.Average)
72
 
      {
73
 
      }
74
 
      
75
 
      
76
 
      //////////////////////////////////////////////////////////////////////////
77
 
      // public properties
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;}}
83
 
   }
84
 
}