libcmml  0.9.1
Macros | Functions | Variables
cmml-timeshift.c File Reference
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <cmml.h>

Macros

#define BUFSIZE   100000
 

Functions

static void PrintUsage (char *prog)
 
static int read_stream (CMML *cmml, const CMML_Stream *stream, void *user_data)
 
static int read_head (CMML *cmml, const CMML_Head *head, void *user_data)
 
static int read_clip (CMML *cmml, const CMML_Clip *clip, void *user_data)
 
int main (int argc, char *argv[])
 

Variables

static FILE * outfile
 
static double secs
 

Detailed Description

cmml-timeshift: parses a CMML instance document and applies a timeshift to all the clip tags.

Usage: cmml-timeshift [options] filename
Apply a timeshift to all the clip tags.
 
Possible options:
  -s offset, --sec offset
                 Specify the offset in seconds to add to clip tags
  -o filename, --output filename
                 Specify the output filename. The file is written
                 to standard output by default.
  -h, --help     Display this help information
  -v, --version  Display version information

Macro Definition Documentation

◆ BUFSIZE

#define BUFSIZE   100000

the size of the print buffer

Referenced by main(), read_clip(), read_head(), and read_stream().

Function Documentation

◆ PrintUsage()

static void PrintUsage ( char *  prog)
static

PrintUsage: prints out help on how to use this program

Parameters
progthe program's name

Referenced by main().

◆ read_stream()

static int read_stream ( CMML cmml,
const CMML_Stream stream,
void *  user_data 
)
static

read_stream: the callback for a stream element

Parameters
cmmlthe CMML* handle in use
streamthe stream element's content represented in a CMML_Stream*
user_datauser defined data
Returns
0 on success, 1 on error

References BUFSIZE, cmml_error_snprint(), cmml_get_last_error(), cmml_stream_pretty_snprint(), and outfile.

Referenced by main().

◆ read_head()

static int read_head ( CMML cmml,
const CMML_Head head,
void *  user_data 
)
static

read_head: the callback for a head element

Parameters
cmmlthe CMML* handle in use
headthe head element's content represented in a CMML_Head*
user_datauser defined data
Returns
0 on success, 1 on error

References BUFSIZE, cmml_error_snprint(), cmml_get_last_error(), cmml_head_pretty_snprint(), and outfile.

Referenced by main().

◆ read_clip()

static int read_clip ( CMML cmml,
const CMML_Clip clip,
void *  user_data 
)
static

read_clip: the callback for a clip element

Parameters
cmmlthe CMML* handle in use
clipthe clip element's content represented in a CMML_Clip*
user_datauser defined data
Returns
0 on success, 1 on error

References BUFSIZE, cmml_clip_clone(), cmml_clip_destroy(), cmml_clip_pretty_snprint(), cmml_error_snprint(), cmml_get_last_error(), cmml_sec_parse(), cmml_time_free(), cmml_time_new_secs(), CMML_Clip::end_time, outfile, CMML_Time::sec, secs, CMML_Clip::start_time, CMML_Time::t, and CMML_Time::tstr.

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

main function of cmml-timeshift, which opens the CMML file, seeks to any given offsets, registers the callbacks, and then steps through the file in chunks of BUFSIZE size, during which the callbacks get activated as the relevant elements get parsed.

References BUFSIZE, cmml_close(), CMML_EOF, cmml_error_snprint(), cmml_get_last_error(), cmml_get_preamble(), cmml_new(), cmml_open(), cmml_preamble_snprint(), cmml_read(), cmml_set_read_callbacks(), cmml_set_sloppy(), outfile, PrintUsage(), read_clip(), read_head(), read_stream(), secs, and CMML_Error::type.

Variable Documentation

◆ outfile

FILE* outfile
static

outfile: defines FILE pointer to print output to

Referenced by main(), read_clip(), read_head(), and read_stream().

◆ secs

double secs
static

secs: number of seconds to offset the clip start/end times

Examples:
cmml-validate.c.

Referenced by main(), and read_clip().