Share this page

# web_stream_open

Opens a media stream.

## C Language

int web_stream_open("ID=<string>", "URL=<url>", "Protocol=<protocol>", ["Bandwidth=<n>"], ["StreamBufferingTimeout=<seconds>"], ["DumpPath=<path>"], ["EventReportCB=<name of function>], [“AdaptiveMode=<0 or 1>”], ["Duration=<seconds>"],LAST);

Stream Functions

Argument | Description
--- | ---
ID | The StreamID to be used in other actions on the stream. The ID is created with this function call. An integer greater than 0.
URL | The full absolute address of the media.
Protocol | The communications protocol. One of HTTP or HLS.
Bandwidth | The expected bandwidth. If 0, the Runtime Setting is used.
StreamBufferingTimeout | The timeout in seconds from the beginning of the download until it is possible to begin play. If timed out, the web_stream_play call is aborted with a failed status. This argument overrides the runtime setting Streaming > Time out for video buffering.
DumpPath | Path for downloading streaming file.
EventReportCB See Web Stream Event Callback | The name of a user-coded callback function to report events.
AdaptiveMode | 0 for OFF (default) and 1 for ON. If set to ON, HLS (HTTP Live Streaming) video segments are downloaded only when being played. By default, AdaptiveMode is set to OFF and all HLS video segments are downloaded from the beginning of stream play.
Duration | The total length of the video, in seconds. When this value is set, the video does not need to be decoded when downloaded. Relevant for HTTP protocol only. When a video is streamed with web_stream_open, it frequently requires high CPU usage to decode the video, and analyze the total duration and buffered time stamp. By setting the total duration of the video manually, you can improve performance.
LAST | Required marker for the end of the argument list.

## Return Values

This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.

## Parameterization

Standard parameterization is not available for this function.

## General Information

The web_stream_open function opens a media stream.

The event report callback is invoked zero or more times when events occur.

This function is not recorded. You can insert it manually into your script.

## Example

This is an example of a web streaming script:

Copy code

    Action()
    {
          /**
          HTML5 Video
          /*/
          web_stream_open("ID=1", "URL=http://my_server/streaming-test/Video2/Class%20-%206.mp4", "EventReportCB=PrintBytes", "Protocol=HTTP", "StreamBufferingTimeout=38", LAST);
          web_stream_set_param_double("1",SPEED, 2.0);
          web_stream_set_param_int("1", BANDWIDTH, 2000000);
          web_stream_set_param_int("1", BUFFERING_TIMEOUT, 60);

          web_stream_get_state_string("1", SERVER_IP, "ServerIP");
          lr_output_message("IP:, %s",lr_eval_string("{ServerIP}"));
          lr_output_message("Movie Length : %lf",web_stream_get_param_double("1", Duration));

          /***
          Play a video. Seek forward, seek backward, seek from the beginning, pause, and stop.
          **/
          //Play for 30 sec

          lr_think_time(15);
          lr_start_transaction("HTTP Stream");

          web_stream_play("ID=1", "PlayingDuration=30", "Speed=1.5", LAST);
          lr_vuser_status_message("Current time in movie:%lf", web_stream_get_param_double("1", CURRENT_TIME));

          web_stream_pause("ID=1","PausingDuration=20", LAST);
          lr_vuser_status_message("Current time in movie:%lf", web_stream_get_param_double("1", CURRENT_TIME));

          web_stream_play("ID=1", "PlayingDuration=10", LAST);
          lr_vuser_status_message("Current time in movie:%lf", web_stream_get_param_double("1", CURRENT_TIME));

          web_stream_seek("ID=1", "TimeOffset=11", LAST);
          lr_vuser_status_message("Current time in movie:%lf", web_stream_get_param_double("1", CURRENT_TIME));

          web_stream_play("ID=1", "PlayingDuration=10", LAST);
          lr_vuser_status_message("Current time in movie:%lf", web_stream_get_param_double("1", CURRENT_TIME));

          web_stream_seek("ID=1", "RelativeOffset=90", LAST);
          lr_vuser_status_message("Current time in movie:%lf", web_stream_get_param_double("1", CURRENT_TIME));

          web_stream_play("ID=1", "PlayingDuration=10", LAST);
          lr_vuser_status_message("Current time in movie:%lf", web_stream_get_param_double("1", CURRENT_TIME));

          web_stream_seek("ID=1", "RelativeOffset=-17", LAST);
          lr_vuser_status_message("Current time in movie:%lf", web_stream_get_param_double("1", CURRENT_TIME));

          web_stream_stop("ID=1", LAST);

          lr_end_transaction("HTTP Stream", LR_AUTO);

          web_stream_close("ID=1", LAST);

          return 0;
    }

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: