The ZoltanPlayer API (0.2.9)

By Source

zoltan_core.c

_num_songs - Number of songs in current media
_num_groups - Number of groups in current media
_current_song - The song currently being played
_zoltan_sigchld - Signal trap for player death
zoltan_cd_test - CD availability test
_zoltan_cddb_id - Calculates the CDDB id
zoltan_cda_info - Gets info about the CD Audio
zoltan_add_song - Adds a song to the internal database
zoltan_add_group - Adds a new group to the internal database
zoltan_song_find - Travel a directory tree searching for songs
_zoltan_kill_player - Kills the external player, if any
zoltan_notify - Notifies change of song
zoltan_spawn_player - Spawns an external player
zoltan_play - Plays current song
zoltan_stop - Stops the currently playing song
zoltan_pause - (Un)pauses the currently playing song
zoltan_change_group - Change the group of songs
zoltan_build_song_info - Builds a string with the song info
zoltan_poll - Polls the CD
zoltan_cddb_seek_cache - Seeks the local cddb cache
zoltan_cddb_info - Fills CDDB info
zoltan_mount - 'Mounts' the CD
zoltan_hd - Searches songs in the local hard disk directory
zoltan_umount - 'Unmounts' the CD
zoltan_add_player - Adds a player
zoltan_cache_store_song - Caches the length of current song
zoltan_search_cache - Searches the cache for the length of a song
zoltan_load_song_cache - Loads the song cache
zoltan_save_song_cache - Saves the song cache
zoltan_shuffle - Shuffles all songs
zoltan_load_config - Loads the configuration file
zoltan_set_volume - Sets the current global volume
zoltan_time_left - Returns the time until the end of the song
zoltan_startup - Core startup

zoltan_http.c

zoltan_write - Write a string into a socket
zoltan_writef - Write a string into a socket, with formatting
zoltan_client_socket - Opens a connection to a remote server
zoltan_send_http_query - Sends an HTTP query
zoltan_drop_http_response - Drops the HTTP response from the server
_zoltan_cddb_query - Makes a partial query
zoltan_cddb_query - Makes a complete CDDB query
zoltan_server_socket - Opens a TCP/IP server
zoltan_accept - Accepts remote connections
zoltan_client - Sends a command to a zoltan server

zoltan_server.c

zoltan_html_page - Shows the Zoltan html page
zoltan_command - Process a command
zoltan_process_connection - Process an incoming connection

_num_songs

Top

Name

_num_songs - Number of songs in current media

Synopsis

int _num_songs;

Description

Contains the total number of songs in current media.


_num_groups

Top

Name

_num_groups - Number of groups in current media

Synopsis

int _num_groups;

Description

Contains the total number of groups in current media. Should be 1 for Audio CDs.


_current_song

Top

Name

_current_song - The song currently being played

Synopsis

int _current_song;

Description

Contains the song currently being played, or ready for it. A value of -1 means no song (i.e., media is stopped).


_zoltan_sigchld

Top

Name

_zoltan_sigchld - Signal trap for player death

Synopsis

static void _zoltan_sigchld(int s);

Arguments

s
the signal

Description

Signal trap for player (child) death.


zoltan_cd_test

Top

Name

zoltan_cd_test - CD availability test

Synopsis

int zoltan_cd_test(void);

Description

Returns true if there is a CDA / CDROM in drive.


_zoltan_cddb_id

Top

Name

_zoltan_cddb_id - Calculates the CDDB id

Synopsis

static unsigned int _zoltan_cddb_id(void);

Description

Calculates the CDDB id of the inserted CD Audio.


zoltan_cda_info

Top

Name

zoltan_cda_info - Gets info about the CD Audio

Synopsis

int zoltan_cda_info(void);

Description

Gets information about the CD Audio, setting the global variables _cda_num_tracks, _cda_total_time and _cddb_id and calculating the length (in seconds) of the songs. Returns zero if some error ocurred.


zoltan_add_song

Top

Name

zoltan_add_song - Adds a song to the internal database

Synopsis

void zoltan_add_song(char * songinfo, char * filename,
		     char * path, int group, int player);

Arguments

songinfo
text string about the song, human readable
filename
the name of the file that stores the song, if applicable
path
the path where the song file lives, if applicable
group
group of the song
player
the player to be used when playing the song

Description

Adds a song to the internal database. The global variable _num_songs is incremented. All parameters are optional.


zoltan_add_group

Top

Name

zoltan_add_group - Adds a new group to the internal database

Synopsis

void zoltan_add_group(char * groupinfo, int is_playlist);

Arguments

groupinfo
text string about the group, human readable
is_playlist
1 if the group is a playlist

Description

Adds a new group to the internal database. All parameters are optional. The global variable _num_groups is incremented.


zoltan_song_find

Top

Name

zoltan_song_find - Travel a directory tree searching for songs

Synopsis

void zoltan_song_find(char * root, char * directory, int group);

Arguments

directory
the directory

Description

Searches (recursively) a directory, searching for playable songs. If any is found, it's stored in the database. The directories are stored as groups.


_zoltan_kill_player

Top

Name

