mirror of https://github.com/mpv-player/mpv
stream: cosmetics
This commit is contained in:
parent
c5fd3412b6
commit
6832bf3060
|
@ -289,8 +289,6 @@ stream_t *open_output_stream(const char *filename, struct MPOpts *options)
|
||||||
return open_stream_full(filename, STREAM_WRITE, options, NULL);
|
return open_stream_full(filename, STREAM_WRITE, options, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================== STREAMER =========================
|
|
||||||
|
|
||||||
static int stream_reconnect(stream_t *s)
|
static int stream_reconnect(stream_t *s)
|
||||||
{
|
{
|
||||||
#define MAX_RECONNECT_RETRIES 5
|
#define MAX_RECONNECT_RETRIES 5
|
||||||
|
@ -486,12 +484,11 @@ static int stream_seek_unbuffered(stream_t *s, int64_t newpos)
|
||||||
if (newpos == 0 || newpos != s->pos) {
|
if (newpos == 0 || newpos != s->pos) {
|
||||||
switch (s->type) {
|
switch (s->type) {
|
||||||
case STREAMTYPE_STREAM:
|
case STREAMTYPE_STREAM:
|
||||||
//s->pos=newpos; // real seek
|
|
||||||
// Some streaming protocol allow to seek backward and forward
|
// Some streaming protocol allow to seek backward and forward
|
||||||
// A function call that return -1 can tell that the protocol
|
// A function call that return -1 can tell that the protocol
|
||||||
// doesn't support seeking.
|
// doesn't support seeking.
|
||||||
#ifdef CONFIG_NETWORKING
|
#ifdef CONFIG_NETWORKING
|
||||||
if (s->seek) { // new stream seek is much cleaner than streaming_ctrl one
|
if (s->seek) {
|
||||||
if (!s->seek(s, newpos)) {
|
if (!s->seek(s, newpos)) {
|
||||||
mp_tmsg(MSGT_STREAM, MSGL_ERR, "Seek failed\n");
|
mp_tmsg(MSGT_STREAM, MSGL_ERR, "Seek failed\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -525,9 +522,6 @@ static int stream_seek_unbuffered(stream_t *s, int64_t newpos)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// putchar('.');fflush(stdout);
|
|
||||||
//} else {
|
|
||||||
// putchar('%');fflush(stdout);
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -539,8 +533,6 @@ static int stream_seek_long(stream_t *s, int64_t pos)
|
||||||
int res;
|
int res;
|
||||||
int64_t newpos = 0;
|
int64_t newpos = 0;
|
||||||
|
|
||||||
// if( mp_msg_test(MSGT_STREAM,MSGL_DBG3) ) printf("seek_long to 0x%X\n",(unsigned int)pos);
|
|
||||||
|
|
||||||
s->buf_pos = s->buf_len = 0;
|
s->buf_pos = s->buf_len = 0;
|
||||||
|
|
||||||
if (s->mode == STREAM_WRITE) {
|
if (s->mode == STREAM_WRITE) {
|
||||||
|
@ -557,6 +549,7 @@ static int stream_seek_long(stream_t *s, int64_t pos)
|
||||||
mp_msg(MSGT_STREAM, MSGL_DBG3, "s->pos=%" PRIX64 " newpos=%" PRIX64
|
mp_msg(MSGT_STREAM, MSGL_DBG3, "s->pos=%" PRIX64 " newpos=%" PRIX64
|
||||||
" new_bufpos=%" PRIX64 " buflen=%X \n",
|
" new_bufpos=%" PRIX64 " buflen=%X \n",
|
||||||
(int64_t)s->pos, (int64_t)newpos, (int64_t)pos, s->buf_len);
|
(int64_t)s->pos, (int64_t)newpos, (int64_t)pos, s->buf_len);
|
||||||
|
|
||||||
pos -= newpos;
|
pos -= newpos;
|
||||||
|
|
||||||
res = stream_seek_unbuffered(s, newpos);
|
res = stream_seek_unbuffered(s, newpos);
|
||||||
|
@ -576,7 +569,7 @@ static int stream_seek_long(stream_t *s, int64_t pos)
|
||||||
}
|
}
|
||||||
pos -= s->buf_len;
|
pos -= s->buf_len;
|
||||||
}
|
}
|
||||||
// Fill failed, but seek still is a success.
|
// Fill failed, but seek still is a success.
|
||||||
s->pos += pos;
|
s->pos += pos;
|
||||||
s->buf_pos = 0;
|
s->buf_pos = 0;
|
||||||
s->buf_len = 0;
|
s->buf_len = 0;
|
||||||
|
@ -592,8 +585,7 @@ int stream_seek(stream_t *s, int64_t pos)
|
||||||
mp_dbg(MSGT_DEMUX, MSGL_DBG3, "seek to 0x%llX\n", (long long)pos);
|
mp_dbg(MSGT_DEMUX, MSGL_DBG3, "seek to 0x%llX\n", (long long)pos);
|
||||||
|
|
||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
mp_msg(MSGT_DEMUX, MSGL_ERR,
|
mp_msg(MSGT_DEMUX, MSGL_ERR, "Invalid seek to negative position %llx!\n",
|
||||||
"Invalid seek to negative position %llx!\n",
|
|
||||||
(long long)pos);
|
(long long)pos);
|
||||||
pos = 0;
|
pos = 0;
|
||||||
}
|
}
|
||||||
|
@ -602,7 +594,6 @@ int stream_seek(stream_t *s, int64_t pos)
|
||||||
if (x >= 0) {
|
if (x >= 0) {
|
||||||
s->buf_pos = x;
|
s->buf_pos = x;
|
||||||
s->eof = 0;
|
s->eof = 0;
|
||||||
// putchar('*');fflush(stdout);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -626,7 +617,6 @@ int stream_skip(stream_t *s, int64_t len)
|
||||||
}
|
}
|
||||||
if (x > len)
|
if (x > len)
|
||||||
x = len;
|
x = len;
|
||||||
//memcpy(mem,&s->buf[s->buf_pos],x);
|
|
||||||
s->buf_pos += x;
|
s->buf_pos += x;
|
||||||
len -= x;
|
len -= x;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,20 +61,17 @@
|
||||||
// Max buffer for initial probe.
|
// Max buffer for initial probe.
|
||||||
#define STREAM_MAX_BUFFER_SIZE (2 * 1024 * 1024)
|
#define STREAM_MAX_BUFFER_SIZE (2 * 1024 * 1024)
|
||||||
|
|
||||||
/// atm it will always use mode == STREAM_READ
|
|
||||||
/// streams that use the new api should check the mode at open
|
// stream->mode
|
||||||
#define STREAM_READ 0
|
#define STREAM_READ 0
|
||||||
#define STREAM_WRITE 1
|
#define STREAM_WRITE 1
|
||||||
/// Seek flags, if not mannualy set and s->seek isn't NULL
|
|
||||||
/// MP_STREAM_SEEK is automaticly set
|
// stream->flags
|
||||||
#define MP_STREAM_SEEK_BW 2
|
#define MP_STREAM_SEEK_BW 2
|
||||||
#define MP_STREAM_SEEK_FW 4
|
#define MP_STREAM_SEEK_FW 4
|
||||||
#define MP_STREAM_SEEK (MP_STREAM_SEEK_BW | MP_STREAM_SEEK_FW)
|
#define MP_STREAM_SEEK (MP_STREAM_SEEK_BW | MP_STREAM_SEEK_FW)
|
||||||
|
|
||||||
//////////// Open return code
|
|
||||||
#define STREAM_REDIRECTED -2
|
#define STREAM_REDIRECTED -2
|
||||||
/// This can't open the requested protocol (used by stream wich have a
|
|
||||||
/// * protocol when they don't know the requested protocol)
|
|
||||||
#define STREAM_UNSUPPORTED -1
|
#define STREAM_UNSUPPORTED -1
|
||||||
#define STREAM_ERROR 0
|
#define STREAM_ERROR 0
|
||||||
#define STREAM_OK 1
|
#define STREAM_OK 1
|
||||||
|
@ -121,6 +118,7 @@ typedef enum {
|
||||||
streaming_playing_e
|
streaming_playing_e
|
||||||
} streaming_status;
|
} streaming_status;
|
||||||
|
|
||||||
|
// All this is for legacy http streams (and other things using tcp/udp)
|
||||||
typedef struct streaming_control {
|
typedef struct streaming_control {
|
||||||
URL_t *url;
|
URL_t *url;
|
||||||
streaming_status status;
|
streaming_status status;
|
||||||
|
@ -144,9 +142,7 @@ typedef struct stream_info_st {
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *author;
|
const char *author;
|
||||||
const char *comment;
|
const char *comment;
|
||||||
/// mode isn't used atm (ie always READ) but it shouldn't be ignored
|
// opts is set from ->opts
|
||||||
/// opts is at least in it's defaults settings and may have been
|
|
||||||
/// altered by url parsing if enabled and the options string parsing.
|
|
||||||
int (*open)(struct stream *st, int mode, void *opts, int *file_format);
|
int (*open)(struct stream *st, int mode, void *opts, int *file_format);
|
||||||
const char *protocols[MAX_STREAM_PROTOCOLS];
|
const char *protocols[MAX_STREAM_PROTOCOLS];
|
||||||
const void *opts;
|
const void *opts;
|
||||||
|
|
Loading…
Reference in New Issue