-
Notifications
You must be signed in to change notification settings - Fork 25
/
webvtt.h
56 lines (41 loc) · 1.48 KB
/
webvtt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* WebVTT parser
Copyright 2011 Mozilla Foundation
This Source Code Form is subject to the terms of the Mozilla
Public License, v. 2.0. If a copy of the MPL was not distributed
with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef _WEBVTT_H_
#define _WEBVTT_H_
#if defined(__cplusplus)
extern "C" {
#endif
/* webvtt files are a sequence of cues
each cue has a start and end time for presentation
and some text content (which my be marked up)
there may be other attributes, but we ignore them
we store these in a linked list */
typedef struct webvtt_cue webvtt_cue;
struct webvtt_cue {
char *text; /** text value of the cue */
long start, end; /** timestamps in milliseconds */
webvtt_cue *next; /** pointer to the next cue */
};
/* context structure for our parser */
typedef struct webvtt_parser webvtt_parser;
/* allocate and initialize a parser context */
webvtt_parser *webvtt_parse_new(void);
/* shut down and release a parser context */
void webvtt_parse_free(webvtt_parser *ctx);
/* read a webvtt file stored in a buffer */
struct webvtt_cue *
webvtt_parse_buffer(webvtt_parser *ctx, char *buffer, long length);
/* read a webvtt file from an open file */
struct webvtt_cue *
webvtt_parse_file(webvtt_parser *ctx, FILE *in);
/* read a webvtt file from a named file */
struct webvtt_cue *
webvtt_parse_filename(webvtt_parser *ctx, const char *filename);
#if defined(__cplusplus)
} /* close extern "C" */
#endif
#endif /* _WEBVTT_H_ */