tizen 2.3.1 release
[framework/multimedia/gst-plugins-base0.10.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 #define SUBPARSE_MODIFICATION
28
29 GST_DEBUG_CATEGORY_EXTERN (sub_parse_debug);
30 #define GST_CAT_DEFAULT sub_parse_debug
31
32 G_BEGIN_DECLS
33
34 #define GST_TYPE_SUBPARSE \
35   (gst_sub_parse_get_type ())
36 #define GST_SUBPARSE(obj) \
37   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SUBPARSE, GstSubParse))
38 #define GST_SUBPARSE_CLASS(klass) \
39   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SUBPARSE, GstSubParseClass))
40 #define GST_IS_SUBPARSE(obj) \
41   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SUBPARSE))
42 #define GST_IS_SUBPARSE_CLASS(klass) \
43   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SUBPARSE))
44
45 typedef struct _GstSubParse GstSubParse;
46 typedef struct _GstSubParseClass GstSubParseClass;
47
48 /* format enum */
49 typedef enum
50 {
51   GST_SUB_PARSE_FORMAT_UNKNOWN = 0,
52   GST_SUB_PARSE_FORMAT_MDVDSUB = 1,
53   GST_SUB_PARSE_FORMAT_SUBRIP = 2,
54   GST_SUB_PARSE_FORMAT_MPSUB = 3,
55   GST_SUB_PARSE_FORMAT_SAMI = 4,
56   GST_SUB_PARSE_FORMAT_TMPLAYER = 5,
57   GST_SUB_PARSE_FORMAT_MPL2 = 6,
58   GST_SUB_PARSE_FORMAT_SUBVIEWER = 7,
59   GST_SUB_PARSE_FORMAT_DKS = 8,
60   GST_SUB_PARSE_FORMAT_QTTEXT = 9
61 } GstSubParseFormat;
62
63 typedef struct {
64   int      state;
65   GString *buf;
66   guint64  start_time;
67   guint64  duration;
68   guint64  max_duration; /* to clamp duration, 0 = no limit (used by tmplayer parser) */
69   GstSegment *segment;
70   gpointer user_data;
71   gboolean have_internal_fps; /* If TRUE don't overwrite fps by property */
72   gint fps_n, fps_d;     /* used by frame based parsers */
73 #ifdef SUBPARSE_MODIFICATION
74   GList* language_list;
75   gchar* current_language;
76   gchar *msl_language;
77   gboolean langlist_msg_posted;
78 #endif
79 } ParserState;
80
81 typedef gchar* (*Parser) (ParserState *state, const gchar *line);
82
83 struct _GstSubParse {
84   GstElement element;
85
86   GstPad *sinkpad,*srcpad;
87
88   /* contains the input in the input encoding */
89   GstAdapter *adapter;
90   /* contains the UTF-8 decoded input */
91   GString *textbuf;
92
93   GstSubParseFormat parser_type;
94   gboolean parser_detected;
95   const gchar *subtitle_codec;
96
97   Parser parse_line;
98   ParserState state;
99
100   /* seek */
101   guint64 offset;
102   guint64 next_offset;
103   
104   /* Segment */
105   GstSegment    segment;
106   GstSeekFlags  segment_flags;
107   gboolean      need_segment;
108   
109   gboolean flushing;
110   gboolean discont_sent;
111   gboolean valid_utf8;
112   gchar   *detected_encoding;
113   gchar   *encoding;
114
115   gboolean first_buffer;
116
117   /* used by frame based parsers */
118   gint fps_n, fps_d;
119 };
120
121 struct _GstSubParseClass {
122   GstElementClass parent_class;
123 };
124
125 GType gst_sub_parse_get_type (void);
126
127 G_END_DECLS
128
129 #endif /* __GST_SUBPARSE_H__ */