mediastreamer2  2.12.1
Typedefs | Functions
Video streaming API - Create and run video streams.

Video streaming API - Easily run video streams from camera capture or static picture files to RTP. More...

Typedefs

typedef VideoStream VideoPreview
 

Functions

VideoStream * video_stream_new2 (const char *ip, int loc_rtp_port, int loc_rtcp_port)
 
int video_stream_start_from_io (VideoStream *stream, RtpProfile *profile, const char *rem_rtp_ip, int rem_rtp_port, const char *rem_rtcp_ip, int rem_rtcp_port, int payload_type, const MSMediaStreamIO *io)
 
MSFiltervideo_stream_get_source_filter (const VideoStream *stream)
 
MSFiltervideo_stream_change_source_filter (VideoStream *stream, MSWebCam *cam, MSFilter *filter, bool_t keep_previous_source)
 This functions changes the source filter for the passed video stream. More...
 
MSFiltervideo_stream_change_camera_keep_previous_source (VideoStream *stream, MSWebCam *cam)
 This is the same function as video_stream_change_source_filter() called with keep_source=1, but the new filter will be created from the MSWebcam that is passed as argument. More...
 
void video_stream_send_fir (VideoStream *stream)
 
void video_stream_send_vfu (VideoStream *stream)
 
MSFiltervideo_stream_stop_keep_source (VideoStream *stream)
 
void video_stream_set_sent_video_size (VideoStream *stream, MSVideoSize vsize)
 
MSVideoSize video_stream_get_sent_video_size (const VideoStream *stream)
 
MSVideoSize video_stream_get_received_video_size (const VideoStream *stream)
 
float video_stream_get_sent_framerate (const VideoStream *stream)
 
float video_stream_get_received_framerate (const VideoStream *stream)
 
const char * video_stream_get_default_video_renderer (void)
 
int video_stream_get_camera_sensor_rotation (VideoStream *stream)
 Gets the camera sensor rotation. More...
 
bool_t video_stream_is_decoding_error_to_be_reported (VideoStream *stream, uint32_t ms)
 
void video_stream_decoding_error_reported (VideoStream *stream)
 
void video_stream_decoding_error_recovered (VideoStream *stream)
 
void video_stream_set_preview_size (VideoStream *stream, MSVideoSize vsize)
 
void video_stream_set_fps (VideoStream *stream, float fps)
 
void audio_stream_link_video (AudioStream *stream, VideoStream *video)
 
void audio_stream_unlink_video (AudioStream *stream, VideoStream *video)
 
void video_stream_use_video_preset (VideoStream *stream, const char *preset)
 
MSFiltervideo_stream_open_remote_play (VideoStream *stream, const char *filename)
 
MSFiltervideo_stream_open_remote_record (VideoStream *stream, const char *filename)
 
MSFiltervideo_preview_stop_reuse_source (VideoPreview *stream)
 
RtpSession * ms_create_duplex_rtp_session (const char *local_ip, int loc_rtp_port, int loc_rtcp_port)
 
void audio_stream_set_audio_route (AudioStream *stream, MSAudioRoute route)
 

Detailed Description

Video streaming API - Easily run video streams from camera capture or static picture files to RTP.

Typedef Documentation

typedef VideoStream VideoPreview

Small API to display a local preview window.

Function Documentation

VideoStream* video_stream_new2 ( const char *  ip,
int  loc_rtp_port,
int  loc_rtcp_port 
)

Creates a VideoStream object listening on a RTP port for a dedicated address.

Parameters
loc_ipthe local ip to listen for RTP packets. Can be ::, O.O.O.O or any ip4/6 addresses
[in]loc_rtp_portthe local UDP port to listen for RTP packets.
[in]loc_rtcp_portthe local UDP port to listen for RTCP packets
Returns
a new VideoStream.
int video_stream_start_from_io ( VideoStream *  stream,
RtpProfile *  profile,
const char *  rem_rtp_ip,
int  rem_rtp_port,
const char *  rem_rtcp_ip,
int  rem_rtcp_port,
int  payload_type,
const MSMediaStreamIO io 
)

Start a video stream according to the specified VideoStreamIO.

