xine-lib 1.2.13-20230125hg15249
Data Structures | Macros | Functions | Variables
input_cdda.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <basedir.h>
#include <xine/xine_internal.h>
#include <xine/xineutils.h>
#include <xine/input_plugin.h>
#include "../xine-engine/bswap.h"
#include "media_helper.h"

Data Structures

struct  cdrom_toc_entry_t
 
struct  cdrom_toc_t
 
struct  sha160_t
 
struct  trackinfo_t
 
struct  cdda_input_plugin_t
 
struct  cdda_input_class_t
 

Macros

#define LOG_MODULE   "input_cdda"
 
#define LOG_VERBOSE
 
#define DEFAULT_CDDA_DEVICE   "/dev/cdrom"
 
#define CDDB_SERVER   "gnudb.gnudb.org"
 
#define CDDB_PORT   8880
 
#define CDDB_PROTOCOL   6
 
#define CDDB_TIMEOUT   5000
 
#define CD_SECONDS_PER_MINUTE   60
 
#define CD_FRAMES_PER_SECOND   75
 
#define CD_RAW_FRAME_SIZE   2352
 
#define CD_LEADOUT_TRACK   0xAA
 
#define CD_BLOCK_OFFSET   150
 
#define sha160_digest_len   20
 
#define MAX_TRACKS   99
 
#define CACHED_FRAMES   90 /* be a multiple of 3, see read_block () */
 
#define _BUFSIZ   300
 

Functions

static void sha160_init (sha160_t *s)
 
static void sha160_trans (sha160_t *s)
 
static void sha160_update (sha160_t *s, const uint8_t *data, size_t len)
 
static void sha160_final (sha160_t *s, uint8_t *dest)
 
static void print_cdrom_toc (xine_t *xine, cdrom_toc_t *toc)
 
static void free_cdrom_toc (cdrom_toc_t *toc)
 
static cdrom_toc_tread_cdrom_toc (int fd)
 
static int read_cdrom_frames (cdda_input_plugin_t *this_gen, int frame, int num_frames, unsigned char *data)
 
static int parse_url (char *urlbuf, char **host, int *port)
 
static int XINE_FORMAT_PRINTF (4, 5)
 
static int network_connect (xine_stream_t *stream, const char *got_url)
 
static cdrom_toc_tnetwork_read_cdrom_toc (xine_stream_t *stream, int fd)
 
static int network_read_cdrom_frames (xine_stream_t *stream, int fd, int first_frame, int num_frames, unsigned char data[2352])
 
static void cdda_device_cb (void *data, xine_cfg_entry_t *cfg)
 
static void enable_cddb_changed_cb (void *data, xine_cfg_entry_t *cfg)
 
static void server_changed_cb (void *data, xine_cfg_entry_t *cfg)
 
static void port_changed_cb (void *data, xine_cfg_entry_t *cfg)
 
static int _cdda_is_cd_changed (cdda_input_plugin_t *this)
 
static void _cdda_mkdir_safe (xine_t *xine, char *path)
 
static void _cdda_mkdir_recursive_safe (xine_t *xine, char *path)
 
static int _cdda_cddb_socket_read (cdda_input_plugin_t *this, char *str, int size)
 
static int _cdda_cddb_send_command (cdda_input_plugin_t *this, char *cmd)
 
static int _cdda_cddb_handle_code (char *buf)
 
static char * _cdda_append (char *first, const char *second)
 
static void _cdda_parse_cddb_info (cdda_input_plugin_t *this, char *buffer, char **dtitle)
 
static int _cdda_load_cached_cddb_infos (cdda_input_plugin_t *this)
 
static void _cdda_save_cached_cddb_infos (cdda_input_plugin_t *this, char *filecontent)
 
static int _cdda_cddb_socket_open (cdda_input_plugin_t *this)
 
static void _cdda_cddb_socket_close (cdda_input_plugin_t *this)
 
static int _cdda_cddb_retrieve (cdda_input_plugin_t *this)
 
static unsigned int _cdda_cddb_sum (int n)
 
static uint32_t _cdda_calc_cddb_id (cdda_input_plugin_t *this)
 
static void _cdda_cdindex (cdda_input_plugin_t *this, cdrom_toc_t *toc)
 
static uint32_t _cdda_get_cddb_id (cdda_input_plugin_t *this)
 
