Copyright 2009 Howard Chu
Copyright 2009 The Flvstreamer Team
-16 December 2009, v2.x
+29 December 2009, v2.x
+- AMF cleanup: bounds checking for all encoders, moved AMF_EncodeNamed* from rtmp.c
+- added SecureToken support
+- added automatic SWF hash calculation
+- added server-side handshake processing
+- added rtmpsrv stub server example
+- added rtmpsuck proxy server
+- tweaks for logging
+- renamed more functions to cleanup namespace for library use
+- tweaks for server operation: objectEncoding, chunksize changes
+
+16 December 2009, v2.0
- rewrote everything else in C, reorganized to make it usable again as a library
- fixed more portability bugs
- plugged memory leaks
11 Mar 2009, v1.4
- fixed resume bug: when the server switches between audio/video packets and FLV
-chunk packets (why should a server want to do that? some actually do!) and rtmpdump
+chunk packets (why should a server want to do that? some actually do!) and rtmpdump
was invoked with --resume the keyframe check prevented rtmpdump from continuing
- fixed endianness
clean:
rm -f *.o rtmpdump$(EXT) streams$(EXT)
-streams: log.o rtmp.o amf.o streams.o parseurl.o swfvfy.o
+streams: log.o rtmp.o amf.o streams.o parseurl.o hashswf.o
$(CC) $(LDFLAGS) $^ -o $@$(EXT) $(SLIBS)
-rtmpdump: log.o rtmp.o amf.o rtmpdump.o parseurl.o swfvfy.o
+rtmpdump: log.o rtmp.o amf.o rtmpdump.o parseurl.o hashswf.o
$(CC) $(LDFLAGS) $^ -o $@$(EXT) $(LIBS)
rtmpsrv: log.o rtmp.o amf.o rtmpsrv.o
$(CC) $(LDFLAGS) $^ -o $@$(EXT) $(SLIBS)
-rtmpsuck: log.o rtmp.o amf.o rtmpsuck.o swfvfy.o
+rtmpsuck: log.o rtmp.o amf.o rtmpsuck.o hashswf.o
$(CC) $(LDFLAGS) $^ -o $@$(EXT) $(SLIBS)
log.o: log.c log.h Makefile
parseurl.o: parseurl.c parseurl.h log.h Makefile
-streams.o: streams.c rtmp.h log.h swfvfy.o Makefile
+streams.o: streams.c rtmp.h log.h hashswf.o Makefile
rtmp.o: rtmp.c rtmp.h handshake.h dh.h log.h amf.h Makefile
amf.o: amf.c amf.h bytes.h log.h Makefile
rtmpdump.o: rtmpdump.c rtmp.h log.h amf.h Makefile
rtmpsrv.o: rtmpsrv.c rtmp.h log.h amf.h Makefile
-swfvfy.o: swfvfy.c
+hashswf.o: hashswf.c
#include <arpa/inet.h>
#endif
+#include "rtmp.h"
+
#include <openssl/sha.h>
#include <openssl/hmac.h>
#include <zlib.h>
#define HEX2BIN(a) (((a)&0x40)?((a)&0xf)+9:((a)&0xf))
int
-SWFVerify(const char *url, unsigned int *size, unsigned char *hash, int ask)
+RTMP_HashSWF(const char *url, unsigned int *size, unsigned char *hash, int ask)
{
FILE *f = NULL;
char *path, *home, date[64];
bool RTMP_FindFirstMatchingProperty(AMFObject *obj, const AVal *name,
AMFObjectProperty *p);
+#ifdef CRYPTO
+/* hashswf.c */
+#define HASHLEN 32
+
+int RTMP_HashSWF(const char *url, unsigned int *size, unsigned char *hash, int ask);
+#endif
#endif
#include "log.h"
#include "parseurl.h"
-#ifdef CRYPTO
-#define HASHLEN 32
-extern int SWFVerify(const char *url, unsigned int *size, unsigned char *hash, int ask);
-#endif
-
#define RTMPDUMP_VERSION "v2.0"
#define RD_SUCCESS 0
}
case 'W':
STR2AVAL(swfUrl, optarg);
- if (SWFVerify(optarg, &swfSize, hash, 1) == 0)
+ if (RTMP_HashSWF(optarg, &swfSize, hash, 1) == 0)
{
swfHash.av_val = (char *)hash;
swfHash.av_len = HASHLEN;
#include <pthread.h>
#endif
-#ifdef CRYPTO
-#define HASHLEN 32
-extern int SWFVerify(const char *url, unsigned int *size, unsigned char *hash, int ask);
-#endif
-
#define RTMPDUMP_PROXY_VERSION "v2.0"
#define RD_SUCCESS 0
{
unsigned char hash[HASHLEN];
server->rc.Link.swfUrl = pval;
- if (SWFVerify(pval.av_val, &server->rc.Link.SWFSize, hash, 0) == 0)
+ if (RTMP_HashSWF(pval.av_val, &server->rc.Link.SWFSize, hash, 0) == 0)
{
server->rc.Link.SWFHash.av_val = malloc(HASHLEN);
memcpy(server->rc.Link.SWFHash.av_val, hash, HASHLEN);
#include <pthread.h>
#endif
-#ifdef CRYPTO
-#define HASHLEN 32
-extern int SWFVerify(const char *url, unsigned int *size, unsigned char *hash, int ask);
-#endif
-
#define RTMPDUMP_STREAMS_VERSION "v2.0"
#define RD_SUCCESS 0
unsigned char hash[HASHLEN];
STR2AVAL(req->swfUrl, arg);
- if (SWFVerify(arg, &req->swfSize, hash, 1) == 0)
+ if (RTMP_HashSWF(arg, &req->swfSize, hash, 1) == 0)
{
req->swfHash.av_val = malloc(HASHLEN);
req->swfHash.av_len = HASHLEN;