Parameters
[in]streamVideoStream object previously created with video_stream_new().
[in]profileRtpProfile object holding the PayloadType that can be used during the video session.
[in]rem_rtp_ipThe remote IP address where to send the encoded video to.
[in]rem_rtp_portThe remote port where to send the encoded video to.
[in]rem_rtcp_ipThe remote IP address for RTCP.
[in]rem_rtcp_portThe remote port for RTCP.
[in]payload_typeThe payload type number used to send the video stream. A valid PayloadType must be available at this index in the profile.
[in]ioA VideoStreamIO describing the input/output of the video stream.
MSFilter* video_stream_get_source_filter ( const VideoStream *  stream)

Returns the current video stream source filter. Be careful, this source will be destroyed if the stream is stopped.

Returns
current stream source
MSFilter* video_stream_change_source_filter ( VideoStream *  stream,
MSWebCam cam,
MSFilter filter,
bool_t  keep_previous_source 
)

This functions changes the source filter for the passed video stream.

This is quite the same function as video_stream_change_camera, but this one allows you to pass the source filter that is created for the camera and reuse it. This gives you the ability to switch rapidly between two streams, whereas re-creating them each time would be costly (especially with webcams).

Note
Since the video_stream_stop() will automatically destroy the source, it is advised that you use video_stream_stop_keep_source() instead, so that you can manually destroy the source filters after the stream is stopped.

Example usage:

    video_stream_start(stream, profile, [...], noWebcamDevice);
    // We manage the sources for the stream ourselves:
    MSFilter* noWebCamFilter = video_stream_get_source_filter(stream);
    MSFilter* frontCamFilter = ms_web_cam_create_reader(frontCamDevice);

            sleep(1);
            video_stream_change_source_filter(stream, frontCamDevice, frontCamFilter, TRUE); // will keep the previous filter
            sleep(1);
            video_stream_change_source_filter(stream, noWebcamDevice, noWebCamFilter, TRUE); // keep the previous filter

    sleep(1)
    video_stream_stop_keep_source(stream);
    ms_filter_destroy(noWebCamFilter);
    ms_filter_destroy(frontCamFilter);
Parameters
streamthe video stream to modify
camthe camera that you want to set as the new source
cam_filterthe filter for this camera. It can be obtained with ms_web_cam_create_reader(cam)
Returns
the previous source if keep_previous_source is TRUE, otherwise NULL
MSFilter* video_stream_change_camera_keep_previous_source ( VideoStream *  stream,
MSWebCam cam 
)

This is the same function as video_stream_change_source_filter() called with keep_source=1, but the new filter will be created from the MSWebcam that is passed as argument.

Parameters
streamthe video stream
camthe MSWebcam from which the new source filter should be created.
Returns
the previous source filter
void video_stream_send_fir ( VideoStream *  stream)

Asks the video stream to send a Full-Intra Request.

Parameters
[in]streamThe videostream object.
void video_stream_send_vfu ( VideoStream *  stream)

