1 /* GStreamer 2 * Copyright (C) 2015 Samsung Electronics Co., Ltd. 3 * @Author: Chengjun Wang <cjun.wang@samsung.com> 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 22 #ifndef __GST_CEA_CC_OVERLAY_H__ 23 #define __GST_CEA_CC_OVERLAY_H__ 24 25 #include <gst/gst.h> 26 #include <pango/pangocairo.h> 27 #include <gstcea708decoder.h> 28 29 G_BEGIN_DECLS 30 #define GST_TYPE_CEA_CC_OVERLAY \ 31 (gst_cea_cc_overlay_get_type()) 32 #define GST_CEA_CC_OVERLAY(obj) \ 33 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CEA_CC_OVERLAY,GstCeaCcOverlay)) 34 #define GST_CEA_CC_OVERLAY_CLASS(klass) \ 35 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CEA_CC_OVERLAY,GstCeaCcOverlayClass)) 36 #define GST_CEA_CC_OVERLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\ 37 GST_TYPE_CEA_CC_OVERLAY, GstCeaCcOverlayClass)) 38 #define GST_IS_CEA_CC_OVERLAY(obj) \ 39 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CEA_CC_OVERLAY)) 40 #define GST_IS_CEA_CC_OVERLAY_CLASS(klass) \ 41 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CEA_CC_OVERLAY)) 42 43 typedef struct _GstCeaCcOverlay GstCeaCcOverlay; 44 typedef struct _GstCeaCcOverlayClass GstCeaCcOverlayClass; 45 46 typedef enum 47 { 48 CCTYPE_608_CC1 = 0, 49 CCTYPE_608_CC2, 50 CCTYPE_708_ADD, 51 CCTYPE_708_START, 52 } DtvccType; 53 54 /** 55 * GstBaseTextOverlayHAlign: 56 * @GST_CEA_CC_OVERLAY_WIN_H_LEFT: closed caption window horizontal anchor left 57 * @GST_CEA_CC_OVERLAY_WIN_H_CENTER: closed caption window horizontal anchor center 58 * @GST_CEA_CC_OVERLAY_WIN_H_RIGHT: closed caption window horizontal anchor right 59 * @GST_CEA_CC_OVERLAY_WIN_H_AUTO: closed caption window horizontal anchor auto 60 * 61 * Closed Caption Window Horizontal anchor position. 62 */ 63 typedef enum 64 { 65 GST_CEA_CC_OVERLAY_WIN_H_LEFT, 66 GST_CEA_CC_OVERLAY_WIN_H_CENTER, 67 GST_CEA_CC_OVERLAY_WIN_H_RIGHT, 68 GST_CEA_CC_OVERLAY_WIN_H_AUTO 69 } GstCeaCcOverlayWinHPos; 70 71 /** 72 * GstCeaCcOverlay: 73 * 74 * Opaque ccoverlay data structure. 75 */ 76 struct _GstCeaCcOverlay 77 { 78 GstElement parent; 79 GstPad *video_sinkpad; 80 GstPad *cc_sinkpad; 81 GstPad *srcpad; 82 /* There are two possible 608 streams encapsulated by 708 */ 83 gint16 cea608_index[NUM_608_CCTYPES]; 84 gint16 cea708_index; 85 guint8 cea608_buffer[NUM_608_CCTYPES][DTVCC_LENGTH]; 86 guint8 cea708_buffer[DTVCC_LENGTH]; 87 88 /* TRUE if input is CDP, FALSE if cc_data triplet */ 89 gboolean is_cdp; 90 91 GstSegment segment; 92 GstSegment cc_segment; 93 GstVideoOverlayComposition *current_composition; 94 guint64 current_comp_start_time; 95 GstVideoOverlayComposition *next_composition; 96 guint64 next_comp_start_time; 97 GstCeaCcOverlayWinHPos default_window_h_pos; 98 gboolean cc_pad_linked; 99 gboolean video_flushing; 100 gboolean video_eos; 101 gboolean cc_flushing; 102 gboolean cc_eos; 103 104 GMutex lock; 105 GCond cond; /* to signal removal of a queued text 106 * buffer, arrival of a text buffer, 107 * a text segment update, or a change 108 * in status (e.g. shutdown, flushing) */ 109 110 GstVideoInfo info; 111 GstVideoFormat format; 112 gint width; 113 gint height; 114 gboolean silent; 115 Cea708Dec *decoder; 116 gint image_width; 117 gint image_height; 118 119 gboolean need_update; 120 121 gboolean attach_compo_to_buffer; 122 }; 123 124 /* FIXME : Pango context and MT-safe since 1.32.6 */ 125 struct _GstCeaCcOverlayClass 126 { 127 GstElementClass parent_class; 128 129 PangoContext *pango_context; 130 GMutex *pango_lock; 131 }; 132 133 GType gst_cea_cc_overlay_get_type (void); 134 135 G_END_DECLS 136 #endif /* __GST_CEA_CC_OVERLAY_H__ */ 137