1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
/*
* GStreamer
* Copyright (C) 2022 Matthew Waters <matthew@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <gst/gst.h>
#include <gst/video/video.h>
#ifndef __CCUTILS_H__
#define __CCUTILS_H__
G_BEGIN_DECLS
GST_DEBUG_CATEGORY_EXTERN(ccutils_debug_cat);
struct cdp_fps_entry
{
guint8 fps_idx; /* value stored in cdp */
guint fps_n, fps_d;
guint max_cc_count;
guint max_ccp_count;
guint max_cea608_count;
};
G_GNUC_INTERNAL
const struct cdp_fps_entry * cdp_fps_entry_from_fps (guint fps_n, guint fps_d);
G_GNUC_INTERNAL
const struct cdp_fps_entry * cdp_fps_entry_from_id (guint8 id);
extern const struct cdp_fps_entry null_fps_entry;
typedef enum {
GST_CC_CDP_MODE_TIME_CODE = (1<<0),
GST_CC_CDP_MODE_CC_DATA = (1<<1),
GST_CC_CDP_MODE_CC_SVC_INFO = (1<<2)
} GstCCCDPMode;
G_GNUC_INTERNAL
guint convert_cea708_cc_data_to_cdp (GstObject * dbg_obj,
GstCCCDPMode cdp_mode,
guint16 cdp_hdr_sequence_cntr,
const guint8 * cc_data,
guint cc_data_len,
guint8 * cdp,
guint cdp_len,
const GstVideoTimeCode * tc,
const struct cdp_fps_entry *fps_entry);
G_GNUC_INTERNAL
guint convert_cea708_cdp_to_cc_data (GstObject * dbg_obj,
const guint8 * cdp,
guint cdp_len,
guint8 *cc_data,
GstVideoTimeCode * tc,
const struct cdp_fps_entry **out_fps_entry);
G_GNUC_INTERNAL
gint drop_ccp_from_cc_data (guint8 * cc_data,
guint cc_data_len);
#define MAX_CDP_PACKET_LEN 256
#define MAX_CEA608_LEN 32
/**
* GstCCBufferCea608PaddingStrategy:
* @CC_BUFFER_CEA608_PADDING_STRATEGY_INPUT_REMOVE: Keep whatever padding was provided on the input.
* Do not add, remove, or modify, any padding bytes.
* @CC_BUFFER_CEA608_PADDING_STRATEGY_VALID: Always modify any padding data to become valid.
* This may cause a stream to show as a CEA-608 caption stream with no contents.
*
* Since: 1.26
*/
/**
* @CC_BUFFER_CEA608_PADDING_STRATEGY_INPUT_REMOVE:
* Since: 1.26
*/
/**
* @CC_BUFFER_CEA608_PADDING_STRATEGY_VALID:
* Since: 1.26
*/
typedef enum {
CC_BUFFER_CEA608_PADDING_STRATEGY_INPUT_REMOVE = (1 << 0),
CC_BUFFER_CEA608_PADDING_STRATEGY_VALID = (1 << 1),
} CCBufferCea608PaddingStrategy;
#define GST_TYPE_CC_BUFFER_CEA608_PADDING_STRATEGY (gst_cc_buffer_cea608_padding_strategy_get_type())
GType gst_cc_buffer_cea608_padding_strategy_get_type (void);
typedef enum {
CC_BUFFER_PUSH_OK,
CC_BUFFER_PUSH_NO_DATA,
CC_BUFFER_PUSH_OVERFLOW,
} CCBufferPushReturn;
G_DECLARE_FINAL_TYPE (CCBuffer, cc_buffer, GST, CC_BUFFER, GObject);
G_GNUC_INTERNAL
CCBuffer * cc_buffer_new (void);
G_GNUC_INTERNAL
void cc_buffer_get_stored_size (CCBuffer * buf,
guint * cea608_1_len,
guint * cea608_2_len,
guint * cc_data_len);
G_GNUC_INTERNAL
CCBufferPushReturn cc_buffer_push_separated (CCBuffer * buf,
const guint8 * cea608_1,
guint cea608_1_len,
const guint8 * cea608_2,
guint cea608_2_len,
const guint8 * cc_data,
guint cc_data_len);
G_GNUC_INTERNAL
CCBufferPushReturn cc_buffer_push_cc_data (CCBuffer * buf,
const guint8 * cc_data,
guint cc_data_len);
G_GNUC_INTERNAL
void cc_buffer_take_cc_data (CCBuffer * buf,
const struct cdp_fps_entry * fps_entry,
guint8 * cc_data,
guint * cc_data_len);
G_GNUC_INTERNAL
void cc_buffer_take_separated (CCBuffer * buf,
const struct cdp_fps_entry * fps_entry,
guint8 * cea608_1,
guint * cea608_1_len,
guint8 * cea608_2,
guint * cea608_2_len,
guint8 * cc_data,
guint * cc_data_len);
G_GNUC_INTERNAL
void cc_buffer_take_cea608_field1 (CCBuffer * buf,
const struct cdp_fps_entry * fps_entry,
guint8 * cea608_1,
guint * cea608_1_len);
G_GNUC_INTERNAL
void cc_buffer_take_cea608_field2 (CCBuffer * buf,
const struct cdp_fps_entry * fps_entry,
guint8 * cea608_2,
guint * cea608_2_len);
G_GNUC_INTERNAL
gboolean cc_buffer_is_empty (CCBuffer * buf);
G_GNUC_INTERNAL
void cc_buffer_discard (CCBuffer * buf);
G_GNUC_INTERNAL
void cc_buffer_set_max_buffer_time (CCBuffer * buf,
GstClockTime max_time);
G_GNUC_INTERNAL
void cc_buffer_set_output_padding (CCBuffer * buf,
gboolean output_padding,
gboolean output_ccp_padding);
G_GNUC_INTERNAL
void cc_buffer_set_cea608_padding_strategy(CCBuffer * buf,
CCBufferCea608PaddingStrategy padding_strategy);
G_GNUC_INTERNAL
void cc_buffer_set_cea608_valid_timeout (CCBuffer * buf, GstClockTime valid_timeout);
G_END_DECLS
#endif
|