Projects
Essentials
rtmpdump
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 8
View file
rtmpdump.changes
Changed
@@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Thu Nov 1 16:30:15 UTC 2012 - i@margueirte.su + +- update to 2.4.git20121102. + * Aside from various minor bugfixes since 2.3, RTMPE type 9 handshakes + are now supported. + +------------------------------------------------------------------- Thu Dec 15 14:15:45 UTC 2011 - ismail@namtrac.org - Update to latest git as of 14.11.2011
View file
rtmpdump.spec
Changed
@@ -4,7 +4,7 @@ # Name: rtmpdump -Version: 2.3.99.git20111114 +Version: 2.4.git20121102 Release: 0 License: GPL-2.0 %define soname 0
View file
rtmpdump-2.3.99.git20111114.tar.bz2/Makefile -> rtmpdump-2.4.git20121102.tar.bz2/Makefile
Changed
@@ -12,7 +12,7 @@ #CRYPTO=POLARSSL #CRYPTO=GNUTLS LIBZ=-lz -LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ) +LIB_GNUTLS=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ) LIB_OPENSSL=-lssl -lcrypto $(LIBZ) LIB_POLARSSL=-lpolarssl $(LIBZ) CRYPTO_LIB=$(LIB_$(CRYPTO))
View file
rtmpdump-2.3.99.git20111114.tar.bz2/librtmp/Makefile -> rtmpdump-2.4.git20121102.tar.bz2/librtmp/Makefile
Changed
@@ -28,7 +28,7 @@ LIBS_posix= LIBS_darwin= LIBS_mingw=-lws2_32 -lwinmm -lgdi32 -LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ) +LIB_GNUTLS=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ) LIB_OPENSSL=-lssl -lcrypto $(LIBZ) LIB_POLARSSL=-lpolarssl $(LIBZ) PRIVATE_LIBS=$(LIBS_$(SYS)) @@ -39,11 +39,11 @@ SO_VERSION=0 SOX_posix=so SOX_darwin=dylib -SOX_mingw=so # useless +SOX_mingw=dll SOX=$(SOX_$(SYS)) -SO_posix=$(SOX).$(SO_VERSION) -SO_darwin=$(SO_VERSION).$(SOX) -SO_mingw=dll +SO_posix=.$(SOX).$(SO_VERSION) +SO_darwin=.$(SO_VERSION).$(SOX) +SO_mingw=-$(SO_VERSION).$(SOX) SO_EXT=$(SO_$(SYS)) SODIR_posix=$(LIBDIR) @@ -64,7 +64,7 @@ SHARED=yes SODEF_yes=-fPIC -SOLIB_yes=librtmp.$(SO_EXT) +SOLIB_yes=librtmp$(SO_EXT) SOINST_yes=install_so SO_DEF=$(SODEF_$(SHARED)) SO_LIB=$(SOLIB_$(SHARED)) @@ -81,12 +81,12 @@ all: librtmp.a $(SO_LIB) clean: - rm -f *.o *.a *.$(SOX) *.$(SO_EXT) librtmp.pc + rm -f *.o *.a *.$(SOX) *$(SO_EXT) librtmp.pc librtmp.a: $(OBJS) $(AR) rs $@ $? -librtmp.$(SO_EXT): $(OBJS) +librtmp$(SO_EXT): $(OBJS) $(CC) $(SO_LDFLAGS) $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB) ln -sf $@ librtmp.$(SOX) @@ -111,8 +111,8 @@ cp librtmp.pc $(LIBDIR)/pkgconfig cp librtmp.3 $(MANDIR)/man3 -install_so: librtmp.$(SO_EXT) - cp librtmp.$(SO_EXT) $(SODIR) +install_so: librtmp$(SO_EXT) + cp librtmp$(SO_EXT) $(SODIR) $(INSTALL_IMPLIB) - cd $(SODIR); ln -sf librtmp.$(SO_EXT) librtmp.$(SOX) + cd $(SODIR); ln -sf librtmp$(SO_EXT) librtmp.$(SOX)
View file
rtmpdump-2.3.99.git20111114.tar.bz2/librtmp/amf.c -> rtmpdump-2.4.git20121102.tar.bz2/librtmp/amf.c
Changed
@@ -396,6 +396,14 @@ pBuffer = AMF_Encode(&prop->p_vu.p_object, pBuffer, pBufEnd); break; + case AMF_ECMA_ARRAY: + pBuffer = AMF_EncodeEcmaArray(&prop->p_vu.p_object, pBuffer, pBufEnd); + break; + + case AMF_STRICT_ARRAY: + pBuffer = AMF_EncodeArray(&prop->p_vu.p_object, pBuffer, pBufEnd); + break; + default: RTMP_Log(RTMP_LOGERROR, "%s, invalid type. %d", __FUNCTION__, prop->p_type); pBuffer = NULL; @@ -700,7 +708,6 @@ if (nRes == -1) return -1; nSize -= nRes; - prop->p_type = AMF_OBJECT; break; } case AMF_OBJECT_END: @@ -718,7 +725,6 @@ if (nRes == -1) return -1; nSize -= nRes; - prop->p_type = AMF_OBJECT; break; } case AMF_DATE: @@ -735,13 +741,15 @@ break; } case AMF_LONG_STRING: + case AMF_XML_DOC: { unsigned int nStringSize = AMF_DecodeInt32(pBuffer); if (nSize < (long)nStringSize + 4) return -1; AMF_DecodeLongString(pBuffer, &prop->p_vu.p_aval); nSize -= (4 + nStringSize); - prop->p_type = AMF_STRING; + if (prop->p_type == AMF_LONG_STRING) + prop->p_type = AMF_STRING; break; } case AMF_RECORDSET: @@ -750,12 +758,6 @@ return -1; break; } - case AMF_XML_DOC: - { - RTMP_Log(RTMP_LOGERROR, "AMF_XML_DOC not supported!"); - return -1; - break; - } case AMF_TYPED_OBJECT: { RTMP_Log(RTMP_LOGERROR, "AMF_TYPED_OBJECT not supported!"); @@ -819,6 +821,18 @@ AMF_Dump(&prop->p_vu.p_object); return; } + else if (prop->p_type == AMF_ECMA_ARRAY) + { + RTMP_Log(RTMP_LOGDEBUG, "Property: <%sECMA_ARRAY>", strRes); + AMF_Dump(&prop->p_vu.p_object); + return; + } + else if (prop->p_type == AMF_STRICT_ARRAY) + { + RTMP_Log(RTMP_LOGDEBUG, "Property: <%sSTRICT_ARRAY>", strRes); + AMF_Dump(&prop->p_vu.p_object); + return; + } switch (prop->p_type) { @@ -892,6 +906,76 @@ return pBuffer; } +char * +AMF_EncodeEcmaArray(AMFObject *obj, char *pBuffer, char *pBufEnd) +{ + int i; + + if (pBuffer+4 >= pBufEnd) + return NULL; + + *pBuffer++ = AMF_ECMA_ARRAY; + + pBuffer = AMF_EncodeInt32(pBuffer, pBufEnd, obj->o_num); + + for (i = 0; i < obj->o_num; i++) + { + char *res = AMFProp_Encode(&obj->o_props[i], pBuffer, pBufEnd); + if (res == NULL) + { + RTMP_Log(RTMP_LOGERROR, "AMF_Encode - failed to encode property in index %d", + i); + break; + } + else + { + pBuffer = res; + } + } + + if (pBuffer + 3 >= pBufEnd) + return NULL; /* no room for the end marker */ + + pBuffer = AMF_EncodeInt24(pBuffer, pBufEnd, AMF_OBJECT_END); + + return pBuffer; +} + +char * +AMF_EncodeArray(AMFObject *obj, char *pBuffer, char *pBufEnd) +{ + int i; + + if (pBuffer+4 >= pBufEnd) + return NULL; + + *pBuffer++ = AMF_STRICT_ARRAY; + + pBuffer = AMF_EncodeInt32(pBuffer, pBufEnd, obj->o_num); + + for (i = 0; i < obj->o_num; i++) + { + char *res = AMFProp_Encode(&obj->o_props[i], pBuffer, pBufEnd); + if (res == NULL) + { + RTMP_Log(RTMP_LOGERROR, "AMF_Encode - failed to encode property in index %d", + i); + break; + } + else + { + pBuffer = res; + } + } + + //if (pBuffer + 3 >= pBufEnd) + // return NULL; /* no room for the end marker */ + + //pBuffer = AMF_EncodeInt24(pBuffer, pBufEnd, AMF_OBJECT_END); + + return pBuffer; +} + int AMF_DecodeArray(AMFObject *obj, const char *pBuffer, int nSize, int nArrayLen, int bDecodeName) @@ -1125,7 +1209,7 @@ { if (nIndex >= 0) { - if (nIndex <= obj->o_num) + if (nIndex < obj->o_num) return &obj->o_props[nIndex]; } else
View file
rtmpdump-2.3.99.git20111114.tar.bz2/librtmp/amf.h -> rtmpdump-2.4.git20121102.tar.bz2/librtmp/amf.h
Changed
@@ -104,6 +104,9 @@ double AMF_DecodeNumber(const char *data); char *AMF_Encode(AMFObject * obj, char *pBuffer, char *pBufEnd); + char *AMF_EncodeEcmaArray(AMFObject *obj, char *pBuffer, char *pBufEnd); + char *AMF_EncodeArray(AMFObject *obj, char *pBuffer, char *pBufEnd); + int AMF_Decode(AMFObject * obj, const char *pBuffer, int nSize, int bDecodeName); int AMF_DecodeArray(AMFObject * obj, const char *pBuffer, int nSize,
View file
rtmpdump-2.3.99.git20111114.tar.bz2/librtmp/dh.h -> rtmpdump-2.4.git20121102.tar.bz2/librtmp/dh.h
Changed
@@ -61,7 +61,7 @@ MP_set(&dh->ctx.P, dh->p); MP_set(&dh->ctx.G, dh->g); dh->ctx.len = 128; - dhm_make_public(&dh->ctx, 1024, out, 1, havege_rand, &RTMP_TLS_ctx->hs); + dhm_make_public(&dh->ctx, 1024, out, 1, havege_random, &RTMP_TLS_ctx->hs); MP_new(dh->pub_key); MP_new(dh->priv_key); MP_set(dh->pub_key, &dh->ctx.GX); @@ -77,20 +77,21 @@ } #elif defined(USE_GNUTLS) -#include <gcrypt.h> -typedef gcry_mpi_t MP_t; -#define MP_new(m) m = gcry_mpi_new(1) -#define MP_set_w(mpi, w) gcry_mpi_set_ui(mpi, w) -#define MP_cmp(u, v) gcry_mpi_cmp(u, v) -#define MP_set(u, v) gcry_mpi_set(u, v) -#define MP_sub_w(mpi, w) gcry_mpi_sub_ui(mpi, mpi, w) -#define MP_cmp_1(mpi) gcry_mpi_cmp_ui(mpi, 1) -#define MP_modexp(r, y, q, p) gcry_mpi_powm(r, y, q, p) -#define MP_free(mpi) gcry_mpi_release(mpi) -#define MP_gethex(u, hex, res) res = (gcry_mpi_scan(&u, GCRYMPI_FMT_HEX, hex, 0, 0) == 0) -#define MP_bytes(u) (gcry_mpi_get_nbits(u) + 7) / 8 -#define MP_setbin(u,buf,len) gcry_mpi_print(GCRYMPI_FMT_USG,buf,len,NULL,u) -#define MP_getbin(u,buf,len) gcry_mpi_scan(&u,GCRYMPI_FMT_USG,buf,len,NULL) +#include <gmp.h> +#include <nettle/bignum.h> +typedef mpz_ptr MP_t; +#define MP_new(m) m = malloc(sizeof(*m)); mpz_init2(m, 1) +#define MP_set_w(mpi, w) mpz_set_ui(mpi, w) +#define MP_cmp(u, v) mpz_cmp(u, v) +#define MP_set(u, v) mpz_set(u, v) +#define MP_sub_w(mpi, w) mpz_sub_ui(mpi, mpi, w) +#define MP_cmp_1(mpi) mpz_cmp_ui(mpi, 1) +#define MP_modexp(r, y, q, p) mpz_powm(r, y, q, p) +#define MP_free(mpi) mpz_clear(mpi); free(mpi) +#define MP_gethex(u, hex, res) u = malloc(sizeof(*u)); mpz_init2(u, 1); res = (mpz_set_str(u, hex, 16) == 0) +#define MP_bytes(u) (mpz_sizeinbase(u, 2) + 7) / 8 +#define MP_setbin(u,buf,len) nettle_mpz_get_str_256(len,buf,u) +#define MP_getbin(u,buf,len) u = malloc(sizeof(*u)); mpz_init2(u, 1); nettle_mpz_set_str_256_u(u,len,buf) typedef struct MDH { MP_t p;
View file
rtmpdump-2.3.99.git20111114.tar.bz2/librtmp/handshake.h -> rtmpdump-2.4.git20121102.tar.bz2/librtmp/handshake.h
Changed
@@ -43,21 +43,24 @@ #define RC4_free(h) free(h) #elif defined(USE_GNUTLS) -#include <gcrypt.h> +#include <nettle/hmac.h> +#include <nettle/arcfour.h> #ifndef SHA256_DIGEST_LENGTH #define SHA256_DIGEST_LENGTH 32 #endif -#define HMAC_CTX gcry_md_hd_t -#define HMAC_setup(ctx, key, len) gcry_md_open(&ctx, GCRY_MD_SHA256, GCRY_MD_FLAG_HMAC); gcry_md_setkey(ctx, key, len) -#define HMAC_crunch(ctx, buf, len) gcry_md_write(ctx, buf, len) -#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; memcpy(dig, gcry_md_read(ctx, 0), dlen); gcry_md_close(ctx) - -typedef gcry_cipher_hd_t RC4_handle; -#define RC4_alloc(h) gcry_cipher_open(h, GCRY_CIPHER_ARCFOUR, GCRY_CIPHER_MODE_STREAM, 0) -#define RC4_setkey(h,l,k) gcry_cipher_setkey(h,k,l) -#define RC4_encrypt(h,l,d) gcry_cipher_encrypt(h,(void *)d,l,NULL,0) -#define RC4_encrypt2(h,l,s,d) gcry_cipher_encrypt(h,(void *)d,l,(void *)s,l) -#define RC4_free(h) gcry_cipher_close(h) +#undef HMAC_CTX +#define HMAC_CTX struct hmac_sha256_ctx +#define HMAC_setup(ctx, key, len) hmac_sha256_set_key(&ctx, len, key) +#define HMAC_crunch(ctx, buf, len) hmac_sha256_update(&ctx, len, buf) +#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(&ctx, SHA256_DIGEST_LENGTH, dig) +#define HMAC_close(ctx) + +typedef struct arcfour_ctx* RC4_handle; +#define RC4_alloc(h) *h = malloc(sizeof(struct arcfour_ctx)) +#define RC4_setkey(h,l,k) arcfour_set_key(h, l, k) +#define RC4_encrypt(h,l,d) arcfour_crypt(h,l,(uint8_t *)d,(uint8_t *)d) +#define RC4_encrypt2(h,l,s,d) arcfour_crypt(h,l,(uint8_t *)d,(uint8_t *)s) +#define RC4_free(h) free(h) #else /* USE_OPENSSL */ #include <openssl/sha.h>
View file
rtmpdump-2.3.99.git20111114.tar.bz2/librtmp/hashswf.c -> rtmpdump-2.4.git20121102.tar.bz2/librtmp/hashswf.c
Changed
@@ -42,16 +42,16 @@ #define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; sha2_hmac_finish(&ctx, dig) #define HMAC_close(ctx) #elif defined(USE_GNUTLS) -#include <gnutls/gnutls.h> -#include <gcrypt.h> +#include <nettle/hmac.h> #ifndef SHA256_DIGEST_LENGTH #define SHA256_DIGEST_LENGTH 32 #endif -#define HMAC_CTX gcry_md_hd_t -#define HMAC_setup(ctx, key, len) gcry_md_open(&ctx, GCRY_MD_SHA256, GCRY_MD_FLAG_HMAC); gcry_md_setkey(ctx, key, len) -#define HMAC_crunch(ctx, buf, len) gcry_md_write(ctx, buf, len) -#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; memcpy(dig, gcry_md_read(ctx, 0), dlen) -#define HMAC_close(ctx) gcry_md_close(ctx) +#undef HMAC_CTX +#define HMAC_CTX struct hmac_sha256_ctx +#define HMAC_setup(ctx, key, len) hmac_sha256_set_key(&ctx, len, key) +#define HMAC_crunch(ctx, buf, len) hmac_sha256_update(&ctx, len, buf) +#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(&ctx, SHA256_DIGEST_LENGTH, dig) +#define HMAC_close(ctx) #else /* USE_OPENSSL */ #include <openssl/ssl.h> #include <openssl/sha.h>
View file
rtmpdump-2.3.99.git20111114.tar.bz2/librtmp/parseurl.c -> rtmpdump-2.4.git20121102.tar.bz2/librtmp/parseurl.c
Changed
@@ -137,12 +137,14 @@ * application = app[/appinstance] */ - char *slash2, *slash3 = NULL; + char *slash2, *slash3 = NULL, *slash4 = NULL; int applen, appnamelen; slash2 = strchr(p, '/'); if(slash2) slash3 = strchr(slash2+1, '/'); + if(slash3) + slash4 = strchr(slash3+1, '/'); applen = end-p; /* ondemand, pass all parameters as app */ appnamelen = applen; /* ondemand length */ @@ -156,7 +158,9 @@ appnamelen = 8; } else { /* app!=ondemand, so app is app[/appinstance] */ - if(slash3) + if(slash4) + appnamelen = slash4-p; + else if(slash3) appnamelen = slash3-p; else if(slash2) appnamelen = slash2-p;
View file
rtmpdump-2.3.99.git20111114.tar.bz2/librtmp/rtmp.c -> rtmpdump-2.4.git20121102.tar.bz2/librtmp/rtmp.c
Changed
@@ -27,6 +27,7 @@ #include <stdlib.h> #include <string.h> #include <assert.h> +#include <time.h> #include "rtmp_sys.h" #include "log.h" @@ -34,11 +35,33 @@ #ifdef CRYPTO #ifdef USE_POLARSSL #include <polarssl/havege.h> +#include <polarssl/md5.h> +#include <polarssl/base64.h> +#define MD5_DIGEST_LENGTH 16 + +static const char *my_dhm_P = + "E4004C1F94182000103D883A448B3F80" \ + "2CE4B44A83301270002C20D0321CFD00" \ + "11CCEF784C26A400F43DFB901BCA7538" \ + "F2C6B176001CF5A0FD16D2C48B1D0C1C" \ + "F6AC8E1DA6BCC3B4E1F96B0564965300" \ + "FFA1D0B601EB2800F489AA512C4B248C" \ + "01F76949A60BB7F00A40B1EAB64BDD48" \ + "E8A700D60B7F1200FA8E77B0A979DABF"; + +static const char *my_dhm_G = "4"; + #elif defined(USE_GNUTLS) #include <gnutls/gnutls.h> +#define MD5_DIGEST_LENGTH 16 +#include <nettle/base64.h> +#include <nettle/md5.h> #else /* USE_OPENSSL */ #include <openssl/ssl.h> #include <openssl/rc4.h> +#include <openssl/md5.h> +#include <openssl/bio.h> +#include <openssl/buffer.h> #endif TLS_CTX RTMP_TLS_ctx; #endif @@ -227,6 +250,64 @@ #endif } +void * +RTMP_TLS_AllocServerContext(const char* cert, const char* key) +{ + void *ctx = NULL; +#ifdef CRYPTO + if (!RTMP_TLS_ctx) + RTMP_TLS_Init(); +#ifdef USE_POLARSSL + tls_server_ctx *tc = ctx = calloc(1, sizeof(struct tls_server_ctx)); + tc->dhm_P = my_dhm_P; + tc->dhm_G = my_dhm_G; + tc->hs = &RTMP_TLS_ctx->hs; + if (x509parse_crtfile(&tc->cert, cert)) { + free(tc); + return NULL; + } + if (x509parse_keyfile(&tc->key, key, NULL)) { + x509_free(&tc->cert); + free(tc); + return NULL; + } +#elif defined(USE_GNUTLS) && !defined(NO_SSL) + gnutls_certificate_allocate_credentials((gnutls_certificate_credentials*) &ctx); + if (gnutls_certificate_set_x509_key_file(ctx, cert, key, GNUTLS_X509_FMT_PEM) != 0) { + gnutls_certificate_free_credentials(ctx); + return NULL; + } +#elif !defined(NO_SSL) /* USE_OPENSSL */ + ctx = SSL_CTX_new(SSLv23_server_method()); + if (!SSL_CTX_use_certificate_chain_file(ctx, cert)) { + SSL_CTX_free(ctx); + return NULL; + } + if (!SSL_CTX_use_PrivateKey_file(ctx, key, SSL_FILETYPE_PEM)) { + SSL_CTX_free(ctx); + return NULL; + } +#endif +#endif + return ctx; +} + +void +RTMP_TLS_FreeServerContext(void *ctx) +{ +#ifdef CRYPTO +#ifdef USE_POLARSSL + x509_free(&((tls_server_ctx*)ctx)->cert); + rsa_free(&((tls_server_ctx*)ctx)->key); + free(ctx); +#elif defined(USE_GNUTLS) && !defined(NO_SSL) + gnutls_certificate_free_credentials(ctx); +#elif !defined(NO_SSL) /* USE_OPENSSL */ + SSL_CTX_free(ctx); +#endif +#endif +} + RTMP * RTMP_Alloc() { @@ -320,6 +401,31 @@ const AVal RTMP_DefaultFlashVer = { (char *)DEFAULT_FLASH_VER, sizeof(DEFAULT_FLASH_VER) - 1 }; +static void +SocksSetup(RTMP *r, AVal *sockshost) +{ + if (sockshost->av_len) + { + const char *socksport = strchr(sockshost->av_val, ':'); + char *hostname = strdup(sockshost->av_val); + + if (socksport) + hostname[socksport - sockshost->av_val] = '\0'; + r->Link.sockshost.av_val = hostname; + r->Link.sockshost.av_len = strlen(hostname); + + r->Link.socksport = socksport ? atoi(socksport + 1) : 1080; + RTMP_Log(RTMP_LOGDEBUG, "Connecting via SOCKS proxy: %s:%d", r->Link.sockshost.av_val, + r->Link.socksport); + } + else + { + r->Link.sockshost.av_val = NULL; + r->Link.sockshost.av_len = 0; + r->Link.socksport = 0; + } +} + void RTMP_SetupStream(RTMP *r, int protocol, @@ -384,26 +490,7 @@ } #endif - if (sockshost->av_len) - { - const char *socksport = strchr(sockshost->av_val, ':'); - char *hostname = strdup(sockshost->av_val); - - if (socksport) - hostname[socksport - sockshost->av_val] = '\0'; - r->Link.sockshost.av_val = hostname; - r->Link.sockshost.av_len = strlen(hostname); - - r->Link.socksport = socksport ? atoi(socksport + 1) : 1080; - RTMP_Log(RTMP_LOGDEBUG, "Connecting via SOCKS proxy: %s:%d", r->Link.sockshost.av_val, - r->Link.socksport); - } - else - { - r->Link.sockshost.av_val = NULL; - r->Link.sockshost.av_len = 0; - r->Link.socksport = 0; - } + SocksSetup(r, sockshost); if (tcUrl && tcUrl->av_len) r->Link.tcUrl = *tcUrl; @@ -499,6 +586,10 @@ "Buffer time in milliseconds" }, { AVC("timeout"), OFF(Link.timeout), OPT_INT, 0, "Session timeout in seconds" }, + { AVC("pubUser"), OFF(Link.pubUser), OPT_STR, 0, + "Publisher username" }, + { AVC("pubPasswd"), OFF(Link.pubPasswd), OPT_STR, 0, + "Publisher password" }, { {NULL,0}, 0, 0} }; @@ -756,6 +847,8 @@ (unsigned char *)r->Link.SWFHash, r->Link.swfAge); #endif + SocksSetup(r, &r->Link.sockshost); + if (r->Link.port == 0) { if (r->Link.protocol & RTMP_FEATURE_SSL) @@ -859,6 +952,23 @@ } int +RTMP_TLS_Accept(RTMP *r, void *ctx) +{ +#if defined(CRYPTO) && !defined(NO_SSL) + TLS_server(ctx, r->m_sb.sb_ssl); + TLS_setfd(r->m_sb.sb_ssl, r->m_sb.sb_socket); + if (TLS_accept(r->m_sb.sb_ssl) < 0) + { + RTMP_Log(RTMP_LOGERROR, "%s, TLS_Connect failed", __FUNCTION__); + return FALSE;
View file
rtmpdump-2.3.99.git20111114.tar.bz2/librtmp/rtmp.h -> rtmpdump-2.4.git20121102.tar.bz2/librtmp/rtmp.h
Changed
@@ -157,6 +157,8 @@ AVal subscribepath; AVal usherToken; AVal token; + AVal pubUser; + AVal pubPasswd; AMFObject extras; int edepth; @@ -176,6 +178,13 @@ int protocol; int timeout; /* connection timeout in seconds */ +#define RTMP_PUB_NAME 0x0001 /* send login to server */ +#define RTMP_PUB_RESP 0x0002 /* send salted password hash */ +#define RTMP_PUB_ALLOC 0x0004 /* allocated data for new tcUrl & app */ +#define RTMP_PUB_CLEAN 0x0008 /* need to free allocated data for newer tcUrl & app at exit */ +#define RTMP_PUB_CLATE 0x0010 /* late clean tcUrl & app at exit */ + int pFlags; + unsigned short socksport; unsigned short port; @@ -253,9 +262,11 @@ int m_numCalls; RTMP_METHOD *m_methodCalls; /* remote method calls queue */ - RTMPPacket *m_vecChannelsIn[RTMP_CHANNELS]; - RTMPPacket *m_vecChannelsOut[RTMP_CHANNELS]; - int m_channelTimestamp[RTMP_CHANNELS]; /* abs timestamp of last packet */ + int m_channelsAllocatedIn; + int m_channelsAllocatedOut; + RTMPPacket **m_vecChannelsIn; + RTMPPacket **m_vecChannelsOut; + int *m_channelTimestamp; /* abs timestamp of last packet */ double m_fAudioCodecs; /* audioCodecs for the connect packet */ double m_fVideoCodecs; /* videoCodecs for the connect packet */ @@ -307,6 +318,7 @@ int RTMP_Connect0(RTMP *r, struct sockaddr *svc); int RTMP_Connect1(RTMP *r, RTMPPacket *cp); int RTMP_Serve(RTMP *r); + int RTMP_TLS_Accept(RTMP *r, void *ctx); int RTMP_ReadPacket(RTMP *r, RTMPPacket *packet); int RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int queue); @@ -329,6 +341,9 @@ void RTMP_Free(RTMP *r); void RTMP_EnableWrite(RTMP *r); + void *RTMP_TLS_AllocServerContext(const char* cert, const char* key); + void RTMP_TLS_FreeServerContext(void *ctx); + int RTMP_LibVersion(void); void RTMP_UserInterrupt(void); /* user typed Ctrl-C */
View file
rtmpdump-2.3.99.git20111114.tar.bz2/librtmp/rtmp_sys.h -> rtmpdump-2.4.git20121102.tar.bz2/librtmp/rtmp_sys.h
Changed
@@ -61,21 +61,41 @@ #include "rtmp.h" #ifdef USE_POLARSSL +#include <polarssl/version.h> #include <polarssl/net.h> #include <polarssl/ssl.h> #include <polarssl/havege.h> +#if POLARSSL_VERSION_NUMBER < 0x01010000 +#define havege_random havege_rand +#endif typedef struct tls_ctx { havege_state hs; ssl_session ssn; } tls_ctx; +typedef struct tls_server_ctx { + havege_state *hs; + x509_cert cert; + rsa_context key; + ssl_session ssn; + const char *dhm_P, *dhm_G; +} tls_server_ctx; + #define TLS_CTX tls_ctx * #define TLS_client(ctx,s) s = malloc(sizeof(ssl_context)); ssl_init(s);\ ssl_set_endpoint(s, SSL_IS_CLIENT); ssl_set_authmode(s, SSL_VERIFY_NONE);\ - ssl_set_rng(s, havege_rand, &ctx->hs);\ + ssl_set_rng(s, havege_random, &ctx->hs);\ ssl_set_ciphersuites(s, ssl_default_ciphersuites);\ ssl_set_session(s, 1, 600, &ctx->ssn) +#define TLS_server(ctx,s) s = malloc(sizeof(ssl_context)); ssl_init(s);\ + ssl_set_endpoint(s, SSL_IS_SERVER); ssl_set_authmode(s, SSL_VERIFY_NONE);\ + ssl_set_rng(s, havege_random, ((tls_server_ctx*)ctx)->hs);\ + ssl_set_ciphersuites(s, ssl_default_ciphersuites);\ + ssl_set_session(s, 1, 600, &((tls_server_ctx*)ctx)->ssn);\ + ssl_set_own_cert(s, &((tls_server_ctx*)ctx)->cert, &((tls_server_ctx*)ctx)->key);\ + ssl_set_dh_param(s, ((tls_server_ctx*)ctx)->dhm_P, ((tls_server_ctx*)ctx)->dhm_G) #define TLS_setfd(s,fd) ssl_set_bio(s, net_recv, &fd, net_send, &fd) #define TLS_connect(s) ssl_handshake(s) +#define TLS_accept(s) ssl_handshake(s) #define TLS_read(s,b,l) ssl_read(s,(unsigned char *)b,l) #define TLS_write(s,b,l) ssl_write(s,(unsigned char *)b,l) #define TLS_shutdown(s) ssl_close_notify(s) @@ -89,8 +109,10 @@ } tls_ctx; #define TLS_CTX tls_ctx * #define TLS_client(ctx,s) gnutls_init((gnutls_session_t *)(&s), GNUTLS_CLIENT); gnutls_priority_set(s, ctx->prios); gnutls_credentials_set(s, GNUTLS_CRD_CERTIFICATE, ctx->cred) +#define TLS_server(ctx,s) gnutls_init((gnutls_session_t *)(&s), GNUTLS_SERVER); gnutls_priority_set_direct(s, "NORMAL", NULL); gnutls_credentials_set(s, GNUTLS_CRD_CERTIFICATE, ctx) #define TLS_setfd(s,fd) gnutls_transport_set_ptr(s, (gnutls_transport_ptr_t)(long)fd) #define TLS_connect(s) gnutls_handshake(s) +#define TLS_accept(s) gnutls_handshake(s) #define TLS_read(s,b,l) gnutls_record_recv(s,b,l) #define TLS_write(s,b,l) gnutls_record_send(s,b,l) #define TLS_shutdown(s) gnutls_bye(s, GNUTLS_SHUT_RDWR) @@ -99,8 +121,10 @@ #else /* USE_OPENSSL */ #define TLS_CTX SSL_CTX * #define TLS_client(ctx,s) s = SSL_new(ctx) +#define TLS_server(ctx,s) s = SSL_new(ctx) #define TLS_setfd(s,fd) SSL_set_fd(s,fd) #define TLS_connect(s) SSL_connect(s) +#define TLS_accept(s) SSL_accept(s) #define TLS_read(s,b,l) SSL_read(s,b,l) #define TLS_write(s,b,l) SSL_write(s,b,l) #define TLS_shutdown(s) SSL_shutdown(s)
View file
rtmpdump-2.3.99.git20111114.tar.bz2/rtmpdump.1 -> rtmpdump-2.4.git20121102.tar.bz2/rtmpdump.1
Changed
@@ -1,4 +1,4 @@ -.TH RTMPDUMP 1 "2011-07-20" "RTMPDump v2.4" +.TH RTMPDUMP 1 "2012-07-24" "RTMPDump v2.4" .\" Copyright 2011 Howard Chu. .\" Copying permitted according to the GNU General Public License V2. .SH NAME @@ -177,6 +177,12 @@ Name of live stream to subscribe to. Defaults to .IR playpath . .TP +.B \-\-realtime \-R +Download approximately in realtime, without attempting to speed up via +Pause/Unpause commands ("the BUFX hack"). +Useful for servers that jump backwards in time at the Unpause command. +Resuming and seeking in realtime streams is still possible. +.TP .B \-\-resume \-e Resume an incomplete RTMP download. .TP
View file
rtmpdump-2.3.99.git20111114.tar.bz2/rtmpdump.1.html -> rtmpdump-2.4.git20121102.tar.bz2/rtmpdump.1.html
Changed
@@ -6,7 +6,7 @@ <tr><td>RTMPDUMP(1)<td align="center"><td align="right">RTMPDUMP(1) </thead> <tfoot> -<tr><td>RTMPDump v2.4<td align="center">2011-07-20<td align="right">RTMPDUMP(1) +<tr><td>RTMPDump v2.4<td align="center">2012-07-24<td align="right">RTMPDUMP(1) </tfoot> <tbody><tr><td colspan="3"><br><br><ul> <!-- Copyright 2011 Howard Chu. @@ -34,6 +34,7 @@ [<b>−y</b><i> playpath</i>] [<b>−Y</b>] [<b>−v</b>] +[<b>−R</b>] [<b>−d</b><i> subscription</i>] [<b>−e</b>] [<b>−k</b><i> skip</i>] @@ -218,6 +219,15 @@ </dl> <p> <dl compact><dt> +<b>−−realtime −R</b> +<dd> +Download approximately in realtime, without attempting to speed up via +Pause/Unpause commands ("the BUFX hack"). +Useful for servers that jump backwards in time at the Unpause command. +Resuming and seeking in realtime streams is still possible. +</dl> +<p> +<dl compact><dt> <b>−−resume −e</b> <dd> Resume an incomplete RTMP download.
View file
rtmpdump-2.3.99.git20111114.tar.bz2/rtmpdump.c -> rtmpdump-2.4.git20121102.tar.bz2/rtmpdump.c
Changed
@@ -441,7 +441,7 @@ int Download(RTMP * rtmp, // connected RTMP object - FILE * file, uint32_t dSeek, uint32_t dStopOffset, double duration, int bResume, char *metaHeader, uint32_t nMetaHeaderSize, char *initialFrame, int initialFrameType, uint32_t nInitialFrameSize, int nSkipKeyFrames, int bStdoutMode, int bLiveStream, int bHashes, int bOverrideBufferTime, uint32_t bufferTime, double *percent) // percentage downloaded [out] + FILE * file, uint32_t dSeek, uint32_t dStopOffset, double duration, int bResume, char *metaHeader, uint32_t nMetaHeaderSize, char *initialFrame, int initialFrameType, uint32_t nInitialFrameSize, int nSkipKeyFrames, int bStdoutMode, int bLiveStream, int bRealtimeStream, int bHashes, int bOverrideBufferTime, uint32_t bufferTime, double *percent) // percentage downloaded [out] { int32_t now, lastUpdate; int bufferSize = 64 * 1024; @@ -492,6 +492,8 @@ bResume ? "Resuming" : "Starting", (double) size / 1024.0); } + if (bRealtimeStream) + RTMP_LogPrintf(" in approximately realtime (disabled BUFX speedup hack)\n"); } if (dStopOffset > 0) @@ -578,12 +580,14 @@ } } } -#ifdef _DEBUG else { +#ifdef _DEBUG RTMP_Log(RTMP_LOGDEBUG, "zero read!"); - } #endif + if (rtmp->m_read.status == RTMP_READ_EOF) + break; + } } while (!RTMP_ctrlC && nRead > -1 && RTMP_IsConnected(rtmp) && !RTMP_IsTimedout(rtmp)); @@ -638,6 +642,8 @@ ("\n%s: This program dumps the media content streamed over RTMP.\n\n", prog); RTMP_LogPrintf("--help|-h Prints this help screen.\n"); RTMP_LogPrintf + ("--url|-i url URL with options included (e.g. rtmp://host[:port]/path swfUrl=url tcUrl=url)\n"); + RTMP_LogPrintf ("--rtmp|-r url URL (e.g. rtmp://host[:port]/path)\n"); RTMP_LogPrintf ("--host|-n hostname Overrides the hostname in the rtmp url\n"); @@ -682,6 +688,8 @@ RTMP_LogPrintf ("--subscribe|-d string Stream name to subscribe to (otherwise defaults to playpath if live is specifed)\n"); RTMP_LogPrintf + ("--realtime|-R Don't attempt to speed up download via the Pause/Unpause BUFX hack\n"); + RTMP_LogPrintf ("--flv|-o string FLV output file name, if the file name is - print stream to stdout\n"); RTMP_LogPrintf ("--resume|-e Resume a partial RTMP download\n"); @@ -748,6 +756,7 @@ int protocol = RTMP_PROTOCOL_UNDEFINED; int retries = 0; int bLiveStream = FALSE; // is it a live stream? then we can't seek/resume + int bRealtimeStream = FALSE; // If true, disable the BUFX hack (be patient) int bHashes = FALSE; // display byte counters not hashes by default long int timeout = DEF_TIMEOUT; // timeout connection after 120 seconds @@ -755,6 +764,7 @@ uint32_t dStopOffset = 0; RTMP rtmp = { 0 }; + AVal fullUrl = { 0, 0 }; AVal swfUrl = { 0, 0 }; AVal tcUrl = { 0, 0 }; AVal pageUrl = { 0, 0 }; @@ -817,6 +827,7 @@ {"protocol", 1, NULL, 'l'}, {"playpath", 1, NULL, 'y'}, {"playlist", 0, NULL, 'Y'}, + {"url", 1, NULL, 'i'}, {"rtmp", 1, NULL, 'r'}, {"swfUrl", 1, NULL, 's'}, {"tcUrl", 1, NULL, 't'}, @@ -832,6 +843,7 @@ #endif {"flashVer", 1, NULL, 'f'}, {"live", 0, NULL, 'v'}, + {"realtime", 0, NULL, 'R'}, {"flv", 1, NULL, 'o'}, {"resume", 0, NULL, 'e'}, {"timeout", 1, NULL, 'm'}, @@ -851,7 +863,7 @@ while ((opt = getopt_long(argc, argv, - "hVveqzr:s:t:p:a:b:f:o:u:C:n:c:l:y:Ym:k:d:A:B:T:w:x:W:X:S:#j:", + "hVveqzRr:s:t:i:p:a:b:f:o:u:C:n:c:l:y:Ym:k:d:A:B:T:w:x:W:X:S:#j:", longopts, NULL)) != -1) { switch (opt) @@ -936,6 +948,9 @@ case 'v': bLiveStream = TRUE; // no seeking or resuming possible! break; + case 'R': + bRealtimeStream = TRUE; // seeking and resuming is still possible + break; case 'd': STR2AVAL(subscribepath, optarg); break; @@ -991,6 +1006,9 @@ } break; } + case 'i': + STR2AVAL(fullUrl, optarg); + break; case 's': STR2AVAL(swfUrl, optarg); break; @@ -1069,32 +1087,32 @@ } } - if (!hostname.av_len) + if (!hostname.av_len && !fullUrl.av_len) { RTMP_Log(RTMP_LOGERROR, "You must specify a hostname (--host) or url (-r \"rtmp://host[:port]/playpath\") containing a hostname"); return RD_FAILED; } - if (playpath.av_len == 0) + if (playpath.av_len == 0 && !fullUrl.av_len) { RTMP_Log(RTMP_LOGERROR, "You must specify a playpath (--playpath) or url (-r \"rtmp://host[:port]/playpath\") containing a playpath"); return RD_FAILED; } - if (protocol == RTMP_PROTOCOL_UNDEFINED) + if (protocol == RTMP_PROTOCOL_UNDEFINED && !fullUrl.av_len) { RTMP_Log(RTMP_LOGWARNING, "You haven't specified a protocol (--protocol) or rtmp url (-r), using default protocol RTMP"); protocol = RTMP_PROTOCOL_RTMP; } - if (port == -1) + if (port == -1 && !fullUrl.av_len) { RTMP_Log(RTMP_LOGWARNING, "You haven't specified a port (--port) or rtmp url (-r), using default port 1935"); port = 0; } - if (port == 0) + if (port == 0 && !fullUrl.av_len) { if (protocol & RTMP_FEATURE_SSL) port = 443; @@ -1176,12 +1194,23 @@ } } - RTMP_SetupStream(&rtmp, protocol, &hostname, port, &sockshost, &playpath, - &tcUrl, &swfUrl, &pageUrl, &app, &auth, &swfHash, swfSize, - &flashVer, &subscribepath, &usherToken, dSeek, dStopOffset, bLiveStream, timeout); + if (!fullUrl.av_len) + { + RTMP_SetupStream(&rtmp, protocol, &hostname, port, &sockshost, &playpath, + &tcUrl, &swfUrl, &pageUrl, &app, &auth, &swfHash, swfSize, + &flashVer, &subscribepath, &usherToken, dSeek, dStopOffset, bLiveStream, timeout); + } + else + { + if (RTMP_SetupURL(&rtmp, fullUrl.av_val) == FALSE) + { + RTMP_Log(RTMP_LOGERROR, "Couldn't parse URL: %s", fullUrl.av_val); + return RD_FAILED; + } + } /* Try to keep the stream moving if it pauses on us */ - if (!bLiveStream && !(protocol & RTMP_FEATURE_HTTP)) + if (!bLiveStream && !bRealtimeStream && !(protocol & RTMP_FEATURE_HTTP)) rtmp.Link.lFlags |= RTMP_LF_BUFX; off_t size = 0; @@ -1348,8 +1377,8 @@ nStatus = Download(&rtmp, file, dSeek, dStopOffset, duration, bResume, metaHeader, nMetaHeaderSize, initialFrame, - initialFrameType, nInitialFrameSize, - nSkipKeyFrames, bStdoutMode, bLiveStream, bHashes, + initialFrameType, nInitialFrameSize, nSkipKeyFrames, + bStdoutMode, bLiveStream, bRealtimeStream, bHashes, bOverrideBufferTime, bufferTime, &percent); free(initialFrame); initialFrame = NULL;
View file
rtmpdump-2.3.99.git20111114.tar.bz2/rtmpgw.c -> rtmpdump-2.4.git20121102.tar.bz2/rtmpgw.c
Changed
@@ -85,6 +85,7 @@ uint32_t bufferTime; char *rtmpurl; + AVal fullUrl; AVal playpath; AVal swfUrl; AVal tcUrl; @@ -469,14 +470,14 @@ } // do necessary checks right here to make sure the combined request of default values and GET parameters is correct - if (!req.hostname.av_len) + if (!req.hostname.av_len && !req.fullUrl.av_len) { RTMP_Log(RTMP_LOGERROR, "You must specify a hostname (--host) or url (-r \"rtmp://host[:port]/playpath\") containing a hostname"); status = "400 Missing Hostname"; goto filenotfound; } - if (req.playpath.av_len == 0) + if (req.playpath.av_len == 0 && !req.fullUrl.av_len) { RTMP_Log(RTMP_LOGERROR, "You must specify a playpath (--playpath) or url (-r \"rtmp://host[:port]/playpath\") containing a playpath"); @@ -484,19 +485,19 @@ goto filenotfound;; } - if (req.protocol == RTMP_PROTOCOL_UNDEFINED) + if (req.protocol == RTMP_PROTOCOL_UNDEFINED && !req.fullUrl.av_len) { RTMP_Log(RTMP_LOGWARNING, "You haven't specified a protocol (--protocol) or rtmp url (-r), using default protocol RTMP"); req.protocol = RTMP_PROTOCOL_RTMP; } - if (req.rtmpport == -1) + if (req.rtmpport == -1 && !req.fullUrl.av_len) { RTMP_Log(RTMP_LOGWARNING, "You haven't specified a port (--port) or rtmp url (-r), using default port"); req.rtmpport = 0; } - if (req.rtmpport == 0) + if (req.rtmpport == 0 && !req.fullUrl.av_len) { if (req.protocol & RTMP_FEATURE_SSL) req.rtmpport = 443; @@ -552,9 +553,20 @@ RTMP_Log(RTMP_LOGDEBUG, "Setting buffer time to: %dms", req.bufferTime); RTMP_Init(&rtmp); RTMP_SetBufferMS(&rtmp, req.bufferTime); - RTMP_SetupStream(&rtmp, req.protocol, &req.hostname, req.rtmpport, &req.sockshost, - &req.playpath, &req.tcUrl, &req.swfUrl, &req.pageUrl, &req.app, &req.auth, &req.swfHash, req.swfSize, &req.flashVer, &req.subscribepath, &req.usherToken, dSeek, req.dStopOffset, - req.bLiveStream, req.timeout); + if (!req.fullUrl.av_len) + { + RTMP_SetupStream(&rtmp, req.protocol, &req.hostname, req.rtmpport, &req.sockshost, + &req.playpath, &req.tcUrl, &req.swfUrl, &req.pageUrl, &req.app, &req.auth, &req.swfHash, req.swfSize, &req.flashVer, &req.subscribepath, &req.usherToken, dSeek, req.dStopOffset, + req.bLiveStream, req.timeout); + } + else + { + if (RTMP_SetupURL(&rtmp, req.fullUrl.av_val) == FALSE) + { + RTMP_Log(RTMP_LOGERROR, "Couldn't parse URL: %s", req.fullUrl.av_val); + return; + } + } /* backward compatibility, we always sent this as true before */ if (req.auth.av_len) rtmp.Link.lFlags |= RTMP_LF_AUTH; @@ -908,6 +920,9 @@ } break; } + case 'i': + STR2AVAL(req->fullUrl, arg); + break; case 's': STR2AVAL(req->swfUrl, arg); break; @@ -927,7 +942,7 @@ STR2AVAL(req->auth, arg); break; case 'C': - parseAMF(&req->extras, optarg, &req->edepth); + parseAMF(&req->extras, arg, &req->edepth); break; case 'm': req->timeout = atoi(arg); @@ -993,6 +1008,7 @@ int opt; struct option longopts[] = { {"help", 0, NULL, 'h'}, + {"url", 1, NULL, 'i'}, {"host", 1, NULL, 'n'}, {"port", 1, NULL, 'c'}, {"socks", 1, NULL, 'S'}, @@ -1040,7 +1056,7 @@ while ((opt = getopt_long(argc, argv, - "hvqVzr:s:t:p:a:f:u:n:c:l:y:m:d:D:A:B:T:g:w:x:W:X:S:j:", longopts, + "hvqVzr:s:t:i:p:a:f:u:n:c:l:y:m:d:D:A:B:T:g:w:x:W:X:S:j:", longopts, NULL)) != -1) { switch (opt) @@ -1050,6 +1066,8 @@ ("\nThis program serves media content streamed from RTMP onto HTTP.\n\n"); RTMP_LogPrintf("--help|-h Prints this help screen.\n"); RTMP_LogPrintf + ("--url|-i url URL with options included (e.g. rtmp://host[:port]/path swfUrl=url tcUrl=url)\n"); + RTMP_LogPrintf ("--rtmp|-r url URL (e.g. rtmp://host[:port]/path)\n"); RTMP_LogPrintf ("--host|-n hostname Overrides the hostname in the rtmp url\n");
View file
rtmpdump-2.3.99.git20111114.tar.bz2/rtmpsrv.c -> rtmpdump-2.4.git20121102.tar.bz2/rtmpsrv.c
Changed
@@ -92,6 +92,7 @@ } STREAMING_SERVER; STREAMING_SERVER *rtmpServer = 0; // server structure pointer +void *sslCtx = NULL; STREAMING_SERVER *startStreaming(const char *address, int port); void stopStreaming(STREAMING_SERVER * server); @@ -223,9 +224,6 @@ *enc++ = 0; *enc++ = 0; *enc++ = AMF_OBJECT_END; - *enc++ = 0; - *enc++ = 0; - *enc++ = AMF_OBJECT_END; packet.m_nBodySize = enc - packet.m_body; @@ -770,47 +768,40 @@ switch (packet->m_packetType) { - case 0x01: - // chunk size + case RTMP_PACKET_TYPE_CHUNK_SIZE: // HandleChangeChunkSize(r, packet); break; - case 0x03: - // bytes read report + case RTMP_PACKET_TYPE_BYTES_READ_REPORT: break; - case 0x04: - // ctrl + case RTMP_PACKET_TYPE_CONTROL: // HandleCtrl(r, packet); break; - case 0x05: - // server bw + case RTMP_PACKET_TYPE_SERVER_BW: // HandleServerBW(r, packet); break; - case 0x06: - // client bw + case RTMP_PACKET_TYPE_CLIENT_BW: // HandleClientBW(r, packet); break; - case 0x08: - // audio data + case RTMP_PACKET_TYPE_AUDIO: //RTMP_Log(RTMP_LOGDEBUG, "%s, received: audio %lu bytes", __FUNCTION__, packet.m_nBodySize); break; - case 0x09: - // video data + case RTMP_PACKET_TYPE_VIDEO: //RTMP_Log(RTMP_LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize); break; - case 0x0F: // flex stream send + case RTMP_PACKET_TYPE_FLEX_STREAM_SEND: break; - case 0x10: // flex shared object + case RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT: break; - case 0x11: // flex message + case RTMP_PACKET_TYPE_FLEX_MESSAGE: { RTMP_Log(RTMP_LOGDEBUG, "%s, flex message, size %u bytes, not fully supported", __FUNCTION__, packet->m_nBodySize); @@ -830,16 +821,13 @@ RTMP_Close(r); break; } - case 0x12: - // metadata (notify) + case RTMP_PACKET_TYPE_INFO: break; - case 0x13: - /* shared object */ + case RTMP_PACKET_TYPE_SHARED_OBJECT: break; - case 0x14: - // invoke + case RTMP_PACKET_TYPE_INVOKE: RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %u bytes", __FUNCTION__, packet->m_nBodySize); //RTMP_LogHex(packet.m_body, packet.m_nBodySize); @@ -848,8 +836,7 @@ RTMP_Close(r); break; - case 0x16: - /* flv */ + case RTMP_PACKET_TYPE_FLASH_VIDEO: break; default: RTMP_Log(RTMP_LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__, @@ -889,7 +876,7 @@ { server->state = STREAMING_IN_PROGRESS; - RTMP rtmp = { 0 }; /* our session with the real client */ + RTMP *rtmp = RTMP_Alloc(); /* our session with the real client */ RTMPPacket packet = { 0 }; // timeout for http requests @@ -909,38 +896,44 @@ } else { - RTMP_Init(&rtmp); - rtmp.m_sb.sb_socket = sockfd; - if (!RTMP_Serve(&rtmp)) + RTMP_Init(rtmp); + rtmp->m_sb.sb_socket = sockfd; + if (sslCtx && !RTMP_TLS_Accept(rtmp, sslCtx)) + { + RTMP_Log(RTMP_LOGERROR, "TLS handshake failed"); + goto cleanup; + } + if (!RTMP_Serve(rtmp)) { RTMP_Log(RTMP_LOGERROR, "Handshake failed"); goto cleanup; } } server->arglen = 0; - while (RTMP_IsConnected(&rtmp) && RTMP_ReadPacket(&rtmp, &packet)) + while (RTMP_IsConnected(rtmp) && RTMP_ReadPacket(rtmp, &packet)) { if (!RTMPPacket_IsReady(&packet)) continue; - ServePacket(server, &rtmp, &packet); + ServePacket(server, rtmp, &packet); RTMPPacket_Free(&packet); } cleanup: RTMP_LogPrintf("Closing connection... "); - RTMP_Close(&rtmp); + RTMP_Close(rtmp); /* Should probably be done by RTMP_Close() ... */ - rtmp.Link.playpath.av_val = NULL; - rtmp.Link.tcUrl.av_val = NULL; - rtmp.Link.swfUrl.av_val = NULL; - rtmp.Link.pageUrl.av_val = NULL; - rtmp.Link.app.av_val = NULL; - rtmp.Link.flashVer.av_val = NULL; - if (rtmp.Link.usherToken.av_val) + rtmp->Link.playpath.av_val = NULL; + rtmp->Link.tcUrl.av_val = NULL; + rtmp->Link.swfUrl.av_val = NULL; + rtmp->Link.pageUrl.av_val = NULL; + rtmp->Link.app.av_val = NULL; + rtmp->Link.flashVer.av_val = NULL; + if (rtmp->Link.usherToken.av_val) { - free(rtmp.Link.usherToken.av_val); - rtmp.Link.usherToken.av_val = NULL; + free(rtmp->Link.usherToken.av_val); + rtmp->Link.usherToken.av_val = NULL; } + RTMP_Free(rtmp); RTMP_LogPrintf("done!\n\n"); quit: @@ -1074,20 +1067,32 @@ main(int argc, char **argv) { int nStatus = RD_SUCCESS; + int i; // http streaming server char DEFAULT_HTTP_STREAMING_DEVICE[] = "0.0.0.0"; // 0.0.0.0 is any device char *rtmpStreamingDevice = DEFAULT_HTTP_STREAMING_DEVICE; // streaming device, default 0.0.0.0 int nRtmpStreamingPort = 1935; // port + char *cert = NULL, *key = NULL; RTMP_LogPrintf("RTMP Server %s\n", RTMPDUMP_VERSION); RTMP_LogPrintf("(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL\n\n"); RTMP_debuglevel = RTMP_LOGINFO; - if (argc > 1 && !strcmp(argv[1], "-z")) - RTMP_debuglevel = RTMP_LOGALL; + for (i = 1; i < argc; i++) + { + if (!strcmp(argv[i], "-z")) + RTMP_debuglevel = RTMP_LOGALL; + else if (!strcmp(argv[i], "-c") && i + 1 < argc)
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.