Blame gst-libs/gst/video/video-anc.h

Packit 0652a1
/* GStreamer
Packit 0652a1
 * Copyright (C) <2018> Edward Hervey <edward@centricular.com>
Packit 0652a1
 *
Packit 0652a1
 * This library is free software; you can redistribute it and/or
Packit 0652a1
 * modify it under the terms of the GNU Library General Public
Packit 0652a1
 * License as published by the Free Software Foundation; either
Packit 0652a1
 * version 2 of the License, or (at your option) any later version.
Packit 0652a1
 *
Packit 0652a1
 * This library is distributed in the hope that it will be useful,
Packit 0652a1
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 0652a1
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 0652a1
 * Library General Public License for more details.
Packit 0652a1
 *
Packit 0652a1
 * You should have received a copy of the GNU Library General Public
Packit 0652a1
 * License along with this library; if not, write to the
Packit 0652a1
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit 0652a1
 * Boston, MA 02110-1301, USA.
Packit 0652a1
 */
Packit 0652a1
Packit 0652a1
#ifndef __GST_VIDEO_ANC_H__
Packit 0652a1
#define __GST_VIDEO_ANC_H__
Packit 0652a1
Packit 0652a1
#include <gst/gst.h>
Packit 0652a1
#include <gst/video/video-format.h>
Packit 0652a1
#include <gst/video/video-info.h>
Packit 0652a1
Packit 0652a1
G_BEGIN_DECLS
Packit 0652a1
Packit 0652a1
typedef struct _GstVideoAncillary GstVideoAncillary;
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GstVideoAncillary:
Packit 0652a1
 * @DID: The Data Identifier
Packit 0652a1
 * @SDID_block_number: The Secondary Data Identifier (if type 2) or the Data
Packit 0652a1
 *                     Block Number (if type 1)
Packit 0652a1
 * @data_count: The amount of data (in bytes) in @data (max 255 bytes)
Packit 0652a1
 * @data: (array length=data_count): The user data content of the Ancillary packet.
Packit 0652a1
 *    Does not contain the ADF, DID, SDID nor CS.
Packit 0652a1
 *
Packit 0652a1
 * Video Ancillary data, according to SMPTE-291M specification.
Packit 0652a1
 *
Packit 0652a1
 * Note that the contents of the data are always stored as 8bit data (i.e. do not contain
Packit 0652a1
 * the parity check bits).
Packit 0652a1
 *
Packit 0652a1
 * Since: 1.16
Packit 0652a1
 */
Packit 0652a1
struct _GstVideoAncillary {
Packit 0652a1
  guint8 DID;
Packit 0652a1
  guint8 SDID_block_number;
Packit 0652a1
  guint8 data_count;
Packit 0652a1
  guint8 data[256];
Packit 0652a1
Packit 0652a1
  /*< private >*/
Packit 0652a1
  /* Padding for future extension */
Packit 0652a1
  gpointer _gst_reserved[GST_PADDING];
Packit 0652a1
};
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GstVideoAncillaryDID:
Packit 0652a1
 *
Packit 0652a1
 * Since: 1.16
Packit 0652a1
 */
Packit 0652a1
typedef enum {
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID_UNDEFINED = 0x00,
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID_DELETION  = 0x80,
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID_HANC_3G_AUDIO_DATA_FIRST = 0xa0,
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID_HANC_3G_AUDIO_DATA_LAST = 0xa7,
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID_HANC_HDTV_AUDIO_DATA_FIRST = 0xe0,
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID_HANC_HDTV_AUDIO_DATA_LAST = 0xe7,
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID_HANC_SDTV_AUDIO_DATA_1_FIRST = 0xec,
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID_HANC_SDTV_AUDIO_DATA_1_LAST = 0xef,
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID_CAMERA_POSITION = 0xf0,
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID_HANC_ERROR_DETECTION = 0xf4,
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID_HANC_SDTV_AUDIO_DATA_2_FIRST = 0xf8,
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID_HANC_SDTV_AUDIO_DATA_2_LAST = 0xff,
Packit 0652a1
} GstVideoAncillaryDID;
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GST_VIDEO_ANCILLARY_DID16:
Packit 0652a1
 * @anc: a #GstVideoAncillary
Packit 0652a1
 *
Packit 0652a1
 * Returns the #GstVideoAncillaryDID16 of the ancillary data.
Packit 0652a1
 *
Packit 0652a1
 * Since: 1.16
Packit 0652a1
 *
Packit 0652a1
 * Returns: a #GstVideoAncillaryDID16 identifier
Packit 0652a1
 */
Packit 0652a1
#define GST_VIDEO_ANCILLARY_DID16(anc) ((guint16)((anc)->DID) << 8 | (guint16)((anc)->SDID_block_number))
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GstVideoAncillaryDID16:
Packit 0652a1
 * @GST_VIDEO_ANCILLARY_DID16_S334_EIA_708: CEA 708 Ancillary data according to SMPTE 334
Packit 0652a1
 * @GST_VIDEO_ANCILLARY_DID16_S334_EIA_608: CEA 608 Ancillary data according to SMPTE 334
