libcdio
2.1.0
|
The top-level header for CD-Text information. Applications include this for CD-Text access. More...
#include <cdio/types.h>
Go to the source code of this file.
Macros | |
#define | MIN_CDTEXT_FIELD 0 |
#define | MAX_CDTEXT_FIELDS 10 |
Typedefs | |
typedef struct cdtext_s | cdtext_t |
Opaque type for CD-Text. More... | |
The top-level header for CD-Text information. Applications include this for CD-Text access.
#define MAX_CDTEXT_FIELDS 10 |
#define MIN_CDTEXT_FIELD 0 |
struct cdtext_s cdtext_t |
Opaque type for CD-Text.
enum enum cdtext_field_t |
Enumeration of CD-TEXT text fields.
enum enum cdtext_genre_t |
Enumeration of possible genre codes.
enum typedef enum cdtext_lang_t |
Enumeration of possible CD-TEXT languages.
The language code is encoded as specified in ANNEX 1 to part 5 of EBU Tech 32 58 -E (1991).
int cdtext_data_init | ( | cdtext_t * | p_cdtext, |
uint8_t * | wdata, | ||
size_t | i_data | ||
) |
Fill a cdtext_t object with text pack bytes as they were handed out by the CD drive, but without the 4-byte header which the drive prepended.
The text pack data can be obtained by the calls
Each sets in the buffer passed into values that begin with a 4-byte header. This should be skipped. Here is some sample code:
Instead of calling cdtext_data_init(), you can call cdio_get_cdtext() which returns a pointer to the cdtext_t
object that is attached to the inquired CdIo_t
object. This cdtext_t
object gets created and filled if none is yet attached to the inquired CdIo_t
object.
p_cdtext | the CD-TEXT object |
wdata | the data |
i_data | size of wdata |
void cdtext_destroy | ( | cdtext_t * | p_cdtext | ) |
Free memory associated with the given cdtext_t
object.
p_cdtext | the CD-TEXT object |
const char* cdtext_field2str | ( | cdtext_field_t | i | ) |
Return string representation of given field type.
const char* cdtext_genre2str | ( | cdtext_genre_t | i | ) |
Return string representation of the given genre code.
char* cdtext_get | ( | const cdtext_t * | p_cdtext, |
cdtext_field_t | key, | ||
track_t | track | ||
) |
Returns a copy of the return value of cdtext_get_const or NULL.
Must be freed using cdio_free() when done.
const char* cdtext_get_const | ( | const cdtext_t * | p_cdtext, |
cdtext_field_t | field, | ||
track_t | track | ||
) |
Returns value of the given field.
NULL is returned if key is CDTEXT_INVALID or the field is not set. Strings are encoded in UTF-8.
p_cdtext | the CD-TEXT object |
field | type of the field to return |
track | specifies the track, 0 stands for disc |
Returns the first track number.
p_cdtext | the CD-TEXT object |
cdtext_genre_t cdtext_get_genre | ( | const cdtext_t * | p_cdtext | ) |
Returns the discs genre code.
p_cdtext | the CD-TEXT object |
cdtext_lang_t cdtext_get_language | ( | const cdtext_t * | p_cdtext | ) |
Returns the currently active language.
p_cdtext | the CD-TEXT object |
Returns the last track number.
p_cdtext | the CD-TEXT object |
cdtext_t* cdtext_init | ( | void | ) |
Initialize a new cdtext_t
structure.
When the structure is no longer needed, release the resources using cdtext_delete.
const char* cdtext_lang2str | ( | cdtext_lang_t | i | ) |
Return string representation of the given language code.
cdtext_lang_t* cdtext_list_languages | ( | const cdtext_t * | p_cdtext | ) |
Returns a list of available languages or NULL.
WARNING: The indices in the returned array do not match the indexing as expected by cdtext_set_language_index(). Use cdtext_select_language() with the values of array elements.
Internally the list is stored in a static array.
p_cdtext | the CD-TEXT object |
cdtext_lang_t* cdtext_list_languages_v2 | ( | cdtext_t * | p_cdtext | ) |
Returns an array of available languages or NULL. The index of an array element may be used to select the corresponding language block by call cdtext_set_language_index().
The return value is a pointer into the memory range of *p_cdtext. Do not use it after having freed that memory range.
p_cdtext | the CD-TEXT object |
If an enumeration is CDTEXT_LANGUAGE_INVALID, then the language block has an invalid language code.
If an enumeration is CDTEXT_LANGUAGE_BLOCK_UNUSED, then the block does not exist on CD or could not be read in CD-TEXT for some reason.
Otherwise, the enumeration of element will be a value in CDTEXT_LANGUAGE_UNKNOWN to CDTEXT_LANGUAGE_AMHARIC, and is a block in that language.
bool cdtext_select_language | ( | cdtext_t * | p_cdtext, |
cdtext_lang_t | language | ||
) |
Try to select the given language.
p_cdtext | the CD-TEXT object |
language | string representation of the language |
void cdtext_set | ( | cdtext_t * | p_cdtext, |
cdtext_field_t | key, | ||
const uint8_t * | value, | ||
track_t | track, | ||
const char * | charset | ||
) |
Sets the given field at the given track to the given value.
Recodes to UTF-8 if charset is not NULL
.
p_cdtext | the CD-TEXT object |
key | field to set |
value | value to set |
track | track to work on |
charset | charset to convert from |
Select the given language by block index. See cdtext_list_languages_v2(). If the index is bad, or no language block with that index was read: select the default language at index 0 and return false.
p_cdtext | the CD-TEXT object |
idx | the desired index: 0 to 7. |
idx
. cdtext_lang_t cdtext_str2lang | ( | const char * | lang | ) |
Return the language code of a given language string representation. This is the inverse of cdtext_lang2str().
lang | language to look up |
cdtext_lang_t
which is associated, or CDTEXT_LANGUAGE_INVALID
otherwise.