f40ccee9e25c1f9056e9ebe634abd280b35752b9
[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 #include <gst/base/gstadapter.h>
26
27 GST_DEBUG_CATEGORY_EXTERN (sub_parse_debug);
28 #define GST_CAT_DEFAULT sub_parse_debug
29
30 G_BEGIN_DECLS
31
32 #define GST_TYPE_SUBPARSE \
33   (gst_sub_parse_get_type ())
34 #define GST_SUBPARSE(obj) \
35   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SUBPARSE, GstSubParse))
36 #define GST_SUBPARSE_CLASS(klass) \
37   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SUBPARSE, GstSubParseClass))
38 #define GST_IS_SUBPARSE(obj) \
39   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SUBPARSE))
40 #define GST_IS_SUBPARSE_CLASS(klass) \
41   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SUBPARSE))
42
43 typedef struct _GstSubParse GstSubParse;
44 typedef struct _GstSubParseClass GstSubParseClass;
45
46 /* format enum */
47 typedef enum
48 {
49   GST_SUB_PARSE_FORMAT_UNKNOWN = 0,
50   GST_SUB_PARSE_FORMAT_MDVDSUB = 1,
51   GST_SUB_PARSE_FORMAT_SUBRIP = 2,
52   GST_SUB_PARSE_FORMAT_MPSUB = 3,
53   GST_SUB_PARSE_FORMAT_SAMI = 4,
54   GST_SUB_PARSE_FORMAT_TMPLAYER = 5,
55   GST_SUB_PARSE_FORMAT_MPL2 = 6,
56   GST_SUB_PARSE_FORMAT_SUBVIEWER = 7
57 } GstSubParseFormat;
58
59 typedef struct {
60   int      state;
61   GString *buf;
62   guint64  start_time;
63   guint64  duration;
64   guint64  max_duration; /* to clamp duration, 0 = no limit (used by tmplayer parser) */
65   GstSegment *segment;
66   gpointer user_data;
67   gdouble  fps;          /* used by microdvd parser */
68 } ParserState;
69
70 typedef gchar* (*Parser) (ParserState *state, const gchar *line);
71
72 struct _GstSubParse {
73   GstElement element;
74
75   GstPad *sinkpad,*srcpad;
76
77   /* contains the input in the input encoding */
78   GstAdapter *adapter;
79   /* contains the UTF-8 decoded input */
80   GString *textbuf;
81
82   GstSubParseFormat parser_type;
83   gboolean parser_detected;
84
85   Parser parse_line;
86   ParserState state;
87
88   /* seek */
89   guint64 offset;
90   guint64 next_offset;
91   
92   /* Segment */
93   GstSegment    segment;
94   GstSeekFlags  segment_flags;
95   gboolean      need_segment;
96   
97   gboolean flushing;
98   gboolean valid_utf8;
99   gchar   *detected_encoding;
100   gchar   *encoding;
101
102   gboolean first_buffer;
103 };
104
105 struct _GstSubParseClass {
106   GstElementClass parent_class;
107 };
108
109 GType gst_sub_parse_get_type (void);
110
111 G_END_DECLS
112
113 #endif /* __GST_SUBPARSE_H__ */