Test API to control a media player

Overview

Generic high level test API to control a media player. More…

// typedefs

typedef enum tapi_media_player_client tapi_media_player_client;
typedef enum tapi_media_player_error tapi_media_player_error;
typedef struct tapi_media_player tapi_media_player;

typedef te_errno (*tapi_media_player_method_play)(
    tapi_media_player *player,
    const char *source,
    const char *options
    );

typedef te_errno (*tapi_media_player_method_stop)(tapi_media_player *player);
typedef te_errno (*tapi_media_player_method_get_errors)(tapi_media_player *player);
typedef struct tapi_media_player_methods tapi_media_player_methods;

// enums

enum tapi_media_player_client;
enum tapi_media_player_error;

// structs

struct tapi_media_player;
struct tapi_media_player_methods;

// global functions

tapi_media_player* tapi_media_player_create(const char* ta, tapi_media_player_client client, const char* player);
void tapi_media_player_destroy(tapi_media_player* player);
te_errno tapi_media_player_play(tapi_media_player* player, const char* source, const char* options);
te_errno tapi_media_player_stop(tapi_media_player* player);
te_errno tapi_media_player_get_errors(tapi_media_player* player);
bool tapi_media_player_check_errors(tapi_media_player* player);
void tapi_media_player_log_errors(const tapi_media_player* player);

Detailed Documentation

Generic high level test API to control a media player.

Copyright (C) 2004-2022 OKTET Labs Ltd. All rights reserved.

Typedefs

typedef enum tapi_media_player_client tapi_media_player_client

Supported media players list.

typedef enum tapi_media_player_error tapi_media_player_error

List of possible playback errors.

typedef struct tapi_media_player tapi_media_player

Media player access point.

typedef te_errno (*tapi_media_player_method_play)(
    tapi_media_player *player,
    const char *source,
    const char *options
    )

Play a media file.

Parameters:

player

Player handle.

source

Audio or video file to play (link or local pathname).

options

Custom options to pass to player run command line or NULL to use default ones.

Returns:

Status code.

typedef te_errno (*tapi_media_player_method_stop)(tapi_media_player *player)

Stop playback.

Parameters:

player

Player handle.

Returns:

Status code.

typedef te_errno (*tapi_media_player_method_get_errors)(tapi_media_player *player)

Parse player stderr stream and count playback errors, the counters are located in player.errors.

Parameters:

player

Player handle.

Returns:

Status code.

typedef struct tapi_media_player_methods tapi_media_player_methods

Methods to operate the server.

Global Functions

tapi_media_player* tapi_media_player_create(const char* ta, tapi_media_player_client client, const char* player)

Create media player access point. Start aux RPC server and initialize hooks. Note, tapi_media_player_destroy must be called to release resources.

Parameters:

ta

Test agent name.

client

Program to play media.

player

Pathname to the player, or NULL to use default for specified client.

Returns:

Acccess point.

See also:

tapi_media_player_destroy

void tapi_media_player_destroy(tapi_media_player* player)

Destroy media player access point: stop playback, stop RPC server, and release resources.

Parameters:

player

The player access point (can be NULL to call in cleanup)

See also:

tapi_media_player_create

te_errno tapi_media_player_play(tapi_media_player* player, const char* source, const char* options)

Play a media file.

Parameters:

player

Player handle.

source

Audio or video file to play (link or local pathname).

options

Custom options to pass to player run command line or NULL to use default ones.

Returns:

Status code.

te_errno tapi_media_player_stop(tapi_media_player* player)

Stop playback.

Parameters:

player

Player handle.

Returns:

Status code.

te_errno tapi_media_player_get_errors(tapi_media_player* player)

Parse player stderr stream and count playback errors, the counters are located in player.errors.

Parameters:

player

Player handle.

Returns:

Status code.

bool tapi_media_player_check_errors(tapi_media_player* player)

Check if there were errors during media playback. (Actually just check if counters are zero).

Parameters:

player

Player access point.

Returns:

true if there are errors in counters.

void tapi_media_player_log_errors(const tapi_media_player* player)

Print a number of errors sorted by type which were occurred during media playback using RING function.

Parameters:

player

Player access point.