On Wed, 4 Jul 2012, Jordi Ortiz wrote:

+static int rtsp_read_setup(AVFormatContext *s, char* host, char *controlurl)
+{
+    RTSPState *rt             = s->priv_data;
+    RTSPMessageHeader request = { 0 };
+    int ret                   = 0;
+    char url[1024];
+    RTSPStream *rtsp_st;
+    char responseheaders[1024];
+    int localport    = -1;
+    int transportidx = 0;
+
+    ret = rtsp_read_request(s, &request, "SETUP");
+    if (ret)
+        return ret;
+    rt->seq++;
+    if (!request.nb_transports) {
+        av_log(s, AV_LOG_ERROR, "No transport defined in SETUP\n");
+        return AVERROR_INVALIDDATA;
+    }
+    for (transportidx = 0; transportidx < request.nb_transports;
+         transportidx++) {
+        if (!request.transports[transportidx].mode_record
+            || (request.transports[transportidx].lower_transport
+                != RTSP_LOWER_TRANSPORT_UDP &&
+                request.transports[transportidx].lower_transport
+                != RTSP_LOWER_TRANSPORT_TCP)) {
+            av_log(s, AV_LOG_ERROR, "mode=record/receive not set or transport"
+                   " protocol not supported (yet)\n");
+            return AVERROR_INVALIDDATA;
+        }
+    }
+    if (request.nb_transports > 1)
+        av_log(s, AV_LOG_WARNING, "More than one transport not supported, "
+               "using first of all\n");
+    if (strcmp(rt->rtsp_streams[0]->control_url,
+               controlurl)) {
+        av_log(s, AV_LOG_ERROR, "Unable to find requested track\n");
+        return AVERROR_STREAM_NOT_FOUND;
+    }
+    rtsp_st   = rt->rtsp_streams[0];
+    localport = rt->rtp_port_min;
+
+    if (request.transports[0].lower_transport
+        == RTSP_LOWER_TRANSPORT_TCP) {
+        rt->lower_transport = RTSP_LOWER_TRANSPORT_TCP;
+        if ((ret = ff_rtsp_open_transport_ctx(s, rtsp_st))) {
+            rtsp_send_reply(s, RTSP_STATUS_TRANSPORT, NULL, request.seq);
+            return ret;
+        }
+        snprintf(responseheaders, sizeof(responseheaders), "Transport: "
+                 "RTP/AVP/TCP;unicast;mode=receive;source=%s;interleaved=%d-%d"
+                 "\r\n", host, request.transports[0].interleaved_min,
+                 request.transports[0].interleaved_max);

Here you need to store interleaved_min/max into rtsp_st too, I think I already told you this in some earlier review?

Right now, receiving more than one stream over TCP is broken.


After fixing this and the other things I mentioned, I was able to receive streams from both avconv, QuickTime Broadcaster and Wirecast.

// Martin
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to