gst/subparse/gstsubparse.*: Text subtitle files may or may not be UTF-8. If it's...
[platform/upstream/gstreamer.git] / gst / subparse / gstsubparse.h
1 /* GStreamer
2  * Copyright (C) <2002> David A. Schleef <ds@schleef.org>
3  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef __GST_SUBPARSE_H__
22 #define __GST_SUBPARSE_H__
23
24 #include <gst/gst.h>
25
26 G_BEGIN_DECLS
27
28 #define GST_TYPE_SUBPARSE \
29   (gst_sub_parse_get_type ())
30 #define GST_SUBPARSE(obj) \
31   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SUBPARSE, GstSubParse))
32 #define GST_SUBPARSE_CLASS(klass) \
33   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SUBPARSE, GstSubParse))
34 #define GST_IS_SUBPARSE(obj) \
35   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SUBPARSE))
36 #define GST_IS_SUBPARSE_CLASS(obj) \
37   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SUBPARSE))
38
39 typedef struct _GstSubParse GstSubParse;
40 typedef struct _GstSubParseClass GstSubParseClass;
41
42 /* format enum */
43 typedef enum
44 {
45   GST_SUB_PARSE_FORMAT_UNKNOWN = 0,
46   GST_SUB_PARSE_FORMAT_MDVDSUB = 1,
47   GST_SUB_PARSE_FORMAT_SUBRIP = 2,
48   GST_SUB_PARSE_FORMAT_MPSUB = 3
49 } GstSubParseFormat;
50
51 typedef struct {
52   int      state;
53   GString *buf;
54   guint64  start_time;
55   guint64  duration;
56   GstSegment *segment;
57 } ParserState;
58
59 typedef gchar* (*Parser) (ParserState *state, const gchar *line);
60
61 struct _GstSubParse {
62   GstElement element;
63
64   GstPad *sinkpad,*srcpad;
65
66   GString *textbuf;
67
68   GstSubParseFormat parser_type;
69   gboolean parser_detected;
70
71   Parser parse_line;
72   ParserState state;
73
74   /* seek */
75   guint64 offset;
76   guint64 next_offset;
77   
78   /* Segment */
79   GstSegment *segment;
80   GstSeekFlags  segment_flags;
81   gboolean need_segment;
82   
83   gboolean flushing;
84   gboolean valid_utf8;
85 };
86
87 struct _GstSubParseClass {
88   GstElementClass parent_class;
89 };
90
91 GType gst_sub_parse_get_type (void);
92
93 G_END_DECLS
94
95 #endif /* __GST_SUBPARSE_H__ */