static void _cdda_free_cddb_info (cdda_input_plugin_t *this)
 
static int cdda_open (cdda_input_plugin_t *this_gen, const char *cdda_device, int *fdd)
 
static int cdda_close (cdda_input_plugin_t *this_gen)
 
static uint32_t cdda_plugin_get_capabilities (input_plugin_t *this_gen)
 
static off_t cdda_plugin_read (input_plugin_t *this_gen, void *buf, off_t len)
 
static buf_element_tcdda_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, off_t nlen)
 
static off_t cdda_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin)
 
static off_t cdda_plugin_get_current_pos (input_plugin_t *this_gen)
 
static off_t cdda_plugin_get_length (input_plugin_t *this_gen)
 
static uint32_t cdda_plugin_get_blocksize (input_plugin_t *this_gen)
 
static const char * cdda_plugin_get_mrl (input_plugin_t *this_gen)
 
static int cdda_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type)
 
static void cdda_plugin_dispose (input_plugin_t *this_gen)
 
static int cdda_plugin_open (input_plugin_t *this_gen)
 
static void free_autoplay_list (cdda_input_class_t *this)
 
static const char *const * cdda_class_get_autoplay_list (input_class_t *this_gen, int *num_files)
 
static input_plugin_tcdda_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, const char *mrl)
 
static void cdda_class_dispose (input_class_t *this_gen)
 
static int cdda_class_eject_media (input_class_t *this_gen)
 
static void * init_plugin (xine_t *xine, const void *data)
 

Variables

const plugin_info_t xine_plugin_info[] EXPORTED
 

Macro Definition Documentation

◆ _BUFSIZ

#define _BUFSIZ   300

◆ CACHED_FRAMES

#define CACHED_FRAMES   90 /* be a multiple of 3, see read_block () */

Referenced by cdda_plugin_read().

◆ CD_BLOCK_OFFSET

#define CD_BLOCK_OFFSET   150

◆ CD_FRAMES_PER_SECOND

#define CD_FRAMES_PER_SECOND   75

◆ CD_LEADOUT_TRACK

#define CD_LEADOUT_TRACK   0xAA

Referenced by network_read_cdrom_toc().

◆ CD_RAW_FRAME_SIZE

#define CD_RAW_FRAME_SIZE   2352

◆ CD_SECONDS_PER_MINUTE

#define CD_SECONDS_PER_MINUTE   60

◆ CDDB_PORT

#define CDDB_PORT   8880

Referenced by init_plugin().

◆ CDDB_PROTOCOL

#define CDDB_PROTOCOL   6

Referenced by _cdda_cddb_retrieve().

◆ CDDB_SERVER

#define CDDB_SERVER   "gnudb.gnudb.org"

Referenced by init_plugin().

◆ CDDB_TIMEOUT

#define CDDB_TIMEOUT   5000

Referenced by _cdda_cddb_socket_open().

◆ DEFAULT_CDDA_DEVICE

#define DEFAULT_CDDA_DEVICE   "/dev/cdrom"

Referenced by init_plugin().

◆ LOG_MODULE

#define LOG_MODULE   "input_cdda"

Referenced by _cdda_cddb_socket_open().

◆ LOG_VERBOSE

#define LOG_VERBOSE

◆ MAX_TRACKS

#define MAX_TRACKS   99

Referenced by network_read_cdrom_toc().

◆ sha160_digest_len

#define sha160_digest_len   20

Function Documentation

◆ _cdda_append()

static char * _cdda_append ( char * first,
const char * second )
inlinestatic

Referenced by _cdda_parse_cddb_info().

◆ _cdda_calc_cddb_id()

static uint32_t _cdda_calc_cddb_id ( cdda_input_plugin_t * this)
static

◆ _cdda_cddb_handle_code()

static int _cdda_cddb_handle_code ( char * buf)
static

Referenced by _cdda_cddb_retrieve().

◆ _cdda_cddb_retrieve()

static int _cdda_cddb_retrieve ( cdda_input_plugin_t * this)
static

◆ _cdda_cddb_send_command()

static int _cdda_cddb_send_command ( cdda_input_plugin_t * this,
char * cmd )
static

◆ _cdda_cddb_socket_close()

static void _cdda_cddb_socket_close ( cdda_input_plugin_t * this)
static

