Revision 5306bf41

View differences:

libavformat/Makefile
128 128
OBJS-$(CONFIG_MMF_DEMUXER)               += mmf.o pcm.o
129 129
OBJS-$(CONFIG_MMF_MUXER)                 += mmf.o riff.o
130 130
OBJS-$(CONFIG_MOV_DEMUXER)               += mov.o riff.o isom.o
131
OBJS-$(CONFIG_MOV_MUXER)                 += movenc.o riff.o isom.o avc.o movenchint.o
131
OBJS-$(CONFIG_MOV_MUXER)                 += movenc.o riff.o isom.o avc.o \
132
                                            movenchint.o rtpenc_chain.o
132 133
OBJS-$(CONFIG_MP2_MUXER)                 += mp3enc.o
133 134
OBJS-$(CONFIG_MP3_DEMUXER)               += mp3dec.o
134 135
OBJS-$(CONFIG_MP3_MUXER)                 += mp3enc.o
libavformat/movenchint.c
22 22
#include "movenc.h"
23 23
#include "libavutil/intreadwrite.h"
24 24
#include "internal.h"
25
#include "rtpenc_chain.h"
25 26

  
26 27
int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index)
27 28
{
......
30 31
    MOVTrack *src_track = &mov->tracks[src_index];
31 32
    AVStream *src_st    = s->streams[src_index];
32 33
    int ret = AVERROR(ENOMEM);
33
    AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
34 34

  
35 35
    track->tag = MKTAG('r','t','p',' ');
36 36
    track->src_track = src_index;
37 37

  
38
    if (!rtp_format) {
39
        ret = AVERROR(ENOENT);
40
        goto fail;
41
    }
42

  
43 38
    track->enc = avcodec_alloc_context();
44 39
    if (!track->enc)
45 40
        goto fail;
46 41
    track->enc->codec_type = AVMEDIA_TYPE_DATA;
47 42
    track->enc->codec_tag  = track->tag;
48 43

  
49
    track->rtp_ctx = avformat_alloc_context();
44
    track->rtp_ctx = ff_rtp_chain_mux_open(s, src_st, NULL,
45
                                           RTP_MAX_PACKET_SIZE);
50 46
    if (!track->rtp_ctx)
51 47
        goto fail;
52
    track->rtp_ctx->oformat = rtp_format;
53
    if (!av_new_stream(track->rtp_ctx, 0))
54
        goto fail;
55

  
56
    /* Copy stream parameters */
57
    track->rtp_ctx->streams[0]->sample_aspect_ratio =
58
                        src_st->sample_aspect_ratio;
59

  
60
    avcodec_copy_context(track->rtp_ctx->streams[0]->codec, src_st->codec);
61

  
62
    if ((ret = url_open_dyn_packet_buf(&track->rtp_ctx->pb,
63
                                       RTP_MAX_PACKET_SIZE)) < 0)
64
        goto fail;
65
    ret = av_write_header(track->rtp_ctx);
66
    if (ret)
67
        goto fail;
68 48

  
69 49
    /* Copy the RTP AVStream timebase back to the hint AVStream */
70 50
    track->timescale = track->rtp_ctx->streams[0]->time_base.den;
......
76 56
fail:
77 57
    av_log(s, AV_LOG_WARNING,
78 58
           "Unable to initialize hinting of stream %d\n", src_index);
79
    if (track->rtp_ctx && track->rtp_ctx->pb) {
80
        uint8_t *buf;
81
        url_close_dyn_buf(track->rtp_ctx->pb, &buf);
82
        av_free(buf);
83
    }
84
    if (track->rtp_ctx) {
85
        avformat_free_context(track->rtp_ctx);
86
        track->rtp_ctx = NULL;
87
    }
88 59
    av_freep(&track->enc);
89 60
    /* Set a default timescale, to avoid crashes in dump_format */
90 61
    track->timescale = 90000;

Also available in: Unified diff