Imported Upstream version 0.10.23
[profile/ivi/gst-plugins-bad.git] / gst / dvdspu / gstdvdspu.h
1 /* GStreamer DVD Sub-Picture Unit
2  * Copyright (C) 2007 Fluendo S.A. <info@fluendo.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 #ifndef __GST_DVD_SPU_H__
20 #define __GST_DVD_SPU_H__
21
22 #include <gst/gst.h>
23
24 #include "gstspu-common.h"
25 #include "gstspu-vobsub.h"
26 #include "gstspu-pgs.h"
27
28 G_BEGIN_DECLS
29
30 #define GST_TYPE_DVD_SPU \
31   (gst_dvd_spu_get_type())
32 #define GST_DVD_SPU(obj) \
33   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DVD_SPU,GstDVDSpu))
34 #define GST_DVD_SPU_CLASS(klass) \
35   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DVD_SPU,GstDVDSpuClass))
36 #define GST_IS_DVD_SPU(obj) \
37   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DVD_SPU))
38 #define GST_IS_DVD_SPU_CLASS(klass) \
39   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DVD_SPU))
40
41 #define DVD_SPU_LOCK(s) g_mutex_lock ((s)->spu_lock);
42 #define DVD_SPU_UNLOCK(s) g_mutex_unlock ((s)->spu_lock);
43
44 typedef struct _GstDVDSpuClass GstDVDSpuClass;
45
46 typedef enum SpuStateFlags SpuStateFlags;
47 typedef enum SpuInputType SpuInputType;
48 typedef struct SpuPacket SpuPacket;
49
50 enum SpuInputType {
51   SPU_INPUT_TYPE_NONE   = 0x00,
52   SPU_INPUT_TYPE_VOBSUB = 0x01,
53   SPU_INPUT_TYPE_PGS    = 0x02
54 };
55
56 enum SpuStateFlags {
57   SPU_STATE_NONE        = 0x00,
58   /* Flags cleared on a flush */
59   SPU_STATE_DISPLAY     = 0x01,
60   SPU_STATE_FORCED_DSP  = 0x02,
61   SPU_STATE_STILL_FRAME = 0x04,
62   /* Persistent flags */
63   SPU_STATE_FORCED_ONLY = 0x100
64 };
65
66 #define SPU_STATE_FLAGS_MASK (0xff)
67
68 struct SpuState {
69   GstClockTime next_ts; /* Next event TS in running time */
70   SpuStateFlags flags;
71
72   gint fps_n, fps_d;
73   gint16 vid_width, vid_height;
74   gint16 Y_stride, UV_stride;
75   gint16 Y_height, UV_height;
76
77   guint32 *comp_bufs[3]; /* Compositing buffers for U+V & A */
78   guint16 comp_left;
79   guint16 comp_right;
80
81   SpuVobsubState vobsub;
82   SpuPgsState pgs;
83 };
84
85 /* Structure used to store the queue of pending SPU packets. The start_ts is
86  * stored in running time... 
87  * Also used to carry in-band events so they remain serialised properly */
88 struct SpuPacket {
89   GstClockTime event_ts;
90   GstBuffer *buf;
91   GstEvent *event;
92 };
93
94 struct _GstDVDSpu {
95   GstElement element;
96
97   GstPad *videosinkpad;
98   GstPad *subpic_sinkpad;
99   GstPad *srcpad;
100
101   /* Mutex to protect state we access from different chain funcs */
102   GMutex *spu_lock;
103
104   GstSegment video_seg;
105   GstSegment subp_seg;
106
107   SpuState spu_state;
108   SpuInputType spu_input_type;
109
110   /* GQueue of SpuBuf structures */
111   GQueue *pending_spus;
112
113   /* Accumulator for collecting partial SPU buffers until they're complete */
114   GstBuffer *partial_spu;
115
116   /* Store either a reference or a copy of the last video frame for duplication
117    * during still-frame conditions */
118   GstBuffer *ref_frame;
119
120   /* Buffer to push after handling a DVD event, if any */
121   GstBuffer *pending_frame;
122 };
123
124 struct _GstDVDSpuClass {
125   GstElementClass parent_class;
126 };
127
128 GType gst_dvd_spu_get_type (void);
129
130 G_END_DECLS
131
132 #endif /* __GST_DVD_SPU_H__ */