README
1FLVStreamer v2.1c
2(C) 2009 Andrej Stepanchuk
3(C) 2009-2010 Howard Chu
4(C) 2009-2010 The FLVstreamer Team
5License: GPLv2
6
7To compile type "make" with your platform name, e.g. (for osx, linux, or cygwin)
8
9 $ make posix
10
11For mingw:
12
13 $ make mingw
14
15Please read the Makefile to see what other make variables are used.
16
17
18Connect Parameters
19------------------
20
21Some servers expect additional custom parameters to be attached to the
22RTMP connect request. The "--auth" option handles a specific case, where
23a boolean TRUE followed by the given string are added to the request.
24Other servers may require completely different parameters, so the new
25"--conn" option has been added. This option can be set multiple times
26on the command line, adding one parameter each time.
27
28The argument to the option must take the form <type> : <value> where
29type can be B for boolean, S for string, N for number, and O for object.
30For booleans the value must be 0 or 1. Also, for objects the value must
31be 1 to start a new object, or 0 to end the current object.
32
33Examples:
34 --conn B:0 --conn S:hello --conn N:3.14159
35
36Named parameters can be specified by prefixing 'N' to the type. Then the
37name should come next, and finally the value:
38 --conn NB:myflag:1 --conn NS:category:something --conn NN:pi:3.14159
39
40Objects may be added sequentially:
41 -C O:1 -C NB:flag:1 -C NS:status:success -C O:0 -C O:1 -C NN:time:12.30 -C O:0
42or nested:
43 -C O:1 -C NS:code:hello -C NO:extra:1 -C NS:data:stuff -C O:0 -C O:0
44
45Credit goes to team boxee for the XBMC RTMP code originally used in RTMPDumper.
46The current code is based on the XBMC code but rewritten in C by Howard Chu.
47
48Example Servers
49---------------
50Three different types of servers are also present in this distribution:
51 rtmpsrv - a stub server
52 rtmpsuck - a transparent proxy
53 streams - an RTMP to HTTP gateway
54
55rtmpsrv - Note that this is very incomplete code, and I haven't yet decided
56whether or not to finish it. In its current form it is useful for obtaining
57all the parameters that a real Flash client would send to an RTMP server, so
58that they can be used with flvstreamer.
59
60rtmpsuck - proxy server. See below...
61
62All you need to do is redirect your Flash clients to the machine running this
63server and it will dump out all the connect / play parameters that the Flash
64client sent. The simplest way to cause the redirect is by editing /etc/hosts
65when you know the hostname of the RTMP server, and point it to localhost while
66running rtmpsrv on your machine. (This approach should work on any OS; on
67Windows you would edit %SystemRoot%\system32\drivers\etc\hosts.)
68
69On Linux you can also use iptables to redirect all outbound RTMP traffic.
70You can do this as root:
71
72iptables -t nat -A OUTPUT -p tcp --dport 1935 -j REDIRECT
73
74In my original plan I would have the transparent proxy running as a special
75user (e.g. user "proxy"), and regular Flash clients running as any other user.
76In that case the proxy would make the connection to the real RTMP server. The
77iptables rule would look like this:
78
79iptables -t nat -A OUTPUT -p tcp --dport 1935 -m owner \! --uid-owner proxy \
80 -j REDIRECT
81
82A rule like the above will be needed to use rtmpsuck.
83
84Using it in this mode takes advantage of the Linux support for IP redirects;
85in particular it uses a special getsockopt() call to retrieve the original
86destination address of the connection. That way the proxy can create the
87real outbound connection without any other help from the user. The equivalent
88functionality may exist on other OSs but needs more investigation.
89
90(Based on reading the BSD ipfw manpage, these rules ought to work on BSD:
91
92ipfw add 40 fwd 127.0.0.1 1935 tcp from any to any 1935
93ipfw add 40 fwd 127.0.0.1 1935 tcp from any to any 1935 not uid proxy
94
95Some confirmation from any BSD users would be nice.)
96
97(We have a solution for Windows based on a TDI driver; this is known to
98work on Win2K and WinXP but is assumed to not work on Vista or Win7 as the
99TDI is no longer used on those OS versions. Also, none of the known
100solutions are available as freeware.)
101
102The rtmpsuck command has only one option: "-z" to turn on debug logging.
103It listens on port 1935 for RTMP sessions, but you can also redirect other
104ports to it as needed (read the iptables docs). It first performs an RTMP
105handshake with the client, then waits for the client to send a connect
106request. It parses and prints the connect parameters, then makes an
107outbound connection to the real RTMP server. It performs an RTMP handshake
108with that server, forwards the connect request, and from that point on it
109just relays packets back and forth between the two endpoints.
110
111It also checks for a few packets that it treats specially: a play packet
112from the client will get parsed so that the playpath can be displayed. It
113also handles SWF Verification requests from the server, without forwarding
114them to the client. (There would be no point, since the response is tied to
115each session's handshake.)
116
117Once the play command is processed, all subsequent audio/video data received
118from the server will be written to a file, as well as being delivered back
119to the client.
120
121The point of all this, instead of just using a sniffer, is that since rtmpsuck
122has performed real handshakes with both the client and the server, it can
123negotiate whatever encryption keys are needed and so record the unencrypted
124data.
125
126streams - HTTP gateway: this is an HTTP server that accepts requests that
127consist of flvstreamer parameters. It then connects to the specified RTMP
128server and returns the retrieved data in the HTTP response. The only valid
129HTTP request is "GET /" but additional options can be provided in normal
130URL-encoded fashion. E.g.
131 GET /?r=rtmp:%2f%2fserver%2fmyapp&y=somefile HTTP/1.0
132
133is equivalent the flvstreamer parameters "-r rtmp://server/myapp -y somefile".
134
135Note that only the shortform (single letter) flvstreamer options are supported.
136