tizen 2.3 release
[framework/multimedia/gst-plugins-ext0.10.git] / submux / src / gstsubmux.h
1 /*
2  * N-Project
3  * Copyright (c) 2008 Samsung Electronics, Inc.
4  * All rights reserved.
5  *
6  * This software is a confidential and proprietary information
7  * of Samsung Electronics, Inc. ("Confidential Information").  You
8  * shall not disclose such Confidential Information and shall use
9  * it only in accordance with the terms of the license agreement
10  * you entered into with Samsung Electronics.
11  */
12
13 /*
14  * This file defines the functions of Gstreamer plug-in for submux
15  *
16  * @file
17  * @author      Deepak Singh (deep.singh@samsung.com)
18  * @version     1.0
19  * @usage
20  * @brief       This plug-in is targeted to be used for ARM MP4ASP decoding.
21  */
22
23 /*! Revision History:
24  *! ---------------------------------------------------------------------------
25  *!     DATE             |         AUTHOR               |       COMMENTS
26  *! ---------------------------------------------------------------------------
27  *! 17-Jan-2014            deep.singh@samsung.com              created
28  */
29
30
31
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <sys/types.h>
35 #include <string.h>
36 #include <errno.h>
37 #include <sys/time.h>
38 #include <string.h>
39 #include <gst/gst.h>
40 #include <gst/gsterror.h>
41 #include <glib.h>
42 #include <gst/app/gstappsrc.h>
43 #include <gst/app/gstappsink.h>
44 #include <gst/base/gstadapter.h>
45 G_BEGIN_DECLS
46
47 #define GST_TYPE_SUBMUX        (gst_submux_get_type())
48 #define GST_SUBMUX(obj)        (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SUBMUX,Gstsubmux))
49 #define GST_SUBMUX_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SUBMUX,GstsubmuxClass))
50 #define GST_SUBMUX_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_SUBMUX,GstsubmuxClass))
51 #define GST_IS_SUBMUX(obj)     (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SUBMUX))
52 #define GST_IS_SUBMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SUBMUX))
53 #define GST_SUBMUX_CAST(obj)    ((Gstsubmux *)(obj))
54 #define MAX_LANG 10
55
56 typedef struct _Gstsubmux Gstsubmux;
57 typedef struct _GstsubmuxClass GstsubmuxClass;
58 typedef struct _GstsubmuxPrivate GstsubmuxPrivate;
59 typedef struct _LanguageStruct  GstLangStruct;
60 typedef struct _GstSubMuxStream GstSubmuxStream;
61 typedef struct _GstSubMuxPipe SubMuxPipe;
62
63 typedef enum
64 {
65   GST_SUB_PARSE_FORMAT_UNKNOWN = 0,
66   GST_SUB_PARSE_FORMAT_MDVDSUB = 1,
67   GST_SUB_PARSE_FORMAT_SUBRIP = 2,
68   GST_SUB_PARSE_FORMAT_MPSUB = 3,
69   GST_SUB_PARSE_FORMAT_SAMI = 4,
70   GST_SUB_PARSE_FORMAT_TMPLAYER = 5,
71   GST_SUB_PARSE_FORMAT_MPL2 = 6,
72   GST_SUB_PARSE_FORMAT_SUBVIEWER = 7,
73   GST_SUB_PARSE_FORMAT_DKS = 8,
74   GST_SUB_PARSE_FORMAT_QTTEXT = 9
75 } GstSubMuxFormat;
76 typedef enum
77 {
78   GST_SUB_PARSE_REGEX_UNKNOWN = 0,
79   GST_SUB_PARSE_REGEX_MDVDSUB = 1,
80   GST_SUB_PARSE_REGEX_SUBRIP = 2,
81   GST_SUB_PARSE_REGEX_DKS = 3,
82 } GstSubMuxRegex;
83 struct _GstSubMuxPipe
84 {
85   GstElement *pipe;
86   GstElement *appsrc;
87   GstElement *appsink;
88   GstElement *parser;
89   GstPad *app_sinkpad;
90 };
91 struct _GstSubMuxStream
92 {
93   void *parent;
94   gboolean need_segment;
95   gboolean discont_came;
96   gboolean flushing;
97   SubMuxPipe pipe_struc;
98   gboolean eos_sent;
99   gboolean eos_came;
100   GstClockTime duration;
101   GstClockTime last_ts; /* last timestamp of subtitle present in subtitle file*/
102   GstClockTime eos_ts;
103   GstClockTime seek_ts;
104   GstBuffer *buffer;
105   GQueue *queue;
106   GMutex *queue_lock;
107   GCond *queue_empty;
108   gboolean flush_done;
109 };
110 struct _Gstsubmux
111 {
112     GstElement     element;
113
114     /*< private >*/
115     GstsubmuxPrivate *priv;
116
117     /* pads */
118     guint sinkpads_count;
119     gboolean external_sinkpad;
120     gboolean stop_loop;
121     GstPad *srcpad;
122     GList *sinkpad;
123     gboolean pipeline_made;
124     //GstPad *sinkpad;
125     GList *buffer_list;
126     gboolean init_done;
127     GList *msl_streams;
128     GList *streams;
129     gboolean flushing;
130     gboolean need_segment;
131     GstSubmuxStream muxed_stream;
132     gchar   *encoding;
133     gchar   *detected_encoding;
134     gint fps_n, fps_d;
135     GstSegment    segment;
136     GstTask *loop_task;
137     GstSeekFlags  segment_flags;
138     gboolean seek_came ;
139     gboolean finalize;
140     gboolean langlist_msg_posted;
141     GstBuffer **cur_buf_array;
142     gchar* external_filepath;
143 };
144
145 struct _GstsubmuxPrivate
146 {
147     gboolean first_buffer;
148     GstSubMuxFormat parser_type;
149     GList *lang_list;
150     gboolean is_internal;
151     guint stream_count;
152 };
153
154
155 struct _LanguageStruct
156 {
157     gchar *language_code;
158     gchar *language_key;
159     gboolean active;
160 };
161
162 struct _GstsubmuxClass
163 {
164   GstElementClass parent_class;
165 };
166
167 GType           gst_submux_get_type         (void);
168
169 G_END_DECLS
170
171