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., 51 Franklin St, Fifth Floor, 17 * Boston, MA 02110-1301, 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 GstVideoInfo info; 73 74 guint32 *comp_bufs[3]; /* Compositing buffers for U+V & A */ 75 guint16 comp_left; 76 guint16 comp_right; 77 78 SpuVobsubState vobsub; 79 SpuPgsState pgs; 80 }; 81 82 /* Structure used to store the queue of pending SPU packets. The start_ts is 83 * stored in running time... 84 * Also used to carry in-band events so they remain serialised properly */ 85 struct SpuPacket { 86 GstClockTime event_ts; 87 GstBuffer *buf; 88 GstEvent *event; 89 }; 90 91 struct _GstDVDSpu { 92 GstElement element; 93 94 GstPad *videosinkpad; 95 GstPad *subpic_sinkpad; 96 GstPad *srcpad; 97 98 /* Mutex to protect state we access from different chain funcs */ 99 GMutex spu_lock; 100 101 GstSegment video_seg; 102 GstSegment subp_seg; 103 104 SpuState spu_state; 105 SpuInputType spu_input_type; 106 107 /* GQueue of SpuBuf structures */ 108 GQueue *pending_spus; 109 110 /* Accumulator for collecting partial SPU buffers until they're complete */ 111 GstBuffer *partial_spu; 112 113 /* Store either a reference or a copy of the last video frame for duplication 114 * during still-frame conditions */ 115 GstBuffer *ref_frame; 116 117 /* Buffer to push after handling a DVD event, if any */ 118 GstBuffer *pending_frame; 119 }; 120 121 struct _GstDVDSpuClass { 122 GstElementClass parent_class; 123 }; 124 125 GType gst_dvd_spu_get_type (void); 126 GST_ELEMENT_REGISTER_DECLARE (dvdspu); 127 128 typedef enum { 129 GST_DVD_SPU_DEBUG_RENDER_RECTANGLE = (1 << 0), 130 GST_DVD_SPU_DEBUG_HIGHLIGHT_RECTANGLE = (1 << 1) 131 } GstDVDSPUDebugFlags; 132 133 extern GstDVDSPUDebugFlags dvdspu_debug_flags; 134 135 136 G_END_DECLS 137 138 #endif /* __GST_DVD_SPU_H__ */ 139