_zoltan_kill_player - Kills the external player, if any

Synopsis

static void _zoltan_kill_player(void);

Description

Kills the external player, if it's running.


zoltan_notify

Top

Name

zoltan_notify - Notifies change of song

Synopsis

void zoltan_notify(void);

Description

If current song is different from the previously one being played, notify using the external program.


zoltan_spawn_player

Top

Name

zoltan_spawn_player - Spawns an external player

Synopsis

static void zoltan_spawn_player(void);

Description

Strips path from filename, changes to that directory, parses the external player exec line (substituting possible s strings with the song name) and spawns the external player. Only returns to caller on player exec error.


zoltan_play

Top

Name

zoltan_play - Plays current song

Synopsis

void zoltan_play(void);

Description

Plays the currently selected song.


zoltan_stop

Top

Name

zoltan_stop - Stops the currently playing song

Synopsis

void zoltan_stop(void);

Description

Stops the currently playing song, if any.


zoltan_pause

Top

Name

zoltan_pause - (Un)pauses the currently playing song

Synopsis

void zoltan_pause(void);

Description

Unpauses the currently playing song.


zoltan_change_group

Top

Name

zoltan_change_group - Change the group of songs

Synopsis

void zoltan_change_group(int inc);

Arguments

inc
number of groups to jump (positive forward, negative backward)

Description

Change the group of songs adding the increment to the group of the current song. A call to zoltan_play() should follow. A CD Audio has only one group, so any group change makes it restart from the beginning.


zoltan_build_song_info

Top

Name

zoltan_build_song_info - Builds a string with the song info

Synopsis

char * zoltan_build_song_info(void);

Description

Builds a string with the song information (song name, song group and time duration, where available). Returns a pointer to a static buffer.


zoltan_poll

Top

Name

zoltan_poll - Polls the CD

Synopsis

void zoltan_poll(void);

Description

Polls the sound system. If file is a CDROM, tests if external player has dead (by ending the song or aborting); in that case, move to next song and play it. On CD Audio, asks the interface what track is currently playing. This function must be called frequently.


zoltan_cddb_seek_cache

Top

Name

zoltan_cddb_seek_cache - Seeks the local cddb cache

Synopsis

int zoltan_cddb_seek_cache(void);

Description

Seeks the local cddb cache for a file with the same name as the CDDB id contained in _cddb_id. If that file is found, the information is loaded as song info and 1 is returned.


zoltan_cddb_info

Top

Name

zoltan_cddb_info - Fills CDDB info

Synopsis

void zoltan_cddb_info(void);

Description

Seeks in the local cddb cache (via zoltan_cddb_seek_cache()) and, if not found, queries a remote server via zoltan_cddb_query().


zoltan_mount

Top

Name

zoltan_mount - 'Mounts' the CD

Synopsis

int zoltan_mount(void);

Description

'Mounts' the CD. If a CDROM, really mount it into _mount_point; If a CDA, reads info about it using zoltan_cda_info(). Returns zero if the CD could not be 'mounted'.


zoltan_hd

Top

Name

zoltan_hd - Searches songs in the local hard disk directory

Synopsis

void zoltan_hd(void);

Description

Searches the local hard disk directory (pointed by _hd_song_dir) for songs, and fills the database with anything found.


zoltan_umount

Top

Name

zoltan_umount - 'Unmounts' the CD

Synopsis

void zoltan_umount(void);

Description

'Unmounts' the CD. If it's a CDROM, it really unmounts it. If it's a CD Audio, stop it. Anyway, it's ejected.


zoltan_add_player

Top

Name

zoltan_add_player - Adds a player

Synopsis

void zoltan_add_player(char * ext, char * path);

Arguments

ext
the file extension the player is able to play
path
the path to the player program

Description

Adds a player to the internal database.


zoltan_cache_store_song

Top

Name

zoltan_cache_store_song - Caches the length of current song

Synopsis

void zoltan_cache_store_song(void);

Description

Stores the length of the current song in the cache, and marks it as dirty for later saving.


zoltan_search_cache

Top

Name

zoltan_search_cache - Searches the cache for the length of a song

Synopsis

int zoltan_search_cache(char * filename);

Arguments

filename
Filename of the song

Description

Searches in the cache the length of the song which filename is sent as argument. If song length is not cached, returns 0.


zoltan_load_song_cache

Top

Name

zoltan_load_song_cache - Loads the song cache

Synopsis

void zoltan_load_song_cache(void);

Description

Loads the song length cache.


zoltan_save_song_cache

Top

Name

zoltan_save_song_cache - Saves the song cache

Synopsis

void zoltan_save_song_cache(void);

Description

Saves the song length cache, if marked as dirty.


zoltan_shuffle

Top

Name

zoltan_shuffle - Shuffles all songs

Synopsis

void zoltan_shuffle(int toggle);

Arguments

toggle
shuffle yes / no

Description

If toggle is 1, shuffles all the songs; they will be played in random order. A value of 0, resets normal order.


zoltan_load_config

Top

Name

zoltan_load_config - Loads the configuration file

Synopsis

void zoltan_load_config(char * configfile);

