• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * GStreamer
3  * Copyright (C) 2018 Sebastian Dröge <sebastian@centricular.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 #ifndef __GST_CCCONVERTER_H__
22 #define __GST_CCCONVERTER_H__
23 
24 #include <gst/gst.h>
25 #include <gst/base/base.h>
26 #include <gst/video/video.h>
27 
28 G_BEGIN_DECLS
29 #define GST_TYPE_CCCONVERTER \
30   (gst_cc_converter_get_type())
31 #define GST_CCCONVERTER(obj) \
32   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CCCONVERTER,GstCCConverter))
33 #define GST_CCCONVERTER_CLASS(klass) \
34   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CCCONVERTER,GstCCConverterClass))
35 #define GST_IS_CCCONVERTER(obj) \
36   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CCCONVERTER))
37 #define GST_IS_CCCONVERTER_CLASS(klass) \
38   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CCCONVERTER))
39 
40 typedef struct _GstCCConverter GstCCConverter;
41 typedef struct _GstCCConverterClass GstCCConverterClass;
42 
43 #define MAX_CDP_PACKET_LEN 256
44 #define MAX_CEA608_LEN 32
45 
46 typedef enum {
47   GST_CC_CONVERTER_CDP_MODE_TIME_CODE   = (1<<0),
48   GST_CC_CONVERTER_CDP_MODE_CC_DATA     = (1<<1),
49   GST_CC_CONVERTER_CDP_MODE_CC_SVC_INFO = (1<<2)
50 } GstCCConverterCDPMode;
51 
52 struct _GstCCConverter
53 {
54   GstBaseTransform parent;
55 
56   GstCCConverterCDPMode cdp_mode;
57 
58   GstVideoCaptionType input_caption_type;
59   GstVideoCaptionType output_caption_type;
60 
61   /* CDP sequence numbers when outputting CDP */
62   guint16 cdp_hdr_sequence_cntr;
63 
64   gint in_fps_n, in_fps_d;
65   gint out_fps_n, out_fps_d;
66 
67   /* for framerate differences, we need to keep previous/next frames in order
68    * to split/merge data across multiple input or output buffers.  The data is
69    * stored as cc_data */
70   guint8    scratch_cea608_1[MAX_CEA608_LEN];
71   guint     scratch_cea608_1_len;
72   guint8    scratch_cea608_2[MAX_CEA608_LEN];
73   guint     scratch_cea608_2_len;
74   guint8    scratch_ccp[MAX_CDP_PACKET_LEN];
75   guint     scratch_ccp_len;
76 
77   guint     input_frames;
78   guint     output_frames;
79   GstVideoTimeCode current_output_timecode;
80   /* previous buffer for copying metas onto */
81   GstBuffer *previous_buffer;
82 };
83 
84 struct _GstCCConverterClass
85 {
86   GstBaseTransformClass parent_class;
87 };
88 
89 GType gst_cc_converter_get_type (void);
90 
91 GST_ELEMENT_REGISTER_DECLARE (ccconverter);
92 
93 G_END_DECLS
94 #endif /* __GST_CCCONVERTER_H__ */
95