Streaming Through Firewalls and Proxies: From the Client's Perspective
Developing a Strategy
The good news is that negotiating firewalls is not as mysterious or as sophisticated as it sounds. In fact, your approach can be rather simple:
- Try a series of port and protocol combinations and take the first one that works. While doing so, be careful not to try them too quickly in succession and to clean up those that fail. Leave at least 1,500 milliseconds between connection attempts.
- When you have a good connection, immediately play just the first frame of the video. This enables you to get a representation of the video in place on the web page, without having to store a separate JPEG file as a placeholder. Use the best quality video that you have, because even modem users can receive one frame of high-quality video relatively quickly.
- As soon as the first frame is in place, detect the bandwidth. Bandwidth detection can take up to 5 or more seconds, depending on the client connection. While the user is still watching the web page load and you have a frame grab to hide behind, perform this time-intensive task. By the time the user figures out that this is a video and that they can play it, the bandwidth detection job will be done.
- After bandwidth is detected, read the length of the file on the server. You should do this because in most instances you will need to know the length to build a scrub bar, and you cannot rely on duration information to be written correctly into the header of the Flash Video (FLV) file. It is much more reliable (and very quick) to get the server to read it.
- After you have the stream length, expose (or enable) the playback controls. This prevents users from attempting to play back the video before you know the speed at which they are connected. When they click the Play button, you can direct them to the appropriate stream for their bandwidth on the server. This may be an entirely different stream from the one you used to generate the first frame.