summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-04-21 02:16:03 (UTC)
committer llornkcor <llornkcor>2002-04-21 02:16:03 (UTC)
commit1c459273c0e9e387fd5fe2e2c05bef4db5bce115 (patch) (unidiff)
treecba3a1247a06ec54508c154b0232b7d33d581413 /core
parent0e028a1857c7648bc329cbbf5cb35435be909ea6 (diff)
downloadopie-1c459273c0e9e387fd5fe2e2c05bef4db5bce115.zip
opie-1c459273c0e9e387fd5fe2e2c05bef4db5bce115.tar.gz
opie-1c459273c0e9e387fd5fe2e2c05bef4db5bce115.tar.bz2
I really dont understand..
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/libmad.pro4
-rw-r--r--core/multimedia/opieplayer/libmad/libmadplugin.cpp68
2 files changed, 23 insertions, 49 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmad.pro b/core/multimedia/opieplayer/libmad/libmad.pro
index 679242b..8278bf0 100644
--- a/core/multimedia/opieplayer/libmad/libmad.pro
+++ b/core/multimedia/opieplayer/libmad/libmad.pro
@@ -1,14 +1,14 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3HEADERS = libmad_version.h fixed.h bit.h timer.h stream.h frame.h synth.h decoder.h \ 3HEADERS = libmad_version.h fixed.h bit.h timer.h stream.h frame.h synth.h decoder.h \
4 layer12.h layer3.h huffman.h libmad_global.h mad.h libmadplugin.h libmadpluginimpl.h 4 layer12.h layer3.h huffman.h libmad_global.h mad.h libmadplugin.h libmadpluginimpl.h
5SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c synth.c decoder.c \ 5SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c synth.c decoder.c \
6 layer12.c layer3.c huffman.c libmadplugin.cpp libmadpluginimpl.cpp 6 network.c layer12.c layer3.c huffman.c libmadplugin.cpp libmadpluginimpl.cpp
7TARGET = madplugin 7TARGET = madplugin
8DESTDIR = ../../../plugins/codecs 8DESTDIR = $(OPIEDIR)/plugins/codecs
9INCLUDEPATH += $(OPIEDIR)/include .. 9INCLUDEPATH += $(OPIEDIR)/include ..
10DEPENDPATH += ../$(OPIEDIR)/include .. 10DEPENDPATH += ../$(OPIEDIR)/include ..
11LIBS += -lqpe -lm 11LIBS += -lqpe -lm
12VERSION = 1.0.0 12VERSION = 1.0.0
13 13
14TRANSLATIONS = ../../i18n/pt_BR/libmadplugin.ts 14TRANSLATIONS = ../../i18n/pt_BR/libmadplugin.ts
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
index 7978805..7bb6541 100644
--- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp
+++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
@@ -14,17 +14,12 @@
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qapplication.h>
21#include <qpe/config.h>
22#include <qmessagebox.h>
23#include <qstring.h>
24
25#include <stdio.h> 20#include <stdio.h>
26#include <stdarg.h> 21#include <stdarg.h>
27#include <stdlib.h> 22#include <stdlib.h>
28#include <sys/types.h> 23#include <sys/types.h>
29#include <sys/stat.h> 24#include <sys/stat.h>
30#include <fcntl.h> 25#include <fcntl.h>
@@ -33,13 +28,14 @@
33#include <ctype.h> 28#include <ctype.h>
34#include <errno.h> 29#include <errno.h>
35#include <time.h> 30#include <time.h>
36#include <locale.h> 31#include <locale.h>
37#include <math.h> 32#include <math.h>
38#include <assert.h> 33#include <assert.h>
39 34#include <qapplication.h>
35#include <qpe/config.h>
40 36
41// for network handling 37// for network handling
42#include <netinet/in.h> 38#include <netinet/in.h>
43#include <netdb.h> 39#include <netdb.h>
44#include <sys/socket.h> 40#include <sys/socket.h>
45#include <arpa/inet.h> 41#include <arpa/inet.h>
@@ -234,70 +230,58 @@ int LibMadPlugin::http_read_line(int tcp_sock, char *buf, int size) {
234 230
235 buf[offset] = 0; 231 buf[offset] = 0;
236 return offset; 232 return offset;
237} 233}
238 234
239int LibMadPlugin::http_open(const QString& path ) { 235int LibMadPlugin::http_open(const QString& path ) {
240 qDebug("Open http");
241 char *host; 236 char *host;
242 int port; 237 int port;
243 char *request; 238 char *request;
244 int tcp_sock; 239 int tcp_sock;
245 char http_request[PATH_MAX]; 240 char http_request[PATH_MAX];
246 char filename[PATH_MAX]; 241 char filename[PATH_MAX];
247 // char c; 242 char c;
248 char *arg =strdup(path.latin1()); 243 char *arg =strdup(path.latin1());
249 244
250 QString errorMsg;
251
252 /* Check for URL syntax */ 245 /* Check for URL syntax */
253// if (strncmp(arg, "http://", strlen("http://"))) { 246 if (strncmp(arg, "http://", strlen("http://")))
254// qDebug("Url syntax error"); 247 return (0);
255// return (0);
256// }
257 248
258 qDebug("Parse URL"); 249 /* Parse URL */
259 port = 80; 250 port = 80;
260 host = arg + strlen("http://"); 251 host = arg + strlen("http://");
261 252 if ((request = strchr(host, '/')) == NULL)
262 // we need to think of something better than that 253 return (0);
263 //if ((request = strchr(host, '/')) == NULL) {
264 // qDebug("Url syntax 2error %s", host);
265 // return (0);
266 // }
267
268 *request++ = 0; 254 *request++ = 0;
269 255
270 if (strchr(host, ':') != NULL) /* port is specified */ 256 if (strchr(host, ':') != NULL) /* port is specified */
271 { 257 {
272 port = atoi(strchr(host, ':') + 1); 258 port = atoi(strchr(host, ':') + 1);
273 *strchr(host, ':') = 0; 259 *strchr(host, ':') = 0;
274 } 260 }
275 261
276 qDebug("Open a TCP socket"); 262 /* Open a TCP socket */
277 if (!(tcp_sock = tcp_open(host, port))) { 263 if (!(tcp_sock = tcp_open(host, port)))
278 perror("http_open"); 264 {
279 errorMsg="http_open "+(QString)strerror(errno); 265 perror("http_open");
280 QMessageBox::message("OPiePlayer",errorMsg);
281 return (0); 266 return (0);
282 } 267 }
283 268
284 snprintf(filename, sizeof(filename) - strlen(host) - 75, "%s", request); 269 snprintf(filename, sizeof(filename) - strlen(host) - 75, "%s", request);
285 270
286 /* Send HTTP GET request */ 271 /* Send HTTP GET request */
287 /* Please don't use a Agent know by shoutcast (Lynx, Mozilla) seems to be reconized and print 272 /* Please don't use a Agent know by shoutcast (Lynx, Mozilla) seems to be reconized and print
288 * a html page and not the stream */ 273 * a html page and not the stream */
289 snprintf(http_request, sizeof(http_request), "GET /%s HTTP/1.0\r\n" 274 snprintf(http_request, sizeof(http_request), "GET /%s HTTP/1.0\r\n"
290/* "User-Agent: Mozilla/2.0 (Win95; I)\r\n" */ 275/* "User-Agent: Mozilla/2.0 (Win95; I)\r\n" */
291 "Pragma: no-cache\r\n" "Host: %s\r\n" "Accept: */*\r\n" "\r\n", filename, host); 276 "Pragma: no-cache\r\n" "Host: %s\r\n" "Accept: */*\r\n" "\r\n", filename, host);
292 qDebug("send"); 277
293 send(tcp_sock, http_request, strlen(http_request), 0); 278 send(tcp_sock, http_request, strlen(http_request), 0);
294 279
295 qDebug("Parse server reply"); 280 /* Parse server reply */
296#if 0 281#if 0
297 qDebug("do 0");
298 do 282 do
299 read(tcp_sock, &c, sizeof(char)); 283 read(tcp_sock, &c, sizeof(char));
300 while (c != ' '); 284 while (c != ' ');
301 read(tcp_sock, http_request, 4 * sizeof(char)); 285 read(tcp_sock, http_request, 4 * sizeof(char));
302 http_request[4] = 0; 286 http_request[4] = 0;
303 if (strcmp(http_request, "200 ")) 287 if (strcmp(http_request, "200 "))
@@ -325,23 +309,23 @@ int LibMadPlugin::http_open(const QString& path ) {
325 fprintf(stderr, "http_open: %s\n", strerror(errno)); 309 fprintf(stderr, "http_open: %s\n", strerror(errno));
326 return 0; 310 return 0;
327 } 311 }
328 312
329 if (strncmp(http_request, "Location:", 9) == 0) 313 if (strncmp(http_request, "Location:", 9) == 0)
330 { 314 {
331 qDebug("redirect"); 315 /* redirect */
332 std::close(tcp_sock); 316 std::close(tcp_sock);
333 317
334 http_request[strlen(http_request) - 1] = '\0'; 318 http_request[strlen(http_request) - 1] = '\0';
335 319
336 return http_open(&http_request[10]); 320 return http_open(&http_request[10]);
337 } 321 }
338 322
339 if (strncmp(http_request, "ICY ", 4) == 0) 323 if (strncmp(http_request, "ICY ", 4) == 0)
340 { 324 {
341 qDebug(" This is icecast streaming"); 325 /* This is icecast streaming */
342 if (strncmp(http_request + 4, "200 ", 4)) 326 if (strncmp(http_request + 4, "200 ", 4))
343 { 327 {
344 fprintf(stderr, "http_open: %s\n", http_request); 328 fprintf(stderr, "http_open: %s\n", http_request);
345 return 0; 329 return 0;
346 } 330 }
347 } 331 }
@@ -357,43 +341,36 @@ int LibMadPlugin::http_open(const QString& path ) {
357 return (tcp_sock); 341 return (tcp_sock);
358} 342}
359 343
360 344
361bool LibMadPlugin::open( const QString& path ) { 345bool LibMadPlugin::open( const QString& path ) {
362 debugMsg( "LibMadPlugin::open" ); 346 debugMsg( "LibMadPlugin::open" );
363 Config cfg("OpiePlayer"); 347 Config cfg("MediaPlayer");
364 cfg.setGroup("Options"); 348 cfg.setGroup("Options");
365 bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE); 349 bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE);
366 qDebug("buffer size is %d", bufferSize); 350 qDebug("buffer size is %d", bufferSize);
367 d->bad_last_frame = 0; 351 d->bad_last_frame = 0;
368 d->flush = TRUE; 352 d->flush = TRUE;
369 info = QString( "" ); 353 info = QString( "" );
370 354
371 qDebug( "Opening %s", path.latin1() ); 355 //qDebug( "Opening %s", path.latin1() );
356
372 357
373 bool isStream=FALSE;
374 if (path.left( 4 ) == "http" ) { 358 if (path.left( 4 ) == "http" ) {
375 d->input.fd = http_open(path); 359 d->input.fd = http_open(path);
376 if(d->input.fd == 0) {
377 qDebug("http_open error");
378 }
379 isStream=TRUE;
380 qDebug("Opened ok");
381 360
382 } else { 361 } else {
383 d->input.path = path.latin1(); 362 d->input.path = path.latin1();
384 d->input.fd = ::open( d->input.path, O_RDONLY ); 363 d->input.fd = ::open( d->input.path, O_RDONLY );
385 } 364 }
386 if (d->input.fd == -1) { 365 if (d->input.fd == -1) {
387 qDebug("error opening %s", d->input.path ); 366 qDebug("error opening %s", d->input.path );
388 return FALSE; 367 return FALSE;
389 } 368 }
390 if(!isStream) { 369
391 qDebug("Print ID#tags"); 370 printID3Tags();
392 printID3Tags();
393 }
394 371
395#if defined(HAVE_MMAP) 372#if defined(HAVE_MMAP)
396 struct stat stat; 373 struct stat stat;
397 if (fstat(d->input.fd, &stat) == -1) { 374 if (fstat(d->input.fd, &stat) == -1) {
398 qDebug("error calling fstat"); return FALSE; 375 qDebug("error calling fstat"); return FALSE;
399 } 376 }
@@ -415,17 +392,14 @@ bool LibMadPlugin::open( const QString& path ) {
415 } 392 }
416 d->input.length = 0; 393 d->input.length = 0;
417 } 394 }
418 395
419 d->input.eof = 0; 396 d->input.eof = 0;
420 397
421qDebug("about to mad_stream");
422 mad_stream_init(&d->stream); 398 mad_stream_init(&d->stream);
423qDebug("mad_frame");
424 mad_frame_init(&d->frame); 399 mad_frame_init(&d->frame);
425qDebug("mad_synth");
426 mad_synth_init(&d->synth); 400 mad_synth_init(&d->synth);
427 401
428 return TRUE; 402 return TRUE;
429} 403}
430 404
431 405