~njh-aelius/maxosx/musicbrainz-tags

« back to all changes in this revision

Viewing changes to Frameworks/taglib/taglib/taglib/speex/speexfile.cpp

  • Committer: stephen_booth
  • Date: 2008-04-30 01:48:01 UTC
  • Revision ID: svn-v4:6b6cea13-1402-0410-9567-a7afb52bf336:trunk:1371
Fixing the taglib source tree

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 - 2008 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
23
 
 *   USA                                                                   *
24
 
 *                                                                         *
25
 
 *   Alternatively, this file is available under the Mozilla Public        *
26
 
 *   License Version 1.1.  You may obtain a copy of the License at         *
27
 
 *   http://www.mozilla.org/MPL/                                           *
28
 
 ***************************************************************************/
29
 
 
30
 
#include <bitset>
31
 
 
32
 
#include <tstring.h>
33
 
#include <tdebug.h>
34
 
 
35
 
#include "speexfile.h"
36
 
 
37
 
using namespace TagLib;
38
 
 
39
 
class Speex::File::FilePrivate
40
 
{
41
 
public:
42
 
  FilePrivate() :
43
 
    comment(0),
44
 
    properties(0) {}
45
 
 
46
 
  ~FilePrivate()
47
 
  {
48
 
    delete comment;
49
 
    delete properties;
50
 
  }
51
 
 
52
 
  Ogg::XiphComment *comment;
53
 
  Properties *properties;
54
 
};
55
 
 
56
 
////////////////////////////////////////////////////////////////////////////////
57
 
// public members
58
 
////////////////////////////////////////////////////////////////////////////////
59
 
 
60
 
Speex::File::File(FileName file, bool readProperties,
61
 
                   Properties::ReadStyle propertiesStyle) : Ogg::File(file)
62
 
{
63
 
  d = new FilePrivate;
64
 
  read(readProperties, propertiesStyle);
65
 
}
66
 
 
67
 
Speex::File::~File()
68
 
{
69
 
  delete d;
70
 
}
71
 
 
72
 
Ogg::XiphComment *Speex::File::tag() const
73
 
{
74
 
  return d->comment;
75
 
}
76
 
 
77
 
Speex::Properties *Speex::File::audioProperties() const
78
 
{
79
 
  return d->properties;
80
 
}
81
 
 
82
 
bool Speex::File::save()
83
 
{
84
 
  if(!d->comment)
85
 
    d->comment = new Ogg::XiphComment;
86
 
 
87
 
  setPacket(1, d->comment->render());
88
 
 
89
 
  return Ogg::File::save();
90
 
}
91
 
 
92
 
////////////////////////////////////////////////////////////////////////////////
93
 
// private members
94
 
////////////////////////////////////////////////////////////////////////////////
95
 
 
96
 
void Speex::File::read(bool readProperties, Properties::ReadStyle propertiesStyle)
97
 
{
98
 
  ByteVector speexHeaderData = packet(0);
99
 
 
100
 
  if(!speexHeaderData.startsWith("Speex   ")) {
101
 
    debug("Speex::File::read() -- invalid Speex identification header");
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
 
}