summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-20 21:02:20 (UTC)
committer llornkcor <llornkcor>2002-04-20 21:02:20 (UTC)
commitb452044ec1b3327f25f8552045b4229c8af39bf7 (patch) (unidiff)
tree1a3785f1af71fe38aabe131a2a8f0ad8a5be76c9
parent99904a1df601bb5d1c0e6d43a3e04a63fe13cf51 (diff)
downloadopie-b452044ec1b3327f25f8552045b4229c8af39bf7.zip
opie-b452044ec1b3327f25f8552045b4229c8af39bf7.tar.gz
opie-b452044ec1b3327f25f8552045b4229c8af39bf7.tar.bz2
http streaming
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/libmad.pro2
-rw-r--r--core/multimedia/opieplayer/libmad/libmadplugin.cpp55
2 files changed, 40 insertions, 17 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmad.pro b/core/multimedia/opieplayer/libmad/libmad.pro
index eddf242..679242b 100644
--- a/core/multimedia/opieplayer/libmad/libmad.pro
+++ b/core/multimedia/opieplayer/libmad/libmad.pro
@@ -5,7 +5,7 @@ HEADERS = libmad_version.h fixed.h bit.h timer.h stream.h frame.h synth.h de
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 layer12.c layer3.c huffman.c libmadplugin.cpp libmadpluginimpl.cpp
7TARGET = madplugin 7TARGET = madplugin
8DESTDIR = ../../plugins/codecs 8DESTDIR = ../../../plugins/codecs
9INCLUDEPATH += $(OPIEDIR)/include .. 9INCLUDEPATH += $(OPIEDIR)/include ..
10DEPENDPATH += ../$(OPIEDIR)/include .. 10DEPENDPATH += ../$(OPIEDIR)/include ..
11LIBS += -lqpe -lm 11LIBS += -lqpe -lm
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
index 46f2450..4665408 100644
--- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp
+++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
@@ -17,6 +17,11 @@
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
20#include <stdio.h> 25#include <stdio.h>
21#include <stdarg.h> 26#include <stdarg.h>
22#include <stdlib.h> 27#include <stdlib.h>
@@ -31,8 +36,7 @@
31#include <locale.h> 36#include <locale.h>
32#include <math.h> 37#include <math.h>
33#include <assert.h> 38#include <assert.h>
34#include <qapplication.h> 39
35#include <qpe/config.h>
36 40
37// for network handling 41// for network handling
38#include <netinet/in.h> 42#include <netinet/in.h>
@@ -233,6 +237,7 @@ int LibMadPlugin::http_read_line(int tcp_sock, char *buf, int size) {
233} 237}
234 238
235int LibMadPlugin::http_open(const QString& path ) { 239int LibMadPlugin::http_open(const QString& path ) {
240 qDebug("Open http");
236 char *host; 241 char *host;
237 int port; 242 int port;
238 char *request; 243 char *request;
@@ -242,15 +247,21 @@ int LibMadPlugin::http_open(const QString& path ) {
242 char c; 247 char c;
243 char *arg =strdup(path.latin1()); 248 char *arg =strdup(path.latin1());
244 249
250 QString errorMsg;
251
245 /* Check for URL syntax */ 252 /* Check for URL syntax */
246 if (strncmp(arg, "http://", strlen("http://"))) 253// if (strncmp(arg, "http://", strlen("http://"))) {
247 return (0); 254// qDebug("Url syntax error");
255// return (0);
256// }
248 257
249 /* Parse URL */ 258 qDebug("Parse URL");
250 port = 80; 259 port = 80;
251 host = arg + strlen("http://"); 260 host = arg + strlen("http://");
252 if ((request = strchr(host, '/')) == NULL) 261 if ((request = strchr(host, '/')) == NULL) {
262 qDebug("Url syntax 2error %s", host);
253 return (0); 263 return (0);
264 }
254 *request++ = 0; 265 *request++ = 0;
255 266
256 if (strchr(host, ':') != NULL) /* port is specified */ 267 if (strchr(host, ':') != NULL) /* port is specified */
@@ -259,10 +270,11 @@ int LibMadPlugin::http_open(const QString& path ) {
259 *strchr(host, ':') = 0; 270 *strchr(host, ':') = 0;
260 } 271 }
261 272
262 /* Open a TCP socket */ 273 qDebug("Open a TCP socket");
263 if (!(tcp_sock = tcp_open(host, port))) 274 if (!(tcp_sock = tcp_open(host, port))) {
264 {
265 perror("http_open"); 275 perror("http_open");
276 errorMsg="http_open "+(QString)strerror(errno);
277 QMessageBox::message("OPiePlayer",errorMsg);
266 return (0); 278 return (0);
267 } 279 }
268 280
@@ -274,11 +286,12 @@ int LibMadPlugin::http_open(const QString& path ) {
274 snprintf(http_request, sizeof(http_request), "GET /%s HTTP/1.0\r\n" 286 snprintf(http_request, sizeof(http_request), "GET /%s HTTP/1.0\r\n"
275/* "User-Agent: Mozilla/2.0 (Win95; I)\r\n" */ 287/* "User-Agent: Mozilla/2.0 (Win95; I)\r\n" */
276 "Pragma: no-cache\r\n" "Host: %s\r\n" "Accept: */*\r\n" "\r\n", filename, host); 288 "Pragma: no-cache\r\n" "Host: %s\r\n" "Accept: */*\r\n" "\r\n", filename, host);
277 289 qDebug("send");
278 send(tcp_sock, http_request, strlen(http_request), 0); 290 send(tcp_sock, http_request, strlen(http_request), 0);
279 291
280 /* Parse server reply */ 292 qDebug("Parse server reply");
281#if 0 293#if 0
294 qDebug("do 0");
282 do 295 do
283 read(tcp_sock, &c, sizeof(char)); 296 read(tcp_sock, &c, sizeof(char));
284 while (c != ' '); 297 while (c != ' ');
@@ -312,7 +325,7 @@ int LibMadPlugin::http_open(const QString& path ) {
312 325
313 if (strncmp(http_request, "Location:", 9) == 0) 326 if (strncmp(http_request, "Location:", 9) == 0)
314 { 327 {
315 /* redirect */ 328 qDebug("redirect");
316 std::close(tcp_sock); 329 std::close(tcp_sock);
317 330
318 http_request[strlen(http_request) - 1] = '\0'; 331 http_request[strlen(http_request) - 1] = '\0';
@@ -322,7 +335,7 @@ int LibMadPlugin::http_open(const QString& path ) {
322 335
323 if (strncmp(http_request, "ICY ", 4) == 0) 336 if (strncmp(http_request, "ICY ", 4) == 0)
324 { 337 {
325 /* This is icecast streaming */ 338 qDebug(" This is icecast streaming");
326 if (strncmp(http_request + 4, "200 ", 4)) 339 if (strncmp(http_request + 4, "200 ", 4))
327 { 340 {
328 fprintf(stderr, "http_open: %s\n", http_request); 341 fprintf(stderr, "http_open: %s\n", http_request);
@@ -352,11 +365,16 @@ bool LibMadPlugin::open( const QString& path ) {
352 d->flush = TRUE; 365 d->flush = TRUE;
353 info = QString( "" ); 366 info = QString( "" );
354 367
355 //qDebug( "Opening %s", path.latin1() ); 368 qDebug( "Opening %s", path.latin1() );
356
357 369
370 bool isStream=FALSE;
358 if (path.left( 4 ) == "http" ) { 371 if (path.left( 4 ) == "http" ) {
359 d->input.fd = http_open(path); 372 d->input.fd = http_open(path);
373 if(d->input.fd == 0) {
374 qDebug("http_open error");
375 }
376 isStream=TRUE;
377 qDebug("Opened ok");
360 378
361 } else { 379 } else {
362 d->input.path = path.latin1(); 380 d->input.path = path.latin1();
@@ -366,8 +384,10 @@ bool LibMadPlugin::open( const QString& path ) {
366 qDebug("error opening %s", d->input.path ); 384 qDebug("error opening %s", d->input.path );
367 return FALSE; 385 return FALSE;
368 } 386 }
369 387 if(!isStream) {
388 qDebug("Print ID#tags");
370 printID3Tags(); 389 printID3Tags();
390 }
371 391
372#if defined(HAVE_MMAP) 392#if defined(HAVE_MMAP)
373 struct stat stat; 393 struct stat stat;
@@ -395,8 +415,11 @@ bool LibMadPlugin::open( const QString& path ) {
395 415
396 d->input.eof = 0; 416 d->input.eof = 0;
397 417
418qDebug("about to mad_stream");
398 mad_stream_init(&d->stream); 419 mad_stream_init(&d->stream);
420qDebug("mad_frame");
399 mad_frame_init(&d->frame); 421 mad_frame_init(&d->frame);
422qDebug("mad_synth");
400 mad_synth_init(&d->synth); 423 mad_synth_init(&d->synth);
401 424
402 return TRUE; 425 return TRUE;