Arguments

configfile
the file name

Description

Loads the configuration file. Aborts if file can't be open.


zoltan_set_volume

Top

Name

zoltan_set_volume - Sets the current global volume

Synopsis

void zoltan_set_volume(void);

Description

Sets the current volume (stored in the variable _zoltan_volume) using the system mixer. Global, PCM and CD volumes are currently set at the same time to the same value (this will probably change).


zoltan_time_left

Top

Name

zoltan_time_left - Returns the time until the end of the song

Synopsis

int zoltan_time_left(void);

Description

Returns the time (in seconds) left until the end of the song. If no song length is known, it returns an approximated time. Used mainly to set the reload page time.


zoltan_startup

Top

Name

zoltan_startup - Core startup

Synopsis

int zoltan_startup(char * configfile);

Arguments

configfile
the configuration file

Description

Opens the devices and clears the database. Returns 0 if configuration file could not be open (fatal error).


zoltan_write

Top

Name

zoltan_write - Write a string into a socket

Synopsis

void zoltan_write(int a, char * str);

Arguments

a
the socket
str
the string

Description

Writes a string into a socket, calculating it size.


zoltan_writef

Top

Name

zoltan_writef - Write a string into a socket, with formatting

Synopsis

void zoltan_writef(int a, char * fmt, ...);

Arguments

a
the socket
fmt
the format string

Description

Writes a string into a socket, with the same formatting as the printf() series of functions.


zoltan_client_socket

Top

Name

zoltan_client_socket - Opens a connection to a remote server

Synopsis

int zoltan_client_socket(char * server, int port);

Arguments

server
the remote host name
port
the remote port

Description

Opens a connection to a remote server. Very generic; can be used for any TCP/IP connection. Returns the connected socket, or -1 on error.


zoltan_send_http_query

Top

Name

zoltan_send_http_query - Sends an HTTP query

Synopsis

void zoltan_send_http_query(int s, char * query, char * host);

Arguments

s
the socket
query
the query
host
the host name

Description

Sends an HTTP query with a HTTP 1.0 GET command. The HTTP response from the server will be waiting in the socket.


zoltan_drop_http_response

Top

Name

zoltan_drop_http_response - Drops the HTTP response from the server

Synopsis

void zoltan_drop_http_response(int s);

Arguments

s
the socket

Description

Drops the HTTP response from the server, as it's not used in Zoltan.


_zoltan_cddb_query

Top

Name

_zoltan_cddb_query - Makes a partial query

Synopsis

static int _zoltan_cddb_query(char * genre);

Arguments

genre
the possible genre of the current CD

Description

Makes a query in the specified genre for the CDDB id contained in _cddb_id. Returns 1 if an entry in the CDDB database could be found.


zoltan_cddb_query

Top

Name

zoltan_cddb_query - Makes a complete CDDB query

Synopsis

int zoltan_cddb_query(void);

Description

Makes a complete CDDB query for the CDDB id contained in _cddb_id, trying all different genres. Returns 1 if the entry could be found.


zoltan_server_socket

Top

Name

zoltan_server_socket - Opens a TCP/IP server

Synopsis

int zoltan_server_socket(int port);

Arguments

port
the server port

Description

Opens a TCP/IP server on the specified port. The returned socket is marked as non-blocking. Very generic; can be used for any TCP/IP server. Returns the rendez-vous socket.


zoltan_accept

Top

Name

zoltan_accept - Accepts remote connections

Synopsis

int zoltan_accept(int s);

Arguments

s
the rendez-vous socket

Description

Accepts remote connections from the specified rendez-vous socket. Returns -1 on error, 0 if the calling would block (i.e., there is no connection waiting) or the connection socket otherwise.


zoltan_client

Top

Name

zoltan_client - Sends a command to a zoltan server

Synopsis

int zoltan_client(char * server, int port, char * command,
	char * reply_buffer, int reply_size);

Arguments

server
the zoltan server hostname
port
the zoltan server port
command
the command to be sent

Description

Sends a command to a zoltan server. The server reply is stored in reply_buffer, if defined. Returns the size of the data read, or 0 if the connection could not be done.


zoltan_html_page

Top

Name

zoltan_html_page - Shows the Zoltan html page

Synopsis

static void zoltan_html_page(int a, int read_only);

Arguments

a
socket
read_only
flag for generating a static page

Description

Generates a html page with current zoltan status (current song info, available songs, etc.) and writes into the socket. If read_only is not set, the page contains clickable references for directly playing songs and some navigation links.


zoltan_command

Top

Name

zoltan_command - Process a command

Synopsis

static void zoltan_command(int a, char * cmd);

Arguments

a
the connection socket
cmd
the command to be processed

Description

Processes a command, received from an HTTP connection. The correspondent zoltan command is called, and the html page is generated.


zoltan_process_connection

Top

Name

zoltan_process_connection - Process an incoming connection

Synopsis

void zoltan_process_connection(int s);

Arguments

s
the socket

Description

Processes a complete incoming HTTP connection, calling zoltan_command() if applicable.


Angel Ortega - angel@triptico.com