Commit 416e3508 authored by Fabrice Bellard's avatar Fabrice Bellard

added correct RTSP aborting - added option to force TCP usage in RTSP playback...

added correct RTSP aborting - added option to force TCP usage in RTSP playback - added experimental RTSP pause support

Originally committed as revision 2062 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 09787fb8
...@@ -73,6 +73,7 @@ typedef struct VideoState { ...@@ -73,6 +73,7 @@ typedef struct VideoState {
int no_background; int no_background;
int abort_request; int abort_request;
int paused; int paused;
int last_paused;
AVFormatContext *ic; AVFormatContext *ic;
int dtg_active_format; int dtg_active_format;
...@@ -1041,6 +1042,14 @@ static void stream_component_close(VideoState *is, int stream_index) ...@@ -1041,6 +1042,14 @@ static void stream_component_close(VideoState *is, int stream_index)
} }
} }
/* since we have only one decoding thread, we can use a global
variable instead of a thread local variable */
static VideoState *global_video_state;
static int decode_interrupt_cb(void)
{
return (global_video_state && global_video_state->abort_request);
}
/* this thread gets the stream from the disk or the network */ /* this thread gets the stream from the disk or the network */
static int decode_thread(void *arg) static int decode_thread(void *arg)
...@@ -1055,6 +1064,9 @@ static int decode_thread(void *arg) ...@@ -1055,6 +1064,9 @@ static int decode_thread(void *arg)
is->video_stream = -1; is->video_stream = -1;
is->audio_stream = -1; is->audio_stream = -1;
global_video_state = is;
url_set_interrupt_cb(decode_interrupt_cb);
err = av_open_input_file(&ic, is->filename, NULL, 0, NULL); err = av_open_input_file(&ic, is->filename, NULL, 0, NULL);
if (err < 0) if (err < 0)
return 0; return 0;
...@@ -1101,6 +1113,22 @@ static int decode_thread(void *arg) ...@@ -1101,6 +1113,22 @@ static int decode_thread(void *arg)
for(;;) { for(;;) {
if (is->abort_request) if (is->abort_request)
break; break;
if (is->paused != is->last_paused) {
is->last_paused = is->paused;
if (ic->iformat == &rtsp_demux) {
if (is->paused)
rtsp_pause(ic);
else
rtsp_resume(ic);
}
}
if (is->paused && ic->iformat == &rtsp_demux) {
/* wait 10 ms to avoid trying to get another packet */
/* XXX: horrible */
SDL_Delay(10);
continue;
}
/* if the queue are full, no need to read more */ /* if the queue are full, no need to read more */
if (is->audioq.size > MAX_AUDIOQ_SIZE || if (is->audioq.size > MAX_AUDIOQ_SIZE ||
is->videoq.size > MAX_VIDEOQ_SIZE) { is->videoq.size > MAX_VIDEOQ_SIZE) {
...@@ -1126,6 +1154,9 @@ static int decode_thread(void *arg) ...@@ -1126,6 +1154,9 @@ static int decode_thread(void *arg)
} }
fail: fail:
/* disable interrupting */
global_video_state = NULL;
/* close each stream */ /* close each stream */
if (is->audio_stream >= 0) if (is->audio_stream >= 0)
stream_component_close(is, is->audio_stream); stream_component_close(is, is->audio_stream);
...@@ -1134,6 +1165,8 @@ static int decode_thread(void *arg) ...@@ -1134,6 +1165,8 @@ static int decode_thread(void *arg)
av_close_input_file(is->ic); av_close_input_file(is->ic);
is->ic = NULL; /* safety */ is->ic = NULL; /* safety */
url_set_interrupt_cb(NULL);
return 0; return 0;
} }
...@@ -1315,6 +1348,12 @@ static void opt_format(const char *arg) ...@@ -1315,6 +1348,12 @@ static void opt_format(const char *arg)
} }
} }
void opt_rtp_tcp(void)
{
/* only tcp protocol */
rtsp_default_protocols = (1 << RTSP_PROTOCOL_RTP_TCP);
}
const OptionDef options[] = { const OptionDef options[] = {
{ "h", 0, {(void*)show_help}, "show help" }, { "h", 0, {(void*)show_help}, "show help" },
{ "x", HAS_ARG, {(void*)opt_width}, "force displayed width", "width" }, { "x", HAS_ARG, {(void*)opt_width}, "force displayed width", "width" },
...@@ -1324,6 +1363,7 @@ const OptionDef options[] = { ...@@ -1324,6 +1363,7 @@ const OptionDef options[] = {
{ "nodisp", OPT_BOOL, {(void*)&display_disable}, "disable graphical display" }, { "nodisp", OPT_BOOL, {(void*)&display_disable}, "disable graphical display" },
{ "f", HAS_ARG, {(void*)opt_format}, "force format", "fmt" }, { "f", HAS_ARG, {(void*)opt_format}, "force format", "fmt" },
{ "stats", OPT_BOOL | OPT_EXPERT, {(void*)&show_status}, "show status", "" }, { "stats", OPT_BOOL | OPT_EXPERT, {(void*)&show_status}, "show status", "" },
{ "rtp_tcp", OPT_EXPERT, {(void*)&opt_rtp_tcp}, "force RTP/TCP protocol usage", "" },
{ NULL, }, { NULL, },
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment