2022-05-12 03:19:58 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
2022-05-13 05:19:43 +00:00
|
|
|
#include <gst/video/video.h>
|
2022-05-12 03:19:58 +00:00
|
|
|
|
|
|
|
#ifndef __CCUTILS_H__
|
|
|
|
#define __CCUTILS_H__
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2022-05-13 05:19:43 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN(ccutils_debug_cat);
|
|
|
|
|
2022-05-12 03:19:58 +00:00
|
|
|
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;
|
|
|
|
|
2022-05-13 05:19:43 +00:00
|
|
|
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;
|
|
|
|
|
2022-06-01 07:47:55 +00:00
|
|
|
G_GNUC_INTERNAL
|
2022-05-13 05:19:43 +00:00
|
|
|
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);
|
|
|
|
|
2022-06-01 07:47:55 +00:00
|
|
|
G_GNUC_INTERNAL
|
2022-05-30 11:39:13 +00:00
|
|
|
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);
|
2022-06-01 07:47:55 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
gint drop_ccp_from_cc_data (guint8 * cc_data,
|
|
|
|
guint cc_data_len);
|
2022-05-30 11:39:13 +00:00
|
|
|
|
|
|
|
#define MAX_CDP_PACKET_LEN 256
|
2022-06-01 07:47:55 +00:00
|
|
|
#define MAX_CEA608_LEN 32
|
|
|
|
|
2024-03-08 07:22:53 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2022-06-01 07:47:55 +00:00
|
|
|
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
|
2022-06-01 11:24:41 +00:00
|
|
|
gboolean cc_buffer_push_separated (CCBuffer * buf,
|
2022-06-01 07:47:55 +00:00
|
|
|
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
|
2022-06-01 11:24:41 +00:00
|
|
|
gboolean cc_buffer_push_cc_data (CCBuffer * buf,
|
2022-06-01 07:47:55 +00:00
|
|
|
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
|
2022-06-01 11:24:41 +00:00
|
|
|
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
|
2022-06-01 07:47:55 +00:00
|
|
|
void cc_buffer_discard (CCBuffer * buf);
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
void cc_buffer_set_max_buffer_time (CCBuffer * buf,
|
|
|
|
GstClockTime max_time);
|
2022-06-01 11:24:41 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
void cc_buffer_set_output_padding (CCBuffer * buf,
|
2023-10-02 12:34:42 +00:00
|
|
|
gboolean output_padding,
|
|
|
|
gboolean output_ccp_padding);
|
2024-03-08 07:22:53 +00:00
|
|
|
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);
|
2022-05-30 11:39:13 +00:00
|
|
|
|
2022-05-12 03:19:58 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif
|