On Thu, 16 Aug 2012, Jordi Ortiz wrote:

@@ -1489,7 +1959,9 @@ static int get_packet(URLContext *s, int for_header)
            ff_rtmp_packet_destroy(&rpkt);
            return AVERROR_EOF;
        }
-        if (for_header && (rt->state == STATE_PLAYING || rt->state == 
STATE_PUBLISHING)) {
+        if (for_header && (rt->state == STATE_PLAYING    ||
+                           rt->state == STATE_PUBLISHING ||
+                           rt->state == STATE_RECEIVING)) {
            ff_rtmp_packet_destroy(&rpkt);
            return 0;
        }
@@ -1514,6 +1986,14 @@ static int get_packet(URLContext *s, int for_header)
            bytestream_put_be32(&p, 0);
            ff_rtmp_packet_destroy(&rpkt);
            return 0;
+        } else if (rpkt.type == RTMP_PT_NOTIFY) {
+            ret = handle_notify(s, &rpkt);
+            if (ret) {
+                av_log(s, AV_LOG_ERROR, "Handle notify error\n");
+                return ret;

Here you leak the packet

+            }
+            ff_rtmp_packet_destroy(&rpkt);
+            return 0;
        } else if (rpkt.type == RTMP_PT_METADATA) {
            // we got raw FLV data, make it available for FLV demuxer
            rt->flv_off  = 0;
@@ -1584,23 +2064,41 @@ static int rtmp_open(URLContext *s, const char *uri, 
int flags)
    AVDictionary *opts = NULL;
    int ret;

+    if (rt->listen_timeout > 0)
+        rt->listen = 1;
+
    rt->is_input = !(flags & AVIO_FLAG_WRITE);

    av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), 
&port,
                 path, sizeof(path), s->filename);

    if (!strcmp(proto, "rtmpt") || !strcmp(proto, "rtmpts")) {
+        if (rt->listen) {
+            av_log(s, AV_LOG_ERROR, "rtmp_listen not available for %s\n",
+                   proto);
+            return AVERROR_OPTION_NOT_FOUND;
+        }
        if (!strcmp(proto, "rtmpts"))

Instead of repeating this check 3 times, you could check if (rt->listen && strcmp(proto, "rtmp")) above. Also, OPTION_NOT_FOUND isn't totally right here, I'd rather have AVERROR(EINVAL).

We could also split the options arrays so that the rtmp_listen option would only be available for rtmp but not for the other ones.

Pushed with these things fixed (except for splitting the options array).

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

Reply via email to