Commit 282c9354 authored by Andrey Utkin's avatar Andrey Utkin Committed by Michael Niedermayer

avformat/rtsp: Use ff_rtsp_averror()

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 24dfd6e7
...@@ -1478,7 +1478,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, ...@@ -1478,7 +1478,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
goto fail; goto fail;
} else if (reply->status_code != RTSP_STATUS_OK || } else if (reply->status_code != RTSP_STATUS_OK ||
reply->nb_transports != 1) { reply->nb_transports != 1) {
err = AVERROR_INVALIDDATA; err = ff_rtsp_averror(reply->status_code, AVERROR_INVALIDDATA);
goto fail; goto fail;
} }
...@@ -1778,7 +1778,7 @@ redirect: ...@@ -1778,7 +1778,7 @@ redirect:
sizeof(cmd)); sizeof(cmd));
ff_rtsp_send_cmd(s, "OPTIONS", rt->control_uri, cmd, reply, NULL); ff_rtsp_send_cmd(s, "OPTIONS", rt->control_uri, cmd, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK) { if (reply->status_code != RTSP_STATUS_OK) {
err = AVERROR_INVALIDDATA; err = ff_rtsp_averror(reply->status_code, AVERROR_INVALIDDATA);
goto fail; goto fail;
} }
......
...@@ -532,7 +532,7 @@ static int rtsp_read_play(AVFormatContext *s) ...@@ -532,7 +532,7 @@ static int rtsp_read_play(AVFormatContext *s)
} }
ff_rtsp_send_cmd(s, "PLAY", rt->control_uri, cmd, reply, NULL); ff_rtsp_send_cmd(s, "PLAY", rt->control_uri, cmd, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK) { if (reply->status_code != RTSP_STATUS_OK) {
return -1; return ff_rtsp_averror(reply->status_code, -1);
} }
if (rt->transport == RTSP_TRANSPORT_RTP && if (rt->transport == RTSP_TRANSPORT_RTP &&
reply->range_start != AV_NOPTS_VALUE) { reply->range_start != AV_NOPTS_VALUE) {
...@@ -564,7 +564,7 @@ static int rtsp_read_pause(AVFormatContext *s) ...@@ -564,7 +564,7 @@ static int rtsp_read_pause(AVFormatContext *s)
else if (!(rt->server_type == RTSP_SERVER_REAL && rt->need_subscription)) { else if (!(rt->server_type == RTSP_SERVER_REAL && rt->need_subscription)) {
ff_rtsp_send_cmd(s, "PAUSE", rt->control_uri, NULL, reply, NULL); ff_rtsp_send_cmd(s, "PAUSE", rt->control_uri, NULL, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK) { if (reply->status_code != RTSP_STATUS_OK) {
return -1; return ff_rtsp_averror(reply->status_code, -1);
} }
} }
rt->state = RTSP_STATE_PAUSED; rt->state = RTSP_STATE_PAUSED;
...@@ -591,12 +591,12 @@ int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply) ...@@ -591,12 +591,12 @@ int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply)
sizeof(cmd)); sizeof(cmd));
} }
ff_rtsp_send_cmd(s, "DESCRIBE", rt->control_uri, cmd, reply, &content); ff_rtsp_send_cmd(s, "DESCRIBE", rt->control_uri, cmd, reply, &content);
if (!content)
return AVERROR_INVALIDDATA;
if (reply->status_code != RTSP_STATUS_OK) { if (reply->status_code != RTSP_STATUS_OK) {
av_freep(&content); av_freep(&content);
return AVERROR_INVALIDDATA; return ff_rtsp_averror(reply->status_code, AVERROR_INVALIDDATA);
} }
if (!content)
return AVERROR_INVALIDDATA;
av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", content); av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", content);
/* now we got the SDP description, we parse it */ /* now we got the SDP description, we parse it */
...@@ -717,10 +717,10 @@ static int rtsp_read_header(AVFormatContext *s) ...@@ -717,10 +717,10 @@ static int rtsp_read_header(AVFormatContext *s)
if (rt->initial_pause) { if (rt->initial_pause) {
/* do not start immediately */ /* do not start immediately */
} else { } else {
if (rtsp_read_play(s) < 0) { if ((ret = rtsp_read_play(s)) < 0) {
ff_rtsp_close_streams(s); ff_rtsp_close_streams(s);
ff_rtsp_close_connections(s); ff_rtsp_close_connections(s);
return AVERROR_INVALIDDATA; return ret;
} }
} }
} }
...@@ -814,7 +814,7 @@ retry: ...@@ -814,7 +814,7 @@ retry:
ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri, ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri,
cmd, reply, NULL); cmd, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK) if (reply->status_code != RTSP_STATUS_OK)
return AVERROR_INVALIDDATA; return ff_rtsp_averror(reply->status_code, AVERROR_INVALIDDATA);
rt->need_subscription = 1; rt->need_subscription = 1;
} }
} }
...@@ -849,7 +849,7 @@ retry: ...@@ -849,7 +849,7 @@ retry:
ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri, ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri,
cmd, reply, NULL); cmd, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK) if (reply->status_code != RTSP_STATUS_OK)
return AVERROR_INVALIDDATA; return ff_rtsp_averror(reply->status_code, AVERROR_INVALIDDATA);
rt->need_subscription = 0; rt->need_subscription = 0;
if (rt->state == RTSP_STATE_STREAMING) if (rt->state == RTSP_STATE_STREAMING)
...@@ -910,6 +910,7 @@ static int rtsp_read_seek(AVFormatContext *s, int stream_index, ...@@ -910,6 +910,7 @@ static int rtsp_read_seek(AVFormatContext *s, int stream_index,
int64_t timestamp, int flags) int64_t timestamp, int flags)
{ {
RTSPState *rt = s->priv_data; RTSPState *rt = s->priv_data;
int ret;
rt->seek_timestamp = av_rescale_q(timestamp, rt->seek_timestamp = av_rescale_q(timestamp,
s->streams[stream_index]->time_base, s->streams[stream_index]->time_base,
...@@ -919,11 +920,11 @@ static int rtsp_read_seek(AVFormatContext *s, int stream_index, ...@@ -919,11 +920,11 @@ static int rtsp_read_seek(AVFormatContext *s, int stream_index,
case RTSP_STATE_IDLE: case RTSP_STATE_IDLE:
break; break;
case RTSP_STATE_STREAMING: case RTSP_STATE_STREAMING:
if (rtsp_read_pause(s) != 0) if ((ret = rtsp_read_pause(s)) != 0)
return -1; return ret;
rt->state = RTSP_STATE_SEEKING; rt->state = RTSP_STATE_SEEKING;
if (rtsp_read_play(s) != 0) if ((ret = rtsp_read_play(s)) != 0)
return -1; return ret;
break; break;
case RTSP_STATE_PAUSED: case RTSP_STATE_PAUSED:
rt->state = RTSP_STATE_IDLE; rt->state = RTSP_STATE_IDLE;
......
...@@ -84,7 +84,7 @@ int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr) ...@@ -84,7 +84,7 @@ int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr)
reply, NULL, sdp, strlen(sdp)); reply, NULL, sdp, strlen(sdp));
av_free(sdp); av_free(sdp);
if (reply->status_code != RTSP_STATUS_OK) if (reply->status_code != RTSP_STATUS_OK)
return AVERROR_INVALIDDATA; return ff_rtsp_averror(reply->status_code, AVERROR_INVALIDDATA);
/* Set up the RTSPStreams for each AVStream */ /* Set up the RTSPStreams for each AVStream */
for (i = 0; i < s->nb_streams; i++) { for (i = 0; i < s->nb_streams; i++) {
...@@ -116,7 +116,7 @@ static int rtsp_write_record(AVFormatContext *s) ...@@ -116,7 +116,7 @@ static int rtsp_write_record(AVFormatContext *s)
"Range: npt=0.000-\r\n"); "Range: npt=0.000-\r\n");
ff_rtsp_send_cmd(s, "RECORD", rt->control_uri, cmd, reply, NULL); ff_rtsp_send_cmd(s, "RECORD", rt->control_uri, cmd, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK) if (reply->status_code != RTSP_STATUS_OK)
return -1; return ff_rtsp_averror(reply->status_code, -1);
rt->state = RTSP_STATE_STREAMING; rt->state = RTSP_STATE_STREAMING;
return 0; return 0;
} }
......
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