summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/vorbis/libtremorplugin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/vorbis/libtremorplugin.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp b/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp
index c1e1a23..53c4b2b 100644
--- a/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp
+++ b/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp
@@ -1,138 +1,137 @@
1/**************************************************************************** 1/****************************************************************************
2* libtremorplugin.cpp 2* libtremorplugin.cpp
3* 3*
4* Copyright (C) 2002 Latchesar Ionkov <lucho@ionkov.net> 4* Copyright (C) 2002 Latchesar Ionkov <lucho@ionkov.net>
5* 5*
6* This program is free software; you can redistribute it and/or modify 6* This program is free software; you can redistribute it and/or modify
7* it under the terms of the GNU General Public License as published by 7* it under the terms of the GNU General Public License as published by
8* the Free Software Foundation; either version 2 of the License, or 8* the Free Software Foundation; either version 2 of the License, or
9* (at your option) any later version. 9* (at your option) any later version.
10* 10*
11* This program is distributed in the hope that it will be useful, 11* This program is distributed in the hope that it will be useful,
12* but WITHOUT ANY WARRANTY; without even the implied warranty of 12* but WITHOUT ANY WARRANTY; without even the implied warranty of
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14* GNU General Public License for more details. 14* GNU General Public License for more details.
15* 15*
16* You should have received a copy of the GNU General Public License 16* You should have received a copy of the GNU General Public License
17* along with this program; if not, write to the Free Software 17* along with this program; if not, write to the Free Software
18* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19****************************************************************************/ 19****************************************************************************/
20// fixed and adapted for opieplayer 2003 ljp <llornkcor@handhelds.org> 20// fixed and adapted for opieplayer 2003 ljp <llornkcor@handhelds.org>
21 21
22#include <stdio.h> 22#include <stdio.h>
23#include <stdarg.h> 23#include <stdarg.h>
24#include <stdlib.h> 24#include <stdlib.h>
25#include <sys/types.h> 25#include <sys/types.h>
26#include <sys/stat.h> 26#include <sys/stat.h>
27#include <fcntl.h> 27#include <fcntl.h>
28#include <unistd.h> 28#include <unistd.h>
29#include <string.h> 29#include <string.h>
30#include <errno.h> 30#include <errno.h>
31#include <time.h> 31#include <time.h>
32#include <locale.h> 32#include <locale.h>
33#include <math.h> 33#include <math.h>
34#include <assert.h> 34#include <assert.h>
35 35
36#include <qmap.h> 36#include <qmap.h>
37 37
38#include "libtremorplugin.h" 38#include "libtremorplugin.h"
39 39
40 40
41extern "C" { 41extern "C" {
42#include "tremor/ivorbiscodec.h"
43#include "tremor/ivorbisfile.h" 42#include "tremor/ivorbisfile.h"
44} 43}
45 44
46 45
47#define MPEG_BUFFER_SIZE 65536 46#define MPEG_BUFFER_SIZE 65536
48//#define debugMsg(a) qDebug(a) 47//#define debugMsg(a) qDebug(a)
49#define debugMsg(a) 48#define debugMsg(a)
50 49
51 50
52class LibTremorPluginData { 51class LibTremorPluginData {
53public: 52public:
54 char* filename; 53 char* filename;
55 FILE* f; 54 FILE* f;
56 OggVorbis_File vf; 55 OggVorbis_File vf;
57 vorbis_info* vi; 56 vorbis_info* vi;
58 vorbis_comment* vc; 57 vorbis_comment* vc;
59 bool bos; 58 bool bos;
60 int csection; 59 int csection;
61 QString finfo; 60 QString finfo;
62}; 61};
63 62
64 63
65LibTremorPlugin::LibTremorPlugin() { 64LibTremorPlugin::LibTremorPlugin() {
66qDebug("<<<<<<<<<<<<<TREMOR!!!!!>>>>>>>>>>>>>>>>>>"); 65qDebug("<<<<<<<<<<<<<TREMOR!!!!!>>>>>>>>>>>>>>>>>>");
67 d = new LibTremorPluginData; 66 d = new LibTremorPluginData;
68 d->f = 0; 67 d->f = 0;
69 d->vi = 0; 68 d->vi = 0;
70 d->vc = 0; 69 d->vc = 0;
71 d->bos = 0; 70 d->bos = 0;
72 d->csection = 0; 71 d->csection = 0;
73 d->finfo = ""; 72 d->finfo = "";
74} 73}
75 74
76 75
77LibTremorPlugin::~LibTremorPlugin() { 76LibTremorPlugin::~LibTremorPlugin() {
78 close(); 77 close();
79 delete d; 78 delete d;
80} 79}
81 80
82 81
83bool LibTremorPlugin::isFileSupported( const QString& path ) { 82bool LibTremorPlugin::isFileSupported( const QString& path ) {
84 debugMsg( "LibTremorPlugin::isFileSupported" ); 83 debugMsg( "LibTremorPlugin::isFileSupported" );
85 84
86 // Mpeg file extensions 85 // Mpeg file extensions
87 // "mp2","mp3","m1v","m2v","m2s","mpg","vob","mpeg",ac3" 86 // "mp2","mp3","m1v","m2v","m2s","mpg","vob","mpeg",ac3"
88 // Other media extensions 87 // Other media extensions
89 // "wav","mid","mod","s3m","ogg","avi","mov","sid" 88 // "wav","mid","mod","s3m","ogg","avi","mov","sid"
90 89
91 char *ext = strrchr( path.latin1(), '.' ); 90 char *ext = strrchr( path.latin1(), '.' );
92 91
93 // Test file extension 92 // Test file extension
94 if ( ext ) { 93 if ( ext ) {
95 if ( strncasecmp(ext, ".ogg", 4) == 0 ) 94 if ( strncasecmp(ext, ".ogg", 4) == 0 )
96 return TRUE; 95 return TRUE;
97 } 96 }
98 97
99 return FALSE; 98 return FALSE;
100} 99}
101 100
102 101
103bool LibTremorPlugin::open( const QString& path ) { 102bool LibTremorPlugin::open( const QString& path ) {
104 debugMsg( "LibTremorPlugin::open" ); 103 debugMsg( "LibTremorPlugin::open" );
105 104
106 d->filename = (char*) path.latin1(); 105 d->filename = (char*) path.latin1();
107 d->f = fopen( d->filename, "r" ); 106 d->f = fopen( d->filename, "r" );
108 if (d->f == 0) { 107 if (d->f == 0) {
109 qDebug("error opening %s", d->filename ); 108 qDebug("error opening %s", d->filename );
110 return FALSE; 109 return FALSE;
111 } 110 }
112 111
113 if (ov_open(d->f, &d->vf, NULL, 0) < 0) { 112 if (ov_open(d->f, &d->vf, NULL, 0) < 0) {
114 qDebug("error opening %s", d->filename); 113 qDebug("error opening %s", d->filename);
115 return FALSE; 114 return FALSE;
116 } 115 }
117 116
118 d->vc = ov_comment(&d->vf, -1); 117 d->vc = ov_comment(&d->vf, -1);
119 d->vi = ov_info(&d->vf, -1); 118 d->vi = ov_info(&d->vf, -1);
120 d->bos = false; 119 d->bos = false;
121 120
122 QString comments[] = { "title", "artist", "album", "year", "tracknumber", "" }; 121 QString comments[] = { "title", "artist", "album", "year", "tracknumber", "" };
123 QString cdescr[] = { "Title", "Artist", "Album", "Year", "Track", "" }; 122 QString cdescr[] = { "Title", "Artist", "Album", "Year", "Track", "" };
124 123
125 124
126 QMap<QString, QString> cmap; 125 QMap<QString, QString> cmap;
127 char** cptr = d->vc->user_comments; 126 char** cptr = d->vc->user_comments;
128 127
129 while (*cptr != 0) { 128 while (*cptr != 0) {
130 QString s(*cptr); 129 QString s(*cptr);
131 int n = s.find('='); 130 int n = s.find('=');
132 131
133 if (n < 0) { 132 if (n < 0) {
134 continue; 133 continue;
135 } 134 }
136 135
137 QString key = s.left(n).lower(); 136 QString key = s.left(n).lower();
138 QString value = s.mid(n+1); 137 QString value = s.mid(n+1);