Packit 0652a1
 * @GST_VIDEO_ANCILLARY_DID16_S2016_3_AFD_BAR: AFD/Bar Ancillary data according to SMPTE 2016-3 (Since: 1.18)
Packit 0652a1
 *
Packit 0652a1
 * Some know types of Ancillary Data identifiers.
Packit 0652a1
 *
Packit 0652a1
 * Since: 1.16
Packit 0652a1
 */
Packit 0652a1
typedef enum {
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID16_S334_EIA_708	= 0x6101,
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID16_S334_EIA_608	= 0x6102,
Packit 0652a1
  GST_VIDEO_ANCILLARY_DID16_S2016_3_AFD_BAR	= 0x4105,
Packit 0652a1
} GstVideoAncillaryDID16;
Packit 0652a1
Packit 0652a1
/* Closed Caption support */
Packit 0652a1
/**
Packit 0652a1
 * GstVideoCaptionType:
Packit 0652a1
 * @GST_VIDEO_CAPTION_TYPE_UNKNOWN: Unknown type of CC
Packit 0652a1
 * @GST_VIDEO_CAPTION_TYPE_CEA608_RAW: CEA-608 as byte pairs. Note that
Packit 0652a1
 *      this format is not recommended since is does not specify to
Packit 0652a1
 *      which field the caption comes from and therefore assumes
Packit 0652a1
 *      it comes from the first field (and that there is no information
Packit 0652a1
 *      on the second field). Use @GST_VIDEO_CAPTION_TYPE_CEA708_RAW
Packit 0652a1
 *      if you wish to store CEA-608 from two fields and prefix each byte pair
Packit 0652a1
 *      with 0xFC for the first field and 0xFD for the second field.
Packit 0652a1
 * @GST_VIDEO_CAPTION_TYPE_CEA608_S334_1A: CEA-608 as byte triplets as defined
Packit 0652a1
 *      in SMPTE S334-1 Annex A. The second and third byte of the byte triplet
Packit 0652a1
 *      is the raw CEA608 data, the first byte is a bitfield: The top/7th bit is
Packit 0652a1
 *      0 for the second field, 1 for the first field, bit 6 and 5 are 0 and
Packit 0652a1
 *      bits 4 to 0 are a 5 bit unsigned integer that represents the line
Packit 0652a1
 *      offset relative to the base-line of the original image format (line 9
Packit 0652a1
 *      for 525-line field 1, line 272 for 525-line field 2, line 5 for
Packit 0652a1
 *      625-line field 1 and line 318 for 625-line field 2).
Packit 0652a1
 * @GST_VIDEO_CAPTION_TYPE_CEA708_RAW: CEA-708 as cc_data byte triplets. They
Packit 0652a1
 *      can also contain 608-in-708 and the first byte of each triplet has to
Packit 0652a1
 *      be inspected for detecting the type.
Packit 0652a1
 * @GST_VIDEO_CAPTION_TYPE_CEA708_CDP: CEA-708 (and optionally CEA-608) in
Packit 0652a1
 *      a CDP (Caption Distribution Packet) defined by SMPTE S-334-2.
Packit 0652a1
 *      Contains the whole CDP (starting with 0x9669).
Packit 0652a1
 *
Packit 0652a1
 * The various known types of Closed Caption (CC).
Packit 0652a1
 *
Packit 0652a1
 * Since: 1.16
Packit 0652a1
 */
Packit 0652a1
typedef enum {
Packit 0652a1
  GST_VIDEO_CAPTION_TYPE_UNKNOWN                = 0,
Packit 0652a1
  GST_VIDEO_CAPTION_TYPE_CEA608_RAW		= 1,
Packit 0652a1
  GST_VIDEO_CAPTION_TYPE_CEA608_S334_1A		= 2,
Packit 0652a1
  GST_VIDEO_CAPTION_TYPE_CEA708_RAW		= 3,
Packit 0652a1
  GST_VIDEO_CAPTION_TYPE_CEA708_CDP		= 4
Packit 0652a1
} GstVideoCaptionType;
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
GstVideoCaptionType
Packit 0652a1
gst_video_caption_type_from_caps (const GstCaps *caps);
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
GstCaps *
Packit 0652a1
gst_video_caption_type_to_caps (GstVideoCaptionType type);
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GstVideoCaptionMeta:
Packit 0652a1
 * @meta: parent #GstMeta
Packit 0652a1
 * @caption_type: The type of Closed Caption contained in the meta.
Packit 0652a1
 * @data: (array length=size): The Closed Caption data.
Packit 0652a1
 * @size: The size in bytes of @data
Packit 0652a1
 *
Packit 0652a1
 * Extra buffer metadata providing Closed Caption.
Packit 0652a1
 *
Packit 0652a1
 * Since: 1.16
Packit 0652a1
 */
