Skip to content
Snippets Groups Projects
rtmpproto.c 101 KiB
Newer Older
  • Learn to ignore specific revisions
  •                                                 &rt->prev_pkt[0],
                                                    &rt->nb_prev_pkt[0], c)) <= 0)
    
                 return ret;
    
            if ((ret = rtmp_parse_result(s, rt, &rpkt)) < 0)
                return ret;
    
            ff_rtmp_packet_destroy(&rpkt);
        }
    
    
    #define OFFSET(x) offsetof(RTMPContext, x)
    #define DEC AV_OPT_FLAG_DECODING_PARAM
    #define ENC AV_OPT_FLAG_ENCODING_PARAM
    
    static const AVOption rtmp_options[] = {
        {"rtmp_app", "Name of application to connect to on the RTMP server", OFFSET(app), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
    
        {"rtmp_buffer", "Set buffer time in milliseconds. The default is 3000.", OFFSET(client_buffer_time), AV_OPT_TYPE_INT, {.i64 = 3000}, 0, INT_MAX, DEC|ENC},
    
        {"rtmp_conn", "Append arbitrary AMF data to the Connect message", OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
    
        {"rtmp_flashver", "Version of the Flash plugin used to run the SWF player.", OFFSET(flashver), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
    
        {"rtmp_flush_interval", "Number of packets flushed in the same request (RTMPT only).", OFFSET(flush_interval), AV_OPT_TYPE_INT, {.i64 = 10}, 0, INT_MAX, ENC},
        {"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), AV_OPT_TYPE_INT, {.i64 = -2}, INT_MIN, INT_MAX, DEC, "rtmp_live"},
    
        {"any", "both", 0, AV_OPT_TYPE_CONST, {.i64 = -2}, 0, 0, DEC, "rtmp_live"},
        {"live", "live stream", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, DEC, "rtmp_live"},
        {"recorded", "recorded stream", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, DEC, "rtmp_live"},
    
        {"rtmp_pageurl", "URL of the web page in which the media was embedded. By default no value will be sent.", OFFSET(pageurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC},
    
        {"rtmp_playpath", "Stream identifier to play or to publish", OFFSET(playpath), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
    
        {"rtmp_subscribe", "Name of live stream to subscribe to. Defaults to rtmp_playpath.", OFFSET(subscribe), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC},
    
        {"rtmp_swfhash", "SHA256 hash of the decompressed SWF file (32 bytes).", OFFSET(swfhash), AV_OPT_TYPE_BINARY, .flags = DEC},
    
        {"rtmp_swfsize", "Size of the decompressed SWF file, required for SWFVerification.", OFFSET(swfsize), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, DEC},
    
        {"rtmp_swfurl", "URL of the SWF player. By default no value will be sent", OFFSET(swfurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
    
        {"rtmp_swfverify", "URL to player swf file, compute hash/size automatically.", OFFSET(swfverify), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC},
    
        {"rtmp_tcurl", "URL of the target stream. Defaults to proto://host[:port]/app.", OFFSET(tcurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
    
        {"rtmp_listen", "Listen for incoming rtmp connections", OFFSET(listen), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC, "rtmp_listen" },
    
        {"listen",      "Listen for incoming rtmp connections", OFFSET(listen), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC, "rtmp_listen" },
    
        {"timeout", "Maximum timeout (in seconds) to wait for incoming connections. -1 is infinite. Implies -rtmp_listen 1",  OFFSET(listen_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC, "rtmp_listen" },
    
    #define RTMP_PROTOCOL(flavor)                    \
    static const AVClass flavor##_class = {          \
        .class_name = #flavor,                       \
        .item_name  = av_default_item_name,          \
        .option     = rtmp_options,                  \
        .version    = LIBAVUTIL_VERSION_INT,         \
    };                                               \
                                                     \
    URLProtocol ff_##flavor##_protocol = {           \
        .name           = #flavor,                   \
        .url_open       = rtmp_open,                 \
        .url_read       = rtmp_read,                 \
    
        .url_read_seek  = rtmp_seek,                 \
    
        .url_write      = rtmp_write,                \
        .url_close      = rtmp_close,                \
        .priv_data_size = sizeof(RTMPContext),       \
        .flags          = URL_PROTOCOL_FLAG_NETWORK, \
        .priv_data_class= &flavor##_class,           \
    
    RTMP_PROTOCOL(rtmp)
    RTMP_PROTOCOL(rtmpe)
    RTMP_PROTOCOL(rtmps)
    RTMP_PROTOCOL(rtmpt)
    RTMP_PROTOCOL(rtmpte)
    RTMP_PROTOCOL(rtmpts)