mirror of
https://github.com/mpv-player/mpv
synced 2024-12-21 22:30:22 +00:00
stream/network.c, stream/http.c: cleanup
Simplify mime_type_table loop git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32644 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove dead define git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32645 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove GCC warning hack not needed anymore git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32646 b3059339-0415-0410-9bf9-f77b7e298cf2 Use calloc instead of malloc+memset. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32647 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
9bf59a1fcb
commit
a9b5a9348d
@ -764,7 +764,6 @@ static void print_icy_metadata(HTTP_header_t *http_hdr) {
|
|||||||
//! If this function succeeds you must closesocket stream->fd
|
//! If this function succeeds you must closesocket stream->fd
|
||||||
static int http_streaming_start(stream_t *stream, int* file_format) {
|
static int http_streaming_start(stream_t *stream, int* file_format) {
|
||||||
HTTP_header_t *http_hdr = NULL;
|
HTTP_header_t *http_hdr = NULL;
|
||||||
unsigned int i;
|
|
||||||
int fd = stream->fd;
|
int fd = stream->fd;
|
||||||
int res = STREAM_UNSUPPORTED;
|
int res = STREAM_UNSUPPORTED;
|
||||||
int redirect = 0;
|
int redirect = 0;
|
||||||
@ -853,16 +852,16 @@ static int http_streaming_start(stream_t *stream, int* file_format) {
|
|||||||
// Look if we can use the Content-Type
|
// Look if we can use the Content-Type
|
||||||
content_type = http_get_field( http_hdr, "Content-Type" );
|
content_type = http_get_field( http_hdr, "Content-Type" );
|
||||||
if( content_type!=NULL ) {
|
if( content_type!=NULL ) {
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
mp_msg(MSGT_NETWORK,MSGL_V,"Content-Type: [%s]\n", content_type );
|
mp_msg(MSGT_NETWORK,MSGL_V,"Content-Type: [%s]\n", content_type );
|
||||||
// Check in the mime type table for a demuxer type
|
// Check in the mime type table for a demuxer type
|
||||||
i = 0;
|
for (i = 0; mime_type_table[i].mime_type != NULL; i++) {
|
||||||
while(mime_type_table[i].mime_type != NULL) {
|
|
||||||
if( !strcasecmp( content_type, mime_type_table[i].mime_type ) ) {
|
if( !strcasecmp( content_type, mime_type_table[i].mime_type ) ) {
|
||||||
*file_format = mime_type_table[i].demuxer_type;
|
*file_format = mime_type_table[i].demuxer_type;
|
||||||
res = seekable;
|
res = seekable;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Not found in the mime type table, don't fail,
|
// Not found in the mime type table, don't fail,
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#define DUMP2FILE
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -114,13 +112,11 @@ const mime_struct_t mime_type_table[] = {
|
|||||||
|
|
||||||
streaming_ctrl_t *
|
streaming_ctrl_t *
|
||||||
streaming_ctrl_new(void) {
|
streaming_ctrl_new(void) {
|
||||||
streaming_ctrl_t *streaming_ctrl;
|
streaming_ctrl_t *streaming_ctrl = calloc(1, sizeof(*streaming_ctrl));
|
||||||
streaming_ctrl = malloc(sizeof(streaming_ctrl_t));
|
|
||||||
if( streaming_ctrl==NULL ) {
|
if( streaming_ctrl==NULL ) {
|
||||||
mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
|
mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset( streaming_ctrl, 0, sizeof(streaming_ctrl_t) );
|
|
||||||
return streaming_ctrl;
|
return streaming_ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,10 +471,6 @@ nop_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *stream_ctr
|
|||||||
int
|
int
|
||||||
nop_streaming_seek( int fd, off_t pos, streaming_ctrl_t *stream_ctrl ) {
|
nop_streaming_seek( int fd, off_t pos, streaming_ctrl_t *stream_ctrl ) {
|
||||||
return -1;
|
return -1;
|
||||||
// To shut up gcc warning
|
|
||||||
fd++;
|
|
||||||
pos++;
|
|
||||||
stream_ctrl=NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user