author | harlekin <harlekin> | 2002-04-22 22:05:28 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-04-22 22:05:28 (UTC) |
commit | 1ce5e1128e3c062d45e6dcfbcda20f195b4d5b13 (patch) (unidiff) | |
tree | 81303ba33d6f6aa7e56b9ea6ff6d85a7a894ede0 | |
parent | f77f012023dbe7582a4b4297f61c6521ad8a3aa5 (diff) | |
download | opie-1ce5e1128e3c062d45e6dcfbcda20f195b4d5b13.zip opie-1ce5e1128e3c062d45e6dcfbcda20f195b4d5b13.tar.gz opie-1ce5e1128e3c062d45e6dcfbcda20f195b4d5b13.tar.bz2 |
more updates for shoutcast
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp index 0f952f4..8b692ef 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp +++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp | |||
@@ -297,33 +297,33 @@ int LibMadPlugin::http_read_line(int tcp_sock, char *buf, int size) { | |||
297 | return -1; | 297 | return -1; |
298 | if (buf[offset] != '\r') /* Strip \r from answer */ | 298 | if (buf[offset] != '\r') /* Strip \r from answer */ |
299 | offset++; | 299 | offset++; |
300 | } while (offset < size - 1 && buf[offset - 1] != '\n'); | 300 | } while (offset < size - 1 && buf[offset - 1] != '\n'); |
301 | 301 | ||
302 | buf[offset] = 0; | 302 | buf[offset] = 0; |
303 | return offset; | 303 | return offset; |
304 | } | 304 | } |
305 | 305 | ||
306 | int LibMadPlugin::http_open(const QString& path ) { | 306 | int LibMadPlugin::http_open(const QString& path ) { |
307 | char *host; | 307 | char *host; |
308 | int port; | 308 | int port; |
309 | char *request; | 309 | char *request; |
310 | int tcp_sock; | 310 | int tcp_sock; |
311 | char http_request[PATH_MAX]; | 311 | char http_request[PATH_MAX]; |
312 | char filename[PATH_MAX]; | 312 | char filename[PATH_MAX]; |
313 | char c; | 313 | //char c; |
314 | char *arg =strdup(path.latin1()); | 314 | char *arg =strdup(path.latin1()); |
315 | 315 | ||
316 | /* Check for URL syntax */ | 316 | /* Check for URL syntax */ |
317 | if (strncmp(arg, "http://", strlen("http://"))) { | 317 | if (strncmp(arg, "http://", strlen("http://"))) { |
318 | return (0); | 318 | return (0); |
319 | } | 319 | } |
320 | 320 | ||
321 | /* Parse URL */ | 321 | /* Parse URL */ |
322 | port = 80; | 322 | port = 80; |
323 | host = arg + strlen("http://"); | 323 | host = arg + strlen("http://"); |
324 | if ((request = strchr(host, '/')) == NULL) { | 324 | if ((request = strchr(host, '/')) == NULL) { |
325 | return (0); | 325 | return (0); |
326 | } | 326 | } |
327 | 327 | ||
328 | *request++ = 0; | 328 | *request++ = 0; |
329 | 329 | ||
@@ -359,60 +359,57 @@ int LibMadPlugin::http_open(const QString& path ) { | |||
359 | if (strcmp(http_request, "200 ")) { | 359 | if (strcmp(http_request, "200 ")) { |
360 | fprintf(stderr, "http_open: "); | 360 | fprintf(stderr, "http_open: "); |
361 | do { | 361 | do { |
362 | read(tcp_sock, &c, sizeof(char)); | 362 | read(tcp_sock, &c, sizeof(char)); |
363 | fprintf(stderr, "%c", c); | 363 | fprintf(stderr, "%c", c); |
364 | } while (c != '\r'); | 364 | } while (c != '\r'); |
365 | fprintf(stderr, "\n"); | 365 | fprintf(stderr, "\n"); |
366 | return (0); | 366 | return (0); |
367 | } | 367 | } |
368 | #endif | 368 | #endif |
369 | 369 | ||
370 | QString name; | 370 | QString name; |
371 | QString genre; | 371 | QString genre; |
372 | QString bitrate; | 372 | QString bitrate; |
373 | QString url; | 373 | QString url; |
374 | QString message = tr("Info: "); | 374 | QString message = tr("Info: "); |
375 | |||
376 | do { | 375 | do { |
377 | 376 | ||
378 | int len; | 377 | int len; |
379 | 378 | ||
380 | len = http_read_line(tcp_sock, http_request, sizeof(http_request)); | 379 | len = http_read_line(tcp_sock, http_request, sizeof(http_request)); |
381 | 380 | ||
382 | if (len == -1) { | 381 | if (len == -1) { |
383 | fprintf(stderr, "http_open: %s\n", strerror(errno)); | 382 | qDebug( "http_open: "+ QString(strerror(errno)) +"\n"); |
384 | return 0; | 383 | return 0; |
385 | } | 384 | } |
386 | 385 | ||
387 | if (strncmp(http_request, "Location:", 9) == 0) { | 386 | if (QString(http_request).left(9) == "Location:") { |
388 | /* redirect */ | 387 | /* redirect */ |
389 | std::close(tcp_sock); | 388 | std::close(tcp_sock); |
390 | |||
391 | http_request[strlen(http_request) - 1] = '\0'; | 389 | http_request[strlen(http_request) - 1] = '\0'; |
392 | |||
393 | return http_open(&http_request[10]); | 390 | return http_open(&http_request[10]); |
394 | } | 391 | } |
395 | 392 | ||
396 | if (strncmp(http_request, "ICY ", 4) == 0) { | 393 | if (QString(http_request).left(4) == "ICY ") { |
397 | /* This is icecast streaming */ | 394 | /* This is shoutcast/icecast streaming */ |
398 | if (strncmp(http_request + 4, "200 ", 4)) { | 395 | if (strncmp(http_request + 4, "200 ", 4)) { |
399 | fprintf(stderr, "http_open: %s\n", http_request); | 396 | qDebug("http_open: " + QString(http_request) + "\n"); |
400 | return 0; | 397 | return 0; |
401 | } | 398 | } |
402 | } else if (strncmp(http_request, "icy-", 4) == 0) { | 399 | } else if (QString(http_request).left(4) == "icy-") { |
403 | /* we can have: icy-noticeX, icy-name, icy-genre, icy-url, icy-pub, icy-metaint, icy-br */ | 400 | /* we can have: icy-noticeX, icy-name, icy-genre, icy-url, icy-pub, icy-metaint, icy-br */ |
404 | if ( QString( http_request ).left( 8 ) == "icy-name" ) { | 401 | if ( QString( http_request ).left( 8 ) == "icy-name" ) { |
405 | name = tr("Name: ") + QString(http_request).mid(9, (QString(http_request).length())- 9 ); | 402 | name = tr("Name: ") + QString(http_request).mid(9, (QString(http_request).length())- 9 ); |
406 | } else if ( QString( http_request ).left( 9 ) == "icy-genre" ) { | 403 | } else if ( QString( http_request ).left( 9 ) == "icy-genre" ) { |
407 | genre = tr("Genre: ") + QString(http_request).mid(10, (QString(http_request).length())-10 ); | 404 | genre = tr("Genre: ") + QString(http_request).mid(10, (QString(http_request).length())-10 ); |
408 | } else if ( QString( http_request ).left( 6 ) == "icy-br" ) { | 405 | } else if ( QString( http_request ).left( 6 ) == "icy-br" ) { |
409 | bitrate = tr("Bitrate: ") + QString(http_request).mid(7, (QString(http_request).length())- 7 ); | 406 | bitrate = tr("Bitrate: ") + QString(http_request).mid(7, (QString(http_request).length())- 7 ); |
410 | } else if ( QString( http_request ).left( 7 ) == "icy-url" ) { | 407 | } else if ( QString( http_request ).left( 7 ) == "icy-url" ) { |
411 | url = tr("URL: ") + QString(http_request).mid(8, (QString(http_request).length())- 8 ); | 408 | url = tr("URL: ") + QString(http_request).mid(8, (QString(http_request).length())- 8 ); |
412 | } else if ( QString( http_request ).left( 10 ) == "icy-notice" ) { | 409 | } else if ( QString( http_request ).left( 10 ) == "icy-notice" ) { |
413 | message += QString(http_request).mid(11, QString(http_request).length()-11 ) ; | 410 | message += QString(http_request).mid(11, QString(http_request).length()-11 ) ; |
414 | } | 411 | } |
415 | } | 412 | } |
416 | } while (strcmp(http_request, "\n") != 0); | 413 | } while (strcmp(http_request, "\n") != 0); |
417 | 414 | ||
418 | info = QString(name + genre + url + bitrate + message).replace( QRegExp("\n"), " : " ); | 415 | info = QString(name + genre + url + bitrate + message).replace( QRegExp("\n"), " : " ); |