~njh-aelius/maxosx/musicbrainz-tags

« back to all changes in this revision

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

  • Committer: stephen_booth
  • Date: 2008-04-30 02:09:12 UTC
  • Revision ID: svn-v4:6b6cea13-1402-0410-9567-a7afb52bf336:trunk:1372
Update to latest taglib SVN

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
using namespace TagLib::Ogg;
 
39
 
 
40
class Speex::File::FilePrivate
 
41
{
 
42
public:
 
43
  FilePrivate() :
 
44
    comment(0),
 
45
    properties(0) {}
 
46
 
 
47
  ~FilePrivate()
 
48
  {
 
49
    delete comment;
 
50
    delete properties;
 
51
  }
 
52
 
 
53
  Ogg::XiphComment *comment;
 
54
  Properties *properties;
 
55
};
 
56
 
 
57
////////////////////////////////////////////////////////////////////////////////
 
58
// public members
 
59
////////////////////////////////////////////////////////////////////////////////
 
60
 
 
61
Speex::File::File(FileName file, bool readProperties,
 
62
                   Properties::ReadStyle propertiesStyle) : Ogg::File(file)
 
63
{
 
64
  d = new FilePrivate;
 
65
  read(readProperties, propertiesStyle);
 
66
}
 
67
 
 
68
Speex::File::~File()
 
69
{
 
70
  delete d;
 
71
}
 
72
 
 
73
Ogg::XiphComment *Speex::File::tag() const
 
74
{
 
75
  return d->comment;
 
76
}
 
77
 
 
78
Speex::Properties *Speex::File::audioProperties() const
 
79
{
 
80
  return d->properties;
 
81
}
 
82
 
 
83
bool Speex::File::save()
 
84
{
 
85
  if(!d->comment)
 
86
    d->comment = new Ogg::XiphComment;
 
87
 
 
88
  setPacket(1, d->comment->render());
 
89
 
 
90
  return Ogg::File::save();
 
91
}
 
92
 
 
93
////////////////////////////////////////////////////////////////////////////////
 
94
// private members
 
95
////////////////////////////////////////////////////////////////////////////////
 
96
 
 
97
void Speex::File::read(bool readProperties, Properties::ReadStyle propertiesStyle)
 
98
{
 
99
  ByteVector speexHeaderData = packet(0);
 
100
 
 
101
  if(!speexHeaderData.startsWith("Speex   ")) {
 
102
    debug("Speex::File::read() -- invalid Speex identification header");
 
103
    return;
 
104
  }
 
105
 
 
106
  ByteVector commentHeaderData = packet(1);
 
107
 
 
108
  d->comment = new Ogg::XiphComment(commentHeaderData);
 
109
 
 
110
  if(readProperties)
 
111
    d->properties = new Properties(this, propertiesStyle);
 
112
}