libcmml
0.9.1
|
#include <stdio.h>
#include <expat.h>
Go to the source code of this file.
Data Structures | |
struct | CMML_UTC |
struct | CMML_Time |
struct | _CMML_List |
struct | CMML_Preamble |
struct | CMML_ParamElement |
struct | CMML_ImportElement |
struct | CMML_Stream |
struct | CMML_MetaElement |
struct | CMML_LinkElement |
struct | CMML_Head |
struct | CMML_Clip |
struct | CMML_Element |
struct | CMML_Error |
Typedefs | |
typedef void | CMML |
typedef enum _CMML_Time_Type | CMML_Time_Type |
typedef struct _CMML_List | CMML_List |
typedef void *(* | CMML_CloneFunc )(void *data) |
typedef void *(* | CMML_FreeFunc )(void *data) |
typedef int(* | CMML_CmpFunc )(void *cmp_ctx, void *s1, void *s2) |
typedef enum _CMML_Element_Type | CMML_Element_Type |
typedef enum _CMML_Error_Type | CMML_Error_Type |
typedef int(* | CMMLReadStream )(CMML *cmml, const CMML_Stream *stream, void *user_data) |
typedef int(* | CMMLReadHead )(CMML *cmml, const CMML_Head *head, void *user_data) |
typedef int(* | CMMLReadClip )(CMML *cmml, const CMML_Clip *clip, void *user_data) |
cmml.h includes definitions of the public API and data types required to parse CMML 2.0 files.
typedef void CMML |
A CMML handle.
typedef enum _CMML_Time_Type CMML_Time_Type |
CMML_Time_Type: enumerates the different time types
typedef struct _CMML_List CMML_List |
CMML_List: A doubly linked list
typedef void*(* CMML_CloneFunc)(void *data) |
CMML_CloneFunc: Signature of a cloning function for CMML_List.
typedef void*(* CMML_FreeFunc)(void *data) |
CMML_FreeFunc: Signature of a freeing function.
typedef int(* CMML_CmpFunc)(void *cmp_ctx, void *s1, void *s2) |
CMML_CmpFunc: Signature of a comparison function for CMML_List to compares two scalars, returning: +ve, s1 > s2 0, s1 == s2 -ve, s1 < s2
typedef enum _CMML_Element_Type CMML_Element_Type |
CMML_Element_Type: indication of what the CMML_Element actually represents.
typedef enum _CMML_Error_Type CMML_Error_Type |
CMML_Error_Type: indication of the type of error that occured. There are three classes of errors:
typedef int(* CMMLReadStream)(CMML *cmml, const CMML_Stream *stream, void *user_data) |
CMMLReadStream: Signature for a callback called when the CMML stream element is parsed
cmml | the CMML* handle in use |
stream | the stream element's content represented in a CMML_Stream* |
user_data | user defined data |
CMMLReadHead: Signature for a callback called when the CMML head element is parsed
cmml | the CMML* handle in use |
head | the head element's content represented in a CMML_Head* |
user_data | user defined data |
CMMLReadClip: Signature for a callback called when a CMML clip element is parsed
cmml | the CMML* handle in use |
clip | the clip element's content represented in a CMML_Clip* |
user_data | user defined data |
enum _CMML_Time_Type |
enum _CMML_Element_Type |
CMML_Element_Type: indication of what the CMML_Element actually represents.
Enumerator | |
---|---|
CMML_NONE |
no element |
CMML_CMML |
cmml element |
CMML_STREAM |
stream element |
CMML_IMPORT |
import element |
CMML_HEAD |
head element |
CMML_CLIP |
clip element |
enum _CMML_Error_Type |
CMML_Error_Type: indication of the type of error that occured. There are three classes of errors:
CMML* cmml_open | ( | char * | XMLfilename) |
cmml_open: Takes a filename and opens it as read-only. Then checks whether it is an XML file satisfying the CMML specification with the xml directive and the cmml tag. It returns a CMML object. If you're working on an already opened FILE*, use cmml_open_stdio instead.
XMLfilename | a CMML file to open |
Referenced by main().
CMML* cmml_new | ( | FILE * | file) |
cmml_attach_parser: Takes a FILE pointer to an already-opened CMML document. Returns a CMML object containing internal initialised data structures, etc, which is used in subsequent operations on the CMML file. This function must be called exactly once, after the file descriptor has been opened.
file | an open FILE pointer |
Referenced by main().
FILE* cmml_destroy | ( | CMML * | cmml) |
cmml_detach_parser: Close a CMML object. Return the FILE pointer from which the CMML object was derived.
cmml | a CMML* handle |
cmml_close: Close a CMML object.
cmml | a CMML* handle |
Referenced by main().
int cmml_set_read_callbacks | ( | CMML * | cmml, |
CMMLReadStream | read_stream, | ||
CMMLReadHead | read_head, | ||
CMMLReadClip | read_clip, | ||
void * | user_data | ||
) |
cmml_set_read_callbacks: registration function for callbacks.
cmml | a CMML* handle |
read_stream | a CMMLReadStream callback function for the stream tag |
read_head | a CMMLReadHead callback function for the head tag |
read_clip | a CMMLReadClip callback function for the a tag |
user_data | a pointer to a user defined object being passed to the callbacks |
Referenced by main().
long cmml_read | ( | CMML * | cmml, |
long | n | ||
) |
cmml_read: read n bytes from a file descriptor and parse them. Activates registered callbacks when reaching stream, head or clip end tags and blocks until they have completed. Stores parsed info in status. If an error or EOF occurs, returns -1 in which case you can check the error code with cmml_last_error().
cmml | a CMML* handle |
n | number of bytes to read |
Referenced by main().
void cmml_set_sloppy | ( | CMML * | cmml, |
int | value | ||
) |
cmml_set_sloppy: Sets the parsing and error indication to ignore sloppy errors, which are defined below the CMML_FORMAT_ERROR in the CMML_ErrorType struct
cmml | a CMML* handle |
value | a bool value to set the sloppy handling |
Referenced by main().
CMML_Preamble* cmml_get_preamble | ( | CMML * | cmml) |
cmml_get_preamble: returns a structure containing some of the parsing informtion received out of a stream.
cmml | a CMML* handle |
Referenced by main().
CMML_Stream* cmml_get_last_stream | ( | CMML * | cmml) |
cmml_get_last_stream: Return a copy of the current stream element.
cmml | a CMML* handle |
cmml_get_last_head: Return a copy of the current head element.
cmml | a CMML* handle |
cmml_get_last_clip: Return a copy of the current clip element.
cmml | a CMML* handle |
cmml_get_previous_clip: Return a copy of the previous clip element.
cmml | a CMML* handle |
CMML_Error* cmml_get_last_error | ( | CMML * | cmml) |
cmml_get_last_error: Return the error status of the most recently executed cmml command.
cmml | a CMML* handle |
Referenced by main(), read_clip(), read_head(), and read_stream().
void cmml_error_clear | ( | CMML * | cmml) |
cmml_error_clear: Clear the last error.
cmml | a CMML* handle |
cmml_set_window: sets the active temporal interval of a cmml stream; all clips outside that interval get ignored
cmml | a CMML* handle |
start | the start time of the interval given as CMML_Time* structure |
end | the end time of the interval given as CMML_Time* structure |
double cmml_skip_to_secs | ( | CMML * | cmml, |
double | seconds | ||
) |
cmml_skip_to_secs: seeks forward thru clip tags to required time offset (no backwards seeking: streaming!).
cmml | a CMML* handle |
seconds | the time offset to seek to |
Referenced by main().
double cmml_skip_to_utc | ( | CMML * | cmml, |
const char * | utc | ||
) |
cmml_skip_to_utc: seeks forward thru clip tags to required time offset (no backwards seeking: streaming!).
cmml | a CMML* handle |
utc | the time offset to seek to |
Referenced by main().
double cmml_skip_to_id | ( | CMML * | cmml, |
const char * | id | ||
) |
cmml_skip_to_id: seeks forward thru clip tags to required id (no backwards seeking: streaming!).
cmml | a CMML* handle |
id | the name of the clip tag to seek to |
Referenced by main().
double cmml_skip_to_offset | ( | CMML * | cmml, |
const char * | offset | ||
) |
cmml_skip_to_offset: seek forward thru clip tags and time to required fragment offset (no backwards seeking: streaming!).
cmml | a CMML* handl |
offset | the offset given as id or time spec |
CMML_Preamble* cmml_preamble_new | ( | char * | encoding, |
char * | id, | ||
char * | lang, | ||
char * | dir, | ||
char * | granulerate | ||
) |
cmml_preamble_new: Create a new CMML_Preamble.
encoding | the character encoding to be used; UTF-8 if NULL |
id | the id attribute of the cmml tag; not used if NULL |
lang | the lang attribute of the cmml tag; not used if NULL |
dir | the dir attribute of the cmml tag; not used if NULL |
granulerate | the granulerate attribute of the cmml tag; not used if NULL |
Referenced by main().
CMML_Element* cmml_element_new | ( | CMML_Element_Type | type) |
cmml_element_new: Create a new CMML_Element.
type | the element type to create (head, stream, or clip) |
CMML_Stream* cmml_stream_new | ( | void | ) |
cmml_stream_new: Create a new CMML_Stream.
CMML_Head* cmml_head_new | ( | void | ) |
cmml_head_new: Create a new CMML_Head.
Referenced by main().
cmml_clip_new: Create a new CMML_Anchr.
start_time | the start time at which to create an clip |
end_time | the end time at which to end the clip |
Referenced by main().
CMML_Error* cmml_error_new | ( | CMML_Error_Type | type) |
cmml_error_new: Create a new CMML_Error.
type | the type of error to create as from the given list |
CMML_Preamble* cmml_preamble_clone | ( | CMML_Preamble * | src) |
cmml_preamble_clone: Create a copy of a CMML_Preamble.
src | the original preamble |
CMML_Element* cmml_element_clone | ( | CMML_Element * | src) |
cmml_element_clone: Create a copy of an element.
src | the original element |
CMML_Stream* cmml_stream_clone | ( | CMML_Stream * | src) |
cmml_stream_clone: Create a copy of a stream element.
src | the original stream element |
cmml_head_clone: Create a copy of a head element.
src | the original head element |
cmml_clip_clone: Create a copy of a clip element.
src | the original clip element |
Referenced by read_clip().
void cmml_preamble_destroy | ( | CMML_Preamble * | preamble) |
cmml_preamble_destroy: Free all memory associated with a CMML_Preamble.
preamble | the preamble to free |
Referenced by main().
void cmml_element_destroy | ( | CMML_Element * | element) |
cmml_element_destroy: Free all memory associated with a CMML_Element.
element | the element to free |
void cmml_stream_destroy | ( | CMML_Stream * | stream) |
cmml_stream_destroy: Free a stream element.
stream | the stream element to free |
void cmml_head_destroy | ( | CMML_Head * | head) |
cmml_head_destroy: Free a head element.
head | the head element to free |
Referenced by main().
void cmml_clip_destroy | ( | CMML_Clip * | clip) |
cmml_clip_destroy: Free a clip element.
clip | the clip element to free |
Referenced by main(), and read_clip().
void cmml_error_destroy | ( | CMML_Error * | error) |
cmml_error_destroy: Free an error streucture.
error | the error structure to free |
int cmml_preamble_snprint | ( | char * | buf, |
int | n, | ||
CMML_Preamble * | pre | ||
) |
cmml_preamble_snprint: Prints the preamble as given in the cmml structure into the buffer buf of size n.
buf | the buffer to print into |
n | the size of the buffer buf |
pre | the preamble to print |
Referenced by main().
int cmml_element_snprint | ( | char * | buf, |
int | n, | ||
CMML_Element * | elem | ||
) |
cmml_element_snprint: Given a buffer buf of size n, write a CMML representation of a CMML_Element into it.
buf | the buffer to print into |
n | the size of the buffer buf |
elem | the element to print |
int cmml_stream_snprint | ( | char * | buf, |
int | n, | ||
CMML_Stream * | stream | ||
) |
cmml_stream_snprint: Prints a stream element into a buffer.
buf | the buffer to print into |
n | the size of the buffer buf |
stream | the stream element structure |
int cmml_stream_pretty_snprint | ( | char * | buf, |
int | n, | ||
CMML_Stream * | stream | ||
) |
cmml_stream_pretty_snprint: Prints a stream element into a buffer.
buf | the buffer to print into |
n | the size of the buffer buf |
stream | the stream element structure |
Referenced by read_stream().
int cmml_head_snprint | ( | char * | buf, |
int | n, | ||
CMML_Head * | head | ||
) |
cmml_head_snprint: Prints a head element into a buffer.
buf | the buffer to print into |
n | the size of the buffer buf |
head | the head element structure |
int cmml_head_pretty_snprint | ( | char * | buf, |
int | n, | ||
CMML_Head * | head | ||
) |
cmml_head_pretty_snprint: Prints a head element into a buffer.
buf | the buffer to print into |
n | the size of the buffer buf |
head | the head element structure |
Referenced by main(), and read_head().
int cmml_clip_snprint | ( | char * | buf, |
int | n, | ||
CMML_Clip * | clip | ||
) |
cmml_clip_snprint: Prints a clip element into a buffer.
buf | the buffer to print into |
n | the size of the buffer buf |
clip | the clip element structure |
int cmml_clip_pretty_snprint | ( | char * | buf, |
int | n, | ||
CMML_Clip * | clip | ||
) |
cmml_clip_pretty_snprint: Prints a clip element into a buffer.
buf | the buffer to print into |
n | the size of the buffer buf |
clip | the clip element structure |
Referenced by main(), and read_clip().
int cmml_error_snprint | ( | char * | buf, |
int | n, | ||
CMML_Error * | error, | ||
CMML * | cmml | ||
) |
cmml_error_snprint: Prints a string description of the CMML_Error.
buf | the buffer to print into |
n | the size of the buffer buf |
error | the error structure |
cmml | the cmml status structure (required for expat errors) |
Referenced by main(), read_clip(), read_head(), and read_stream().
CMML_List* cmml_list_new | ( | void | ) |
cmml_list_new: Create a new list.
cmml_list_clone: Copy a list using the default cloning function.
list | the list to clone |
CMML_List* cmml_list_clone_with | ( | CMML_List * | list, |
CMML_CloneFunc | clone | ||
) |
cmml_list_clone_with: Clone a list using a custom clone function.
list | the list to clone |
clone | the function to use to clone a list item |
cmml_list_tail: Returns the tail element of a list.
list | the list |
cmml_list_prepend: Prepend a new node to a list containing given data.
list | the list |
data | the data element of the newly created node |
cmml_list_append: Append a new node to a list containing given data.
list | the list |
data | the data element of the newly created node |
cmml_list_add_before: Add a new node containing given data before a given node
list | the list |
data | the data element of the newly created node |
node | the node before which to add the newly created node |
cmml_list_add_after: Add a new node containing given data after a given node.
list | the list |
data | the data element of the newly created node |
node | the node after which to add the newly created node |
cmml_list_find: Find the first node containing given data in a list.
list | the list |
data | the data element to find |
cmml_list_remove: Remove a node from a list.
list | the list |
node | the node to remove |
int cmml_list_length | ( | CMML_List * | list) |
cmml_list_length: Query the number of items in a list.
list | the list |
int cmml_list_is_empty | ( | CMML_List * | list) |
cmml_list_is_empty: Query if a list is empty, ie. contains no items.
list | the list |
int cmml_list_is_singleton | ( | CMML_List * | list) |
cmml_list_is_singleton: Query if the list is singleton, ie. contains exactly one item
list | the list |
CMML_List* cmml_list_free_with | ( | CMML_List * | list, |
CMML_FreeFunc | free_func | ||
) |
cmml_list_free_with: Free a list, using a given function to free each data element
list | the list |
free_func | a function to free each data element |
cmml_list_free: Free a list, using anx_free() to free each data element.
list | the list |
CMML_Time* cmml_time_new | ( | const char * | s) |
cmml_time_new: Creates a time struct from a string that contains a name-value time spec pair.
s | name-value time specification string |
Referenced by main().
CMML_Time* cmml_sec_new | ( | const char * | s) |
cmml_sec_new: Creates a time struct only from name-value sec specs.
s | name-value time specification string |
CMML_Time* cmml_time_new_secs | ( | double | seconds) |
cmml_time_new_sec: Creates a time struct from a npt sec specs.
seconds | sec spec to be used for creating a new time struct |
Referenced by read_clip().
CMML_Time* cmml_utc_new | ( | const char * | s) |
cmml_utc_new: Creates a time struct only from name-value utc specs.
s | name-value time specification string |
cmml_time_interval_new: Handles start and end times for clip tags, where we will only store sec offsets.
s | the time construct; examples: npt:40-79 or smpte-25:00:20:20-00:21:30,00:40:21 |
t_start | the start time returned |
t_end | the end time (if any) returned |
cmml_time_new_in_sec: For parsing/converting start and end time specs in clips into a seconds representation, which is the only one libcmml stores internally for clips.
s | the string that contains the time spec |
ref | the reference utc time if given in the stream tag |
base | the basetime in seconds as given in the stream tag |
cmml_time_utc_to_sec: Convert a time from utc to seconds with reference to a basetime
t | the given time struct |
ref | the reference utc time if given in the stream tag |
base | the basetime in seconds as given in the stream tag |
void cmml_time_free | ( | CMML_Time * | t) |
cmml_time_clone: Copying times
t | the given time struct |
double cmml_sec_parse | ( | const char * | s) |
cmml_sec_parse: for parsing sec specs with "npt:", "smpte:" etc.
s | the string containing the name-value time specification |
Referenced by read_clip().
CMML_UTC* cmml_utc_parse | ( | const char * | s) |
cmml_utc_parse: for parsing utc times with "clock:"
s | the string containing only the utc string as YYYYMMDDTHHmmss.hhZ |
cmml_utc_clone: for copying utc times
t | the src utc time structure |
cmml_utc_diff: for calculating the difference between two utc times as t2-t1 in seconds
t2 | the more recent utc time |
t1 | the less recent utc time |
int cmml_npt_snprint | ( | char * | buf, |
int | n, | ||
double | seconds | ||
) |
cmml_npt_snprint: prints npt time to a string
buf | buffer to print string to |
n | the size of the buffer buf |
seconds | the npt time in seconds as a double |
Referenced by main().
int cmml_utc_snprint | ( | char * | buf, |
int | n, | ||
CMML_UTC * | t | ||
) |
cmml_utc_snprint: for printing utc times
buf | the buffer to print into |
n | the size of the buffer buf |
t | the utc time structure |
int cmml_utc_pretty_snprint | ( | char * | buf, |
int | n, | ||
CMML_UTC * | t | ||
) |
cmml_utc_pretty_snprint: for printing utc times
buf | the buffer to print into |
n | the size of the buffer buf |
t | the utc time structure |