![]() |
home | contact us | about us | |
| (by Lou Burne, last updated 10-APRIL-2012) | ||
| A | Create an FlvStuffer object. The FlvStuffer is a class for saving RTMP audio, video and meta-data messages into an FLV file. |
| B | Create an RtmpClient object. The RtmpClient constructor takes one parameters, a reference to the main
application window. Since
LiveTv.cs runs in a console, which is windowless, this parameter can be null. EventsEnabled - Set EventsEnabled to false so the RtmpClient doesn't waste time composing events when no one is listening. |
| C | Create a new
RTMP connection. The RtmpConnection object returned encapsulates a connection to
the remote RTMP server. The behavior flags instruct the RtmpClient library to automatically respond to any request for pings or data acknowledgements that come from the server. |
| D | Live feeds can take a few seconds to get going so we set the response timeout to 20 seconds. |
| E | Set
up a callback function to automaytically mount any streams that
the server opens. It is common for RTMP servers to automaytically open stream id=0, "stream0", when a connection is made. In the callback, we use an C# anonymous function to set the buffer size. For the majority of RTMP servers this code will still work if this section is commented out. |
| F | Connect to the
RTMP application. The RTMP application we are connecting to uses standard connection parameters. |
| G | Call an RtmpConnection function to create a stream. This returns an RtmpStream object. An RTMP connection can theoretically support multiple streams, but in reality few RTMP servers are sophisticated enough to do this well. |
| G | Create a WorkingSet object. WorkingSet is a simple class that wraps up some objects so that they can be passed to a callback function as a single parameter. |
| H | Register a
callback function for the new stream. Instead of a separate callback function defined in our code file, we are using a C# anonymous function. For each RTMP message received on our stream, we display the details on the console, and then pass the message to the FlvStuffer to update the FLV file. This callback could be made more efficient by limiting the callbacks to only those types of messages we need to put into the FLV file, i.e., audio, video and meta-data. |
| I | Play the stream. We need to use a special start position value (SpecialStartValue_PlayLiveStream) to indicate to the RTMP Server that this is a live stream. |
| J | Loop until the streaming stops, or the user presses the "C" key. |
| K | Clean up the
RTMP session. Delete the stream, close the connection. The RtmpClient object will be disposed of when it falls out of scope. |
| L | Closing the FlvStuffer will set the correct duration for the FLV file, and flush and close the FLV file. |
![]() |
© 1998-2012 Broccoli Products Ltd Reg Number: 2895355 Reg Office: 27 Old Gloucester Street, London. WC1N 3AX |
Privacy Policy Copyright Notice Liability Disclaimer Contact Us |
|