Revision 0f943ce6

View differences:

Changelog
66 66
- VorbisComment writing for FLAC, Ogg FLAC and Ogg Speex files
67 67
- RTP depacketization of Theora
68 68
- HTTP Digest authentication
69
- RTMP/RTMPT/RTMPS/RTMPE/RTMPTE protocol support via librtmp
69 70

  
70 71

  
71 72

  
configure
177 177
  --enable-libnut          enable NUT (de)muxing via libnut,
178 178
                           native (de)muxer exists [no]
179 179
  --enable-libopenjpeg     enable JPEG 2000 decoding via OpenJPEG [no]
180
  --enable-librtmp         enable RTMP[E] support via librtmp [no]
180 181
  --enable-libschroedinger enable Dirac support via libschroedinger [no]
181 182
  --enable-libspeex        enable Speex decoding via libspeex [no]
182 183
  --enable-libtheora       enable Theora encoding via libtheora [no]
......
920 921
    libopencore_amrnb
921 922
    libopencore_amrwb
922 923
    libopenjpeg
924
    librtmp
923 925
    libschroedinger
924 926
    libspeex
925 927
    libtheora
......
2615 2617
enabled libopencore_amrnb  && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
2616 2618
enabled libopencore_amrwb  && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
2617 2619
enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
2620
enabled librtmp    && require  librtmp librtmp/rtmp.h RTMP_Init -lrtmp
2618 2621
enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
2619 2622
                           require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
2620 2623
enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
......
2893 2896
echo "libopencore-amrnb support ${libopencore_amrnb-no}"
2894 2897
echo "libopencore-amrwb support ${libopencore_amrwb-no}"
2895 2898
echo "libopenjpeg enabled       ${libopenjpeg-no}"
2899
echo "librtmp enabled           ${librtmp-no}"
2896 2900
echo "libschroedinger enabled   ${libschroedinger-no}"
2897 2901
echo "libspeex enabled          ${libspeex-no}"
2898 2902
echo "libtheora enabled         ${libtheora-no}"
libavformat/Makefile
274 274
OBJS-$(CONFIG_GOPHER_PROTOCOL)           += gopher.o
275 275
OBJS-$(CONFIG_HTTP_PROTOCOL)             += http.o httpauth.o
276 276
OBJS-$(CONFIG_PIPE_PROTOCOL)             += file.o
277
OBJS-$(CONFIG_RTMP_PROTOCOL)             += rtmpproto.o rtmppkt.o
277

  
278
# external or internal rtmp
279
RTMP-OBJS-$(CONFIG_LIBRTMP)               = librtmp.o
280
RTMP-OBJS-$(!CONFIG_LIBRTMP)              = rtmpproto.o rtmppkt.o
281
OBJS-$(CONFIG_RTMP_PROTOCOL)             += $(RTMP-OBJS-yes)
282

  
278 283
OBJS-$(CONFIG_RTP_PROTOCOL)              += rtpproto.o
279 284
OBJS-$(CONFIG_TCP_PROTOCOL)              += tcp.o
280 285
OBJS-$(CONFIG_UDP_PROTOCOL)              += udp.o
libavformat/allformats.c
218 218
    REGISTER_PROTOCOL (HTTP, http);
219 219
    REGISTER_PROTOCOL (PIPE, pipe);
220 220
    REGISTER_PROTOCOL (RTMP, rtmp);
221
#if CONFIG_LIBRTMP
222
    REGISTER_PROTOCOL (RTMP, rtmpt);
223
    REGISTER_PROTOCOL (RTMP, rtmpe);
224
    REGISTER_PROTOCOL (RTMP, rtmpte);
225
    REGISTER_PROTOCOL (RTMP, rtmps);
226
#endif
221 227
    REGISTER_PROTOCOL (RTP, rtp);
222 228
    REGISTER_PROTOCOL (TCP, tcp);
223 229
    REGISTER_PROTOCOL (UDP, udp);
libavformat/avformat.h
22 22
#define AVFORMAT_AVFORMAT_H
23 23

  
24 24
#define LIBAVFORMAT_VERSION_MAJOR 52
25
#define LIBAVFORMAT_VERSION_MINOR 57
26
#define LIBAVFORMAT_VERSION_MICRO  1
25
#define LIBAVFORMAT_VERSION_MINOR 58
26
#define LIBAVFORMAT_VERSION_MICRO  0
27 27

  
28 28
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
29 29
                                               LIBAVFORMAT_VERSION_MINOR, \
libavformat/librtmp.c
1
/*
2
 * RTMP network protocol
3
 * Copyright (c) 2010 Howard Chu
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
/**
23
 * @file libavformat/librtmp.c
24
 * RTMP protocol based on http://rtmpdump.mplayerhq.hu librtmp
25
 */
26

  
27
#include "avformat.h"
28

  
29
#include <librtmp/rtmp.h>
30
#include <librtmp/log.h>
31

  
32
static int rtmp_close(URLContext *s)
33
{
34
    RTMP *r = s->priv_data;
35

  
36
    RTMP_Close(r);
37
    av_free(r);
38
    return 0;
39
}
40

  
41
/**
42
 * Opens RTMP connection and verifies that the stream can be played.
43
 *
44
 * URL syntax: rtmp://server[:port][/app][/playpath][ keyword=value]...
45
 *             where 'app' is first one or two directories in the path
46
 *             (e.g. /ondemand/, /flash/live/, etc.)
47
 *             and 'playpath' is a file name (the rest of the path,
48
 *             may be prefixed with "mp4:")
49
 *
50
 *             Additional RTMP library options may be appended as
51
 *             space-separated key-value pairs.
52
 */