References _x_io_tcp_close(), and NULL.

Referenced by _cdda_cddb_retrieve().

◆ _cdda_cddb_socket_open()

static int _cdda_cddb_socket_open ( cdda_input_plugin_t * this)
static

◆ _cdda_cddb_socket_read()

static int _cdda_cddb_socket_read ( cdda_input_plugin_t * this,
char * str,
int size )
static

◆ _cdda_cddb_sum()

static unsigned int _cdda_cddb_sum ( int n)
static

Referenced by _cdda_calc_cddb_id().

◆ _cdda_cdindex()

static void _cdda_cdindex ( cdda_input_plugin_t * this,
cdrom_toc_t * toc )
static

◆ _cdda_free_cddb_info()

static void _cdda_free_cddb_info ( cdda_input_plugin_t * this)
static

References _x_freep().

Referenced by cdda_plugin_dispose(), and cdda_plugin_open().

◆ _cdda_get_cddb_id()

static uint32_t _cdda_get_cddb_id ( cdda_input_plugin_t * this)
static

References _cdda_calc_cddb_id(), and NULL.

Referenced by cdda_plugin_open().

◆ _cdda_is_cd_changed()

static int _cdda_is_cd_changed ( cdda_input_plugin_t * this)
static

References NULL, XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by cdda_plugin_open().

◆ _cdda_load_cached_cddb_infos()

static int _cdda_load_cached_cddb_infos ( cdda_input_plugin_t * this)
static

◆ _cdda_mkdir_recursive_safe()

static void _cdda_mkdir_recursive_safe ( xine_t * xine,
char * path )
static

◆ _cdda_mkdir_safe()

static void _cdda_mkdir_safe ( xine_t * xine,
char * path )
static

◆ _cdda_parse_cddb_info()

static void _cdda_parse_cddb_info ( cdda_input_plugin_t * this,
char * buffer,
char ** dtitle )
static

◆ _cdda_save_cached_cddb_infos()

static void _cdda_save_cached_cddb_infos ( cdda_input_plugin_t * this,
char * filecontent )
static

◆ cdda_class_dispose()

static void cdda_class_dispose ( input_class_t * this_gen)
static

◆ cdda_class_eject_media()

static int cdda_class_eject_media ( input_class_t * this_gen)
static

◆ cdda_class_get_autoplay_list()

static const char *const * cdda_class_get_autoplay_list ( input_class_t * this_gen,
int * num_files )
static

◆ cdda_class_get_instance()

static input_plugin_t * cdda_class_get_instance ( input_class_t * cls_gen,
xine_stream_t * stream,
const char * mrl )
static

◆ cdda_close()

static int cdda_close ( cdda_input_plugin_t * this_gen)
static

◆ cdda_device_cb()

static void cdda_device_cb ( void * data,
xine_cfg_entry_t * cfg )
static

References xine_cfg_entry_s::str_value.

Referenced by init_plugin().

◆ cdda_open()

static int cdda_open ( cdda_input_plugin_t * this_gen,
const char * cdda_device,
int * fdd )
static

◆ cdda_plugin_dispose()

static void cdda_plugin_dispose ( input_plugin_t * this_gen)
static

◆ cdda_plugin_get_blocksize()

static uint32_t cdda_plugin_get_blocksize ( input_plugin_t * this_gen)
static

Referenced by cdda_class_get_instance().

◆ cdda_plugin_get_capabilities()

static uint32_t cdda_plugin_get_capabilities ( input_plugin_t * this_gen)
static

References INPUT_CAP_SEEKABLE.

Referenced by cdda_class_get_instance().

◆ cdda_plugin_get_current_pos()

static off_t cdda_plugin_get_current_pos ( input_plugin_t * this_gen)
static

References CD_RAW_FRAME_SIZE.

Referenced by cdda_class_get_instance().

◆ cdda_plugin_get_length()

static off_t cdda_plugin_get_length ( input_plugin_t * this_gen)
static

References CD_RAW_FRAME_SIZE.

Referenced by cdda_class_get_instance().

◆ cdda_plugin_get_mrl()

static const char * cdda_plugin_get_mrl ( input_plugin_t * this_gen)
static

Referenced by cdda_class_get_instance().

◆ cdda_plugin_get_optional_data()

