1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-23 23:56:20 +00:00

Multiple unsv/scast bug fixes.

* use recv instead of read for MinGW compatibility
* detect EOF more reliably
* use ultravox only for unsv:// instead of trying autodetection


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16071 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2005-07-23 15:29:51 +00:00
parent 8f64f240fe
commit 51a7a44449

View File

@ -57,7 +57,7 @@ static unsigned my_read(int fd, char *buffer, int len, streaming_ctrl_t *sc) {
sc->buffer_pos += cp_len; sc->buffer_pos += cp_len;
pos += cp_len; pos += cp_len;
while (pos < len) { while (pos < len) {
int ret = read(fd, &buffer[pos], len - pos); int ret = recv(fd, &buffer[pos], len - pos, 0);
if (ret <= 0) if (ret <= 0)
break; break;
pos += ret; pos += ret;
@ -73,13 +73,16 @@ static unsigned my_read(int fd, char *buffer, int len, streaming_ctrl_t *sc) {
*/ */
static unsigned uvox_meta_read(int fd, streaming_ctrl_t *sc) { static unsigned uvox_meta_read(int fd, streaming_ctrl_t *sc) {
unsigned metaint; unsigned metaint;
unsigned char info[6]; unsigned char info[6] = {0, 0, 0, 0, 0, 0};
int info_read;
do { do {
my_read(fd, info, 1, sc); info_read = my_read(fd, info, 1, sc);
if (info[0] == 0x00) if (info[0] == 0x00)
my_read(fd, info, 6, sc); info_read = my_read(fd, info, 6, sc);
else else
my_read(fd, &info[1], 5, sc); info_read += my_read(fd, &info[1], 5, sc);
if (info_read != 6) // read error or eof
return 0;
// sync byte and reserved flags // sync byte and reserved flags
if (info[0] != 0x5a || (info[1] & 0xfc) != 0x00) { if (info[0] != 0x5a || (info[1] & 0xfc) != 0x00) {
mp_msg(MSGT_DEMUXER, MSGL_ERR, "Invalid or unknown uvox metadata\n"); mp_msg(MSGT_DEMUXER, MSGL_ERR, "Invalid or unknown uvox metadata\n");
@ -141,7 +144,11 @@ static int scast_streaming_read(int fd, char *buffer, int size,
while (done < size) { // now comes the metadata while (done < size) { // now comes the metadata
if (sd->is_ultravox) if (sd->is_ultravox)
{
sd->metaint = uvox_meta_read(fd, sc); sd->metaint = uvox_meta_read(fd, sc);
if (!sd->metaint)
size = done;
}
else else
scast_meta_read(fd, sc); // read and display metadata scast_meta_read(fd, sc); // read and display metadata
sd->metapos = 0; sd->metapos = 0;
@ -162,7 +169,7 @@ static int scast_streaming_start(stream_t *stream) {
int fromhdr; int fromhdr;
scast_data_t *scast_data; scast_data_t *scast_data;
HTTP_header_t *http_hdr = stream->streaming_ctrl->data; HTTP_header_t *http_hdr = stream->streaming_ctrl->data;
int is_ultravox = http_hdr && strcasecmp(http_hdr->protocol, "ICY") != 0; int is_ultravox = strcasecmp(stream->streaming_ctrl->url->protocol, "unsv") == 0;
if (!stream || stream->fd < 0 || !http_hdr) if (!stream || stream->fd < 0 || !http_hdr)
return -1; return -1;
if (is_ultravox) if (is_ultravox)
@ -836,8 +843,7 @@ static int fixup_open(stream_t *stream,int seekable) {
HTTP_header_t *http_hdr = stream->streaming_ctrl->data; HTTP_header_t *http_hdr = stream->streaming_ctrl->data;
int is_icy = http_hdr && strcasecmp(http_hdr->protocol, "ICY") == 0; int is_icy = http_hdr && strcasecmp(http_hdr->protocol, "ICY") == 0;
char *content_type = http_get_field( http_hdr, "Content-Type" ); char *content_type = http_get_field( http_hdr, "Content-Type" );
int is_ultravox = http_hdr && content_type && int is_ultravox = strcasecmp(stream->streaming_ctrl->url->protocol, "unsv") == 0;
strcasecmp(content_type, "misc/ultravox") == 0;
stream->type = STREAMTYPE_STREAM; stream->type = STREAMTYPE_STREAM;
if(!is_icy && !is_ultravox && seekable) if(!is_icy && !is_ultravox && seekable)