Revision 26cb700c

View differences:

libavformat/rtsp.c
1328 1328
    return 0;
1329 1329
}
1330 1330

  
1331
static int rtsp_setup_output_streams(AVFormatContext *s)
1331
static int rtsp_setup_output_streams(AVFormatContext *s, const char *addr)
1332 1332
{
1333 1333
    RTSPState *rt = s->priv_data;
1334 1334
    RTSPMessageHeader reply1, *reply = &reply1;
1335 1335
    char cmd[1024];
1336 1336
    int i;
1337 1337
    char *sdp;
1338
    AVFormatContext sdp_ctx, *ctx_array[1];
1338 1339

  
1339 1340
    /* Announce the stream */
1340 1341
    snprintf(cmd, sizeof(cmd),
......
1344 1345
    sdp = av_mallocz(8192);
1345 1346
    if (sdp == NULL)
1346 1347
        return AVERROR(ENOMEM);
1347
    if (avf_sdp_create(&s, 1, sdp, 8192)) {
1348
    /* We create the SDP based on the RTSP AVFormatContext where we
1349
     * aren't allowed to change the filename field. (We create the SDP
1350
     * based on the RTSP context since the contexts for the RTP streams
1351
     * don't exist yet.) In order to specify a custom URL with the actual
1352
     * peer IP instead of the originally specified hostname, we create
1353
     * a temporary copy of the AVFormatContext, where the custom URL is set.
1354
     *
1355
     * FIXME: Create the SDP without copying the AVFormatContext.
1356
     * This either requires setting up the RTP stream AVFormatContexts
1357
     * already here (complicating things immensely) or getting a more
1358
     * flexible SDP creation interface.
1359
     */
1360
    sdp_ctx = *s;
1361
    ff_url_join(sdp_ctx.filename, sizeof(sdp_ctx.filename),
1362
                "rtsp", NULL, addr, -1, NULL);
1363
    ctx_array[0] = &sdp_ctx;
1364
    if (avf_sdp_create(ctx_array, 1, sdp, 8192)) {
1348 1365
        av_free(sdp);
1349 1366
        return AVERROR_INVALIDDATA;
1350 1367
    }
......
1507 1524
    if (s->iformat)
1508 1525
        err = rtsp_setup_input_streams(s);
1509 1526
    else
1510
        err = rtsp_setup_output_streams(s);
1527
        err = rtsp_setup_output_streams(s, host);
1511 1528
    if (err)
1512 1529
        goto fail;
1513 1530

  

Also available in: Unified diff