static int cdda_plugin_get_optional_data ( input_plugin_t * this_gen,
void * data,
int data_type )
static

Referenced by cdda_class_get_instance().

◆ cdda_plugin_open()

static int cdda_plugin_open ( input_plugin_t * this_gen)
static

◆ cdda_plugin_read()

static off_t cdda_plugin_read ( input_plugin_t * this_gen,
void * buf,
off_t len )
static

◆ cdda_plugin_read_block()

static buf_element_t * cdda_plugin_read_block ( input_plugin_t * this_gen,
fifo_buffer_t * fifo,
off_t nlen )
static

◆ cdda_plugin_seek()

static off_t cdda_plugin_seek ( input_plugin_t * this_gen,
off_t offset,
int origin )
static

◆ enable_cddb_changed_cb()

static void enable_cddb_changed_cb ( void * data,
xine_cfg_entry_t * cfg )
static

References xine_cfg_entry_s::num_value.

Referenced by init_plugin().

◆ free_autoplay_list()

static void free_autoplay_list ( cdda_input_class_t * this)
static

◆ free_cdrom_toc()

static void free_cdrom_toc ( cdrom_toc_t * toc)
static

◆ init_plugin()

static void * init_plugin ( xine_t * xine,
const void * data )
static

◆ network_connect()

static int network_connect ( xine_stream_t * stream,
const char * got_url )
static

◆ network_read_cdrom_frames()

static int network_read_cdrom_frames ( xine_stream_t * stream,
int fd,
int first_frame,
int num_frames,
unsigned char data[2352] )
static

Referenced by cdda_plugin_read().

◆ network_read_cdrom_toc()

static cdrom_toc_t * network_read_cdrom_toc ( xine_stream_t * stream,
int fd )
static

◆ parse_url()

static int parse_url ( char * urlbuf,
char ** host,
int * port )
static

References NULL.

Referenced by network_connect().

◆ port_changed_cb()

static void port_changed_cb ( void * data,
xine_cfg_entry_t * cfg )
static

References xine_cfg_entry_s::num_value.

Referenced by init_plugin().

◆ print_cdrom_toc()

static void print_cdrom_toc ( xine_t * xine,
cdrom_toc_t * toc )
static

◆ read_cdrom_frames()

static int read_cdrom_frames ( cdda_input_plugin_t * this_gen,
int frame,
int num_frames,
unsigned char * data )
static

Referenced by cdda_plugin_read().

◆ read_cdrom_toc()

static cdrom_toc_t * read_cdrom_toc ( int fd)
static

References NULL.

Referenced by cdda_class_get_autoplay_list(), and cdda_plugin_open().

◆ server_changed_cb()

static void server_changed_cb ( void * data,
xine_cfg_entry_t * cfg )
static

References xine_cfg_entry_s::str_value.

Referenced by init_plugin().

◆ sha160_final()

static void sha160_final ( sha160_t * s,
uint8_t * dest )
static

◆ sha160_init()

static void sha160_init ( sha160_t * s)
static

References sha160_t::n, and sha160_t::state.

Referenced by _cdda_cdindex().

◆ sha160_trans()

static void sha160_trans ( sha160_t * s)
static

References _X_BE_32, sha160_t::buf, and sha160_t::state.

Referenced by sha160_final(), and sha160_update().

◆ sha160_update()

static void sha160_update ( sha160_t * s,
const uint8_t * data,
size_t len )
static

References sha160_t::buf, sha160_t::n, and sha160_trans().

Referenced by _cdda_cdindex().

◆ XINE_FORMAT_PRINTF()

static int XINE_FORMAT_PRINTF ( 4 ,
5  )
static

Variable Documentation

◆ EXPORTED

const plugin_info_t xine_plugin_info [] EXPORTED
Initial value:
= {
{ PLUGIN_NONE, 0, NULL, 0, NULL, NULL }
}
static void * init_plugin(xine_t *xine, const void *data)
Definition input_cdda.c:2824
#define XINE_VERSION_CODE
Definition xine_internal.h:57
NULL
Definition xine_plugin.c:78
#define PLUGIN_NONE
Definition xine_plugin.h:29
#define PLUGIN_MUST_PRELOAD
Definition xine_plugin.h:46
#define PLUGIN_INPUT
Definition xine_plugin.h:30