[ English | 简体中文 ]
Media Utils API
General utility interfaces for the media framework, including DTMF dual-tone multi-frequency signal generation, event name lookup, graph/policy dump, and generic command sending.
Header: #include <media_utils.h>
openvela Implementation Notes
- DTMF: Generates DTMF dual-tone multi-frequency signals for
0-9/*#ABCDkeys, with a fixed audio format offormat=s16le:sample_rate=8000:ch_layout=mono(defined by theMEDIA_TONE_DTMF_FORMATmacro) - Debug Interfaces:
media_graph_dump,media_player_dump,media_recorder_dumpandmedia_policy_dumpprint internal state for troubleshooting - Generic Command:
media_process_commandsends custom commands to the media server for extended capabilities (e.g., triggering an operation on a specific filter within a graph) - Event Name Lookup:
media_event_get_nameconvertsMEDIA_EVENT_*numeric values to human-readable strings for log output
DTMF Signal Generation
media_dtmf_get_buffer_size
int media_dtmf_get_buffer_size(const char* numbers);
Queries the buffer size required for DTMF signal generation.
Parameters:
numbersDial key character sequence, with characters in the range0-9and*#ABCD.
Returns:
Returns the buffer size in bytes on success, or a negative errno on failure.
media_dtmf_generate
int media_dtmf_generate(const char* numbers, void* buffer);
Generates one or more consecutive DTMF signals and writes them into the caller-provided buffer.
Parameters:
numbersDial key character sequence, with characters in the range0-9and*#ABCD.bufferOutput buffer; its size should be queried in advance viamedia_dtmf_get_buffer_size.
Returns:
Returns 0 on success, or a negative errno on failure.
Notes:
- When playing DTMF tones, the audio parameters must be fixed to
MEDIA_TONE_DTMF_FORMAT(s16le / 8000Hz / mono).
Event Name Lookup
media_event_get_name
const char* media_event_get_name(int event);
Converts a MEDIA_EVENT_* enum value to a human-readable string.
Parameters:
eventEvent value, one of theMEDIA_EVENT_*constants.
Returns:
Always returns a printable string; returns a placeholder string for unknown events (never returns NULL).
Example:
printf("event: %s\n", media_event_get_name(MEDIA_EVENT_STARTED));
// Output: event: STARTED
Dump Debugging
media_graph_dump
void media_graph_dump(const char* options);
Prints the internal state of the media graph for debugging.
Parameters:
optionsDump options string.
media_policy_dump
void media_policy_dump(const char* options);
Prints the current state of the media policy for debugging.
Parameters:
optionsDump options string.
media_player_dump
void media_player_dump(const char* options);
Prints the internal state of the media player for debugging.
Parameters:
optionsDump options string.
media_recorder_dump
void media_recorder_dump(const char* options);
Prints the internal state of the media recorder for debugging.
Parameters:
optionsDump options string.
Generic Command
media_process_command
int media_process_command(const char* target, const char* cmd,
const char* arg, char* res, int res_len);
Sends a custom command to a specified graph filter instance within the media server.
Parameters:
targetTarget graph filter instance name.cmdCommand type.argCommand argument.resResponse message output buffer.res_lenResponse buffer length.
Returns:
Returns 0 on success, or a negative errno on failure.