36 #include <librtmp/rtmp.h>
37 #include <librtmp/log.h>
112 RTMP_LogSetLevel(
level);
115 if (ctx->
app) len += strlen(ctx->
app) +
sizeof(
" app=");
116 if (ctx->
tcurl) len += strlen(ctx->
tcurl) +
sizeof(
" tcUrl=");
117 if (ctx->
pageurl) len += strlen(ctx->
pageurl) +
sizeof(
" pageUrl=");
121 char *sep, *p = ctx->
conn;
129 sep = strchr(p,
' ');
135 len += options *
sizeof(
" conn=");
136 len += strlen(ctx->
conn);
140 len += strlen(ctx->
playpath) +
sizeof(
" playpath=");
142 len +=
sizeof(
" live=1");
144 len += strlen(ctx->
subscribe) +
sizeof(
" subscribe=");
150 len +=
sizeof(
" swfUrl=");
153 len += strlen(ctx->
swfverify) +
sizeof(
" swfVfy=1");
155 len += strlen(ctx->
swfurl);
183 char *sep, *p = ctx->
conn;
189 sep = strchr(p,
' ');
226 if (!RTMP_SetupURL(r, filename)) {
234 if (!RTMP_Connect(r,
NULL) || !RTMP_ConnectStream(r, 0)) {
240 if (ctx->
buffer_size >= 0 && (flags & AVIO_FLAG_WRITE)) {
242 if (setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_SNDBUF, &tmp,
sizeof(tmp))) {
262 RTMP *
r = &ctx->
rtmp;
264 int ret = RTMP_Write(r, buf, size);
273 RTMP *
r = &ctx->
rtmp;
275 int ret = RTMP_Read(r, buf, size);
284 RTMP *
r = &ctx->
rtmp;
286 if (!RTMP_Pause(r, pause))
292 int64_t timestamp,
int flags)
295 RTMP *
r = &ctx->
rtmp;
301 if (stream_index < 0)
305 if (!RTMP_SendSeek(r, timestamp))
313 RTMP *
r = &ctx->
rtmp;
315 return RTMP_Socket(r);
318 #define OFFSET(x) offsetof(LibRTMPContext, x)
319 #define DEC AV_OPT_FLAG_DECODING_PARAM
320 #define ENC AV_OPT_FLAG_ENCODING_PARAM
323 {
"rtmp_buffer",
"Set buffer time in milliseconds. The default is 3000.",
OFFSET(client_buffer_time),
AV_OPT_TYPE_STRING, {.str =
"3000"}, 0, 0,
DEC|
ENC},
326 {
"rtmp_live",
"Specify that the media is a live stream.",
OFFSET(live),
AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX,
DEC,
"rtmp_live"},
330 {
"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},
332 {
"rtmp_subscribe",
"Name of live stream to subscribe to. Defaults to rtmp_playpath.",
OFFSET(subscribe),
AV_OPT_TYPE_STRING, {.str =
NULL }, 0, 0,
DEC},
334 {
"rtmp_swfverify",
"URL to player swf file, compute hash/size automatically. (unimplemented)",
OFFSET(swfverify),
AV_OPT_TYPE_STRING, {.str =
NULL }, 0, 0,
DEC},
342 #define RTMP_CLASS(flavor)\
343 static const AVClass lib ## flavor ## _class = {\
344 .class_name = "lib" #flavor " protocol",\
345 .item_name = av_default_item_name,\
347 .version = LIBAVUTIL_VERSION_INT,\
361 .priv_data_class = &librtmp_class,
376 .priv_data_class = &librtmpt_class,
391 .priv_data_class = &librtmpe_class,
406 .priv_data_class = &librtmpte_class,
421 .priv_data_class = &librtmps_class,
#define URL_PROTOCOL_FLAG_NETWORK
static int64_t rtmp_read_seek(URLContext *s, int stream_index, int64_t timestamp, int flags)
const URLProtocol ff_librtmps_protocol
#define AV_LOG_WARNING
Something somehow does not look correct.
int is_streamed
true if streamed (no seek possible), default = false
#define AVIO_FLAG_WRITE
write-only
static int rtmp_read_pause(URLContext *s, int pause)
static int rtmp_close(URLContext *s)
static int rtmp_open(URLContext *s, const char *uri, int flags)
Open RTMP connection and verify that the stream can be played.
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
const URLProtocol ff_librtmpt_protocol
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void rtmp_log(int level, const char *fmt, va_list args)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int av_log_get_level(void)
Get the current log level.
const URLProtocol ff_librtmp_protocol
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
#define AV_TIME_BASE
Internal time base represented as integer.
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
char * client_buffer_time
#define AV_LOG_INFO
Standard information.
static const AVOption options[]
Describe the class of an AVClass context structure.
void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Send the specified message to the log if the level is less than or equal to the current av_log_level...
static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
const URLProtocol ff_librtmpte_protocol
#define flags(name, subs,...)
char * filename
specified URL
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
static int rtmp_get_file_handle(URLContext *s)
static int rtmp_read(URLContext *s, uint8_t *buf, int size)
const URLProtocol ff_librtmpe_protocol
unbuffered private I/O API
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define RTMP_CLASS(flavor)