~ubuntu-branches/ubuntu/intrepid/kid3/intrepid

« back to all changes in this revision

Viewing changes to kid3/taglibext/speex/speexfile.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michele Angrisano
  • Date: 2008-01-09 23:20:54 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080109232054-gtcjxz4ahdnzbt01
Tags: 0.10-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/rules:
    + Use dh_icons instead dh_iconcache.
  - debian/control:
    + Update maintainer field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
    copyright            : (C) 2006 by Lukáš Lalinský
 
3
    email                : lalinsky@gmail.com
 
4
    
 
5
    copyright            : (C) 2002 by Scott Wheeler
 
6
    email                : wheeler@kde.org 
 
7
                           (original Vorbis implementation)
 
8
 ***************************************************************************/
 
9
 
 
10
/***************************************************************************
 
11
 *   This library is free software; you can redistribute it and/or modify  *
 
12
 *   it  under the terms of the GNU Lesser General Public License version  *
 
13
 *   2.1 as published by the Free Software Foundation.                     *
 
14
 *                                                                         *
 
15
 *   This library is distributed in the hope that it will be useful, but   *
 
16
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 
17
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 
18
 *   Lesser General Public License for more details.                       *
 
19
 *                                                                         *
 
20
 *   You should have received a copy of the GNU Lesser General Public      *
 
21
 *   License along with this library; if not, write to the Free Software   *
 
22
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,            *
 
23
 *   MA  02110-1301  USA                                                   *
 
24
 ***************************************************************************/
 
25
 
 
26
#include <bitset>
 
27
 
 
28
#include <tstring.h>
 
29
#if 0
 
30
#include <tdebug.h>
 
31
#endif
 
32
 
 
33
#include "speexfile.h"
 
34
 
 
35
using namespace TagLib;
 
36
 
 
37
class Speex::File::FilePrivate
 
38
{
 
39
public:
 
40
  FilePrivate() :
 
41
    comment(0),
 
42
    properties(0) {}
 
43
 
 
44
  ~FilePrivate()
 
45
  {
 
46
    delete comment;
 
47
    delete properties;
 
48
  }
 
49
 
 
50
  Ogg::XiphComment *comment;
 
51
  Properties *properties;
 
52
};
 
53
 
 
54
////////////////////////////////////////////////////////////////////////////////
 
55
// public members
 
56
////////////////////////////////////////////////////////////////////////////////
 
57
 
 
58
Speex::File::File(const char *file, bool readProperties,
 
59
                   Properties::ReadStyle propertiesStyle) : Ogg::File(file)
 
60
{
 
61
  d = new FilePrivate;
 
62
  read(readProperties, propertiesStyle);
 
63
}
 
64
 
 
65
Speex::File::~File()
 
66
{
 
67
  delete d;
 
68
}
 
69
 
 
70
Ogg::XiphComment *Speex::File::tag() const
 
71
{
 
72
  return d->comment;
 
73
}
 
74
 
 
75
Speex::Properties *Speex::File::audioProperties() const
 
76
{
 
77
  return d->properties;
 
78
}
 
79
 
 
80
bool Speex::File::save()
 
81
{
 
82
  if(!d->comment)
 
83
    d->comment = new Ogg::XiphComment;
 
84
 
 
85
  setPacket(1, d->comment->render());
 
86
 
 
87
  return Ogg::File::save();
 
88
}
 
89
 
 
90
////////////////////////////////////////////////////////////////////////////////
 
91
// private members
 
92
////////////////////////////////////////////////////////////////////////////////
 
93
 
 
94
void Speex::File::read(bool readProperties, Properties::ReadStyle propertiesStyle)
 
95
{
 
96
  ByteVector speexHeaderData = packet(0);
 
97
  
 
98
  if(!speexHeaderData.startsWith("Speex   ")) {
 
99
#if 0
 
100
    debug("Speex::File::read() -- invalid Speex identification header");
 
101
#endif
 
102
    return;
 
103
  }
 
104
  
 
105
  ByteVector commentHeaderData = packet(1);
 
106
 
 
107
  d->comment = new Ogg::XiphComment(commentHeaderData);
 
108
 
 
109
  if(readProperties)
 
110
    d->properties = new Properties(this, propertiesStyle);
 
111
}