Packit 0652a1
typedef struct {
Packit 0652a1
  GstMeta meta;
Packit 0652a1
Packit 0652a1
  GstVideoCaptionType caption_type;
Packit 0652a1
  guint8 *data;
Packit 0652a1
  gsize size;
Packit 0652a1
} GstVideoCaptionMeta;
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
GType	gst_video_caption_meta_api_get_type (void);
Packit 0652a1
#define GST_VIDEO_CAPTION_META_API_TYPE (gst_video_caption_meta_api_get_type())
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
const GstMetaInfo *gst_video_caption_meta_get_info (void);
Packit 0652a1
#define GST_VIDEO_CAPTION_META_INFO (gst_video_caption_meta_get_info())
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * gst_buffer_get_video_caption_meta:
Packit 0652a1
 * @b: A #GstBuffer
Packit 0652a1
 *
Packit 0652a1
 * Gets the #GstVideoCaptionMeta that might be present on @b.
Packit 0652a1
 *
Packit 0652a1
 * Since: 1.16
Packit 0652a1
 *
Packit 0652a1
 * Returns: The first #GstVideoCaptionMeta present on @b, or %NULL if
Packit 0652a1
 * no #GstVideoCaptionMeta are present
Packit 0652a1
 */
Packit 0652a1
#define gst_buffer_get_video_caption_meta(b) \
Packit 0652a1
        ((GstVideoCaptionMeta*)gst_buffer_get_meta((b),GST_VIDEO_CAPTION_META_API_TYPE))
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
GstVideoCaptionMeta *gst_buffer_add_video_caption_meta    (GstBuffer   * buffer,
Packit 0652a1
							   GstVideoCaptionType caption_type,
Packit 0652a1
							   const guint8 *data,
Packit 0652a1
							   gsize size);
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GstVideoVBIParser:
Packit 0652a1
 *
Packit 0652a1
 * A parser for detecting and extracting @GstVideoAncillary data from
Packit 0652a1
 * Vertical Blanking Interval lines of component signals.
Packit 0652a1
 *
Packit 0652a1
 * Since: 1.16
Packit 0652a1
 */
Packit 0652a1
Packit 0652a1
typedef struct _GstVideoVBIParser GstVideoVBIParser;
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
GType gst_video_vbi_parser_get_type (void);
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GstVideoVBIParserResult:
Packit 0652a1
 * @GST_VIDEO_VBI_PARSER_RESULT_DONE: No line were provided, or no more Ancillary data was found.
Packit 0652a1
 * @GST_VIDEO_VBI_PARSER_RESULT_OK: A #GstVideoAncillary was found.
Packit 0652a1
 * @GST_VIDEO_VBI_PARSER_RESULT_ERROR: An error occured
Packit 0652a1
 *
Packit 0652a1
 * Return values for #GstVideoVBIParser
Packit 0652a1
 *
Packit 0652a1
 * Since: 1.16
Packit 0652a1
 */
Packit 0652a1
typedef enum {
Packit 0652a1
  GST_VIDEO_VBI_PARSER_RESULT_DONE  = 0,
Packit 0652a1
  GST_VIDEO_VBI_PARSER_RESULT_OK    = 1,
Packit 0652a1
  GST_VIDEO_VBI_PARSER_RESULT_ERROR = 2
Packit 0652a1
} GstVideoVBIParserResult;
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
GstVideoVBIParserResult gst_video_vbi_parser_get_ancillary(GstVideoVBIParser *parser,
Packit 0652a1
							   GstVideoAncillary *anc);
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
GstVideoVBIParser *gst_video_vbi_parser_new (GstVideoFormat format, guint32 pixel_width);
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
GstVideoVBIParser *gst_video_vbi_parser_copy (const GstVideoVBIParser *parser);
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
void               gst_video_vbi_parser_free (GstVideoVBIParser *parser);
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
void		   gst_video_vbi_parser_add_line (GstVideoVBIParser *parser, const guint8 *data);
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GstVideoVBIEncoder:
Packit 0652a1
 *
Packit 0652a1
 * An encoder for writing ancillary data to the
Packit 0652a1
 * Vertical Blanking Interval lines of component signals.
Packit 0652a1
 *
Packit 0652a1
 * Since: 1.16
Packit 0652a1
 */
Packit 0652a1
Packit 0652a1
typedef struct _GstVideoVBIEncoder GstVideoVBIEncoder;
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
GType gst_video_vbi_encoder_get_type (void);
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
GstVideoVBIEncoder *gst_video_vbi_encoder_new  (GstVideoFormat format, guint32 pixel_width);
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
GstVideoVBIEncoder *gst_video_vbi_encoder_copy (const GstVideoVBIEncoder *encoder);
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
void               gst_video_vbi_encoder_free  (GstVideoVBIEncoder *encoder);
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
gboolean gst_video_vbi_encoder_add_ancillary   (GstVideoVBIEncoder *encoder,
Packit 0652a1
                                                gboolean            composite,
Packit 0652a1
                                                guint8              DID,
Packit 0652a1
                                                guint8              SDID_block_number,
Packit 0652a1
                                                const guint8       *data,
Packit 0652a1
                                                guint               data_count);
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
void gst_video_vbi_encoder_write_line (GstVideoVBIEncoder *encoder, guint8 *data);
Packit 0652a1
Packit 0652a1
G_END_DECLS
Packit 0652a1
Packit 0652a1
#endif /* __GST_VIDEO_ANC_H__ */