RTMP/RTMPT Streaming

VuGen's Flex protocol supports record and replay of streaming data for both the RTMP and RTMPT protocols. You can record using either the regular recording mode or the simplified recording mode. The simplified mode enables VuGen to generate a single function in place of the multiple functions that are generated when the regular recording mode is used.

VuGen also supports RTMPS and RTMPTS in which the streaming data is sent over SSL.

When you use the simplified mode to record, the following occurs:

  • For an RTMP-based stream: VuGen generates a single flex_rtmp_receive_stream step in place of many flex_rtmp_receive and flex_rtmp_send steps.
  • For an RTMPT-based stream: VuGen generates a single modified flex_rtmp_tunneled_send step in place of many flex_rtmp_tunneled_send steps.

The single generated flex_rtmp_receive_stream or flex_rtmp_tunneled_send step makes the Vuser script more readable (by eliminating multiple lines of code), and makes the script replay more reliable. It is recommended that you use the simplified mode for recording your Vuser scripts, unless the Vuser activity includes asynchronous behavior, as described below.

The simplified recording mode is the default recording mode for streaming. To activate the simplified mode, in the Recording Options dialog box, click Flex > RTMP and select Generate single step for RTMP/T stream handling.

The differences between the simplified and regular recording modes are listed below:

 

Simplified mode

Regular mode

(Recording option) Generate single step for RTMP/T stream handling check box Selected Not selected
Functions generated

RTMP: Generates flex_rtmp_receive_stream functions.

RTMPT: Generates flex_rtmp_tunneled_send functions.

Generates flex_rtmp_receive and flex_rtmp_send steps.
Number of functions generated per stream One Multiple
Supports asynchronous behavior No Yes
Default Mode Yes No

Note: The simplified recording mode is supported for Flash Media Server versions 3.5 and 4.

Back to top

Synchronous Vuser behavior

The flex_rtmp_receive_stream and flex_rtmp_tunneled_send functions that are generated when the simplified recording mode is selected are synchronous functions. This means that no other Vuser functions can be executed while either of these functions is executing. For example, consider a Vuser script that includes a flex_rtmp_receive_stream function that streams a video for 5 minutes. During the 5 minute period during which the video is streaming, the Vuser will not be able to perform any other actions, such as clicking the Pause button or skipping to a different location in the video. Clicking a button while a video is streaming is an example of asynchronous behavior.

Although a single generated step makes script replay more reliable, it is not able to replay asynchronous actions (such as pause and seek) that you may have performed while recording the script. The single generated step also does not replay the automatic requests that the client performs when Dynamic Stream is in use. If it is important to replay these asynchronous actions, you must record the Vuser script using the regular recording mode - not the simplified recording mode - and then manually modify the generated script as described below.

Back to top

Modifying scripts to replay asynchronous user actions

If your Vuser script must be able to replay asynchronous actions that are performed while a streaming action is executed, you must record the Vuser script using the regular recording mode - not the simplified recording mode - and then manually modify the generated script. The modified script will include a combination of single streaming steps and the more verbose steps that are generated with regular recording.

Note: In this section, we will use the term required user actions to refer to the actions that must be performed while a video is streamed.

To create a script that can replay asynchronous behavior, first you record the script using the regular recording mode - not the simplified recording mode. Thereafter, identify the flex_rtmp_send steps that represent required user actions. Then replace the steps between the required user actions with single streaming functions. See the sections below for details.

Note: The modification procedure differs slightly between RTMP and RTMPT steps.

Back to top

Modifying recorded Flex RTMP steps

When you use the regular recording mode, VuGen generates flex_rtmp_receive and flex_rtmp_send steps for all communication with the server. This ensures that user actions such as pause and seek, as well as automatic requests that the client performs when Dynamic Stream is in use, are included in the script. However, this method also captures less-necessary lines of code that are difficult to read and may not be reliable during replay of streaming actions.

Note: To activate the regular recording mode, clear the Generate single step for RTMP/T stream handling option in the Flex > RTMP pane of the Recording Options dialog box.

Follow the instructions below to remove the unnecessary flex_rtmp_receive and flex_rtmp_send steps from your script.

  1. Search for the flex_rtmp_send step that contains the initial play argument. For example:

    flex_rtmp_send("send_step2",

    "ConnectionID=10",

    "Snapshot=tRTMP6.inf",

    MESSAGE,

    ...

    MESSAGE,

    ...

    "Argument=<arguments><string>play</string><number>0</number><null/>"

    ...

    LAST);

  2. Delete or comment out the flex_rtmp_receive steps that occur during streaming. For example:

    //This is the start of the stream:
    flex_rtmp_receive("recv_step2",
    	"ConnectionID=10",
    	"Snapshot=tRTMP7.inf",
    	CHANNEL,
    	"ChunkStreamID=2",
    	CHANNEL,
    	"ChunkStreamID=2",
    	CHANNEL,
    	"ChunkStreamID=4",
    	CHANNEL,
    	"ChunkStreamID=2",
    	LAST);
    flex_rtmp_receive("recv_step3",
    	"ConnectionID=10",
    	"Snapshot=tRTMP8.inf",
    	CHANNEL,
    	"ChunkStreamID=5",
    	CHANNEL,
    	...
  3. Remove the flex_rtmp_send steps that are not related to the required user actions, such as "user control message" types. For example:

    flex_rtmp_send("send_step3",
    	"ConnectionID=10",
    	"Snapshot=tRTMP9.inf",
    	MESSAGE,
    	"DataType=user control message",
    	"EventType=set buffer length",
    	"MessageStreamID=1",
    	"BufferLength=100",
    	LAST);
  4. When you find a flex_rtmp_send step that represents a required user action, do the following:

    1. Manually add a flex_rtmp_receive_stream step before the send step.

      - Make sure that the ConnectionID argument has the same value as the steps you removed above it.

      - The Snapshot argument is not relevant for the manually added step.

      - You can use the ContinueToNexStepAfter = <msec> argument to control the minimum play duration of the stream to download before continuing to the next step.

    2. Determine the flex_rtmp_send steps that represent the required user actions. These will likely include arguments such as pauseRaw, pause, seek and play2 (for Dynamic Stream). For example:

      flex_rtmp_send("send_step5",
      "ConnectionID=10",
      "Snapshot=tRTMP62.inf",
      MESSAGE,
      "DataType=command message amf3",
      "ChunkStreamID=8",
      "MessageStreamID=1",
      "Argument=<arguments><string>pauseRaw</string><number>0</number><null/>"
      "<boolean>true</boolean><number>12000</number></arguments>",
      LAST);
    3. Determine whether there are some extra flex_rtmp_send steps that you can remove. For example, if you dragged a button to seek in the stream, subtle jerks in the motion may be recorded as separate pause and seek actions. In these cases, may not need all of them. Keep only those that describe the desired operations.

    4. Identify the flex_rtmp_receive step that indicates that the server has received the end of the user action. For example:

      //This is the confirmation from the server on the "seek" command.
      flex_rtmp_receive("recv_step55",
      "ConnectionID=10",
      "Snapshot=tRTMP68.inf",
      CHANNEL,
      "ChunkStreamID=2",
      CHANNEL,
      "ChunkStreamID=2",
      LAST);
  5. Repeat steps 2 - 4 for each set of unnecessary receive data and required user actions in your script.

For additional details on flex_rtmp_receive_stream including a complete example, see the Function Reference.

Back to top