libklvanc
Loading...
Searching...
No Matches
vanc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016-2017 Kernel Labs Inc. All Rights Reserved
3 *
4 * Address: Kernel Labs Inc., PO Box 745, St James, NY. 11780
5 * Contact: sales@kernellabs.com
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
34
35#ifndef _VANC_H
36#define _VANC_H
37
38#include <stdint.h>
39#include <stdarg.h>
40#include <sys/errno.h>
41#include <sys/errno.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/* A series of callbacks used by the VANC library to inform user applications
49 * that certain messages have been fully decoded.
50 */
51
56
61
66
71
76
81
85struct klvanc_context_s;
86
91
96
101
106{
107 int (*afd)(void *user_context, struct klvanc_context_s *, struct klvanc_packet_afd_s *);
108 int (*eia_708b)(void *user_context, struct klvanc_context_s *, struct klvanc_packet_eia_708b_s *);
109 int (*eia_608)(void *user_context, struct klvanc_context_s *, struct klvanc_packet_eia_608_s *);
110 int (*scte_104)(void *user_context, struct klvanc_context_s *, struct klvanc_packet_scte_104_s *);
111 int (*all)(void *user_context, struct klvanc_context_s *, struct klvanc_packet_header_s *);
112 int (*kl_i64le_counter)(void *user_context, struct klvanc_context_s *, struct klvanc_packet_kl_u64le_counter_s *);
113 int (*sdp)(void *user_context, struct klvanc_context_s *, struct klvanc_packet_sdp_s *);
114 int (*smpte_12_2)(void *user_context, struct klvanc_context_s *, struct klvanc_packet_smpte_12_2_s *);
115 int (*smpte_2108_1)(void *user_context, struct klvanc_context_s *, struct klvanc_packet_smpte_2108_1_s *);
116};
117
118struct klvanc_cache_s;
119
125{
126 int verbose;
128 struct klvanc_callbacks_s *callbacks;
129 void *callback_context;
131
132 void (*log_cb)(void *p, int level, const char *fmt, ...);
133
134 /* Internal use by the library */
135 void *priv;
136 struct klrestricted_code_path_block_s rcp_failedToDecode;
137 unsigned int checksum_failures;
138
139 /* Optional: A cache of VANC lines we've detected in the stream.
140 * see klvanc_context_enable_monitor().
141 * A static array of structs, for did/sdid rapid lookups.
142 * Where DD and SD range from 00..FF.
143 * This contains an array of structs, each containing a set of lines,
144 * optimized for update/query. The structures are typically used by
145 * applications that want to keep tabs on what messages have been
146 * seen in the stream, per line. Its important to understand that
147 * for every message, we cache it, and the same message (same line)
148 * overwrites our previous cached message.
149 */
150 struct klvanc_cache_s *cacheLines;
151
152 /* SCTE104 messages can be fragmented across multiple VANC packets.
153 * See ST2010-2008 Section 5 "Format of VANC Data Packets"
154 * Create a container for multiple vanc packets to be parsed consecutively.
155 * Create storage for 10 packets, track them, free them etc.
156 * Maintain a count of how many are in the list.
157 */
158#define LIBKLVANC_SCTE104_MAX_FRAGMENTS (10)
159 struct klvanc_packet_header_s *scte104_fragments[LIBKLVANC_SCTE104_MAX_FRAGMENTS];
160 int scte104_fragment_count;
161};
162
163#define LIBKLVANC_LOGLEVEL_ERR 0
164#define LIBKLVANC_LOGLEVEL_WARN 1
165#define LIBKLVANC_LOGLEVEL_INFO 2
166#define LIBKLVANC_LOGLEVEL_DEBUG 3
167
176
184
192
204int klvanc_packet_parse(struct klvanc_context_s *ctx, unsigned int lineNr, const unsigned short *words, unsigned int wordCount);
205
213void klvanc_dump_words_console(struct klvanc_context_s *ctx, uint16_t *vanc, int maxlen, unsigned int linenr, int onlyvalid);
214
215#include <libklvanc/vanc-afd.h>
221#include <libklvanc/did.h>
222#include <libklvanc/pixels.h>
224#include <libklvanc/smpte2038.h>
225#include <libklvanc/cache.h>
227#include <libklvanc/vanc-sdp.h>
228
243int klvanc_sdi_create_payload(uint8_t sdid, uint8_t did,
244 const uint8_t *src, uint16_t srcByteCount,
245 uint16_t **dst, uint16_t *dstWordCount,
246 uint32_t bitDepth);
247
254
261
270 struct klvanc_packet_header_s *src);
271
291int klvanc_packet_save(const char *dir, const struct klvanc_packet_header_s *pkt,
292 int lineNr, int did);
293
299
305
306#ifdef __cplusplus
307};
308#endif
309
310#endif /* _VANC_H */
VANC Caching functionality.
Lookup functions that translate did/sdid into printable strings.
Generic code to limit the running of certain code to N times per second. Primary use case is to preve...
Common colorspace conversion functions for VANC.
Functions to parse, create and inspect SMPTE2038 formatted packets.
Definition klrestricted_code_path.h:55
Definition cache.h:46
TODO - Brief description goes here.
Definition vanc.h:106
Application specific context, the library allocates and stores user specific instance information.
Definition vanc.h:125
int allow_bad_checksums
Definition vanc.h:127
int warn_on_decode_failure
Definition vanc.h:130
TODO - Brief description goes here.
Definition vanc-afd.h:76
TODO - Brief description goes here.
Definition vanc-eia_608.h:42
TODO - Brief description goes here.
Definition vanc-eia_708b.h:121
TODO - Brief description goes here.
Definition vanc-packets.h:59
unsigned int lineNr
Definition vanc-packets.h:69
TODO - Brief description goes here.
Definition vanc-kl_u64le_counter.h:42
TODO - Brief description goes here.
Definition vanc-scte_104.h:284
TODO - Brief description goes here.
Definition vanc-sdp.h:37
TODO - Brief description goes here.
Definition vanc-smpte_12_2.h:55
Describes an ST2108 packet.
Definition vanc-smpte_2108_1.h:74
SMPTE 2016-3 Vertical Ancillary Data Mapping of Active Format Description and Bar Data.
VANC checksum routines.
EIA/CEA-608 Closed Captions.
CEA-708 Closed Captions.
VANC counter library used for diagnostics/debugging.
klvanc_packet_type_e
TODO - Brief description goes here.
Definition vanc-packets.h:43
SCTE-104 Automation System to Compression System Communications Applications Program Interface.
WST / OP-47 / RDD8 - Subtitling Distribution Packet (SDP) Format.
SMPTE ST 12-2 Timecode over VANC.
SMPTE ST 2108-1 HDR/WCG over VANC.
int klvanc_context_dump(struct klvanc_context_s *ctx)
Generate user visible context details to the console.
void klvanc_packet_free(struct klvanc_packet_header_s *src)
TODO - Brief description goes here.
const char * klvanc_lookupDescriptionByType(enum klvanc_packet_type_e type)
TODO - Brief description goes here.
const char * klvanc_lookupSpecificationByType(enum klvanc_packet_type_e type)
TODO - Brief description goes here.
void klvanc_dump_words_console(struct klvanc_context_s *ctx, uint16_t *vanc, int maxlen, unsigned int linenr, int onlyvalid)
TODO - Brief description goes here.
int klvanc_packet_parse(struct klvanc_context_s *ctx, unsigned int lineNr, const unsigned short *words, unsigned int wordCount)
Parse a line of payload, trigger callbacks as necessary. lineNr is passed around and only used for r...
int klvanc_packet_payload_append(struct klvanc_packet_header_s *dst, struct klvanc_packet_header_s *src, int srcOffset)
Append the payload words from srd to dst. Start copying from srcOffset position.
int klvanc_context_create(struct klvanc_context_s **ctx)
Create or destroy some basic application/library context. The context is considered private and is l...
int klvanc_packet_copy(struct klvanc_packet_header_s **dst, struct klvanc_packet_header_s *src)
Create a copy of a packet header.
int klvanc_packet_save(const char *dir, const struct klvanc_packet_header_s *pkt, int lineNr, int did)
Write the packet to disk, in a debug friendly format that can be used by other offline tools....
int klvanc_context_destroy(struct klvanc_context_s *ctx)
Deallocate and destroy a context. See klvanc_context_create()
int klvanc_sdi_create_payload(uint8_t sdid, uint8_t did, const uint8_t *src, uint16_t srcByteCount, uint16_t **dst, uint16_t *dstWordCount, uint32_t bitDepth)
Take an array of payload, create a fully formed VANC message. bitDepth of 10 is the only valid input ...