53
static int rtmp_open(URLContext *s, const char *uri, int flags)
54
{
55
    RTMP *r;
56
    int rc;
57

  
58
    r = av_mallocz(sizeof(RTMP));
59
    if (!r)
60
        return AVERROR(ENOMEM);
61

  
62
    switch(av_log_get_level()) {
63
    default:
64
    case AV_LOG_FATAL:   rc = RTMP_LOGCRIT;    break;
65
    case AV_LOG_ERROR:   rc = RTMP_LOGERROR;   break;
66
    case AV_LOG_WARNING: rc = RTMP_LOGWARNING; break;
67
    case AV_LOG_INFO:    rc = RTMP_LOGINFO;    break;
68
    case AV_LOG_VERBOSE: rc = RTMP_LOGDEBUG;   break;
69
    case AV_LOG_DEBUG:   rc = RTMP_LOGDEBUG2;  break;
70
    }
71
    RTMP_LogSetLevel(rc);
72

  
73
    RTMP_Init(r);
74
    if (!RTMP_SetupURL(r, s->filename)) {
75
        rc = -1;
76
        goto fail;
77
    }
78

  
79
    if (flags & URL_WRONLY)
80
        r->Link.protocol |= RTMP_FEATURE_WRITE;
81

  
82
    if (!RTMP_Connect(r, NULL) || !RTMP_ConnectStream(r, 0)) {
83
        rc = -1;
84
        goto fail;
85
    }
86

  
87
    s->priv_data = r;
88
    s->is_streamed = 1;
89
    return 0;
90
fail:
91
    av_free(r);
92
    return rc;
93
}
94

  
95
static int rtmp_write(URLContext *s, uint8_t *buf, int size)
96
{
97
    RTMP *r = s->priv_data;
98

  
99
    return RTMP_Write(r, buf, size);
100
}
101

  
102
static int rtmp_read(URLContext *s, uint8_t *buf, int size)
103
{
104
    RTMP *r = s->priv_data;
105

  
106
    return RTMP_Read(r, buf, size);
107
}
108

  
109
static int rtmp_read_pause(URLContext *s, int pause)
110
{
111
    RTMP *r = s->priv_data;
112

  
113
    if (pause)
114
        r->m_pauseStamp =
115
            r->m_channelTimestamp[r->m_mediaChannel];
116
    if (!RTMP_SendPause(r, pause, r->m_pauseStamp))
117
        return -1;
118
    return 0;
119
}
120

  
121
static int64_t rtmp_read_seek(URLContext *s, int stream_index,
122
                              int64_t timestamp, int flags)
123
{
124
    RTMP *r = s->priv_data;
125

  
126
    if (flags & AVSEEK_FLAG_BYTE)
127
        return AVERROR_NOTSUPP;
128

  
129
    /* seeks are in milliseconds */
130
    timestamp = av_rescale(timestamp, AV_TIME_BASE, 1000);
131
    if (!RTMP_SendSeek(r, timestamp))
132
        return -1;
133
    return timestamp;
134
}
135

  
136
static int rtmp_get_file_handle(URLContext *s)
137
{
138
    RTMP *r = s->priv_data;
139

  
140
    return r->m_sb.sb_socket;
141
}
142

  
143
URLProtocol rtmp_protocol = {
144
    "rtmp",
145
    rtmp_open,
146
    rtmp_read,
147
    rtmp_write,
148
    NULL,                   /* seek */
149
    rtmp_close,
150
    NULL,                   /* next */
151
    rtmp_read_pause,
152
    rtmp_read_seek,
153
    rtmp_get_file_handle
154
};
155

  
156
URLProtocol rtmpt_protocol = {
157
    "rtmpt",
158
    rtmp_open,
159
    rtmp_read,
160
    rtmp_write,
161
    NULL,                   /* seek */
162
    rtmp_close,
163
    NULL,                   /* next */
164
    rtmp_read_pause,
165
    rtmp_read_seek,
166
    rtmp_get_file_handle
167
};
168

  
169
URLProtocol rtmpe_protocol = {
170
    "rtmpe",
171
    rtmp_open,
172
    rtmp_read,
173
    rtmp_write,
174
    NULL,                   /* seek */
175
    rtmp_close,
176
    NULL,                   /* next */
177
    rtmp_read_pause,
178
    rtmp_read_seek,
179
    rtmp_get_file_handle
180
};
181

  
182
URLProtocol rtmpte_protocol = {
183
    "rtmpte",
184
    rtmp_open,
185
    rtmp_read,
186
    rtmp_write,
187
    NULL,                   /* seek */
188
    rtmp_close,
189
    NULL,                   /* next */
190
    rtmp_read_pause,
191
    rtmp_read_seek,
192
    rtmp_get_file_handle
193
};
194

  
195
URLProtocol rtmps_protocol = {
196
    "rtmps",
197
    rtmp_open,
198
    rtmp_read,
199
    rtmp_write,
200
    NULL,                   /* seek */
201
    rtmp_close,
202
    NULL,                   /* next */
203
    rtmp_read_pause,
204
    rtmp_read_seek,
205
    rtmp_get_file_handle
206
};

Also available in: Unified diff