diff options
Diffstat (limited to 'stream')
-rw-r--r-- | stream/http.c | 18 | ||||
-rw-r--r-- | stream/stream.c | 20 | ||||
-rw-r--r-- | stream/stream.h | 3 | ||||
-rw-r--r-- | stream/stream_bluray.c | 19 | ||||
-rw-r--r-- | stream/stream_cdda.c | 31 | ||||
-rw-r--r-- | stream/stream_cddb.c | 2 | ||||
-rw-r--r-- | stream/vcd_read.h | 21 | ||||
-rw-r--r-- | stream/vcd_read_win32.h | 2 |
8 files changed, 49 insertions, 67 deletions
diff --git a/stream/http.c b/stream/http.c index bb96739c45..eb0ea701b6 100644 --- a/stream/http.c +++ b/stream/http.c @@ -350,6 +350,7 @@ http_is_header_entire( HTTP_header_t *http_hdr ) { if( http_hdr==NULL ) return -1; if( http_hdr->buffer==NULL ) return 0; // empty + if(http_hdr->buffer_size > 128*1024) return 1; if( strstr(http_hdr->buffer, "\r\n\r\n")==NULL && strstr(http_hdr->buffer, "\n\n")==NULL ) return 0; return 1; @@ -414,12 +415,12 @@ http_response_parse( HTTP_header_t *http_hdr ) { hdr_sep_len = 4; ptr = strstr( http_hdr->buffer, "\r\n\r\n" ); if( ptr==NULL ) { + hdr_sep_len = 2; ptr = strstr( http_hdr->buffer, "\n\n" ); if( ptr==NULL ) { mp_msg(MSGT_NETWORK,MSGL_ERR,"Header may be incomplete. No CRLF CRLF found.\n"); - return -1; + hdr_sep_len = 0; } - hdr_sep_len = 2; } pos_hdr_sep = ptr-http_hdr->buffer; @@ -429,7 +430,18 @@ http_response_parse( HTTP_header_t *http_hdr ) { ptr = hdr_ptr; while( *ptr!='\r' && *ptr!='\n' ) ptr++; len = ptr-hdr_ptr; - if( len==0 ) break; + if (len == 0 || !memchr(hdr_ptr, ':', len)) { + mp_msg(MSGT_NETWORK, MSGL_ERR, "Broken response header, missing ':'\n"); + pos_hdr_sep = ptr - http_hdr->buffer; + hdr_sep_len = 0; + break; + } + if (len > 16 && !strncasecmp(hdr_ptr + 4, "icy-metaint:", 12)) + { + mp_msg(MSGT_NETWORK, MSGL_WARN, "Server sent a severely broken icy-metaint HTTP header!\n"); + hdr_ptr += 4; + len -= 4; + } field = realloc(field, len+1); if( field==NULL ) { mp_msg(MSGT_NETWORK,MSGL_ERR,"Memory allocation failed\n"); diff --git a/stream/stream.c b/stream/stream.c index d0bd0b58d6..75c7d4fb5c 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -649,16 +649,14 @@ static const uint8_t *find_newline(const uint8_t *buf, int len, int utf16) return (uint8_t *)memchr(buf, '\n', len); case 1: while (buf < end - 1) { - GET_UTF16(c, buf < end - 1 ? get_le16_inc(&buf) : 0, return NULL; - ) + GET_UTF16(c, buf < end - 1 ? get_le16_inc(&buf) : 0, return NULL;) if (buf <= end && c == '\n') return buf - 1; } break; case 2: while (buf < end - 1) { - GET_UTF16(c, buf < end - 1 ? get_be16_inc(&buf) : 0, return NULL; - ) + GET_UTF16(c, buf < end - 1 ? get_be16_inc(&buf) : 0, return NULL;) if (buf <= end && c == '\n') return buf - 1; } @@ -667,6 +665,8 @@ static const uint8_t *find_newline(const uint8_t *buf, int len, int utf16) return NULL; } +#define EMPTY_STMT do{}while(0); + /** * Copy a number of bytes, converting to UTF-8 if input is UTF-16 * \param dst buffer to copy to @@ -691,20 +691,16 @@ static int copy_characters(uint8_t *dst, int dstsize, case 1: while (src < end - 1 && dst_end - dst > 8) { uint8_t tmp; - GET_UTF16(c, src < end - 1 ? get_le16_inc(&src) : 0,; - ) - PUT_UTF8(c, tmp, *dst++ = tmp; - ) + GET_UTF16(c, src < end - 1 ? get_le16_inc(&src) : 0, EMPTY_STMT) + PUT_UTF8(c, tmp, *dst++ = tmp; EMPTY_STMT) } *len -= end - src; return dstsize - (dst_end - dst); case 2: while (src < end - 1 && dst_end - dst > 8) { uint8_t tmp; - GET_UTF16(c, src < end - 1 ? get_be16_inc(&src) : 0,; - ) - PUT_UTF8(c, tmp, *dst++ = tmp; - ) + GET_UTF16(c, src < end - 1 ? get_be16_inc(&src) : 0, EMPTY_STMT) + PUT_UTF8(c, tmp, *dst++ = tmp; EMPTY_STMT) } *len -= end - src; return dstsize - (dst_end - dst); diff --git a/stream/stream.h b/stream/stream.h index 746667c564..fb3d08097f 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -408,11 +408,10 @@ int stream_read_internal(stream_t *s, void *buf, int len); /// Internal seek function bypassing the stream buffer int stream_seek_internal(stream_t *s, int64_t newpos); -extern int bluray_angle; -extern int bluray_chapter; extern int dvd_title; extern int dvd_angle; +extern int bluray_angle; extern char *bluray_device; typedef struct { diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c index 8ee69aaa80..81fd882f86 100644 --- a/stream/stream_bluray.c +++ b/stream/stream_bluray.c @@ -50,12 +50,10 @@ char *bluray_device = NULL; int bluray_angle = 0; -int bluray_chapter = 0; struct bluray_priv_s { BLURAY *bd; int current_angle; - int current_chapter; int current_title; }; @@ -135,7 +133,7 @@ static int bluray_stream_control(stream_t *s, int cmd, void *arg) } case STREAM_CTRL_GET_CURRENT_CHAPTER: { - *((unsigned int *) arg) = b->current_chapter; + *((unsigned int *) arg) = bd_get_current_chapter(b->bd); return 1; } @@ -247,9 +245,8 @@ static int bluray_stream_open(stream_t *s, int mode, int title, title_guess, title_count; uint64_t title_size; - unsigned int chapter = 0, angle = 0; + unsigned int angle = 0; uint64_t max_duration = 0; - int64_t chapter_pos = 0; char *device = NULL; int i; @@ -328,16 +325,6 @@ static int bluray_stream_open(stream_t *s, int mode, if (!info) goto err_no_info; - /* Select chapter */ - chapter = bluray_chapter ? bluray_chapter : BLURAY_DEFAULT_CHAPTER; - chapter = FFMIN(chapter, info->chapter_count); - - if (chapter) - chapter_pos = bd_chapter_pos(bd, chapter); - - mp_msg(MSGT_IDENTIFY, MSGL_INFO, - "ID_BLURAY_CURRENT_CHAPTER=%d\n", chapter + 1); - /* Select angle */ angle = bluray_angle ? bluray_angle : BLURAY_DEFAULT_ANGLE; angle = FFMIN(angle, info->angle_count); @@ -358,10 +345,8 @@ err_no_info: b = calloc(1, sizeof(struct bluray_priv_s)); b->bd = bd; b->current_angle = angle; - b->current_chapter = chapter; b->current_title = title; - s->start_pos = chapter_pos; s->end_pos = title_size; s->sector_size = BLURAY_SECTOR_SIZE; s->flags = mode | MP_STREAM_SEEK; diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index 2541e70174..6fbd18fcc2 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -71,7 +71,7 @@ static struct cdda_params { int toc_offset; int no_skip; char *device; - m_span_t span; + int span[2]; } cdda_dflts = { .search_overlap = -1, }; @@ -91,11 +91,9 @@ static const m_option_t cdda_params_fields[] = { {"noskip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"skip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0, 1, 0, NULL}, {"device", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"span", ST_OFF(span), CONF_TYPE_OBJ_PARAMS, 0, 0, 0, - (void *)&m_span_params_def}, + {"span", ST_OFF(span), CONF_TYPE_INT_PAIR, 0, 0, 0, NULL}, /// For url parsing - {"hostname", ST_OFF(span), CONF_TYPE_OBJ_PARAMS, 0, 0, 0, - (void *)&m_span_params_def}, + {"hostname", ST_OFF(span), CONF_TYPE_INT_PAIR, 0, 0, 0, NULL}, {"port", ST_OFF(speed), CONF_TYPE_INT, M_OPT_RANGE, 1, 100, NULL}, {"filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL}, {0} @@ -122,8 +120,7 @@ const m_option_t cdda_opts[] = { {"noskip", &cdda_dflts.no_skip, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"skip", &cdda_dflts.no_skip, CONF_TYPE_FLAG, 0, 1, 0, NULL}, {"device", &cdda_dflts.device, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"span", &cdda_dflts.span, CONF_TYPE_OBJ_PARAMS, 0, 0, 0, - (void *)&m_span_params_def}, + {"span", &cdda_dflts.span, CONF_TYPE_INT_PAIR, 0, 0, 0, NULL}, {NULL, NULL, 0, 0, 0, 0, NULL} }; @@ -435,19 +432,19 @@ static int open_cdda(stream_t *st, int m, void *opts, int *file_format) cdda_speed_set(cdd, p->speed); last_track = cdda_tracks(cdd); - if (p->span.start > last_track) - p->span.start = last_track; - if (p->span.end < p->span.start) - p->span.end = p->span.start; - if (p->span.end > last_track) - p->span.end = last_track; - if (p->span.start) - priv->start_sector = cdda_track_firstsector(cdd, p->span.start); + if (p->span[0] > last_track) + p->span[0] = last_track; + if (p->span[1] < p->span[0]) + p->span[1] = p->span[0]; + if (p->span[1] > last_track) + p->span[1] = last_track; + if (p->span[0]) + priv->start_sector = cdda_track_firstsector(cdd, p->span[0]); else priv->start_sector = cdda_disc_firstsector(cdd); - if (p->span.end) - priv->end_sector = cdda_track_lastsector(cdd, p->span.end); + if (p->span[1]) + priv->end_sector = cdda_track_lastsector(cdd, p->span[1]); else priv->end_sector = cdda_disc_lastsector(cdd); diff --git a/stream/stream_cddb.c b/stream/stream_cddb.c index d2ed37deb6..7f4558e7e7 100644 --- a/stream/stream_cddb.c +++ b/stream/stream_cddb.c @@ -57,7 +57,7 @@ #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) #include <sys/cdio.h> #elif defined(__MINGW32__) || defined(__CYGWIN__) -#include <ddk/ntddcdrm.h> +#include <ntddcdrm.h> #elif defined(__bsdi__) #include <dvd.h> #elif defined(__APPLE__) || defined(__DARWIN__) diff --git a/stream/vcd_read.h b/stream/vcd_read.h index 9d0f68ea66..2d4a88604a 100644 --- a/stream/vcd_read.h +++ b/stream/vcd_read.h @@ -29,17 +29,16 @@ #include "core/mp_msg.h" #include "stream.h" //=================== VideoCD ========================== -#if defined(__linux__) || defined(sun) || defined(__bsdi__) typedef struct mp_vcd_priv_st mp_vcd_priv_t; -#if defined(__linux__) -#include <linux/cdrom.h> -#elif defined(sun) +#ifdef sun #include <sys/cdio.h> static int sun_vcd_read(mp_vcd_priv_t*, int*); -#elif defined(__bsdi__) +#elif defined(__bsdi__) #include <dvd.h> +#else +#include <linux/cdrom.h> #endif struct mp_vcd_priv_st { @@ -154,11 +153,11 @@ static int vcd_end_track(mp_vcd_priv_t* vcd) } static int vcd_read(mp_vcd_priv_t* vcd,char *mem){ -#if defined(__linux__) || defined(__bsdi__) +#ifndef sun memcpy(vcd->buf,&vcd->entry.cdte_addr.msf,sizeof(struct cdrom_msf)); if(ioctl(vcd->fd,CDROMREADRAW,vcd->buf)==-1) return 0; // EOF? memcpy(mem,&vcd->buf[VCD_SECTOR_OFFS],VCD_SECTOR_DATA); -#elif defined(sun) +#else { int offset; if (sun_vcd_read(vcd, &offset) <= 0) return 0; @@ -180,7 +179,7 @@ static int vcd_read(mp_vcd_priv_t* vcd,char *mem){ } -#ifdef sun +#ifdef sun #include <sys/scsi/generic/commands.h> #include <sys/scsi/impl/uscsi.h> @@ -251,10 +250,4 @@ static int sun_vcd_read(mp_vcd_priv_t* vcd, int *offset) } #endif /*sun*/ -#else /* __linux__ || sun || __bsdi__ */ - -#error vcd is not yet supported on this arch... - -#endif - #endif /* MPLAYER_VCD_READ_H */ diff --git a/stream/vcd_read_win32.h b/stream/vcd_read_win32.h index 30679d707e..59570881f0 100644 --- a/stream/vcd_read_win32.h +++ b/stream/vcd_read_win32.h @@ -22,7 +22,7 @@ #include <stddef.h> #include <stdlib.h> #include <string.h> -#include <ddk/ntddcdrm.h> +#include <ntddcdrm.h> #include "core/mp_msg.h" typedef struct mp_vcd_priv_st mp_vcd_priv_t; |