summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>2012-07-20 16:36:47 +0200
committerMartin Storsjö <martin@martin.st>2012-07-23 16:32:09 +0300
commit08cd95e8a37674401ed24e5e6f4f7402edb7fdeb (patch)
tree3b0c2a52c4f70859b9a72ecab74f781d4a092f65 /libavformat
parentacd554c103459ae7a5d89caa611e91bbc9bf695f (diff)
downloadffmpeg-08cd95e8a37674401ed24e5e6f4f7402edb7fdeb.tar.gz
RTMPTE protocol support
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/Makefile1
-rw-r--r--libavformat/allformats.c1
-rw-r--r--libavformat/rtmpcrypt.c33
-rw-r--r--libavformat/rtmpproto.c23
-rw-r--r--libavformat/version.h2
5 files changed, 54 insertions, 6 deletions
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 31a53345e7..2263b9648d 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -357,6 +357,7 @@ OBJS-$(CONFIG_RTMP_PROTOCOL) += rtmpproto.o rtmppkt.o
OBJS-$(CONFIG_RTMPE_PROTOCOL) += rtmpproto.o rtmppkt.o
OBJS-$(CONFIG_RTMPS_PROTOCOL) += rtmpproto.o rtmppkt.o
OBJS-$(CONFIG_RTMPT_PROTOCOL) += rtmpproto.o rtmppkt.o
+OBJS-$(CONFIG_RTMPTE_PROTOCOL) += rtmpproto.o rtmppkt.o
OBJS-$(CONFIG_RTMPTS_PROTOCOL) += rtmpproto.o rtmppkt.o
OBJS-$(CONFIG_RTP_PROTOCOL) += rtpproto.o
OBJS-$(CONFIG_SCTP_PROTOCOL) += sctp.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 4e694b26fe..40770e5253 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -263,6 +263,7 @@ void av_register_all(void)
REGISTER_PROTOCOL (RTMPE, rtmpe);
REGISTER_PROTOCOL (RTMPS, rtmps);
REGISTER_PROTOCOL (RTMPT, rtmpt);
+ REGISTER_PROTOCOL (RTMPTE, rtmpte);
REGISTER_PROTOCOL (RTMPTS, rtmpts);
REGISTER_PROTOCOL (RTP, rtp);
REGISTER_PROTOCOL (SCTP, sctp);
diff --git a/libavformat/rtmpcrypt.c b/libavformat/rtmpcrypt.c
index e5afcc94ff..6a4332de86 100644
--- a/libavformat/rtmpcrypt.c
+++ b/libavformat/rtmpcrypt.c
@@ -26,6 +26,7 @@
#include "libavutil/blowfish.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
#include "libavutil/rc4.h"
#include "libavutil/xtea.h"
@@ -37,11 +38,13 @@
/* protocol handler context */
typedef struct RTMPEContext {
+ const AVClass *class;
URLContext *stream; ///< TCP stream
FF_DH *dh; ///< Diffie-Hellman context
struct AVRC4 key_in; ///< RC4 key used for decrypt data
struct AVRC4 key_out; ///< RC4 key used for encrypt data
int handshaked; ///< flag indicating when the handshake is performed
+ int tunneling; ///< use a HTTP connection (RTMPTE)
} RTMPEContext;
static const uint8_t rtmpe8_keys[16][16] = {
@@ -248,11 +251,17 @@ static int rtmpe_open(URLContext *h, const char *uri, int flags)
av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, NULL, 0, uri);
- if (port < 0)
- port = 1935;
+ if (rt->tunneling) {
+ if (port < 0)
+ port = 80;
+ ff_url_join(url, sizeof(url), "ffrtmphttp", NULL, host, port, NULL);
+ } else {
+ if (port < 0)
+ port = 1935;
+ ff_url_join(url, sizeof(url), "tcp", NULL, host, port, NULL);
+ }
- /* open the tcp connection */
- ff_url_join(url, sizeof(url), "tcp", NULL, host, port, NULL);
+ /* open the tcp or ffrtmphttp connection */
if ((ret = ffurl_open(&rt->stream, url, AVIO_FLAG_READ_WRITE,
&h->interrupt_callback, NULL)) < 0) {
rtmpe_close(h);
@@ -298,6 +307,21 @@ static int rtmpe_write(URLContext *h, const uint8_t *buf, int size)
return size;
}
+#define OFFSET(x) offsetof(RTMPEContext, x)
+#define DEC AV_OPT_FLAG_DECODING_PARAM
+
+static const AVOption ffrtmpcrypt_options[] = {
+ {"ffrtmpcrypt_tunneling", "Use a HTTP tunneling connection (RTMPTE).", OFFSET(tunneling), AV_OPT_TYPE_INT, {0}, 0, 1, DEC},
+ { NULL },
+};
+
+static const AVClass ffrtmpcrypt_class = {
+ .class_name = "ffrtmpcrypt",
+ .item_name = av_default_item_name,
+ .option = ffrtmpcrypt_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
URLProtocol ff_ffrtmpcrypt_protocol = {
.name = "ffrtmpcrypt",
.url_open = rtmpe_open,
@@ -306,4 +330,5 @@ URLProtocol ff_ffrtmpcrypt_protocol = {
.url_close = rtmpe_close,
.priv_data_size = sizeof(RTMPEContext),
.flags = URL_PROTOCOL_FLAG_NETWORK,
+ .priv_data_class = &ffrtmpcrypt_class,
};
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 67a89c5c82..f7ba7d5ef8 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -1192,7 +1192,10 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
if (port < 0)
port = RTMPS_DEFAULT_PORT;
ff_url_join(buf, sizeof(buf), "tls", NULL, hostname, port, NULL);
- } else if (!strcmp(proto, "rtmpe")) {
+ } else if (!strcmp(proto, "rtmpe") || (!strcmp(proto, "rtmpte"))) {
+ if (!strcmp(proto, "rtmpte"))
+ av_dict_set(&opts, "ffrtmpcrypt_tunneling", "1", 1);
+
/* open the encrypted connection */
ff_url_join(buf, sizeof(buf), "ffrtmpcrypt", NULL, hostname, port, NULL);
rt->encrypted = 1;
@@ -1574,6 +1577,24 @@ URLProtocol ff_rtmpt_protocol = {
.priv_data_class = &rtmpt_class,
};
+static const AVClass rtmpte_class = {
+ .class_name = "rtmpte",
+ .item_name = av_default_item_name,
+ .option = rtmp_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+URLProtocol ff_rtmpte_protocol = {
+ .name = "rtmpte",
+ .url_open = rtmp_open,
+ .url_read = rtmp_read,
+ .url_write = rtmp_write,
+ .url_close = rtmp_close,
+ .priv_data_size = sizeof(RTMPContext),
+ .flags = URL_PROTOCOL_FLAG_NETWORK,
+ .priv_data_class = &rtmpte_class,
+};
+
static const AVClass rtmpts_class = {
.class_name = "rtmpts",
.item_name = av_default_item_name,
diff --git a/libavformat/version.h b/libavformat/version.h
index 3681e8db13..bc6cae664b 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 54
-#define LIBAVFORMAT_VERSION_MINOR 11
+#define LIBAVFORMAT_VERSION_MINOR 12
#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \