Revision 6f5a3d0a

View differences:

Changelog
60 60
- WMAVoice decoder
61 61
- FFprobe tool
62 62
- AMR-NB decoder
63
- RTSP muxer
63 64

  
64 65

  
65 66

  
configure
1351 1351
ogg_demuxer_select="golomb"
1352 1352
psp_muxer_select="mov_muxer"
1353 1353
rtsp_demuxer_deps="sdp_demuxer"
1354
rtsp_muxer_deps="sdp_demuxer"
1355
rtsp_muxer_select="rtp_muxer"
1354 1356
sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
1355 1357
spdif_muxer_select="aac_parser"
1356 1358
tg2_muxer_select="mov_muxer"
doc/general.texi
210 210
@item RTMP                      @tab X @tab X
211 211
    @tab Output is performed by publishing stream to RTMP server
212 212
@item RTP                       @tab   @tab X
213
@item RTSP                      @tab   @tab X
213
@item RTSP                      @tab X @tab X
214 214
@item SDP                       @tab   @tab X
215 215
@item Sega FILM/CPK             @tab   @tab X
216 216
    @tab Used in many Sega Saturn console games.
libavformat/Makefile
210 210
                                            rtpenc_h264.o \
211 211
                                            avc.o
212 212
OBJS-$(CONFIG_RTSP_DEMUXER)              += rtsp.o
213
OBJS-$(CONFIG_RTSP_MUXER)                += rtsp.o rtspenc.o
213 214
OBJS-$(CONFIG_SDP_DEMUXER)               += rtsp.o        \
214 215
                                            rdt.o         \
215 216
                                            rtp.o         \
libavformat/allformats.c
172 172
    REGISTER_MUXDEMUX (ROQ, roq);
173 173
    REGISTER_DEMUXER  (RPL, rpl);
174 174
    REGISTER_MUXER    (RTP, rtp);
175
    REGISTER_DEMUXER  (RTSP, rtsp);
175
    REGISTER_MUXDEMUX (RTSP, rtsp);
176 176
    REGISTER_DEMUXER  (SDP, sdp);
177 177
#if CONFIG_SDP_DEMUXER
178 178
    av_register_rtp_dynamic_payload_handlers();
libavformat/avformat.h
22 22
#define AVFORMAT_AVFORMAT_H
23 23

  
24 24
#define LIBAVFORMAT_VERSION_MAJOR 52
25
#define LIBAVFORMAT_VERSION_MINOR 52
25
#define LIBAVFORMAT_VERSION_MINOR 53
26 26
#define LIBAVFORMAT_VERSION_MICRO  0
27 27

  
28 28
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
libavformat/rtsp.c
691 691
    return 0;
692 692
}
693 693

  
694
#if CONFIG_RTSP_DEMUXER
694
#if CONFIG_RTSP_DEMUXER || CONFIG_RTSP_MUXER
695 695
static int rtsp_probe(AVProbeData *p)
696 696
{
697 697
    if (av_strstart(p->filename, "rtsp:", NULL))
......
1533 1533
    }
1534 1534
    return err;
1535 1535
}
1536
#endif
1536 1537

  
1538
#if CONFIG_RTSP_DEMUXER
1537 1539
static int rtsp_read_header(AVFormatContext *s,
1538 1540
                            AVFormatParameters *ap)
1539 1541
{
libavformat/rtspenc.c
1
/*
2
 * RTSP muxer
3
 * Copyright (c) 2010 Martin Storsjo
4
 *
5
 * This file is part of FFmpeg.
6
 *
7
 * FFmpeg is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21

  
22
#include "avformat.h"
23

  
24
#include <sys/time.h>
25
#if HAVE_SYS_SELECT_H
26
#include <sys/select.h>
27
#endif
28
#include "network.h"
29
#include "rtsp.h"
30

  
31
static int rtsp_write_record(AVFormatContext *s)
32
{
33
    RTSPState *rt = s->priv_data;
34
    RTSPMessageHeader reply1, *reply = &reply1;
35
    char cmd[1024];
36

  
37
    snprintf(cmd, sizeof(cmd),
38
             "RECORD %s RTSP/1.0\r\n"
39
             "Range: npt=%0.3f-\r\n",
40
             s->filename,
41
             (double) 0);
42
    rtsp_send_cmd(s, cmd, reply, NULL);
43
    if (reply->status_code != RTSP_STATUS_OK)
44
        return -1;
45
    rt->state = RTSP_STATE_STREAMING;
46
    return 0;
47
}
48

  
49
static int rtsp_write_header(AVFormatContext *s)
50
{
51
    RTSPState *rt = s->priv_data;
52
    int ret;
53

  
54
    ret = rtsp_connect(s);
55
    if (ret)
56
        return ret;
57

  
58
    if (rtsp_write_record(s) < 0) {
59
        rtsp_close_streams(s);
60
        url_close(rt->rtsp_hd);
61
        return AVERROR_INVALIDDATA;
62
    }
63
    return 0;
64
}
65

  
66
static int rtsp_write_packet(AVFormatContext *s, AVPacket *pkt)
67
{
68
    RTSPState *rt = s->priv_data;
69
    RTSPStream *rtsp_st;
70
    fd_set rfds;
71
    int n, tcp_fd;
72
    struct timeval tv;
73
    AVFormatContext *rtpctx;
74

  
75
    FD_ZERO(&rfds);
76
    tcp_fd = url_get_file_handle(rt->rtsp_hd);
77
    FD_SET(tcp_fd, &rfds);
78

  
79
    tv.tv_sec = 0;
80
    tv.tv_usec = 0;
81
    n = select(tcp_fd + 1, &rfds, NULL, NULL, &tv);
82
    if (n > 0) {
83
        if (FD_ISSET(tcp_fd, &rfds)) {
84
            RTSPMessageHeader reply;
85

  
86
            if (rtsp_read_reply(s, &reply, NULL, 0) < 0)
87
                return AVERROR(EPIPE);
88
            /* XXX: parse message */
89
            if (rt->state != RTSP_STATE_STREAMING)
90
                return AVERROR(EPIPE);
91
        }
92
    }
93

  
94
    if (pkt->stream_index < 0 || pkt->stream_index >= rt->nb_rtsp_streams)
95
        return AVERROR_INVALIDDATA;
96
    rtsp_st = rt->rtsp_streams[pkt->stream_index];
97
    rtpctx = rtsp_st->transport_priv;
98

  
99
    pkt->stream_index = 0;
100
    return av_write_frame(rtpctx, pkt);
101
}
102

  
103
static int rtsp_write_close(AVFormatContext *s)
104
{
105
    RTSPState *rt = s->priv_data;
106
    char cmd[1024];
107

  
108
    snprintf(cmd, sizeof(cmd),
109
             "TEARDOWN %s RTSP/1.0\r\n",
110
             s->filename);
111
    rtsp_send_cmd_async(s, cmd);
112

  
113
    rtsp_close_streams(s);
114
    url_close(rt->rtsp_hd);
115
    return 0;
116
}
117

  
118
AVOutputFormat rtsp_muxer = {
119
    "rtsp",
120
    NULL_IF_CONFIG_SMALL("RTSP output format"),
121
    NULL,
122
    NULL,
123
    sizeof(RTSPState),
124
    CODEC_ID_PCM_MULAW,
125
    CODEC_ID_NONE,
126
    rtsp_write_header,
127
    rtsp_write_packet,
128
    rtsp_write_close,
129
    .flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER,
130
};
131

  

Also available in: Unified diff