comparison src/librtmp-1-v2.4.patch @ 2586:5136e4e6e487

package librtmp: update to v2.4 and beyond Includes nettle support.
author Mark Brand <mabrand@mabrand.nl>
date Wed, 13 Jun 2012 13:58:03 +0200
parents
children
comparison
equal deleted inserted replaced
2585:42c0a3b89b06 2586:5136e4e6e487
1 From 272a91d06d71c2a326996f62797ed9ab42f69859 Mon Sep 17 00:00:00 2001
2 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
3 Date: Wed, 30 Jun 2010 22:34:59 +0000
4 Subject: [PATCH 01/34] zlib dependency is only when CRYPTO is enabled
5
6 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@536 400ebc74-4327-4243-bc38-086b20814532
7 ---
8 Makefile | 9 +++++----
9 librtmp/hashswf.c | 4 ++--
10 2 files changed, 7 insertions(+), 6 deletions(-)
11
12 diff --git a/Makefile b/Makefile
13 index 7470eb4..c7767b4 100644
14 --- a/Makefile
15 +++ b/Makefile
16 @@ -11,9 +11,10 @@ SYS=posix
17 CRYPTO=OPENSSL
18 #CRYPTO=POLARSSL
19 #CRYPTO=GNUTLS
20 -LIB_GNUTLS=-lgnutls -lgcrypt
21 -LIB_OPENSSL=-lssl -lcrypto
22 -LIB_POLARSSL=-lpolarssl
23 +LIBZ=-lz
24 +LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
25 +LIB_OPENSSL=-lssl -lcrypto$ (LIBZ)
26 +LIB_POLARSSL=-lpolarssl $(LIBZ)
27 CRYPTO_LIB=$(LIB_$(CRYPTO))
28 DEF_=-DNO_CRYPTO
29 CRYPTO_DEF=$(DEF_$(CRYPTO))
30 @@ -33,7 +34,7 @@ MANDIR=$(DESTDIR)$(mandir)
31
32 LIBS_posix=
33 LIBS_mingw=-lws2_32 -lwinmm -lgdi32
34 -LIBS=$(CRYPTO_LIB) -lz $(LIBS_$(SYS)) $(XLIBS)
35 +LIBS=$(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
36
37 THREADLIB_posix=-lpthread
38 THREADLIB_mingw=
39 diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
40 index 06d2bbb..277f21c 100644
41 --- a/librtmp/hashswf.c
42 +++ b/librtmp/hashswf.c
43 @@ -66,10 +66,10 @@
44 extern void RTMP_TLS_Init();
45 extern TLS_CTX RTMP_TLS_ctx;
46
47 -#endif /* CRYPTO */
48 -
49 #include <zlib.h>
50
51 +#endif /* CRYPTO */
52 +
53 #define AGENT "Mozilla/5.0"
54
55 HTTPResult
56 --
57 1.7.10.4
58
59
60 From 6556b9f9328acb1199dc1cc3f22fa82c86b51c8a Mon Sep 17 00:00:00 2001
61 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
62 Date: Thu, 1 Jul 2010 12:00:43 +0000
63 Subject: [PATCH 02/34] Fix typo
64
65 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@537 400ebc74-4327-4243-bc38-086b20814532
66 ---
67 Makefile | 2 +-
68 1 file changed, 1 insertion(+), 1 deletion(-)
69
70 diff --git a/Makefile b/Makefile
71 index c7767b4..1fcdd78 100644
72 --- a/Makefile
73 +++ b/Makefile
74 @@ -13,7 +13,7 @@ CRYPTO=OPENSSL
75 #CRYPTO=GNUTLS
76 LIBZ=-lz
77 LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
78 -LIB_OPENSSL=-lssl -lcrypto$ (LIBZ)
79 +LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
80 LIB_POLARSSL=-lpolarssl $(LIBZ)
81 CRYPTO_LIB=$(LIB_$(CRYPTO))
82 DEF_=-DNO_CRYPTO
83 --
84 1.7.10.4
85
86
87 From 8a5901c8a74280c898deb4ebf1a2f5d6f68bce42 Mon Sep 17 00:00:00 2001
88 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
89 Date: Sat, 3 Jul 2010 10:25:48 +0000
90 Subject: [PATCH 03/34] Document the escape coding used for special characters
91 in values
92
93 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@538 400ebc74-4327-4243-bc38-086b20814532
94 ---
95 librtmp/librtmp.3 | 11 ++++++++---
96 1 file changed, 8 insertions(+), 3 deletions(-)
97
98 diff --git a/librtmp/librtmp.3 b/librtmp/librtmp.3
99 index 055b52b..a5a7558 100644
100 --- a/librtmp/librtmp.3
101 +++ b/librtmp/librtmp.3
102 @@ -57,14 +57,19 @@ The session handle is freed using
103 .BR RTMP_Free ().
104
105 All data is transferred using FLV format. The basic session requires
106 -an RTMP URL. Additional options may be specified by appending
107 -space-separated key=value pairs to the URL. The RTMP URL format
108 -is of the form
109 +an RTMP URL. The RTMP URL format is of the form
110 .nf
111 rtmp[t][e|s]://hostname[:port][/app[/playpath]]
112 .fi
113
114 Plain rtmp, as well as tunneled and encrypted sessions are supported.
115 +
116 +Additional options may be specified by appending space-separated
117 +key=value pairs to the URL. Special characters in values may need
118 +to be escaped to prevent misinterpretation by the option parser.
119 +The escape encoding uses a backslash followed by two hexadecimal digits
120 +representing the ASCII value of the character. E.g., spaces must
121 +be escaped as \fB\\20\fP and backslashes must be escaped as \fB\\5c\fP.
122 .SH OPTIONS
123 .SS "Network Parameters"
124 These options define how to connect to the media server.
125 --
126 1.7.10.4
127
128
129 From c41568f57bec297581e8508a7e6a3d1e470dc81d Mon Sep 17 00:00:00 2001
130 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
131 Date: Sat, 3 Jul 2010 10:28:57 +0000
132 Subject: [PATCH 04/34] Update from prev commit
133
134 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@539 400ebc74-4327-4243-bc38-086b20814532
135 ---
136 librtmp/librtmp.3 | 2 +-
137 librtmp/librtmp.3.html | 13 +++++++++----
138 2 files changed, 10 insertions(+), 5 deletions(-)
139
140 diff --git a/librtmp/librtmp.3 b/librtmp/librtmp.3
141 index a5a7558..66197d5 100644
142 --- a/librtmp/librtmp.3
143 +++ b/librtmp/librtmp.3
144 @@ -1,4 +1,4 @@
145 -.TH LIBRTMP 3 "2010-05-29" "RTMPDump v2.2e"
146 +.TH LIBRTMP 3 "2010-07-03" "RTMPDump v2.3"
147 .\" Copyright 2010 Howard Chu.
148 .\" Copying permitted according to the GNU General Public License V2.
149 .SH NAME
150 diff --git a/librtmp/librtmp.3.html b/librtmp/librtmp.3.html
151 index daf636f..e5e6f4b 100644
152 --- a/librtmp/librtmp.3.html
153 +++ b/librtmp/librtmp.3.html
154 @@ -6,7 +6,7 @@
155 <tr><td>LIBRTMP(3)<td align="center"><td align="right">LIBRTMP(3)
156 </thead>
157 <tfoot>
158 -<tr><td>RTMPDump v2.2e<td align="center">2010-05-29<td align="right">LIBRTMP(3)
159 +<tr><td>RTMPDump v2.3<td align="center">2010-07-03<td align="right">LIBRTMP(3)
160 </tfoot>
161 <tbody><tr><td colspan="3"><br><br><ul>
162 <!-- Copyright 2010 Howard Chu.
163 @@ -75,14 +75,19 @@ The session handle is freed using
164 <b>RTMP_Free</b>().
165 <p>
166 All data is transferred using FLV format. The basic session requires
167 -an RTMP URL. Additional options may be specified by appending
168 -space-separated key=value pairs to the URL. The RTMP URL format
169 -is of the form
170 +an RTMP URL. The RTMP URL format is of the form
171 <pre>
172 rtmp[t][e|s]://hostname[:port][/app[/playpath]]
173 </pre>
174 <p>
175 Plain rtmp, as well as tunneled and encrypted sessions are supported.
176 +<p>
177 +Additional options may be specified by appending space-separated
178 +key=value pairs to the URL. Special characters in values may need
179 +to be escaped to prevent misinterpretation by the option parser.
180 +The escape encoding uses a backslash followed by two hexadecimal digits
181 +representing the ASCII value of the character. E.g., spaces must
182 +be escaped as <b>\20</b> and backslashes must be escaped as <b>\5c</b>.
183 </ul>
184
185 <h3>OPTIONS</h3><ul>
186 --
187 1.7.10.4
188
189
190 From f1c4f0ed07659cbeae4ffaa78ca8cce7500afa58 Mon Sep 17 00:00:00 2001
191 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
192 Date: Mon, 5 Jul 2010 20:07:39 +0000
193 Subject: [PATCH 05/34] Hide strtime()
194
195 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@541 400ebc74-4327-4243-bc38-086b20814532
196 ---
197 librtmp/hashswf.c | 2 +-
198 1 file changed, 1 insertion(+), 1 deletion(-)
199
200 diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
201 index 277f21c..23e754b 100644
202 --- a/librtmp/hashswf.c
203 +++ b/librtmp/hashswf.c
204 @@ -435,7 +435,7 @@ make_unix_time(char *s)
205 /* Convert a Unix time to a network time string
206 * Weekday, DD-MMM-YYYY HH:MM:SS GMT
207 */
208 -void
209 +static void
210 strtime(time_t * t, char *s)
211 {
212 struct tm *tm;
213 --
214 1.7.10.4
215
216
217 From da78eba764eda23fb3bf9aa91bd6c5fee1839932 Mon Sep 17 00:00:00 2001
218 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
219 Date: Mon, 5 Jul 2010 20:16:55 +0000
220 Subject: [PATCH 06/34] Remove obsolete XBOX defs
221
222 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@542 400ebc74-4327-4243-bc38-086b20814532
223 ---
224 librtmp/rtmp_sys.h | 11 ++++-------
225 1 file changed, 4 insertions(+), 7 deletions(-)
226
227 diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h
228 index 0874cbe..6a3f215 100644
229 --- a/librtmp/rtmp_sys.h
230 +++ b/librtmp/rtmp_sys.h
231 @@ -24,17 +24,14 @@
232
233 #ifdef _WIN32
234
235 -#ifdef _XBOX
236 -#include <xtl.h>
237 -#include <winsockx.h>
238 +#include <winsock2.h>
239 +#include <ws2tcpip.h>
240 +
241 +#ifdef _MSC_VER /* MSVC */
242 #define snprintf _snprintf
243 #define strcasecmp stricmp
244 #define strncasecmp strnicmp
245 #define vsnprintf _vsnprintf
246 -
247 -#else /* !_XBOX */
248 -#include <winsock2.h>
249 -#include <ws2tcpip.h>
250 #endif
251
252 #define GetSockError() WSAGetLastError()
253 --
254 1.7.10.4
255
256
257 From eef87483b92036a1631c98c9c85dc3cae66411ee Mon Sep 17 00:00:00 2001
258 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
259 Date: Mon, 5 Jul 2010 20:17:16 +0000
260 Subject: [PATCH 07/34] Update XBOX/XBMC support
261
262 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@543 400ebc74-4327-4243-bc38-086b20814532
263 ---
264 librtmp/hashswf.c | 2 +-
265 1 file changed, 1 insertion(+), 1 deletion(-)
266
267 diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
268 index 23e754b..3c56b69 100644
269 --- a/librtmp/hashswf.c
270 +++ b/librtmp/hashswf.c
271 @@ -466,7 +466,7 @@ RTMP_HashSWF(const char *url, unsigned int *size, unsigned char *hash,
272
273 date[0] = '\0';
274 #ifdef _WIN32
275 -#ifdef _XBOX
276 +#ifdef XBMC4XBOX
277 hpre.av_val = "Q:";
278 hpre.av_len = 2;
279 home.av_val = "\\UserData";
280 --
281 1.7.10.4
282
283
284 From 24f7e724fc10d737a0f14c7741711b6b542c9d45 Mon Sep 17 00:00:00 2001
285 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
286 Date: Thu, 8 Jul 2010 10:38:33 +0000
287 Subject: [PATCH 08/34] Don't link explicitly against static library
288
289 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@544 400ebc74-4327-4243-bc38-086b20814532
290 ---
291 Makefile | 27 +++++++++++++--------------
292 1 file changed, 13 insertions(+), 14 deletions(-)
293
294 diff --git a/Makefile b/Makefile
295 index 1fcdd78..741e438 100644
296 --- a/Makefile
297 +++ b/Makefile
298 @@ -34,7 +34,7 @@ MANDIR=$(DESTDIR)$(mandir)
299
300 LIBS_posix=
301 LIBS_mingw=-lws2_32 -lwinmm -lgdi32
302 -LIBS=$(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
303 +LIBS=-L librtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
304
305 THREADLIB_posix=-lpthread
306 THREADLIB_mingw=
307 @@ -48,9 +48,11 @@ EXT_posix=
308 EXT_mingw=.exe
309 EXT=$(EXT_$(SYS))
310
311 -all: $(LIBRTMP) progs
312 +PROGS=rtmpdump rtmpgw rtmpsrv rtmpsuck
313
314 -progs: rtmpdump rtmpgw rtmpsrv rtmpsuck
315 +all: $(LIBRTMP) $(PROGS)
316 +
317 +$(PROGS): $(LIBRTMP)
318
319 install: progs
320 -mkdir -p $(BINDIR) $(SBINDIR) $(MANDIR)/man1 $(MANDIR)/man8
321 @@ -69,20 +71,17 @@ FORCE:
322 $(LIBRTMP): FORCE
323 @cd librtmp; $(MAKE) all
324
325 -# note: $^ is GNU Make's equivalent to BSD $>
326 -# we use both since either make will ignore the one it doesn't recognize
327 -
328 -rtmpdump: rtmpdump.o $(LIBRTMP)
329 - $(CC) $(LDFLAGS) $^ $> -o $@$(EXT) $(LIBS)
330 +rtmpdump: rtmpdump.o
331 + $(CC) $(LDFLAGS) -o $@$(EXT) $@.o $(LIBS)
332
333 -rtmpsrv: rtmpsrv.o thread.o $(LIBRTMP)
334 - $(CC) $(LDFLAGS) $^ $> -o $@$(EXT) $(SLIBS)
335 +rtmpsrv: rtmpsrv.o thread.o
336 + $(CC) $(LDFLAGS) -o $@$(EXT) $@.o thread.o $(SLIBS)
337
338 -rtmpsuck: rtmpsuck.o thread.o $(LIBRTMP)
339 - $(CC) $(LDFLAGS) $^ $> -o $@$(EXT) $(SLIBS)
340 +rtmpsuck: rtmpsuck.o thread.o
341 + $(CC) $(LDFLAGS) -o $@$(EXT) $@.o thread.o $(SLIBS)
342
343 -rtmpgw: rtmpgw.o thread.o $(LIBRTMP)
344 - $(CC) $(LDFLAGS) $^ $> -o $@$(EXT) $(SLIBS)
345 +rtmpgw: rtmpgw.o thread.o
346 + $(CC) $(LDFLAGS) -o $@$(EXT) $@.o thread.o $(SLIBS)
347
348 rtmpgw.o: rtmpgw.c $(INCRTMP) Makefile
349 rtmpdump.o: rtmpdump.c $(INCRTMP) Makefile
350 --
351 1.7.10.4
352
353
354 From 5a3d6003a9745595583015c5b3b24e7bea818790 Mon Sep 17 00:00:00 2001
355 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
356 Date: Thu, 8 Jul 2010 11:11:47 +0000
357 Subject: [PATCH 09/34] Fix install target
358
359 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@545 400ebc74-4327-4243-bc38-086b20814532
360 ---
361 Makefile | 2 +-
362 1 file changed, 1 insertion(+), 1 deletion(-)
363
364 diff --git a/Makefile b/Makefile
365 index 741e438..75628dd 100644
366 --- a/Makefile
367 +++ b/Makefile
368 @@ -54,7 +54,7 @@ all: $(LIBRTMP) $(PROGS)
369
370 $(PROGS): $(LIBRTMP)
371
372 -install: progs
373 +install: $(PROGS)
374 -mkdir -p $(BINDIR) $(SBINDIR) $(MANDIR)/man1 $(MANDIR)/man8
375 cp rtmpdump$(EXT) $(BINDIR)
376 cp rtmpgw$(EXT) rtmpsrv$(EXT) rtmpsuck$(EXT) $(SBINDIR)
377 --
378 1.7.10.4
379
380
381 From 2340f0e27cd21d624d5f915fc42182750be6fca6 Mon Sep 17 00:00:00 2001
382 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
383 Date: Mon, 12 Jul 2010 08:20:04 +0000
384 Subject: [PATCH 10/34] MacOSX/Darwin shared library flags
385
386 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@546 400ebc74-4327-4243-bc38-086b20814532
387 ---
388 Makefile | 3 +++
389 README | 6 +++++-
390 librtmp/Makefile | 11 ++++++++++-
391 3 files changed, 18 insertions(+), 2 deletions(-)
392
393 diff --git a/Makefile b/Makefile
394 index 75628dd..fda3c74 100644
395 --- a/Makefile
396 +++ b/Makefile
397 @@ -33,10 +33,12 @@ SBINDIR=$(DESTDIR)$(sbindir)
398 MANDIR=$(DESTDIR)$(mandir)
399
400 LIBS_posix=
401 +LIBS_darwin=
402 LIBS_mingw=-lws2_32 -lwinmm -lgdi32
403 LIBS=-L librtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
404
405 THREADLIB_posix=-lpthread
406 +THREADLIB_darwin=-lpthread
407 THREADLIB_mingw=
408 THREADLIB=$(THREADLIB_$(SYS))
409 SLIBS=$(THREADLIB) $(LIBS)
410 @@ -45,6 +47,7 @@ LIBRTMP=librtmp/librtmp.a
411 INCRTMP=librtmp/rtmp_sys.h librtmp/rtmp.h librtmp/log.h librtmp/amf.h
412
413 EXT_posix=
414 +EXT_darwin=
415 EXT_mingw=.exe
416 EXT=$(EXT_$(SYS))
417
418 diff --git a/README b/README
419 index 6607a1d..5689853 100644
420 --- a/README
421 +++ b/README
422 @@ -10,7 +10,11 @@ To compile type "make" with SYS=<platform name>, e.g.
423
424 $ make SYS=posix
425
426 -for Linux, MacOSX, Unix, etc. or
427 +for Linux, Unix, etc. or
428 +
429 + $ make SYS=darwin
430 +
431 +for MacOSX or
432
433 $ make SYS=mingw
434
435 diff --git a/librtmp/Makefile b/librtmp/Makefile
436 index 6774db7..2fd5869 100644
437 --- a/librtmp/Makefile
438 +++ b/librtmp/Makefile
439 @@ -17,6 +17,7 @@ REQ_GNUTLS=gnutls
440 REQ_OPENSSL=libssl,libcrypto
441 LIBZ=-lz
442 LIBS_posix=
443 +LIBS_darwin=
444 LIBS_mingw=-lws2_32 -lwinmm -lgdi32
445 LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
446 LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
447 @@ -26,9 +27,16 @@ CRYPTO_REQ=$(REQ_$(CRYPTO))
448 CRYPTO_DEF=$(DEF_$(CRYPTO))
449
450 SO_posix=so.0
451 +SO_darwin=so.0
452 SO_mingw=dll
453 SO_EXT=$(SO_$(SYS))
454
455 +SO_LDFLAGS_posix=-shared -Wl,-soname,$@
456 +SO_LDFLAGS_darwin=-bundle -flat_namespace -undefined suppress -fno-common \
457 + -headerpad_max_install_names
458 +SO_LDFLAGS_mingw=
459 +SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
460 +
461 SHARED=yes
462 SODEF_yes=-fPIC
463 SOLIB_yes=librtmp.$(SO_EXT)
464 @@ -40,6 +48,7 @@ SO_INST=$(SOINST_$(SHARED))
465 DEF=-DRTMPDUMP_VERSION=\"$(VERSION)\" $(CRYPTO_DEF) $(XDEF)
466 OPT=-O2
467 CFLAGS=-Wall $(XCFLAGS) $(INC) $(DEF) $(OPT) $(SO_DEF)
468 +LDFLAGS=$(XLDFLAGS)
469
470 incdir=$(prefix)/include/librtmp
471 bindir=$(prefix)/bin
472 @@ -61,7 +70,7 @@ librtmp.a: $(OBJS)
473 $(AR) rs $@ $?
474
475 librtmp.$(SO_EXT): $(OBJS)
476 - $(CC) -shared -Wl,-soname,$@ $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB)
477 + $(CC) $(SO_LDFLAGS) $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB)
478 ln -sf $@ librtmp.so
479
480 log.o: log.c log.h Makefile
481 --
482 1.7.10.4
483
484
485 From 13798268e10fc8c56eecf5fce297375f7fca1526 Mon Sep 17 00:00:00 2001
486 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
487 Date: Mon, 9 Aug 2010 21:46:31 +0000
488 Subject: [PATCH 11/34] Fixes for Darwin - use dylib, not bundle for shared
489 lib
490
491 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@547 400ebc74-4327-4243-bc38-086b20814532
492 ---
493 Makefile | 2 +-
494 librtmp/Makefile | 17 +++++++++++------
495 2 files changed, 12 insertions(+), 7 deletions(-)
496
497 diff --git a/Makefile b/Makefile
498 index fda3c74..c322e9a 100644
499 --- a/Makefile
500 +++ b/Makefile
501 @@ -35,7 +35,7 @@ MANDIR=$(DESTDIR)$(mandir)
502 LIBS_posix=
503 LIBS_darwin=
504 LIBS_mingw=-lws2_32 -lwinmm -lgdi32
505 -LIBS=-L librtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
506 +LIBS=-Llibrtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
507
508 THREADLIB_posix=-lpthread
509 THREADLIB_darwin=-lpthread
510 diff --git a/librtmp/Makefile b/librtmp/Makefile
511 index 2fd5869..a4bf67e 100644
512 --- a/librtmp/Makefile
513 +++ b/librtmp/Makefile
514 @@ -26,13 +26,14 @@ CRYPTO_LIB=$(LIB_$(CRYPTO)) $(LIBS_$(SYS))
515 CRYPTO_REQ=$(REQ_$(CRYPTO))
516 CRYPTO_DEF=$(DEF_$(CRYPTO))
517
518 -SO_posix=so.0
519 -SO_darwin=so.0
520 +SO_VERSION=0
521 +SO_posix=so.$(SO_VERSION)
522 +SO_darwin=$(SO_VERSION).dylib
523 SO_mingw=dll
524 SO_EXT=$(SO_$(SYS))
525
526 SO_LDFLAGS_posix=-shared -Wl,-soname,$@
527 -SO_LDFLAGS_darwin=-bundle -flat_namespace -undefined suppress -fno-common \
528 +SO_LDFLAGS_darwin=-dynamiclib -flat_namespace -undefined suppress -fno-common \
529 -headerpad_max_install_names
530 SO_LDFLAGS_mingw=
531 SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
532 @@ -92,9 +93,13 @@ install_base: librtmp.a librtmp.pc
533 cp librtmp.pc $(LIBDIR)/pkgconfig
534 cp librtmp.3 $(MANDIR)/man3
535
536 -install_so.0: librtmp.so.0
537 - cp librtmp.so.0 $(LIBDIR)
538 - cd $(LIBDIR); ln -sf librtmp.so.0 librtmp.so
539 +install_so.$(SO_VERSION): librtmp.$(SO_EXT)
540 + cp librtmp.$(SO_EXT) $(LIBDIR)
541 + cd $(LIBDIR); ln -sf librtmp.$(SO_EXT) librtmp.so
542 +
543 +install_$(SO_VERSION).dylib: librtmp.$(SO_EXT)
544 + cp librtmp.$(SO_EXT) $(LIBDIR)
545 + cd $(LIBDIR); ln -sf librtmp.$(SO_EXT) librtmp.dylib
546
547 install_dll: librtmp.dll
548 cp librtmp.dll $(BINDIR)
549 --
550 1.7.10.4
551
552
553 From eb806247dc8eab25d8a675a4f633d3feaf2b2045 Mon Sep 17 00:00:00 2001
554 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
555 Date: Tue, 10 Aug 2010 06:41:50 +0000
556 Subject: [PATCH 12/34] More dynlib tweaks
557
558 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@548 400ebc74-4327-4243-bc38-086b20814532
559 ---
560 librtmp/Makefile | 48 ++++++++++++++++++++++++++----------------------
561 1 file changed, 26 insertions(+), 22 deletions(-)
562
563 diff --git a/librtmp/Makefile b/librtmp/Makefile
564 index a4bf67e..6a1b08b 100644
565 --- a/librtmp/Makefile
566 +++ b/librtmp/Makefile
567 @@ -2,6 +2,15 @@ VERSION=v2.3
568
569 prefix=/usr/local
570
571 +incdir=$(prefix)/include/librtmp
572 +bindir=$(prefix)/bin
573 +libdir=$(prefix)/lib
574 +mandir=$(prefix)/man
575 +BINDIR=$(DESTDIR)$(bindir)
576 +INCDIR=$(DESTDIR)$(incdir)
577 +LIBDIR=$(DESTDIR)$(libdir)
578 +MANDIR=$(DESTDIR)$(mandir)
579 +
580 CC=$(CROSS_COMPILE)gcc
581 LD=$(CROSS_COMPILE)ld
582 AR=$(CROSS_COMPILE)ar
583 @@ -27,11 +36,20 @@ CRYPTO_REQ=$(REQ_$(CRYPTO))
584 CRYPTO_DEF=$(DEF_$(CRYPTO))
585
586 SO_VERSION=0
587 -SO_posix=so.$(SO_VERSION)
588 -SO_darwin=$(SO_VERSION).dylib
589 +SOX_posix=so
590 +SOX_darwin=dylib
591 +SOX_mingw=so # useless
592 +SOX=$(SOX_$(SYS))
593 +SO_posix=$(SOX).$(SO_VERSION)
594 +SO_darwin=$(SO_VERSION).$(SOX)
595 SO_mingw=dll
596 SO_EXT=$(SO_$(SYS))
597
598 +SODIR_posix=$(LIBDIR)
599 +SODIR_darwin=$(LIBDIR)
600 +SODIR_mingw=$(BINDIR)
601 +SODIR=$(SODIR_$(SYS))
602 +
603 SO_LDFLAGS_posix=-shared -Wl,-soname,$@
604 SO_LDFLAGS_darwin=-dynamiclib -flat_namespace -undefined suppress -fno-common \
605 -headerpad_max_install_names
606 @@ -41,7 +59,7 @@ SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
607 SHARED=yes
608 SODEF_yes=-fPIC
609 SOLIB_yes=librtmp.$(SO_EXT)
610 -SOINST_yes=install_$(SO_EXT)
611 +SOINST_yes=install_so
612 SO_DEF=$(SODEF_$(SHARED))
613 SO_LIB=$(SOLIB_$(SHARED))
614 SO_INST=$(SOINST_$(SHARED))
615 @@ -51,28 +69,20 @@ OPT=-O2
616 CFLAGS=-Wall $(XCFLAGS) $(INC) $(DEF) $(OPT) $(SO_DEF)
617 LDFLAGS=$(XLDFLAGS)
618
619 -incdir=$(prefix)/include/librtmp
620 -bindir=$(prefix)/bin
621 -libdir=$(prefix)/lib
622 -mandir=$(prefix)/man
623 -BINDIR=$(DESTDIR)$(bindir)
624 -INCDIR=$(DESTDIR)$(incdir)
625 -LIBDIR=$(DESTDIR)$(libdir)
626 -MANDIR=$(DESTDIR)$(mandir)
627
628 OBJS=rtmp.o log.o amf.o hashswf.o parseurl.o
629
630 all: librtmp.a $(SO_LIB)
631
632 clean:
633 - rm -f *.o *.a *.so *.$(SO_EXT)
634 + rm -f *.o *.a *.$(SOX) *.$(SO_EXT)
635
636 librtmp.a: $(OBJS)
637 $(AR) rs $@ $?
638
639 librtmp.$(SO_EXT): $(OBJS)
640 $(CC) $(SO_LDFLAGS) $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB)
641 - ln -sf $@ librtmp.so
642 + ln -sf $@ librtmp.$(SOX)
643
644 log.o: log.c log.h Makefile
645 rtmp.o: rtmp.c rtmp.h rtmp_sys.h handshake.h dh.h log.h amf.h Makefile
646 @@ -93,13 +103,7 @@ install_base: librtmp.a librtmp.pc
647 cp librtmp.pc $(LIBDIR)/pkgconfig
648 cp librtmp.3 $(MANDIR)/man3
649
650 -install_so.$(SO_VERSION): librtmp.$(SO_EXT)
651 - cp librtmp.$(SO_EXT) $(LIBDIR)
652 - cd $(LIBDIR); ln -sf librtmp.$(SO_EXT) librtmp.so
653 -
654 -install_$(SO_VERSION).dylib: librtmp.$(SO_EXT)
655 - cp librtmp.$(SO_EXT) $(LIBDIR)
656 - cd $(LIBDIR); ln -sf librtmp.$(SO_EXT) librtmp.dylib
657 +install_so: librtmp.$(SO_EXT)
658 + cp librtmp.$(SO_EXT) $(SODIR)
659 + cd $(SODIR); ln -sf librtmp.$(SO_EXT) librtmp.$(SOX)
660
661 -install_dll: librtmp.dll
662 - cp librtmp.dll $(BINDIR)
663 --
664 1.7.10.4
665
666
667 From 08bdebed5423602d195fa981b3f2663e62820677 Mon Sep 17 00:00:00 2001
668 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
669 Date: Fri, 13 Aug 2010 20:05:35 +0000
670 Subject: [PATCH 13/34] Substitute libdir in pkgconfig file
671
672 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@549 400ebc74-4327-4243-bc38-086b20814532
673 ---
674 librtmp/Makefile | 3 ++-
675 librtmp/librtmp.pc.in | 2 +-
676 2 files changed, 3 insertions(+), 2 deletions(-)
677
678 diff --git a/librtmp/Makefile b/librtmp/Makefile
679 index 6a1b08b..7cba62a 100644
680 --- a/librtmp/Makefile
681 +++ b/librtmp/Makefile
682 @@ -91,7 +91,8 @@ hashswf.o: hashswf.c http.h rtmp.h rtmp_sys.h Makefile
683 parseurl.o: parseurl.c rtmp.h rtmp_sys.h log.h Makefile
684
685 librtmp.pc: librtmp.pc.in Makefile
686 - sed -e "s;@prefix@;$(prefix);" -e "s;@VERSION@;$(VERSION);" \
687 + sed -e "s;@prefix@;$(prefix);" -e "s;@libdir@;$(libdir);" \
688 + -e "s;@VERSION@;$(VERSION);" \
689 -e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" librtmp.pc.in > $@
690
691 install: install_base $(SO_INST)
692 diff --git a/librtmp/librtmp.pc.in b/librtmp/librtmp.pc.in
693 index d58e269..70bd268 100644
694 --- a/librtmp/librtmp.pc.in
695 +++ b/librtmp/librtmp.pc.in
696 @@ -1,6 +1,6 @@
697 prefix=@prefix@
698 exec_prefix=${prefix}
699 -libdir=${exec_prefix}/lib
700 +libdir=@libdir@
701 incdir=${prefix}/include
702
703 Name: librtmp
704 --
705 1.7.10.4
706
707
708 From 59ca19036ed45667b08d98f09e4d4a7a727b77b3 Mon Sep 17 00:00:00 2001
709 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
710 Date: Fri, 13 Aug 2010 20:34:58 +0000
711 Subject: [PATCH 14/34] Less case-sensitive check for Content-length: header
712
713 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@550 400ebc74-4327-4243-bc38-086b20814532
714 ---
715 librtmp/rtmp.c | 8 ++++++--
716 1 file changed, 6 insertions(+), 2 deletions(-)
717
718 diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
719 index f152648..5c678fd 100644
720 --- a/librtmp/rtmp.c
721 +++ b/librtmp/rtmp.c
722 @@ -3664,11 +3664,15 @@ HTTP_read(RTMP *r, int fill)
723 return -1;
724 if (strncmp(r->m_sb.sb_start, "HTTP/1.1 200 ", 13))
725 return -1;
726 - ptr = strstr(r->m_sb.sb_start, "Content-Length:");
727 + ptr = r->m_sb.sb_start + sizeof("HTTP/1.1 200");
728 + while ((ptr = strstr(ptr, "Content-"))) {
729 + if (!strncasecmp(ptr+8, "length:", 7)) break;
730 + ptr += 8;
731 + }
732 if (!ptr)
733 return -1;
734 hlen = atoi(ptr+16);
735 - ptr = strstr(ptr, "\r\n\r\n");
736 + ptr = strstr(ptr+16, "\r\n\r\n");
737 if (!ptr)
738 return -1;
739 ptr += 4;
740 --
741 1.7.10.4
742
743
744 From 8afb3681407a0a83dcb1fec449b83854da440738 Mon Sep 17 00:00:00 2001
745 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
746 Date: Fri, 8 Oct 2010 07:45:54 +0000
747 Subject: [PATCH 15/34] Log error message for unsupported SWF Verification
748 types
749
750 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@551 400ebc74-4327-4243-bc38-086b20814532
751 ---
752 librtmp/rtmp.c | 8 +++++++-
753 1 file changed, 7 insertions(+), 1 deletion(-)
754
755 diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
756 index 5c678fd..3e4e00a 100644
757 --- a/librtmp/rtmp.c
758 +++ b/librtmp/rtmp.c
759 @@ -2789,11 +2789,17 @@ HandleCtrl(RTMP *r, const RTMPPacket *packet)
760 if (nType == 0x1A)
761 {
762 RTMP_Log(RTMP_LOGDEBUG, "%s, SWFVerification ping received: ", __FUNCTION__);
763 + if (packet->m_nBodySize > 2 && packet->m_body[2] > 0x01)
764 + {
765 + RTMP_Log(RTMP_LOGERROR,
766 + "%s: SWFVerification Type %d request not supported! Patches welcome...",
767 + __FUNCTION__, packet->m_body[2]);
768 + }
769 #ifdef CRYPTO
770 /*RTMP_LogHex(packet.m_body, packet.m_nBodySize); */
771
772 /* respond with HMAC SHA256 of decompressed SWF, key is the 30byte player key, also the last 30 bytes of the server handshake are applied */
773 - if (r->Link.SWFSize)
774 + else if (r->Link.SWFSize)
775 {
776 RTMP_SendCtrl(r, 0x1B, 0, 0);
777 }
778 --
779 1.7.10.4
780
781
782 From 9ca7e22d94c6e07e8ef05acbf636809a5914f50c Mon Sep 17 00:00:00 2001
783 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
784 Date: Tue, 26 Oct 2010 23:51:10 +0000
785 Subject: [PATCH 16/34] Timeout fix from Antti Ajanki
786
787 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@552 400ebc74-4327-4243-bc38-086b20814532
788 ---
789 librtmp/rtmp.c | 3 +++
790 rtmpdump.c | 2 +-
791 2 files changed, 4 insertions(+), 1 deletion(-)
792
793 diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
794 index 3e4e00a..db882dc 100644
795 --- a/librtmp/rtmp.c
796 +++ b/librtmp/rtmp.c
797 @@ -1019,6 +1019,9 @@ RTMP_ToggleStream(RTMP *r)
798
799 if (!r->m_pausing)
800 {
801 + if (RTMP_IsTimedout(r) && r->m_read.status == RTMP_READ_EOF)
802 + r->m_read.status = 0;
803 +
804 res = RTMP_SendPause(r, TRUE, r->m_pauseStamp);
805 if (!res)
806 return res;
807 diff --git a/rtmpdump.c b/rtmpdump.c
808 index 7aa19ab..c1cd95b 100644
809 --- a/rtmpdump.c
810 +++ b/rtmpdump.c
811 @@ -583,7 +583,7 @@ Download(RTMP * rtmp, // connected RTMP object
812 #endif
813
814 }
815 - while (!RTMP_ctrlC && nRead > -1 && RTMP_IsConnected(rtmp));
816 + while (!RTMP_ctrlC && nRead > -1 && RTMP_IsConnected(rtmp) && !RTMP_IsTimedout(rtmp));
817 free(buffer);
818 if (nRead < 0)
819 nRead = rtmp->m_read.status;
820 --
821 1.7.10.4
822
823
824 From 1379a2c0d22f238d97970a7e7420287a9bd794de Mon Sep 17 00:00:00 2001
825 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
826 Date: Fri, 24 Dec 2010 22:35:35 +0000
827 Subject: [PATCH 17/34] Fix infinite loop on Error/Close
828
829 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@554 400ebc74-4327-4243-bc38-086b20814532
830 ---
831 librtmp/rtmp.c | 4 ++--
832 1 file changed, 2 insertions(+), 2 deletions(-)
833
834 diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
835 index db882dc..e6e8ed8 100644
836 --- a/librtmp/rtmp.c
837 +++ b/librtmp/rtmp.c
838 @@ -3395,10 +3395,10 @@ RTMP_Close(RTMP *r)
839 {
840 if (r->m_stream_id > 0)
841 {
842 - if ((r->Link.protocol & RTMP_FEATURE_WRITE))
843 - SendFCUnpublish(r);
844 i = r->m_stream_id;
845 r->m_stream_id = 0;
846 + if ((r->Link.protocol & RTMP_FEATURE_WRITE))
847 + SendFCUnpublish(r);
848 SendDeleteStream(r, i);
849 }
850 if (r->m_clientID.av_val)
851 --
852 1.7.10.4
853
854
855 From 8c713f4c5c8e72369b48d15772e19d1c9ebd5a19 Mon Sep 17 00:00:00 2001
856 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
857 Date: Fri, 25 Feb 2011 05:51:40 +0000
858 Subject: [PATCH 18/34] Fix FLV timestamps during resume
859
860 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@557 400ebc74-4327-4243-bc38-086b20814532
861 ---
862 librtmp/rtmp.c | 2 +-
863 1 file changed, 1 insertion(+), 1 deletion(-)
864
865 diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
866 index e6e8ed8..e2925a7 100644
867 --- a/librtmp/rtmp.c
868 +++ b/librtmp/rtmp.c
869 @@ -4083,7 +4083,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
870 /* grab first timestamp and see if it needs fixing */
871 nTimeStamp = AMF_DecodeInt24(packetBody + 4);
872 nTimeStamp |= (packetBody[7] << 24);
873 - delta = packet.m_nTimeStamp - nTimeStamp;
874 + delta = packet.m_nTimeStamp - nTimeStamp + r->m_read.nResumeTS;
875
876 while (pos + 11 < nPacketLen)
877 {
878 --
879 1.7.10.4
880
881
882 From bca1ef01727cac659f7ac171c791490efe4e48d6 Mon Sep 17 00:00:00 2001
883 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
884 Date: Thu, 10 Mar 2011 14:30:06 +0000
885 Subject: [PATCH 19/34] Add Libs.private to pkgconfig for Windows
886
887 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@558 400ebc74-4327-4243-bc38-086b20814532
888 ---
889 librtmp/Makefile | 6 ++++--
890 librtmp/librtmp.pc.in | 1 +
891 2 files changed, 5 insertions(+), 2 deletions(-)
892
893 diff --git a/librtmp/Makefile b/librtmp/Makefile
894 index 7cba62a..87618af 100644
895 --- a/librtmp/Makefile
896 +++ b/librtmp/Makefile
897 @@ -31,7 +31,8 @@ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
898 LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
899 LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
900 LIB_POLARSSL=-lpolarssl $(LIBZ)
901 -CRYPTO_LIB=$(LIB_$(CRYPTO)) $(LIBS_$(SYS))
902 +PRIVATE_LIBS=$(LIBS_$(SYS))
903 +CRYPTO_LIB=$(LIB_$(CRYPTO)) $(PRIVATE_LIBS)
904 CRYPTO_REQ=$(REQ_$(CRYPTO))
905 CRYPTO_DEF=$(DEF_$(CRYPTO))
906
907 @@ -93,7 +94,8 @@ parseurl.o: parseurl.c rtmp.h rtmp_sys.h log.h Makefile
908 librtmp.pc: librtmp.pc.in Makefile
909 sed -e "s;@prefix@;$(prefix);" -e "s;@libdir@;$(libdir);" \
910 -e "s;@VERSION@;$(VERSION);" \
911 - -e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" librtmp.pc.in > $@
912 + -e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" \
913 + -e "s;@PRIVATE_LIBS@;$(PRIVATE_LIBS));" librtmp.pc.in > $@
914
915 install: install_base $(SO_INST)
916
917 diff --git a/librtmp/librtmp.pc.in b/librtmp/librtmp.pc.in
918 index 70bd268..5933ca1 100644
919 --- a/librtmp/librtmp.pc.in
920 +++ b/librtmp/librtmp.pc.in
921 @@ -9,4 +9,5 @@ Version: @VERSION@
922 Requires: @CRYPTO_REQ@
923 URL: http://rtmpdump.mplayerhq.hu
924 Libs: -L${libdir} -lrtmp -lz
925 +Libs.private; @PRIVATE_LIBS@
926 Cflags: -I${incdir}
927 --
928 1.7.10.4
929
930
931 From 25447a0f675cc6e9eefc8eb420ad3a2725be8ab1 Mon Sep 17 00:00:00 2001
932 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
933 Date: Thu, 10 Mar 2011 14:33:32 +0000
934 Subject: [PATCH 20/34] Fix typos in prev commit
935
936 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@559 400ebc74-4327-4243-bc38-086b20814532
937 ---
938 librtmp/Makefile | 2 +-
939 librtmp/librtmp.pc.in | 2 +-
940 2 files changed, 2 insertions(+), 2 deletions(-)
941
942 diff --git a/librtmp/Makefile b/librtmp/Makefile
943 index 87618af..1ea31a0 100644
944 --- a/librtmp/Makefile
945 +++ b/librtmp/Makefile
946 @@ -95,7 +95,7 @@ librtmp.pc: librtmp.pc.in Makefile
947 sed -e "s;@prefix@;$(prefix);" -e "s;@libdir@;$(libdir);" \
948 -e "s;@VERSION@;$(VERSION);" \
949 -e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" \
950 - -e "s;@PRIVATE_LIBS@;$(PRIVATE_LIBS));" librtmp.pc.in > $@
951 + -e "s;@PRIVATE_LIBS@;$(PRIVATE_LIBS);" librtmp.pc.in > $@
952
953 install: install_base $(SO_INST)
954
955 diff --git a/librtmp/librtmp.pc.in b/librtmp/librtmp.pc.in
956 index 5933ca1..a82beca 100644
957 --- a/librtmp/librtmp.pc.in
958 +++ b/librtmp/librtmp.pc.in
959 @@ -9,5 +9,5 @@ Version: @VERSION@
960 Requires: @CRYPTO_REQ@
961 URL: http://rtmpdump.mplayerhq.hu
962 Libs: -L${libdir} -lrtmp -lz
963 -Libs.private; @PRIVATE_LIBS@
964 +Libs.private: @PRIVATE_LIBS@
965 Cflags: -I${incdir}
966 --
967 1.7.10.4
968
969
970 From 0a219ffeeb0094111fd00c509fce3ddd6eba2de2 Mon Sep 17 00:00:00 2001
971 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
972 Date: Mon, 14 Mar 2011 06:48:09 +0000
973 Subject: [PATCH 21/34] Bump up play command buffer sizes
974
975 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@560 400ebc74-4327-4243-bc38-086b20814532
976 ---
977 rtmpsrv.c | 4 ++--
978 1 file changed, 2 insertions(+), 2 deletions(-)
979
980 diff --git a/rtmpsrv.c b/rtmpsrv.c
981 index f2af85b..4d5699f 100644
982 --- a/rtmpsrv.c
983 +++ b/rtmpsrv.c
984 @@ -266,7 +266,7 @@ static int
985 SendPlayStart(RTMP *r)
986 {
987 RTMPPacket packet;
988 - char pbuf[384], *pend = pbuf+sizeof(pbuf);
989 + char pbuf[512], *pend = pbuf+sizeof(pbuf);
990
991 packet.m_nChannel = 0x03; // control channel (invoke)
992 packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
993 @@ -298,7 +298,7 @@ static int
994 SendPlayStop(RTMP *r)
995 {
996 RTMPPacket packet;
997 - char pbuf[384], *pend = pbuf+sizeof(pbuf);
998 + char pbuf[512], *pend = pbuf+sizeof(pbuf);
999
1000 packet.m_nChannel = 0x03; // control channel (invoke)
1001 packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
1002 --
1003 1.7.10.4
1004
1005
1006 From a1bcab1da064cca8a534d26970333220b57a72f0 Mon Sep 17 00:00:00 2001
1007 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
1008 Date: Wed, 16 Mar 2011 12:11:21 +0000
1009 Subject: [PATCH 22/34] Fix rtmpt read hangs
1010
1011 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@561 400ebc74-4327-4243-bc38-086b20814532
1012 ---
1013 librtmp/rtmp.c | 17 ++++++++++++++---
1014 1 file changed, 14 insertions(+), 3 deletions(-)
1015
1016 diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
1017 index e2925a7..3042c7f 100644
1018 --- a/librtmp/rtmp.c
1019 +++ b/librtmp/rtmp.c
1020 @@ -877,7 +877,13 @@ RTMP_Connect1(RTMP *r, RTMPPacket *cp)
1021 r->m_clientID.av_val = NULL;
1022 r->m_clientID.av_len = 0;
1023 HTTP_Post(r, RTMPT_OPEN, "", 1);
1024 - HTTP_read(r, 1);
1025 + if (HTTP_read(r, 1) != 0)
1026 + {
1027 + r->m_msgCounter = 0;
1028 + RTMP_Log(RTMP_LOGDEBUG, "%s, Could not connect for handshake", __FUNCTION__);
1029 + RTMP_Close(r);
1030 + return 0;
1031 + }
1032 r->m_msgCounter = 0;
1033 }
1034 RTMP_Log(RTMP_LOGDEBUG, "%s, ... connected, handshaking", __FUNCTION__);
1035 @@ -1284,7 +1290,12 @@ ReadN(RTMP *r, char *buffer, int n)
1036 return 0;
1037 }
1038 }
1039 - HTTP_read(r, 0);
1040 + if (HTTP_read(r, 0) == -1)
1041 + {
1042 + RTMP_Log(RTMP_LOGDEBUG, "%s, No valid HTTP response found", __FUNCTION__);
1043 + RTMP_Close(r);
1044 + return 0;
1045 + }
1046 }
1047 if (r->m_resplen && !r->m_sb.sb_size)
1048 RTMPSockBuf_Fill(&r->m_sb);
1049 @@ -3670,7 +3681,7 @@ HTTP_read(RTMP *r, int fill)
1050 if (fill)
1051 RTMPSockBuf_Fill(&r->m_sb);
1052 if (r->m_sb.sb_size < 144)
1053 - return -1;
1054 + return -2;
1055 if (strncmp(r->m_sb.sb_start, "HTTP/1.1 200 ", 13))
1056 return -1;
1057 ptr = r->m_sb.sb_start + sizeof("HTTP/1.1 200");
1058 --
1059 1.7.10.4
1060
1061
1062 From aa2825fbb1d1f70652d558a730baed28149ebbdd Mon Sep 17 00:00:00 2001
1063 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
1064 Date: Sat, 19 Mar 2011 23:32:53 +0000
1065 Subject: [PATCH 23/34] Drop back on the handshake version, avoid rtmpe 9
1066
1067 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@562 400ebc74-4327-4243-bc38-086b20814532
1068 ---
1069 librtmp/handshake.h | 6 ++++--
1070 1 file changed, 4 insertions(+), 2 deletions(-)
1071
1072 diff --git a/librtmp/handshake.h b/librtmp/handshake.h
1073 index 958579a..d4d2913 100644
1074 --- a/librtmp/handshake.h
1075 +++ b/librtmp/handshake.h
1076 @@ -400,8 +400,10 @@ HandShake(RTMP * r, int FP9HandShake)
1077 /* set version to at least 9.0.115.0 */
1078 if (encrypted)
1079 {
1080 - clientsig[4] = 128;
1081 - clientsig[6] = 3;
1082 +/* clientsig[4] = 128;
1083 + clientsig[6] = 3; */
1084 + clientsig[4] = 0x7c;
1085 + clientsig[6] = 0x2;
1086 }
1087 else
1088 {
1089 --
1090 1.7.10.4
1091
1092
1093 From ac1843db901184bef349615e3b67d7d2fcebdb7f Mon Sep 17 00:00:00 2001
1094 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
1095 Date: Tue, 22 Mar 2011 15:13:18 +0000
1096 Subject: [PATCH 24/34] Fix prev commit
1097
1098 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@563 400ebc74-4327-4243-bc38-086b20814532
1099 ---
1100 librtmp/handshake.h | 4 ++--
1101 1 file changed, 2 insertions(+), 2 deletions(-)
1102
1103 diff --git a/librtmp/handshake.h b/librtmp/handshake.h
1104 index d4d2913..b172dbf 100644
1105 --- a/librtmp/handshake.h
1106 +++ b/librtmp/handshake.h
1107 @@ -402,8 +402,8 @@ HandShake(RTMP * r, int FP9HandShake)
1108 {
1109 /* clientsig[4] = 128;
1110 clientsig[6] = 3; */
1111 - clientsig[4] = 0x7c;
1112 - clientsig[6] = 0x2;
1113 + clientsig[4] = 9;
1114 + clientsig[6] = 0x7c;
1115 }
1116 else
1117 {
1118 --
1119 1.7.10.4
1120
1121
1122 From 495e1e64106f10a7a1c15f0e2f870a02aa90605c Mon Sep 17 00:00:00 2001
1123 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
1124 Date: Thu, 7 Apr 2011 19:07:31 +0000
1125 Subject: [PATCH 25/34] Handle Play.PublishNotify like Play.Start
1126
1127 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@566 400ebc74-4327-4243-bc38-086b20814532
1128 ---
1129 librtmp/rtmp.c | 5 ++++-
1130 1 file changed, 4 insertions(+), 1 deletion(-)
1131
1132 diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
1133 index 3042c7f..286b6ae 100644
1134 --- a/librtmp/rtmp.c
1135 +++ b/librtmp/rtmp.c
1136 @@ -2282,6 +2282,8 @@ static const AVal av_NetStream_Play_Complete = AVC("NetStream.Play.Complete");
1137 static const AVal av_NetStream_Play_Stop = AVC("NetStream.Play.Stop");
1138 static const AVal av_NetStream_Seek_Notify = AVC("NetStream.Seek.Notify");
1139 static const AVal av_NetStream_Pause_Notify = AVC("NetStream.Pause.Notify");
1140 +static const AVal av_NetStream_Play_PublishNotify =
1141 +AVC("NetStream.Play.PublishNotify");
1142 static const AVal av_NetStream_Play_UnpublishNotify =
1143 AVC("NetStream.Play.UnpublishNotify");
1144 static const AVal av_NetStream_Publish_Start = AVC("NetStream.Publish.Start");
1145 @@ -2449,7 +2451,8 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
1146 RTMP_Log(RTMP_LOGERROR, "Closing connection: %s", code.av_val);
1147 }
1148
1149 - else if (AVMATCH(&code, &av_NetStream_Play_Start))
1150 + else if (AVMATCH(&code, &av_NetStream_Play_Start)
1151 + || AVMATCH(&code, &av_NetStream_Play_PublishNotify))
1152 {
1153 int i;
1154 r->m_bPlaying = TRUE;
1155 --
1156 1.7.10.4
1157
1158
1159 From 041cf3f2c927b26dc4b27b5e802fbb89362ea3e2 Mon Sep 17 00:00:00 2001
1160 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
1161 Date: Thu, 7 Apr 2011 19:11:13 +0000
1162 Subject: [PATCH 26/34] Handle multiple sessions at once (ugly)
1163
1164 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@567 400ebc74-4327-4243-bc38-086b20814532
1165 ---
1166 rtmpsuck.c | 13 ++++++++-----
1167 1 file changed, 8 insertions(+), 5 deletions(-)
1168
1169 diff --git a/rtmpsuck.c b/rtmpsuck.c
1170 index ce6d879..3293e8b 100644
1171 --- a/rtmpsuck.c
1172 +++ b/rtmpsuck.c
1173 @@ -718,15 +718,15 @@ controlServerThread(void *unused)
1174 TFRET();
1175 }
1176
1177 -void doServe(STREAMING_SERVER * server, // server socket and state (our listening socket)
1178 - int sockfd // client connection socket
1179 - )
1180 +TFTYPE doServe(void *arg) // server socket and state (our listening socket)
1181 {
1182 + STREAMING_SERVER *server = arg;
1183 RTMPPacket pc = { 0 }, ps = { 0 };
1184 RTMPChunk rk = { 0 };
1185 char *buf = NULL;
1186 unsigned int buflen = 131072;
1187 int paused = FALSE;
1188 + int sockfd = server->socket;
1189
1190 // timeout for http requests
1191 fd_set rfds;
1192 @@ -990,7 +990,7 @@ quit:
1193 if (server->state == STREAMING_IN_PROGRESS)
1194 server->state = STREAMING_ACCEPTING;
1195
1196 - return;
1197 + TFRET();
1198 }
1199
1200 TFTYPE
1201 @@ -1003,6 +1003,7 @@ serverThread(void *arg)
1202 {
1203 struct sockaddr_in addr;
1204 socklen_t addrlen = sizeof(struct sockaddr_in);
1205 + STREAMING_SERVER *srv2 = malloc(sizeof(STREAMING_SERVER));
1206 int sockfd =
1207 accept(server->socket, (struct sockaddr *) &addr, &addrlen);
1208
1209 @@ -1020,8 +1021,10 @@ serverThread(void *arg)
1210 RTMP_Log(RTMP_LOGDEBUG, "%s: accepted connection from %s\n", __FUNCTION__,
1211 inet_ntoa(addr.sin_addr));
1212 #endif
1213 + *srv2 = *server;
1214 + srv2->socket = sockfd;
1215 /* Create a new thread and transfer the control to that */
1216 - doServe(server, sockfd);
1217 + ThreadCreate(doServe, srv2);
1218 RTMP_Log(RTMP_LOGDEBUG, "%s: processed request\n", __FUNCTION__);
1219 }
1220 else
1221 --
1222 1.7.10.4
1223
1224
1225 From 6155179b296f9749f713bb9bf47e9ca1fdb1a201 Mon Sep 17 00:00:00 2001
1226 From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
1227 Date: Thu, 7 Apr 2011 19:33:28 +0000
1228 Subject: [PATCH 27/34] Use symbolic constants for packet types. From Peter
1229 Miller @ opensource.org.au
1230
1231 git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@568 400ebc74-4327-4243-bc38-086b20814532
1232 ---
1233 librtmp/rtmp.c | 132 ++++++++++++++++++++++++++++++--------------------------
1234 librtmp/rtmp.h | 26 +++++++++--
1235 rtmpsrv.c | 8 ++--
1236 rtmpsuck.c | 112 ++++++++++++++++++++++++++---------------------
1237 4 files changed, 161 insertions(+), 117 deletions(-)
1238
1239 diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
1240 index 286b6ae..5ef3ae9 100644
1241 --- a/librtmp/rtmp.c
1242 +++ b/librtmp/rtmp.c
1243 @@ -1103,32 +1103,32 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
1244 int bHasMediaPacket = 0;
1245 switch (packet->m_packetType)
1246 {
1247 - case 0x01:
1248 + case RTMP_PACKET_TYPE_CHUNK_SIZE:
1249 /* chunk size */
1250 HandleChangeChunkSize(r, packet);
1251 break;
1252
1253 - case 0x03:
1254 + case RTMP_PACKET_TYPE_BYTES_READ_REPORT:
1255 /* bytes read report */
1256 RTMP_Log(RTMP_LOGDEBUG, "%s, received: bytes read report", __FUNCTION__);
1257 break;
1258
1259 - case 0x04:
1260 + case RTMP_PACKET_TYPE_CONTROL:
1261 /* ctrl */
1262 HandleCtrl(r, packet);
1263 break;
1264
1265 - case 0x05:
1266 + case RTMP_PACKET_TYPE_SERVER_BW:
1267 /* server bw */
1268 HandleServerBW(r, packet);
1269 break;
1270
1271 - case 0x06:
1272 + case RTMP_PACKET_TYPE_CLIENT_BW:
1273 /* client bw */
1274 HandleClientBW(r, packet);
1275 break;
1276
1277 - case 0x08:
1278 + case RTMP_PACKET_TYPE_AUDIO:
1279 /* audio data */
1280 /*RTMP_Log(RTMP_LOGDEBUG, "%s, received: audio %lu bytes", __FUNCTION__, packet.m_nBodySize); */
1281 HandleAudio(r, packet);
1282 @@ -1139,7 +1139,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
1283 r->m_mediaStamp = packet->m_nTimeStamp;
1284 break;
1285
1286 - case 0x09:
1287 + case RTMP_PACKET_TYPE_VIDEO:
1288 /* video data */
1289 /*RTMP_Log(RTMP_LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize); */
1290 HandleVideo(r, packet);
1291 @@ -1150,19 +1150,22 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
1292 r->m_mediaStamp = packet->m_nTimeStamp;
1293 break;
1294
1295 - case 0x0F: /* flex stream send */
1296 + case RTMP_PACKET_TYPE_FLEX_STREAM_SEND:
1297 + /* flex stream send */
1298 RTMP_Log(RTMP_LOGDEBUG,
1299 "%s, flex stream send, size %lu bytes, not supported, ignoring",
1300 __FUNCTION__, packet->m_nBodySize);
1301 break;
1302
1303 - case 0x10: /* flex shared object */
1304 + case RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT:
1305 + /* flex shared object */
1306 RTMP_Log(RTMP_LOGDEBUG,
1307 "%s, flex shared object, size %lu bytes, not supported, ignoring",
1308 __FUNCTION__, packet->m_nBodySize);
1309 break;
1310
1311 - case 0x11: /* flex message */
1312 + case RTMP_PACKET_TYPE_FLEX_MESSAGE:
1313 + /* flex message */
1314 {
1315 RTMP_Log(RTMP_LOGDEBUG,
1316 "%s, flex message, size %lu bytes, not fully supported",
1317 @@ -1185,7 +1188,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
1318 bHasMediaPacket = 2;
1319 break;
1320 }
1321 - case 0x12:
1322 + case RTMP_PACKET_TYPE_INFO:
1323 /* metadata (notify) */
1324 RTMP_Log(RTMP_LOGDEBUG, "%s, received: notify %lu bytes", __FUNCTION__,
1325 packet->m_nBodySize);
1326 @@ -1193,12 +1196,12 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
1327 bHasMediaPacket = 1;
1328 break;
1329
1330 - case 0x13:
1331 + case RTMP_PACKET_TYPE_SHARED_OBJECT:
1332 RTMP_Log(RTMP_LOGDEBUG, "%s, shared object, not supported, ignoring",
1333 __FUNCTION__);
1334 break;
1335
1336 - case 0x14:
1337 + case RTMP_PACKET_TYPE_INVOKE:
1338 /* invoke */
1339 RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %lu bytes", __FUNCTION__,
1340 packet->m_nBodySize);
1341 @@ -1208,7 +1211,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
1342 bHasMediaPacket = 2;
1343 break;
1344
1345 - case 0x16:
1346 + case RTMP_PACKET_TYPE_FLASH_VIDEO:
1347 {
1348 /* go through FLV packets and handle metadata packets */
1349 unsigned int pos = 0;
1350 @@ -1448,7 +1451,7 @@ SendConnectPacket(RTMP *r, RTMPPacket *cp)
1351
1352 packet.m_nChannel = 0x03; /* control channel (invoke) */
1353 packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
1354 - packet.m_packetType = 0x14; /* INVOKE */
1355 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1356 packet.m_nTimeStamp = 0;
1357 packet.m_nInfoField2 = 0;
1358 packet.m_hasAbsTimestamp = 0;
1359 @@ -1559,7 +1562,7 @@ SendBGHasStream(RTMP *r, double dId, AVal *playpath)
1360
1361 packet.m_nChannel = 0x03; /* control channel (invoke) */
1362 packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1363 - packet.m_packetType = 0x14; /* INVOKE */
1364 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1365 packet.m_nTimeStamp = 0;
1366 packet.m_nInfoField2 = 0;
1367 packet.m_hasAbsTimestamp = 0;
1368 @@ -1591,7 +1594,7 @@ RTMP_SendCreateStream(RTMP *r)
1369
1370 packet.m_nChannel = 0x03; /* control channel (invoke) */
1371 packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1372 - packet.m_packetType = 0x14; /* INVOKE */
1373 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1374 packet.m_nTimeStamp = 0;
1375 packet.m_nInfoField2 = 0;
1376 packet.m_hasAbsTimestamp = 0;
1377 @@ -1617,7 +1620,7 @@ SendFCSubscribe(RTMP *r, AVal *subscribepath)
1378 char *enc;
1379 packet.m_nChannel = 0x03; /* control channel (invoke) */
1380 packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1381 - packet.m_packetType = 0x14; /* INVOKE */
1382 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1383 packet.m_nTimeStamp = 0;
1384 packet.m_nInfoField2 = 0;
1385 packet.m_hasAbsTimestamp = 0;
1386 @@ -1649,7 +1652,7 @@ SendReleaseStream(RTMP *r)
1387
1388 packet.m_nChannel = 0x03; /* control channel (invoke) */
1389 packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1390 - packet.m_packetType = 0x14; /* INVOKE */
1391 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1392 packet.m_nTimeStamp = 0;
1393 packet.m_nInfoField2 = 0;
1394 packet.m_hasAbsTimestamp = 0;
1395 @@ -1679,7 +1682,7 @@ SendFCPublish(RTMP *r)
1396
1397 packet.m_nChannel = 0x03; /* control channel (invoke) */
1398 packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1399 - packet.m_packetType = 0x14; /* INVOKE */
1400 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1401 packet.m_nTimeStamp = 0;
1402 packet.m_nInfoField2 = 0;
1403 packet.m_hasAbsTimestamp = 0;
1404 @@ -1709,7 +1712,7 @@ SendFCUnpublish(RTMP *r)
1405
1406 packet.m_nChannel = 0x03; /* control channel (invoke) */
1407 packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1408 - packet.m_packetType = 0x14; /* INVOKE */
1409 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1410 packet.m_nTimeStamp = 0;
1411 packet.m_nInfoField2 = 0;
1412 packet.m_hasAbsTimestamp = 0;
1413 @@ -1741,7 +1744,7 @@ SendPublish(RTMP *r)
1414
1415 packet.m_nChannel = 0x04; /* source channel (invoke) */
1416 packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
1417 - packet.m_packetType = 0x14; /* INVOKE */
1418 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1419 packet.m_nTimeStamp = 0;
1420 packet.m_nInfoField2 = r->m_stream_id;
1421 packet.m_hasAbsTimestamp = 0;
1422 @@ -1776,7 +1779,7 @@ SendDeleteStream(RTMP *r, double dStreamId)
1423
1424 packet.m_nChannel = 0x03; /* control channel (invoke) */
1425 packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1426 - packet.m_packetType = 0x14; /* INVOKE */
1427 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1428 packet.m_nTimeStamp = 0;
1429 packet.m_nInfoField2 = 0;
1430 packet.m_hasAbsTimestamp = 0;
1431 @@ -1805,7 +1808,7 @@ RTMP_SendPause(RTMP *r, int DoPause, int iTime)
1432
1433 packet.m_nChannel = 0x08; /* video channel */
1434 packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1435 - packet.m_packetType = 0x14; /* invoke */
1436 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1437 packet.m_nTimeStamp = 0;
1438 packet.m_nInfoField2 = 0;
1439 packet.m_hasAbsTimestamp = 0;
1440 @@ -1842,7 +1845,7 @@ RTMP_SendSeek(RTMP *r, int iTime)
1441
1442 packet.m_nChannel = 0x08; /* video channel */
1443 packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1444 - packet.m_packetType = 0x14; /* invoke */
1445 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1446 packet.m_nTimeStamp = 0;
1447 packet.m_nInfoField2 = 0;
1448 packet.m_hasAbsTimestamp = 0;
1449 @@ -1870,7 +1873,7 @@ RTMP_SendServerBW(RTMP *r)
1450
1451 packet.m_nChannel = 0x02; /* control channel (invoke) */
1452 packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
1453 - packet.m_packetType = 0x05; /* Server BW */
1454 + packet.m_packetType = RTMP_PACKET_TYPE_SERVER_BW;
1455 packet.m_nTimeStamp = 0;
1456 packet.m_nInfoField2 = 0;
1457 packet.m_hasAbsTimestamp = 0;
1458 @@ -1890,7 +1893,7 @@ RTMP_SendClientBW(RTMP *r)
1459
1460 packet.m_nChannel = 0x02; /* control channel (invoke) */
1461 packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
1462 - packet.m_packetType = 0x06; /* Client BW */
1463 + packet.m_packetType = RTMP_PACKET_TYPE_CLIENT_BW;
1464 packet.m_nTimeStamp = 0;
1465 packet.m_nInfoField2 = 0;
1466 packet.m_hasAbsTimestamp = 0;
1467 @@ -1911,7 +1914,7 @@ SendBytesReceived(RTMP *r)
1468
1469 packet.m_nChannel = 0x02; /* control channel (invoke) */
1470 packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1471 - packet.m_packetType = 0x03; /* bytes in */
1472 + packet.m_packetType = RTMP_PACKET_TYPE_BYTES_READ_REPORT;
1473 packet.m_nTimeStamp = 0;
1474 packet.m_nInfoField2 = 0;
1475 packet.m_hasAbsTimestamp = 0;
1476 @@ -1937,7 +1940,7 @@ SendCheckBW(RTMP *r)
1477
1478 packet.m_nChannel = 0x03; /* control channel (invoke) */
1479 packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
1480 - packet.m_packetType = 0x14; /* INVOKE */
1481 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1482 packet.m_nTimeStamp = 0; /* RTMP_GetTime(); */
1483 packet.m_nInfoField2 = 0;
1484 packet.m_hasAbsTimestamp = 0;
1485 @@ -1965,7 +1968,7 @@ SendCheckBWResult(RTMP *r, double txn)
1486
1487 packet.m_nChannel = 0x03; /* control channel (invoke) */
1488 packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1489 - packet.m_packetType = 0x14; /* INVOKE */
1490 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1491 packet.m_nTimeStamp = 0x16 * r->m_nBWCheckCounter; /* temp inc value. till we figure it out. */
1492 packet.m_nInfoField2 = 0;
1493 packet.m_hasAbsTimestamp = 0;
1494 @@ -1994,7 +1997,7 @@ SendPong(RTMP *r, double txn)
1495
1496 packet.m_nChannel = 0x03; /* control channel (invoke) */
1497 packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1498 - packet.m_packetType = 0x14; /* INVOKE */
1499 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1500 packet.m_nTimeStamp = 0x16 * r->m_nBWCheckCounter; /* temp inc value. till we figure it out. */
1501 packet.m_nInfoField2 = 0;
1502 packet.m_hasAbsTimestamp = 0;
1503 @@ -2021,7 +2024,7 @@ SendPlay(RTMP *r)
1504
1505 packet.m_nChannel = 0x08; /* we make 8 our stream channel */
1506 packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
1507 - packet.m_packetType = 0x14; /* INVOKE */
1508 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1509 packet.m_nTimeStamp = 0;
1510 packet.m_nInfoField2 = r->m_stream_id; /*0x01000000; */
1511 packet.m_hasAbsTimestamp = 0;
1512 @@ -2089,7 +2092,7 @@ SendPlaylist(RTMP *r)
1513
1514 packet.m_nChannel = 0x08; /* we make 8 our stream channel */
1515 packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
1516 - packet.m_packetType = 0x14; /* INVOKE */
1517 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1518 packet.m_nTimeStamp = 0;
1519 packet.m_nInfoField2 = r->m_stream_id; /*0x01000000; */
1520 packet.m_hasAbsTimestamp = 0;
1521 @@ -2127,7 +2130,7 @@ SendSecureTokenResponse(RTMP *r, AVal *resp)
1522
1523 packet.m_nChannel = 0x03; /* control channel (invoke) */
1524 packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1525 - packet.m_packetType = 0x14;
1526 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1527 packet.m_nTimeStamp = 0;
1528 packet.m_nInfoField2 = 0;
1529 packet.m_hasAbsTimestamp = 0;
1530 @@ -2174,7 +2177,7 @@ RTMP_SendCtrl(RTMP *r, short nType, unsigned int nObject, unsigned int nTime)
1531
1532 packet.m_nChannel = 0x02; /* control channel (ping) */
1533 packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1534 - packet.m_packetType = 0x04; /* ctrl */
1535 + packet.m_packetType = RTMP_PACKET_TYPE_CONTROL;
1536 packet.m_nTimeStamp = 0; /* RTMP_GetTime(); */
1537 packet.m_nInfoField2 = 0;
1538 packet.m_hasAbsTimestamp = 0;
1539 @@ -3372,7 +3375,7 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int queue)
1540 }
1541
1542 /* we invoked a remote method */
1543 - if (packet->m_packetType == 0x14)
1544 + if (packet->m_packetType == RTMP_PACKET_TYPE_INVOKE)
1545 {
1546 AVal method;
1547 char *ptr;
1548 @@ -3748,8 +3751,8 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
1549 char *packetBody = packet.m_body;
1550 unsigned int nPacketLen = packet.m_nBodySize;
1551
1552 - /* Return -3 if this was completed nicely with invoke message
1553 - * Play.Stop or Play.Complete
1554 + /* Return RTMP_READ_COMPLETE if this was completed nicely with
1555 + * invoke message Play.Stop or Play.Complete
1556 */
1557 if (rtnGetNextMediaPacket == 2)
1558 {
1559 @@ -3760,17 +3763,17 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
1560 break;
1561 }
1562
1563 - r->m_read.dataType |= (((packet.m_packetType == 0x08) << 2) |
1564 - (packet.m_packetType == 0x09));
1565 + r->m_read.dataType |= (((packet.m_packetType == RTMP_PACKET_TYPE_AUDIO) << 2) |
1566 + (packet.m_packetType == RTMP_PACKET_TYPE_VIDEO));
1567
1568 - if (packet.m_packetType == 0x09 && nPacketLen <= 5)
1569 + if (packet.m_packetType == RTMP_PACKET_TYPE_VIDEO && nPacketLen <= 5)
1570 {
1571 RTMP_Log(RTMP_LOGDEBUG, "ignoring too small video packet: size: %d",
1572 nPacketLen);
1573 ret = RTMP_READ_IGNORE;
1574 break;
1575 }
1576 - if (packet.m_packetType == 0x08 && nPacketLen <= 1)
1577 + if (packet.m_packetType == RTMP_PACKET_TYPE_AUDIO && nPacketLen <= 1)
1578 {
1579 RTMP_Log(RTMP_LOGDEBUG, "ignoring too small audio packet: size: %d",
1580 nPacketLen);
1581 @@ -3787,7 +3790,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
1582 RTMP_Log(RTMP_LOGDEBUG, "type: %02X, size: %d, TS: %d ms, abs TS: %d",
1583 packet.m_packetType, nPacketLen, packet.m_nTimeStamp,
1584 packet.m_hasAbsTimestamp);
1585 - if (packet.m_packetType == 0x09)
1586 + if (packet.m_packetType == RTMP_PACKET_TYPE_VIDEO)
1587 RTMP_Log(RTMP_LOGDEBUG, "frametype: %02X", (*packetBody & 0xf0));
1588 #endif
1589
1590 @@ -3797,7 +3800,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
1591 if (packet.m_nTimeStamp == 0)
1592 {
1593 if (r->m_read.nMetaHeaderSize > 0
1594 - && packet.m_packetType == 0x12)
1595 + && packet.m_packetType == RTMP_PACKET_TYPE_INFO)
1596 {
1597 AMFObject metaObj;
1598 int nRes =
1599 @@ -3858,7 +3861,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
1600 * in the first FLV stream chunk and we have to compare
1601 * it and filter it out !!
1602 */
1603 - if (packet.m_packetType == 0x16)
1604 + if (packet.m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO)
1605 {
1606 /* basically we have to find the keyframe with the
1607 * correct TS being nResumeTS
1608 @@ -3970,7 +3973,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
1609 * (seeking might put us somewhere before it)
1610 */
1611 if (!(r->m_read.flags & RTMP_READ_GOTKF) &&
1612 - packet.m_packetType != 0x16)
1613 + packet.m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO)
1614 {
1615 RTMP_Log(RTMP_LOGWARNING,
1616 "Stream does not start with requested frame, ignoring data... ");
1617 @@ -3983,7 +3986,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
1618 }
1619 /* ok, do the same for FLV streams */
1620 if (!(r->m_read.flags & RTMP_READ_GOTFLVK) &&
1621 - packet.m_packetType == 0x16)
1622 + packet.m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO)
1623 {
1624 RTMP_Log(RTMP_LOGWARNING,
1625 "Stream does not start with requested FLV frame, ignoring data... ");
1626 @@ -4002,9 +4005,11 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
1627 * the preceding if clause)
1628 */
1629 if (!(r->m_read.flags & RTMP_READ_NO_IGNORE) &&
1630 - packet.m_packetType != 0x16)
1631 - { /* exclude type 0x16 (FLV) since it can
1632 - * contain several FLV packets */
1633 + packet.m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO)
1634 + {
1635 + /* exclude type RTMP_PACKET_TYPE_FLASH_VIDEO since it can
1636 + * contain several FLV packets
1637 + */
1638 if (packet.m_nTimeStamp == 0)
1639 {
1640 ret = RTMP_READ_IGNORE;
1641 @@ -4020,9 +4025,10 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
1642
1643 /* calculate packet size and allocate slop buffer if necessary */
1644 size = nPacketLen +
1645 - ((packet.m_packetType == 0x08 || packet.m_packetType == 0x09
1646 - || packet.m_packetType == 0x12) ? 11 : 0) +
1647 - (packet.m_packetType != 0x16 ? 4 : 0);
1648 + ((packet.m_packetType == RTMP_PACKET_TYPE_AUDIO
1649 + || packet.m_packetType == RTMP_PACKET_TYPE_VIDEO
1650 + || packet.m_packetType == RTMP_PACKET_TYPE_INFO) ? 11 : 0) +
1651 + (packet.m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO ? 4 : 0);
1652
1653 if (size + 4 > buflen)
1654 {
1655 @@ -4048,8 +4054,9 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
1656
1657 /* audio (0x08), video (0x09) or metadata (0x12) packets :
1658 * construct 11 byte header then add rtmp packet's data */
1659 - if (packet.m_packetType == 0x08 || packet.m_packetType == 0x09
1660 - || packet.m_packetType == 0x12)
1661 + if (packet.m_packetType == RTMP_PACKET_TYPE_AUDIO
1662 + || packet.m_packetType == RTMP_PACKET_TYPE_VIDEO
1663 + || packet.m_packetType == RTMP_PACKET_TYPE_INFO)
1664 {
1665 nTimeStamp = r->m_read.nResumeTS + packet.m_nTimeStamp;
1666 prevTagSize = 11 + nPacketLen;
1667 @@ -4059,7 +4066,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
1668 ptr = AMF_EncodeInt24(ptr, pend, nPacketLen);
1669
1670 #if 0
1671 - if(packet.m_packetType == 0x09) { /* video */
1672 + if(packet.m_packetType == RTMP_PACKET_TYPE_VIDEO) {
1673
1674 /* H264 fix: */
1675 if((packetBody[0] & 0x0f) == 7) { /* CodecId = H264 */
1676 @@ -4089,7 +4096,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
1677 len = nPacketLen;
1678
1679 /* correct tagSize and obtain timestamp if we have an FLV stream */
1680 - if (packet.m_packetType == 0x16)
1681 + if (packet.m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO)
1682 {
1683 unsigned int pos = 0;
1684 int delta;
1685 @@ -4167,7 +4174,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
1686 }
1687 ptr += len;
1688
1689 - if (packet.m_packetType != 0x16)
1690 + if (packet.m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO)
1691 {
1692 /* FLV tag packets contain their own prevTagSize */
1693 AMF_EncodeInt32(ptr, pend, prevTagSize);
1694 @@ -4352,11 +4359,12 @@ RTMP_Write(RTMP *r, const char *buf, int size)
1695 buf += 3;
1696 s2 -= 11;
1697
1698 - if (((pkt->m_packetType == 0x08 || pkt->m_packetType == 0x09) &&
1699 - !pkt->m_nTimeStamp) || pkt->m_packetType == 0x12)
1700 + if (((pkt->m_packetType == RTMP_PACKET_TYPE_AUDIO
1701 + || pkt->m_packetType == RTMP_PACKET_TYPE_VIDEO) &&
1702 + !pkt->m_nTimeStamp) || pkt->m_packetType == RTMP_PACKET_TYPE_INFO)
1703 {
1704 pkt->m_headerType = RTMP_PACKET_SIZE_LARGE;
1705 - if (pkt->m_packetType == 0x12)
1706 + if (pkt->m_packetType == RTMP_PACKET_TYPE_INFO)
1707 pkt->m_nBodySize += 16;
1708 }
1709 else
1710 @@ -4371,7 +4379,7 @@ RTMP_Write(RTMP *r, const char *buf, int size)
1711 }
1712 enc = pkt->m_body;
1713 pend = enc + pkt->m_nBodySize;
1714 - if (pkt->m_packetType == 0x12)
1715 + if (pkt->m_packetType == RTMP_PACKET_TYPE_INFO)
1716 {
1717 enc = AMF_EncodeString(enc, pend, &av_setDataFrame);
1718 pkt->m_nBytesRead = enc - pkt->m_body;
1719 diff --git a/librtmp/rtmp.h b/librtmp/rtmp.h
1720 index de0b795..1ece207 100644
1721 --- a/librtmp/rtmp.h
1722 +++ b/librtmp/rtmp.h
1723 @@ -71,9 +71,29 @@ extern "C"
1724
1725 uint32_t RTMP_GetTime(void);
1726
1727 -#define RTMP_PACKET_TYPE_AUDIO 0x08
1728 -#define RTMP_PACKET_TYPE_VIDEO 0x09
1729 -#define RTMP_PACKET_TYPE_INFO 0x12
1730 +/* RTMP_PACKET_TYPE_... 0x00 */
1731 +#define RTMP_PACKET_TYPE_CHUNK_SIZE 0x01
1732 +/* RTMP_PACKET_TYPE_... 0x02 */
1733 +#define RTMP_PACKET_TYPE_BYTES_READ_REPORT 0x03
1734 +#define RTMP_PACKET_TYPE_CONTROL 0x04
1735 +#define RTMP_PACKET_TYPE_SERVER_BW 0x05
1736 +#define RTMP_PACKET_TYPE_CLIENT_BW 0x06
1737 +/* RTMP_PACKET_TYPE_... 0x07 */
1738 +#define RTMP_PACKET_TYPE_AUDIO 0x08
1739 +#define RTMP_PACKET_TYPE_VIDEO 0x09
1740 +/* RTMP_PACKET_TYPE_... 0x0A */
1741 +/* RTMP_PACKET_TYPE_... 0x0B */
1742 +/* RTMP_PACKET_TYPE_... 0x0C */
1743 +/* RTMP_PACKET_TYPE_... 0x0D */
1744 +/* RTMP_PACKET_TYPE_... 0x0E */
1745 +#define RTMP_PACKET_TYPE_FLEX_STREAM_SEND 0x0F
1746 +#define RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT 0x10
1747 +#define RTMP_PACKET_TYPE_FLEX_MESSAGE 0x11
1748 +#define RTMP_PACKET_TYPE_INFO 0x12
1749 +#define RTMP_PACKET_TYPE_SHARED_OBJECT 0x13
1750 +#define RTMP_PACKET_TYPE_INVOKE 0x14
1751 +/* RTMP_PACKET_TYPE_... 0x15 */
1752 +#define RTMP_PACKET_TYPE_FLASH_VIDEO 0x16
1753
1754 #define RTMP_MAX_HEADER_SIZE 18
1755
1756 diff --git a/rtmpsrv.c b/rtmpsrv.c
1757 index 4d5699f..f1b6c66 100644
1758 --- a/rtmpsrv.c
1759 +++ b/rtmpsrv.c
1760 @@ -175,7 +175,7 @@ SendConnectResult(RTMP *r, double txn)
1761
1762 packet.m_nChannel = 0x03; // control channel (invoke)
1763 packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
1764 - packet.m_packetType = 0x14; // INVOKE
1765 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1766 packet.m_nTimeStamp = 0;
1767 packet.m_nInfoField2 = 0;
1768 packet.m_hasAbsTimestamp = 0;
1769 @@ -236,7 +236,7 @@ SendResultNumber(RTMP *r, double txn, double ID)
1770
1771 packet.m_nChannel = 0x03; // control channel (invoke)
1772 packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
1773 - packet.m_packetType = 0x14; // INVOKE
1774 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1775 packet.m_nTimeStamp = 0;
1776 packet.m_nInfoField2 = 0;
1777 packet.m_hasAbsTimestamp = 0;
1778 @@ -270,7 +270,7 @@ SendPlayStart(RTMP *r)
1779
1780 packet.m_nChannel = 0x03; // control channel (invoke)
1781 packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
1782 - packet.m_packetType = 0x14; // INVOKE
1783 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1784 packet.m_nTimeStamp = 0;
1785 packet.m_nInfoField2 = 0;
1786 packet.m_hasAbsTimestamp = 0;
1787 @@ -302,7 +302,7 @@ SendPlayStop(RTMP *r)
1788
1789 packet.m_nChannel = 0x03; // control channel (invoke)
1790 packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
1791 - packet.m_packetType = 0x14; // INVOKE
1792 + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1793 packet.m_nTimeStamp = 0;
1794 packet.m_nInfoField2 = 0;
1795 packet.m_hasAbsTimestamp = 0;
1796 diff --git a/rtmpsuck.c b/rtmpsuck.c
1797 index 3293e8b..661e64b 100644
1798 --- a/rtmpsuck.c
1799 +++ b/rtmpsuck.c
1800 @@ -461,67 +461,71 @@ ServePacket(STREAMING_SERVER *server, int which, RTMPPacket *packet)
1801
1802 switch (packet->m_packetType)
1803 {
1804 - case 0x01:
1805 + case RTMP_PACKET_TYPE_CHUNK_SIZE:
1806 // chunk size
1807 // HandleChangeChunkSize(r, packet);
1808 break;
1809
1810 - case 0x03:
1811 + case RTMP_PACKET_TYPE_BYTES_READ_REPORT:
1812 // bytes read report
1813 break;
1814
1815 - case 0x04:
1816 + case RTMP_PACKET_TYPE_CONTROL:
1817 // ctrl
1818 // HandleCtrl(r, packet);
1819 break;
1820
1821 - case 0x05:
1822 + case RTMP_PACKET_TYPE_SERVER_BW:
1823 // server bw
1824 // HandleServerBW(r, packet);
1825 break;
1826
1827 - case 0x06:
1828 + case RTMP_PACKET_TYPE_CLIENT_BW:
1829 // client bw
1830 // HandleClientBW(r, packet);
1831 break;
1832
1833 - case 0x08:
1834 + case RTMP_PACKET_TYPE_AUDIO:
1835 // audio data
1836 //RTMP_Log(RTMP_LOGDEBUG, "%s, received: audio %lu bytes", __FUNCTION__, packet.m_nBodySize);
1837 break;
1838
1839 - case 0x09:
1840 + case RTMP_PACKET_TYPE_VIDEO:
1841 // video data
1842 //RTMP_Log(RTMP_LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize);
1843 break;
1844
1845 - case 0x0F: // flex stream send
1846 + case RTMP_PACKET_TYPE_FLEX_STREAM_SEND:
1847 + // flex stream send
1848 break;
1849
1850 - case 0x10: // flex shared object
1851 + case RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT:
1852 + // flex shared object
1853 break;
1854
1855 - case 0x11: // flex message
1856 + case RTMP_PACKET_TYPE_FLEX_MESSAGE:
1857 + // flex message
1858 {
1859 ret = ServeInvoke(server, which, packet, packet->m_body + 1);
1860 break;
1861 }
1862 - case 0x12:
1863 + case RTMP_PACKET_TYPE_INFO:
1864 // metadata (notify)
1865 break;
1866
1867 - case 0x13:
1868 + case RTMP_PACKET_TYPE_SHARED_OBJECT:
1869 /* shared object */
1870 break;
1871
1872 - case 0x14:
1873 + case RTMP_PACKET_TYPE_INVOKE:
1874 // invoke
1875 ret = ServeInvoke(server, which, packet, packet->m_body);
1876 break;
1877
1878 - case 0x16:
1879 + case RTMP_PACKET_TYPE_FLASH_VIDEO:
1880 /* flv */
1881 break;
1882 +
1883 default:
1884 RTMP_Log(RTMP_LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,
1885 packet->m_packetType);
1886 @@ -547,21 +551,21 @@ WriteStream(char **buf, // target pointer, maybe preallocated
1887 unsigned int nPacketLen = packet->m_nBodySize;
1888
1889 // skip video info/command packets
1890 - if (packet->m_packetType == 0x09 &&
1891 + if (packet->m_packetType == RTMP_PACKET_TYPE_VIDEO &&
1892 nPacketLen == 2 && ((*packetBody & 0xf0) == 0x50))
1893 {
1894 ret = 0;
1895 break;
1896 }
1897
1898 - if (packet->m_packetType == 0x09 && nPacketLen <= 5)
1899 + if (packet->m_packetType == RTMP_PACKET_TYPE_VIDEO && nPacketLen <= 5)
1900 {
1901 RTMP_Log(RTMP_LOGWARNING, "ignoring too small video packet: size: %d",
1902 nPacketLen);
1903 ret = 0;
1904 break;
1905 }
1906 - if (packet->m_packetType == 0x08 && nPacketLen <= 1)
1907 + if (packet->m_packetType == RTMP_PACKET_TYPE_AUDIO && nPacketLen <= 1)
1908 {
1909 RTMP_Log(RTMP_LOGWARNING, "ignoring too small audio packet: size: %d",
1910 nPacketLen);
1911 @@ -571,19 +575,22 @@ WriteStream(char **buf, // target pointer, maybe preallocated
1912 #ifdef _DEBUG
1913 RTMP_Log(RTMP_LOGDEBUG, "type: %02X, size: %d, TS: %d ms", packet->m_packetType,
1914 nPacketLen, packet->m_nTimeStamp);
1915 - if (packet->m_packetType == 0x09)
1916 + if (packet->m_packetType == RTMP_PACKET_TYPE_VIDEO)
1917 RTMP_Log(RTMP_LOGDEBUG, "frametype: %02X", (*packetBody & 0xf0));
1918 #endif
1919
1920 // calculate packet size and reallocate buffer if necessary
1921 unsigned int size = nPacketLen
1922 +
1923 - ((packet->m_packetType == 0x08 || packet->m_packetType == 0x09
1924 - || packet->m_packetType == 0x12) ? 11 : 0) + (packet->m_packetType !=
1925 - 0x16 ? 4 : 0);
1926 + ((packet->m_packetType == RTMP_PACKET_TYPE_AUDIO
1927 + || packet->m_packetType == RTMP_PACKET_TYPE_VIDEO
1928 + || packet->m_packetType == RTMP_PACKET_TYPE_INFO) ? 11 : 0)
1929 + + (packet->m_packetType != 0x16 ? 4 : 0);
1930
1931 if (size + 4 > len)
1932 - { // the extra 4 is for the case of an FLV stream without a last prevTagSize (we need extra 4 bytes to append it)
1933 + {
1934 + /* The extra 4 is for the case of an FLV stream without a last
1935 + * prevTagSize (we need extra 4 bytes to append it). */
1936 *buf = (char *) realloc(*buf, size + 4);
1937 if (*buf == 0)
1938 {
1939 @@ -594,13 +601,15 @@ WriteStream(char **buf, // target pointer, maybe preallocated
1940 }
1941 char *ptr = *buf, *pend = ptr + size+4;
1942
1943 - // audio (0x08), video (0x09) or metadata (0x12) packets :
1944 - // construct 11 byte header then add rtmp packet's data
1945 - if (packet->m_packetType == 0x08 || packet->m_packetType == 0x09
1946 - || packet->m_packetType == 0x12)
1947 + /* audio (RTMP_PACKET_TYPE_AUDIO), video (RTMP_PACKET_TYPE_VIDEO)
1948 + * or metadata (RTMP_PACKET_TYPE_INFO) packets: construct 11 byte
1949 + * header then add rtmp packet's data. */
1950 + if (packet->m_packetType == RTMP_PACKET_TYPE_AUDIO
1951 + || packet->m_packetType == RTMP_PACKET_TYPE_VIDEO
1952 + || packet->m_packetType == RTMP_PACKET_TYPE_INFO)
1953 {
1954 // set data type
1955 - //*dataType |= (((packet->m_packetType == 0x08)<<2)|(packet->m_packetType == 0x09));
1956 + //*dataType |= (((packet->m_packetType == RTMP_PACKET_TYPE_AUDIO)<<2)|(packet->m_packetType == RTMP_PACKET_TYPE_VIDEO));
1957
1958 (*nTimeStamp) = packet->m_nTimeStamp;
1959 prevTagSize = 11 + nPacketLen;
1960 @@ -619,7 +628,7 @@ WriteStream(char **buf, // target pointer, maybe preallocated
1961 unsigned int len = nPacketLen;
1962
1963 // correct tagSize and obtain timestamp if we have an FLV stream
1964 - if (packet->m_packetType == 0x16)
1965 + if (packet->m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO)
1966 {
1967 unsigned int pos = 0;
1968
1969 @@ -629,8 +638,11 @@ WriteStream(char **buf, // target pointer, maybe preallocated
1970 *nTimeStamp = AMF_DecodeInt24(packetBody + pos + 4);
1971 *nTimeStamp |= (packetBody[pos + 7] << 24);
1972
1973 - // set data type
1974 - //*dataType |= (((*(packetBody+pos) == 0x08)<<2)|(*(packetBody+pos) == 0x09));
1975 +#if 0
1976 + /* set data type */
1977 + *dataType |= (((*(packetBody+pos) == RTMP_PACKET_TYPE_AUDIO) << 2)
1978 + | (*(packetBody+pos) == RTMP_PACKET_TYPE_VIDEO));
1979 +#endif
1980
1981 if (pos + 11 + dataSize + 4 > nPacketLen)
1982 {
1983 @@ -680,7 +692,7 @@ WriteStream(char **buf, // target pointer, maybe preallocated
1984 }
1985 ptr += len;
1986
1987 - if (packet->m_packetType != 0x16)
1988 + if (packet->m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO)
1989 { // FLV tag packets contain their own prevTagSize
1990 AMF_EncodeInt32(ptr, pend, prevTagSize);
1991 //ptr += 4;
1992 @@ -828,7 +840,7 @@ TFTYPE doServe(void *arg) // server socket and state (our listening socket)
1993 if (RTMPPacket_IsReady(&ps))
1994 {
1995 /* change chunk size */
1996 - if (ps.m_packetType == 0x01)
1997 + if (ps.m_packetType == RTMP_PACKET_TYPE_CHUNK_SIZE)
1998 {
1999 if (ps.m_nBodySize >= 4)
2000 {
2001 @@ -839,7 +851,7 @@ TFTYPE doServe(void *arg) // server socket and state (our listening socket)
2002 }
2003 }
2004 /* bytes received */
2005 - else if (ps.m_packetType == 0x03)
2006 + else if (ps.m_packetType == RTMP_PACKET_TYPE_BYTES_READ_REPORT)
2007 {
2008 if (ps.m_nBodySize >= 4)
2009 {
2010 @@ -849,7 +861,7 @@ TFTYPE doServe(void *arg) // server socket and state (our listening socket)
2011 }
2012 }
2013 /* ctrl */
2014 - else if (ps.m_packetType == 0x04)
2015 + else if (ps.m_packetType == RTMP_PACKET_TYPE_CONTROL)
2016 {
2017 short nType = AMF_DecodeInt16(ps.m_body);
2018 /* UpdateBufferMS */
2019 @@ -875,13 +887,16 @@ TFTYPE doServe(void *arg) // server socket and state (our listening socket)
2020 }
2021 }
2022 }
2023 - else if (ps.m_packetType == 0x11 || ps.m_packetType == 0x14)
2024 - if (ServePacket(server, 0, &ps) && server->f_cur)
2025 - {
2026 - fclose(server->f_cur->f_file);
2027 - server->f_cur->f_file = NULL;
2028 - server->f_cur = NULL;
2029 - }
2030 + else if (ps.m_packetType == RTMP_PACKET_TYPE_FLEX_MESSAGE
2031 + || ps.m_packetType == RTMP_PACKET_TYPE_INVOKE)
2032 + {
2033 + if (ServePacket(server, 0, &ps) && server->f_cur)
2034 + {
2035 + fclose(server->f_cur->f_file);
2036 + server->f_cur->f_file = NULL;
2037 + server->f_cur = NULL;
2038 + }
2039 + }
2040 RTMP_SendPacket(&server->rc, &ps, FALSE);
2041 RTMPPacket_Free(&ps);
2042 break;
2043 @@ -902,7 +917,7 @@ TFTYPE doServe(void *arg) // server socket and state (our listening socket)
2044 server->rc.m_pausing = 0;
2045 }
2046 /* change chunk size */
2047 - if (pc.m_packetType == 0x01)
2048 + if (pc.m_packetType == RTMP_PACKET_TYPE_CHUNK_SIZE)
2049 {
2050 if (pc.m_nBodySize >= 4)
2051 {
2052 @@ -912,7 +927,7 @@ TFTYPE doServe(void *arg) // server socket and state (our listening socket)
2053 server->rs.m_outChunkSize = server->rc.m_inChunkSize;
2054 }
2055 }
2056 - else if (pc.m_packetType == 0x04)
2057 + else if (pc.m_packetType == RTMP_PACKET_TYPE_CONTROL)
2058 {
2059 short nType = AMF_DecodeInt16(pc.m_body);
2060 /* SWFverification */
2061 @@ -929,17 +944,18 @@ TFTYPE doServe(void *arg) // server socket and state (our listening socket)
2062 #endif
2063 }
2064 else if (server->f_cur && (
2065 - pc.m_packetType == 0x08 ||
2066 - pc.m_packetType == 0x09 ||
2067 - pc.m_packetType == 0x12 ||
2068 - pc.m_packetType == 0x16) &&
2069 + pc.m_packetType == RTMP_PACKET_TYPE_AUDIO ||
2070 + pc.m_packetType == RTMP_PACKET_TYPE_VIDEO ||
2071 + pc.m_packetType == RTMP_PACKET_TYPE_INFO ||
2072 + pc.m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO) &&
2073 RTMP_ClientPacket(&server->rc, &pc))
2074 {
2075 int len = WriteStream(&buf, &buflen, &server->stamp, &pc);
2076 if (len > 0 && fwrite(buf, 1, len, server->f_cur->f_file) != len)
2077 goto cleanup;
2078 }
2079 - else if ( pc.m_packetType == 0x11 || pc.m_packetType == 0x14)
2080 + else if (pc.m_packetType == RTMP_PACKET_TYPE_FLEX_MESSAGE ||
2081 + pc.m_packetType == RTMP_PACKET_TYPE_INVOKE)
2082 {
2083 if (ServePacket(server, 1, &pc) && server->f_cur)
2084 {
2085 --
2086 1.7.10.4
2087
2088
2089 From e09abc08504988e5c286ffc9c92da3ba76f95a20 Mon Sep 17 00:00:00 2001
2090 From: Compn <tempn@twmi.rr.com>
2091 Date: Tue, 5 Jul 2011 09:48:23 -0400
2092 Subject: [PATCH 28/34] add -shared to mingw ldflags, fixes compilation error
2093 patch by Martin Storsjo
2094
2095 ---
2096 librtmp/Makefile | 2 +-
2097 1 file changed, 1 insertion(+), 1 deletion(-)
2098
2099 diff --git a/librtmp/Makefile b/librtmp/Makefile
2100 index 1ea31a0..785e869 100644
2101 --- a/librtmp/Makefile
2102 +++ b/librtmp/Makefile
2103 @@ -54,7 +54,7 @@ SODIR=$(SODIR_$(SYS))
2104 SO_LDFLAGS_posix=-shared -Wl,-soname,$@
2105 SO_LDFLAGS_darwin=-dynamiclib -flat_namespace -undefined suppress -fno-common \
2106 -headerpad_max_install_names
2107 -SO_LDFLAGS_mingw=
2108 +SO_LDFLAGS_mingw=-shared
2109 SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
2110
2111 SHARED=yes
2112 --
2113 1.7.10.4
2114
2115
2116 From 0e9b4917c1163227c48cd83e081aa972ed7d3111 Mon Sep 17 00:00:00 2001
2117 From: Howard Chu <hyc@symas.com>
2118 Date: Mon, 11 Jul 2011 14:41:11 -0700
2119 Subject: [PATCH 29/34] Revert "Drop back on the handshake version, avoid
2120 rtmpe 9"
2121
2122 This reverts commit aa2825fbb1d1f70652d558a730baed28149ebbdd.
2123
2124 Conflicts:
2125
2126 librtmp/handshake.h
2127 ---
2128 librtmp/handshake.h | 6 ++----
2129 1 file changed, 2 insertions(+), 4 deletions(-)
2130
2131 diff --git a/librtmp/handshake.h b/librtmp/handshake.h
2132 index b172dbf..958579a 100644
2133 --- a/librtmp/handshake.h
2134 +++ b/librtmp/handshake.h
2135 @@ -400,10 +400,8 @@ HandShake(RTMP * r, int FP9HandShake)
2136 /* set version to at least 9.0.115.0 */
2137 if (encrypted)
2138 {
2139 -/* clientsig[4] = 128;
2140 - clientsig[6] = 3; */
2141 - clientsig[4] = 9;
2142 - clientsig[6] = 0x7c;
2143 + clientsig[4] = 128;
2144 + clientsig[6] = 3;
2145 }
2146 else
2147 {
2148 --
2149 1.7.10.4
2150
2151
2152 From d1f14b147e03aa17c968b96d6573320410a5252c Mon Sep 17 00:00:00 2001
2153 From: Howard Chu <hyc@symas.com>
2154 Date: Mon, 11 Jul 2011 16:12:39 -0700
2155 Subject: [PATCH 30/34] Add RTMPE type 9 handshake signature
2156
2157 ---
2158 librtmp/handshake.h | 349 +++++++++++++++++++++++++++++++++++++++++++++++++--
2159 1 file changed, 336 insertions(+), 13 deletions(-)
2160
2161 diff --git a/librtmp/handshake.h b/librtmp/handshake.h
2162 index 958579a..98bf3c8 100644
2163 --- a/librtmp/handshake.h
2164 +++ b/librtmp/handshake.h
2165 @@ -358,6 +358,337 @@ static void rtmpe8_sig(uint8_t *in, uint8_t *out, int keyid)
2166 out[7] = v1;
2167 }
2168
2169 +/* RTMPE type 9 uses Blowfish on the regular signature
2170 + * http://en.wikipedia.org/wiki/Blowfish_(cipher)
2171 + */
2172 +#define BF_ROUNDS 16
2173 +typedef struct bf_key {
2174 + uint32_t s[4][256];
2175 + uint32_t p[BF_ROUNDS+2];
2176 +} bf_key;
2177 +
2178 +static const uint32_t bf_sinit[][256] = {
2179 +
2180 + /* S-Box 0 */
2181 + { 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96,
2182 + 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
2183 + 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658,
2184 + 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
2185 + 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e,
2186 + 0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
2187 + 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, 0x55ca396a, 0x2aab10b6,
2188 + 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
2189 + 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c,
2190 + 0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
2191 + 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, 0xef845d5d, 0xe98575b1,
2192 + 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
2193 + 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a,
2194 + 0x670c9c61, 0xabd388f0, 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
2195 + 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, 0xa1f1651d, 0x39af0176,
2196 + 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
2197 + 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706,
2198 + 0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
2199 + 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, 0xe3fe501a, 0xb6794c3b,
2200 + 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
2201 + 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c,
2202 + 0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
2203 + 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, 0x5579c0bd, 0x1a60320a,
2204 + 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
2205 + 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760,
2206 + 0x53317b48, 0x3e00df82, 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
2207 + 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, 0x695b27b0, 0xbbca58c8,
2208 + 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
2209 + 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33,
2210 + 0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
2211 + 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, 0xd08ed1d0, 0xafc725e0,
2212 + 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
2213 + 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777,
2214 + 0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
2215 + 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, 0x165fa266, 0x80957705,
2216 + 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
2217 + 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e,
2218 + 0x226800bb, 0x57b8e0af, 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
2219 + 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, 0x83260376, 0x6295cfa9,
2220 + 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
2221 + 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f,
2222 + 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
2223 + 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a, },
2224 +
2225 + /* S-Box 1 */
2226 + { 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d,
2227 + 0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
2228 + 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65,
2229 + 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
2230 + 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9,
2231 + 0x3c971814, 0x6b6a70a1, 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
2232 + 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37, 0xf0500c0d,
2233 + 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
2234 + 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc,
2235 + 0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
2236 + 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908,
2237 + 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
2238 + 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124,
2239 + 0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
2240 + 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908,
2241 + 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
2242 + 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b,
2243 + 0x3c11183b, 0x5924a509, 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
2244 + 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c, 0x4e3d06fa,
2245 + 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
2246 + 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d,
2247 + 0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
2248 + 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5,
2249 + 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
2250 + 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96,
2251 + 0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
2252 + 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca,
2253 + 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
2254 + 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77,
2255 + 0x11ed935f, 0x16681281, 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
2256 + 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb, 0x532e3054,
2257 + 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
2258 + 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea,
2259 + 0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
2260 + 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646,
2261 + 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
2262 + 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea,
2263 + 0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
2264 + 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e,
2265 + 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
2266 + 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd,
2267 + 0x675fda79, 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
2268 + 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, },
2269 +
2270 + /* S-Box 2 */
2271 + { 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7,
2272 + 0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
2273 + 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af,
2274 + 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
2275 + 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4,
2276 + 0x0a2c86da, 0xe9b66dfb, 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
2277 + 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec,
2278 + 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
2279 + 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332,
2280 + 0x6841e7f7, 0xca7820fb, 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
2281 + 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, 0x55a867bc, 0xa1159a58,
2282 + 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
2283 + 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22,
2284 + 0x48c1133f, 0xc70f86dc, 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
2285 + 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60,
2286 + 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
2287 + 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99,
2288 + 0xde720c8c, 0x2da2f728, 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
2289 + 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74,
2290 + 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
2291 + 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3,
2292 + 0xb5390f92, 0x690fed0b, 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
2293 + 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, 0x37392eb3, 0xcc115979,
2294 + 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
2295 + 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa,
2296 + 0x3d25bdd8, 0xe2e1c3c9, 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
2297 + 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086,
2298 + 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
2299 + 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24,
2300 + 0x55464299, 0xbf582e61, 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
2301 + 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84,
2302 + 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
2303 + 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09,
2304 + 0x662d09a1, 0xc4324633, 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
2305 + 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, 0xdcb7da83, 0x573906fe,
2306 + 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
2307 + 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0,
2308 + 0x006058aa, 0x30dc7d62, 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
2309 + 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188,
2310 + 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
2311 + 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8,
2312 + 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
2313 + 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0, },
2314 +
2315 + /* S-Box 3 */
2316 + { 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742,
2317 + 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
2318 + 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, 0x5748ab2f, 0xbc946e79,
2319 + 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
2320 + 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a,
2321 + 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
2322 + 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, 0x2826a2f9, 0xa73a3ae1,
2323 + 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
2324 + 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797,
2325 + 0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
2326 + 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, 0xe029ac71, 0xe019a5e6,
2327 + 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
2328 + 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba,
2329 + 0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
2330 + 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, 0x7533d928, 0xb155fdf5,
2331 + 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
2332 + 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce,
2333 + 0x5121ce64, 0x774fbe32, 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
2334 + 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, 0xb39a460a, 0x6445c0dd,
2335 + 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
2336 + 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb,
2337 + 0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
2338 + 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc,
2339 + 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
2340 + 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc,
2341 + 0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
2342 + 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, 0x1a908749, 0xd44fbd9a,
2343 + 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
2344 + 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a,
2345 + 0x0f91fc71, 0x9b941525, 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
2346 + 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, 0xe0ec6e0e, 0x1698db3b,
2347 + 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
2348 + 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e,
2349 + 0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
2350 + 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, 0xf523f357, 0xa6327623,
2351 + 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
2352 + 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a,
2353 + 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
2354 + 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, 0x53113ec0, 0x1640e3d3,
2355 + 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
2356 + 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c,
2357 + 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
2358 + 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6, },
2359 +};
2360 +
2361 +static const uint32_t bf_pinit[] = {
2362 + /* P-Box */
2363 + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0,
2364 + 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
2365 + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b,
2366 +};
2367 +
2368 +#define KEYBYTES 24
2369 +
2370 +static const unsigned char rtmpe9_keys[16][KEYBYTES] = {
2371 + { 0x79, 0x34, 0x77, 0x4c, 0x67, 0xd1, 0x38, 0x3a, 0xdf, 0xb3, 0x56, 0xbe,
2372 + 0x8b, 0x7b, 0xd0, 0x24, 0x38, 0xe0, 0x73, 0x58, 0x41, 0x5d, 0x69, 0x67, },
2373 + { 0x46, 0xf6, 0xb4, 0xcc, 0x01, 0x93, 0xe3, 0xa1, 0x9e, 0x7d, 0x3c, 0x65,
2374 + 0x55, 0x86, 0xfd, 0x09, 0x8f, 0xf7, 0xb3, 0xc4, 0x6f, 0x41, 0xca, 0x5c, },
2375 + { 0x1a, 0xe7, 0xe2, 0xf3, 0xf9, 0x14, 0x79, 0x94, 0xc0, 0xd3, 0x97, 0x43,
2376 + 0x08, 0x7b, 0xb3, 0x84, 0x43, 0x2f, 0x9d, 0x84, 0x3f, 0x21, 0x01, 0x9b, },
2377 + { 0xd3, 0xe3, 0x54, 0xb0, 0xf7, 0x1d, 0xf6, 0x2b, 0x5a, 0x43, 0x4d, 0x04,
2378 + 0x83, 0x64, 0x3e, 0x0d, 0x59, 0x2f, 0x61, 0xcb, 0xb1, 0x6a, 0x59, 0x0d, },
2379 + { 0xc8, 0xc1, 0xe9, 0xb8, 0x16, 0x56, 0x99, 0x21, 0x7b, 0x5b, 0x36, 0xb7,
2380 + 0xb5, 0x9b, 0xdf, 0x06, 0x49, 0x2c, 0x97, 0xf5, 0x95, 0x48, 0x85, 0x7e, },
2381 + { 0xeb, 0xe5, 0xe6, 0x2e, 0xa4, 0xba, 0xd4, 0x2c, 0xf2, 0x16, 0xe0, 0x8f,
2382 + 0x66, 0x23, 0xa9, 0x43, 0x41, 0xce, 0x38, 0x14, 0x84, 0x95, 0x00, 0x53, },
2383 + { 0x66, 0xdb, 0x90, 0xf0, 0x3b, 0x4f, 0xf5, 0x6f, 0xe4, 0x9c, 0x20, 0x89,
2384 + 0x35, 0x5e, 0xd2, 0xb2, 0xc3, 0x9e, 0x9f, 0x7f, 0x63, 0xb2, 0x28, 0x81, },
2385 + { 0xbb, 0x20, 0xac, 0xed, 0x2a, 0x04, 0x6a, 0x19, 0x94, 0x98, 0x9b, 0xc8,
2386 + 0xff, 0xcd, 0x93, 0xef, 0xc6, 0x0d, 0x56, 0xa7, 0xeb, 0x13, 0xd9, 0x30, },
2387 + { 0xbc, 0xf2, 0x43, 0x82, 0x09, 0x40, 0x8a, 0x87, 0x25, 0x43, 0x6d, 0xe6,
2388 + 0xbb, 0xa4, 0xb9, 0x44, 0x58, 0x3f, 0x21, 0x7c, 0x99, 0xbb, 0x3f, 0x24, },
2389 + { 0xec, 0x1a, 0xaa, 0xcd, 0xce, 0xbd, 0x53, 0x11, 0xd2, 0xfb, 0x83, 0xb6,
2390 + 0xc3, 0xba, 0xab, 0x4f, 0x62, 0x79, 0xe8, 0x65, 0xa9, 0x92, 0x28, 0x76, },
2391 + { 0xc6, 0x0c, 0x30, 0x03, 0x91, 0x18, 0x2d, 0x7b, 0x79, 0xda, 0xe1, 0xd5,
2392 + 0x64, 0x77, 0x9a, 0x12, 0xc5, 0xb1, 0xd7, 0x91, 0x4f, 0x96, 0x4c, 0xa3, },
2393 + { 0xd7, 0x7c, 0x2a, 0xbf, 0xa6, 0xe7, 0x85, 0x7c, 0x45, 0xad, 0xff, 0x12,
2394 + 0x94, 0xd8, 0xde, 0xa4, 0x5c, 0x3d, 0x79, 0xa4, 0x44, 0x02, 0x5d, 0x22, },
2395 + { 0x16, 0x19, 0x0d, 0x81, 0x6a, 0x4c, 0xc7, 0xf8, 0xb8, 0xf9, 0x4e, 0xcd,
2396 + 0x2c, 0x9e, 0x90, 0x84, 0xb2, 0x08, 0x25, 0x60, 0xe1, 0x1e, 0xae, 0x18, },
2397 + { 0xe9, 0x7c, 0x58, 0x26, 0x1b, 0x51, 0x9e, 0x49, 0x82, 0x60, 0x61, 0xfc,
2398 + 0xa0, 0xa0, 0x1b, 0xcd, 0xf5, 0x05, 0xd6, 0xa6, 0x6d, 0x07, 0x88, 0xa3, },
2399 + { 0x2b, 0x97, 0x11, 0x8b, 0xd9, 0x4e, 0xd9, 0xdf, 0x20, 0xe3, 0x9c, 0x10,
2400 + 0xe6, 0xa1, 0x35, 0x21, 0x11, 0xf9, 0x13, 0x0d, 0x0b, 0x24, 0x65, 0xb2, },
2401 + { 0x53, 0x6a, 0x4c, 0x54, 0xac, 0x8b, 0x9b, 0xb8, 0x97, 0x29, 0xfc, 0x60,
2402 + 0x2c, 0x5b, 0x3a, 0x85, 0x68, 0xb5, 0xaa, 0x6a, 0x44, 0xcd, 0x3f, 0xa7, },
2403 +};
2404 +
2405 +#define BF_ENC(X,S) \
2406 + (((S[0][X>>24] + S[1][X>>16 & 0xff]) ^ S[2][(X>>8) & 0xff]) + S[3][X & 0xff])
2407 +
2408 +static void bf_enc(uint32_t *x, bf_key *key)
2409 +{
2410 + uint32_t Xl;
2411 + uint32_t Xr;
2412 + uint32_t temp;
2413 + int i;
2414 +
2415 + Xl = x[0];
2416 + Xr = x[1];
2417 +
2418 + for (i = 0; i < BF_ROUNDS; ++i) {
2419 + Xl ^= key->p[i];
2420 + Xr ^= BF_ENC(Xl,key->s);
2421 +
2422 + temp = Xl;
2423 + Xl = Xr;
2424 + Xr = temp;
2425 + }
2426 +
2427 + Xl ^= key->p[BF_ROUNDS];
2428 + Xr ^= key->p[BF_ROUNDS + 1];
2429 +
2430 + x[0] = Xr;
2431 + x[1] = Xl;
2432 +}
2433 +
2434 +static void bf_setkey(const unsigned char *kp, int keybytes, bf_key *key)
2435 +{
2436 + int i;
2437 + int j;
2438 + int k;
2439 + uint32_t data;
2440 + uint32_t d[2];
2441 +
2442 + memcpy(key->p, bf_pinit, sizeof(key->p));
2443 + memcpy(key->s, bf_sinit, sizeof(key->s));
2444 +
2445 + j = 0;
2446 + for (i = 0; i < BF_ROUNDS + 2; ++i) {
2447 + data = 0x00000000;
2448 + for (k = 0; k < 4; ++k) {
2449 + data = (data << 8) | kp[j];
2450 + j = j + 1;
2451 + if (j >= keybytes) {
2452 + j = 0;
2453 + }
2454 + }
2455 + key->p[i] ^= data;
2456 + }
2457 +
2458 + d[0] = 0x00000000;
2459 + d[1] = 0x00000000;
2460 +
2461 + for (i = 0; i < BF_ROUNDS + 2; i += 2) {
2462 + bf_enc(d, key);
2463 +
2464 + key->p[i] = d[0];
2465 + key->p[i + 1] = d[1];
2466 + }
2467 +
2468 + for (i = 0; i < 4; ++i) {
2469 + for (j = 0; j < 256; j += 2) {
2470 +
2471 + bf_enc(d, key);
2472 +
2473 + key->s[i][j] = d[0];
2474 + key->s[i][j + 1] = d[1];
2475 + }
2476 + }
2477 +}
2478 +
2479 +static void rtmpe9_sig(uint8_t *in, uint8_t *out, int keyid)
2480 +{
2481 + uint32_t d[2];
2482 + bf_key key;
2483 +
2484 + bf_setkey(rtmpe9_keys[keyid], KEYBYTES, &key);
2485 +
2486 + /* input is little-endian */
2487 + d[0] = in[0] | (in[1] << 8) | (in[2] << 16) | (in[3] << 24);
2488 + d[1] = in[4] | (in[5] << 8) | (in[6] << 16) | (in[7] << 24);
2489 + bf_enc(d, &key);
2490 + out[0] = d[0] & 0xff;
2491 + out[1] = (d[0] >> 8) & 0xff;
2492 + out[2] = (d[0] >> 16) & 0xff;
2493 + out[3] = (d[0] >> 24) & 0xff;
2494 + out[4] = d[1] & 0xff;
2495 + out[5] = (d[1] >> 8) & 0xff;
2496 + out[6] = (d[1] >> 16) & 0xff;
2497 + out[7] = (d[1] >> 24) & 0xff;
2498 +}
2499 +
2500 static int
2501 HandShake(RTMP * r, int FP9HandShake)
2502 {
2503 @@ -605,8 +936,7 @@ HandShake(RTMP * r, int FP9HandShake)
2504 for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
2505 rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
2506 }
2507 -#if 0
2508 - else if (type == 9))
2509 + else if (type == 9)
2510 {
2511 uint8_t *dptr = digestResp;
2512 uint8_t *sig = signatureResp;
2513 @@ -615,7 +945,6 @@ HandShake(RTMP * r, int FP9HandShake)
2514 rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
2515 }
2516 #endif
2517 -#endif
2518 RTMP_Log(RTMP_LOGDEBUG, "%s: Client signature calculated:", __FUNCTION__);
2519 RTMP_LogHex(RTMP_LOGDEBUG, signatureResp, SHA256_DIGEST_LENGTH);
2520 }
2521 @@ -680,7 +1009,6 @@ HandShake(RTMP * r, int FP9HandShake)
2522 for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
2523 rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
2524 }
2525 -#if 0
2526 else if (type == 9)
2527 {
2528 uint8_t *dptr = digest;
2529 @@ -690,7 +1018,6 @@ HandShake(RTMP * r, int FP9HandShake)
2530 rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
2531 }
2532 #endif
2533 -#endif
2534 RTMP_Log(RTMP_LOGDEBUG, "%s: Signature calculated:", __FUNCTION__);
2535 RTMP_LogHex(RTMP_LOGDEBUG, signature, SHA256_DIGEST_LENGTH);
2536 if (memcmp
2537 @@ -964,8 +1291,7 @@ SHandShake(RTMP * r)
2538 for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
2539 rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
2540 }
2541 -#if 0
2542 - else if (type == 9))
2543 + else if (type == 9)
2544 {
2545 uint8_t *dptr = digestResp;
2546 uint8_t *sig = signatureResp;
2547 @@ -974,7 +1300,6 @@ SHandShake(RTMP * r)
2548 rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
2549 }
2550 #endif
2551 -#endif
2552
2553 /* some info output */
2554 RTMP_Log(RTMP_LOGDEBUG,
2555 @@ -1030,17 +1355,15 @@ SHandShake(RTMP * r)
2556 for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
2557 rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
2558 }
2559 -#if 0
2560 - else if (type == 9))
2561 + else if (type == 9)
2562 {
2563 - uint8_t *dptr = digestResp;
2564 - uint8_t *sig = signatureResp;
2565 + uint8_t *dptr = digest;
2566 + uint8_t *sig = signature;
2567 /* encrypt signatureResp */
2568 for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
2569 rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
2570 }
2571 #endif
2572 -#endif
2573
2574 /* show some information */
2575 RTMP_Log(RTMP_LOGDEBUG, "%s: Digest key: ", __FUNCTION__);
2576 --
2577 1.7.10.4
2578
2579
2580 From be0590a86af80df528e3556b86f110ad4b5cbb27 Mon Sep 17 00:00:00 2001
2581 From: Howard Chu <hyc@symas.com>
2582 Date: Mon, 11 Jul 2011 16:41:28 -0700
2583 Subject: [PATCH 31/34] Add LIB_RTMP macro
2584
2585 Allows changing to static linking on the cmd line
2586 ---
2587 Makefile | 3 ++-
2588 1 file changed, 2 insertions(+), 1 deletion(-)
2589
2590 diff --git a/Makefile b/Makefile
2591 index c322e9a..1597be8 100644
2592 --- a/Makefile
2593 +++ b/Makefile
2594 @@ -35,7 +35,8 @@ MANDIR=$(DESTDIR)$(mandir)
2595 LIBS_posix=
2596 LIBS_darwin=
2597 LIBS_mingw=-lws2_32 -lwinmm -lgdi32
2598 -LIBS=-Llibrtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
2599 +LIB_RTMP=-Llibrtmp -lrtmp
2600 +LIBS=$(LIB_RTMP) $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
2601
2602 THREADLIB_posix=-lpthread
2603 THREADLIB_darwin=-lpthread
2604 --
2605 1.7.10.4
2606
2607
2608 From 4028a5aa7f72cac44a62b4aac596ff3c82e6e019 Mon Sep 17 00:00:00 2001
2609 From: Howard Chu <hyc@symas.com>
2610 Date: Mon, 11 Jul 2011 17:19:25 -0700
2611 Subject: [PATCH 32/34] Additional credit for RTMPE 9 keys
2612
2613 ---
2614 README | 5 +++--
2615 1 file changed, 3 insertions(+), 2 deletions(-)
2616
2617 diff --git a/README b/README
2618 index 5689853..865c6c4 100644
2619 --- a/README
2620 +++ b/README
2621 @@ -1,7 +1,8 @@
2622 -RTMP Dump v2.3
2623 +RTMP Dump v2.4
2624 (C) 2009 Andrej Stepanchuk
2625 -(C) 2009-2010 Howard Chu
2626 +(C) 2009-2011 Howard Chu
2627 (C) 2010 2a665470ced7adb7156fcef47f8199a6371c117b8a79e399a2771e0b36384090
2628 +(C) 2011 33ae1ce77301f4b4494faaa5f609f3c48b9dcf82
2629 License: GPLv2
2630 librtmp license: LGPLv2.1
2631 http://rtmpdump.mplayerhq.hu/
2632 --
2633 1.7.10.4
2634
2635
2636 From 3121324046e4ca1934e7e28293fc8326475d5053 Mon Sep 17 00:00:00 2001
2637 From: Howard Chu <hyc@symas.com>
2638 Date: Mon, 11 Jul 2011 17:22:43 -0700
2639 Subject: [PATCH 33/34] Version bump
2640
2641 ---
2642 Makefile | 2 +-
2643 librtmp/Makefile | 2 +-
2644 2 files changed, 2 insertions(+), 2 deletions(-)
2645
2646 diff --git a/Makefile b/Makefile
2647 index 1597be8..6ef5742 100644
2648 --- a/Makefile
2649 +++ b/Makefile
2650 @@ -1,4 +1,4 @@
2651 -VERSION=v2.3
2652 +VERSION=v2.4
2653
2654 prefix=/usr/local
2655
2656 diff --git a/librtmp/Makefile b/librtmp/Makefile
2657 index 785e869..d61e7a4 100644
2658 --- a/librtmp/Makefile
2659 +++ b/librtmp/Makefile
2660 @@ -1,4 +1,4 @@
2661 -VERSION=v2.3
2662 +VERSION=v2.4
2663
2664 prefix=/usr/local
2665
2666 --
2667 1.7.10.4
2668
2669
2670 From c28f1bab7822de97353849e7787b59e50bbb1428 Mon Sep 17 00:00:00 2001
2671 From: Howard Chu <hyc@symas.com>
2672 Date: Mon, 11 Jul 2011 17:24:33 -0700
2673 Subject: [PATCH 34/34] v2.4 changes
2674
2675 ---
2676 ChangeLog | 5 ++++-
2677 1 file changed, 4 insertions(+), 1 deletion(-)
2678
2679 diff --git a/ChangeLog b/ChangeLog
2680 index f57c580..fb2319f 100644
2681 --- a/ChangeLog
2682 +++ b/ChangeLog
2683 @@ -1,9 +1,12 @@
2684 RTMPDump
2685 Copyright 2008-2009 Andrej Stepanchuk; Distributed under the GPL v2
2686 -Copyright 2009-2010 Howard Chu
2687 +Copyright 2009-2011 Howard Chu
2688 Copyright 2009 The Flvstreamer Team
2689 http://rtmpdump.mplayerhq.hu/
2690
2691 +11 July 2011, v2.4
2692 +- add RTMPE type 9 handshake support
2693 +
2694 30 June 2010, v2.3
2695 - fix RC4 cleanup for GnuTLS/gcrypt
2696 - declare RTMP_Write buf as const
2697 --
2698 1.7.10.4
2699