subparse: Add drop-out-of-segment property
[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., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, 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   GST_SUB_PARSE_FORMAT_DKS = 8,
58   GST_SUB_PARSE_FORMAT_QTTEXT = 9,
59   GST_SUB_PARSE_FORMAT_LRC = 10,
60   GST_SUB_PARSE_FORMAT_VTT = 11
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   guint8 line_position;          /* percent value */
74   gint line_number;              /* line number, can be positive or negative */
75   guint8 text_position;          /* percent value */
76   guint8 text_size;          /* percent value */
77   gchar *vertical;        /* "", "vertical", "vertical-lr" */
78   gchar *alignment;       /* "", "start", "middle", "end" */
79   gconstpointer allowed_tags; /* list of markup tags allowed in the cue text. */
80   gboolean allows_tag_attributes;
81 #ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION
82   GList* language_list;
83   gchar* current_language;
84   gboolean langlist_msg_posted;
85 #endif
86 #ifdef TIZEN_FEATURE_HLS_WEBVTT
87   guint64 local;
88   guint64 mpegts;
89 #endif
90 #ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
91   gboolean drop_out_of_segment;
92 #endif
93 } ParserState;
94
95 typedef gchar* (*Parser) (ParserState *state, const gchar *line);
96
97 struct _GstSubParse {
98   GstElement element;
99
100   GstPad *sinkpad,*srcpad;
101
102   /* contains the input in the input encoding */
103   GstAdapter *adapter;
104   /* contains the UTF-8 decoded input */
105   GString *textbuf;
106
107   GstSubParseFormat parser_type;
108   gboolean parser_detected;
109   const gchar *subtitle_codec;
110
111   Parser parse_line;
112   ParserState state;
113
114   /* seek */
115   guint64 offset;
116
117   /* Segment */
118   GstSegment    segment;
119   gboolean      need_segment;
120
121   gboolean flushing;
122   gboolean valid_utf8;
123   gchar   *detected_encoding;
124   gchar   *encoding;
125 #ifdef TIZEN_FEATURE_UPSTREAM
126   gboolean strip_pango_markup;
127 #endif
128   gboolean first_buffer;
129
130   /* used by frame based parsers */
131   gint fps_n, fps_d;
132 #ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION
133   GMutex seek_lock;
134 #endif
135 };
136
137 struct _GstSubParseClass {
138   GstElementClass parent_class;
139 };
140
141 GType gst_sub_parse_get_type (void);
142
143 G_END_DECLS
144
145 #endif /* __GST_SUBPARSE_H__ */