#include "rtpdec.h"
#include "rdt.h"
-#include "rtpdec_asf.h"
+#include "rtpdec_formats.h"
//#define DEBUG
//#define DEBUG_RTP_TCP
#define SELECT_TIMEOUT_MS 100
#define READ_PACKET_TIMEOUT_S 10
#define MAX_TIMEOUTS READ_PACKET_TIMEOUT_S * 1000 / SELECT_TIMEOUT_MS
+#define SDP_MAX_SIZE 16384
static void get_word_until_chars(char *buf, int buf_size,
const char *sep, const char **pp)
rtsp_st = st->priv_data;
/* XXX: may need to add full url resolution */
- ff_url_split(proto, sizeof(proto), NULL, 0, NULL, 0,
+ av_url_split(proto, sizeof(proto), NULL, 0, NULL, 0,
NULL, NULL, 0, p);
if (proto[0] == '\0') {
/* relative control URL */
rtsp_st->dynamic_handler);
else
rtsp_st->transport_priv = rtp_parse_open(s, st, rtsp_st->rtp_handle,
- rtsp_st->sdp_payload_type,
- &rtsp_st->rtp_payload_data);
+ rtsp_st->sdp_payload_type);
if (!rtsp_st->transport_priv) {
return AVERROR(ENOMEM);
get_word(buf1, sizeof(buf1), &p);
get_word(buf1, sizeof(buf1), &p);
reply->status_code = atoi(buf1);
+ av_strlcpy(reply->reason, p, sizeof(reply->reason));
} else {
ff_rtsp_parse_line(reply, p, &rt->auth_state);
av_strlcat(rt->last_reply, p, sizeof(rt->last_reply));
rt->auth_state.auth_type != HTTP_AUTH_NONE)
goto retry;
+ if (reply->status_code > 400){
+ av_log(s, AV_LOG_ERROR, "method %s failed: %d%s\n",
+ method,
+ reply->status_code,
+ reply->reason);
+ av_log(s, AV_LOG_DEBUG, "%s\n", rt->last_reply);
+ }
+
return 0;
}
rt->transport = reply->transports[0].transport;
}
- /* close RTP connection if not choosen */
+ /* close RTP connection if not chosen */
if (reply->transports[0].lower_transport != RTSP_LOWER_TRANSPORT_UDP &&
(lower_transport == RTSP_LOWER_TRANSPORT_UDP)) {
url_close(rtsp_st->rtp_handle);
rt->start_time = av_gettime();
/* Announce the stream */
- sdp = av_mallocz(8192);
+ sdp = av_mallocz(SDP_MAX_SIZE);
if (sdp == NULL)
return AVERROR(ENOMEM);
/* We create the SDP based on the RTSP AVFormatContext where we
ff_url_join(sdp_ctx.filename, sizeof(sdp_ctx.filename),
"rtsp", NULL, addr, -1, NULL);
ctx_array[0] = &sdp_ctx;
- if (avf_sdp_create(ctx_array, 1, sdp, 8192)) {
+ if (avf_sdp_create(ctx_array, 1, sdp, SDP_MAX_SIZE)) {
av_free(sdp);
return AVERROR_INVALIDDATA;
}
char host[1024], path[1024], tcpname[1024], cmd[2048], auth[128];
char *option_list, *option, *filename;
int port, err, tcp_fd;
- RTSPMessageHeader reply1 = {}, *reply = &reply1;
+ RTSPMessageHeader reply1 = {0}, *reply = &reply1;
int lower_transport_mask = 0;
char real_challenge[64];
struct sockaddr_storage peer;
redirect:
rt->control_transport = RTSP_MODE_PLAIN;
/* extract hostname and port */
- ff_url_split(NULL, 0, auth, sizeof(auth),
+ av_url_split(NULL, 0, auth, sizeof(auth),
host, sizeof(host), &port, path, sizeof(path), s->filename);
if (*auth) {
av_strlcpy(rt->auth, auth, sizeof(rt->auth));
static int rtsp_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
+ RTSPState *rt = s->priv_data;
int ret;
ret = ff_rtsp_connect(s);
if (ret)
return ret;
+ rt->real_setup_cache = av_mallocz(2 * s->nb_streams * sizeof(*rt->real_setup_cache));
+ if (!rt->real_setup_cache)
+ return AVERROR(ENOMEM);
+ rt->real_setup = rt->real_setup_cache + s->nb_streams * sizeof(*rt->real_setup);
+
if (ap->initial_pause) {
/* do not start immediately */
} else {
if (rt->server_type == RTSP_SERVER_REAL) {
int i;
- enum AVDiscard cache[MAX_STREAMS];
for (i = 0; i < s->nb_streams; i++)
- cache[i] = s->streams[i]->discard;
+ rt->real_setup[i] = s->streams[i]->discard;
if (!rt->need_subscription) {
- if (memcmp (cache, rt->real_setup_cache,
+ if (memcmp (rt->real_setup, rt->real_setup_cache,
sizeof(enum AVDiscard) * s->nb_streams)) {
snprintf(cmd, sizeof(cmd),
"Unsubscribe: %s\r\n",
if (rt->need_subscription) {
int r, rule_nr, first = 1;
- memcpy(rt->real_setup_cache, cache,
+ memcpy(rt->real_setup_cache, rt->real_setup,
sizeof(enum AVDiscard) * s->nb_streams);
rt->last_subscription[0] = 0;
return ret;
/* send dummy request to keep TCP connection alive */
- if ((rt->server_type == RTSP_SERVER_WMS ||
- rt->server_type == RTSP_SERVER_REAL) &&
- (av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2) {
+ if ((av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2) {
if (rt->server_type == RTSP_SERVER_WMS) {
ff_rtsp_send_cmd_async(s, "GET_PARAMETER", rt->control_uri, NULL);
} else {
ff_rtsp_close_streams(s);
ff_rtsp_close_connections(s);
ff_network_close();
+ rt->real_setup = NULL;
+ av_freep(&rt->real_setup_cache);
return 0;
}
return 0;
}
-#define SDP_MAX_SIZE 8192
-
static int sdp_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
RTSPState *rt = s->priv_data;