Asks the video stream to generate a Video Fast Update (generally after receiving a Full-Intra Request.

Parameters
[in]streamThe videostream object.
MSFilter* video_stream_stop_keep_source ( VideoStream *  stream)

Stop the video stream, but does not destroy the source of the video. This function can be use in conjunction with video_stream_change_source_filter() to allow manual management of the source filters for a video stream.

Parameters
streamthe stream to stop
Returns
returns the source of the video stream, which you should manually destroy when appropriate.
void video_stream_set_sent_video_size ( VideoStream *  stream,
MSVideoSize  vsize 
)

Try to set the size of the video that is sent. Since this relies also on the bitrate specified, make sure to set the payload bitrate accordingly with rtp_profile_get_payload and normal_bitrate value otherwise the best possible resolution will be taken instead of the requested one.

Parameters
[in]streamThe videostream for which to get the sent video size.
[in]vsizeThe sent video size wished.
MSVideoSize video_stream_get_sent_video_size ( const VideoStream *  stream)

Gets the size of the video that is sent.

Parameters
[in]streamThe videostream for which to get the sent video size.
Returns
The sent video size or MS_VIDEO_SIZE_UNKNOWN if not available.
MSVideoSize video_stream_get_received_video_size ( const VideoStream *  stream)

Gets the size of the video that is received.

Parameters
[in]streamThe videostream for which to get the received video size.
Returns
The received video size or MS_VIDEO_SIZE_UNKNOWN if not available.
float video_stream_get_sent_framerate ( const VideoStream *  stream)

Gets the framerate of the video that is sent.

Parameters
[in]streamThe videostream.
Returns
The actual framerate, 0 if not available..
float video_stream_get_received_framerate ( const VideoStream *  stream)

Gets the framerate of the video that is received.

Parameters
[in]streamThe videostream.
Returns
The received framerate or 0 if not available.
const char* video_stream_get_default_video_renderer ( void  )

Returns the name of the video display filter on the current platform.

int video_stream_get_camera_sensor_rotation ( VideoStream *  stream)

Gets the camera sensor rotation.

This is needed on some mobile platforms to get the number of degrees the camera sensor is rotated relative to the screen.

Parameters
streamThe video stream related to the operation
Returns
The camera sensor rotation in degrees (0 to 360) or -1 if it could not be retrieved
bool_t video_stream_is_decoding_error_to_be_reported ( VideoStream *  stream,
uint32_t  ms 
)

Ask the video stream whether a decoding error should be reported (eg. to send a VFU request).

Parameters
[in]streamThe VideoStream object.
[in]msThe minimum interval in milliseconds between to decoding error report.
Returns
TRUE if the decoding error should be reported, FALSE otherwise.
void video_stream_decoding_error_reported ( VideoStream *  stream)

Tell the video stream that a decoding error has been reported.

Parameters
[in]streamThe VideoStream object.
void video_stream_decoding_error_recovered ( VideoStream *  stream)

Tell the video stream that a decoding error has been recovered so that new decoding can be reported sooner.

Parameters
[in]streamThe VideoStream object.
void video_stream_set_preview_size ( VideoStream *  stream,
MSVideoSize  vsize 
)

Force a resolution for the preview.

Parameters
[in]streamThe VideoStream object.
[in]vsizevideo resolution.
void video_stream_set_fps ( VideoStream *  stream,
float  fps 
)

Force a resolution for the preview.

Parameters
[in]streamThe VideoStream object.
[in]fpsthe frame rate in frame/seconds. A value of zero means "use encoder default value".
void audio_stream_link_video ( AudioStream stream,
VideoStream *  video 
)

Link the audio stream with an existing video stream. This is necessary to enable recording of audio & video into a multimedia file.

void audio_stream_unlink_video ( AudioStream stream,
VideoStream *  video 
)

Unlink the audio stream from the video stream. This must be done if the video stream is about to be stopped.

void video_stream_use_video_preset ( VideoStream *  stream,
const char *  preset 
)

Set a video preset to be used for the video stream.

Parameters
[in]streamVideoStream object
[in]presetThe name of the video preset to be used.
MSFilter* video_stream_open_remote_play ( VideoStream *  stream,
const char *  filename 
)

Open a player to play a video file (mkv) to remote end. The player is returned as a MSFilter so that application can make usual player controls on it using the MSPlayerInterface.

MSFilter* video_stream_open_remote_record ( VideoStream *  stream,
const char *  filename 
)

Open a recorder to record the video coming from remote end into a mkv file. This must be done before the stream is started.

MSFilter* video_preview_stop_reuse_source ( VideoPreview stream)

Stops the video preview graph but keep the source filter for reuse. This is useful when transitioning from a preview-only to a duplex video. The filter needs to be passed to the #video_stream_start_with_source function, otherwise you should destroy it.

Parameters
[in]streamVideoPreview object
Returns
The source filter to be passed to the #video_stream_start_with_source function.
RtpSession* ms_create_duplex_rtp_session ( const char *  local_ip,
int  loc_rtp_port,
int  loc_rtcp_port 
)

Create an RTP session for duplex communication.

Parameters
[in]local_ipThe local IP to bind the RTP and RTCP sockets to.
[in]local_rtp_portThe local port to bind the RTP socket to.
[in]local_rtcp_portThe local port to bind the RTCP socket to.
void audio_stream_set_audio_route ( AudioStream stream,
MSAudioRoute  route 
)

Asks the audio playback filter to route to the selected device (currently only used for blackberry)

Parameters
[in]streamThe AudioStream object
[in]routeThe wanted audio output device (earpiece, speaker)