libclosedcaption 1.0.3
ISDB-Tb/SBTVD (Brazilian DTV) closed caption extraction from MPEG-TS
Loading...
Searching...
No Matches
caption-hooking.h File Reference

Registering the callbacks (hooks) that get the text and the caption commands while caption_closed_run() runs. More...

#include "caption-common.h"
#include "caption-closed.h"
Include dependency graph for caption-hooking.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* CaptionHookingControls_t) (CaptionClosed_t *cc, const uint8_t cmd)
 
typedef void(* CaptionHookingString_t) (CaptionClosed_t *cc, const char *string, const uint8_t len)
 

Functions

void caption_hooking_set_controls (CaptionHookingControls_t callback)
 
void caption_hooking_set_string (CaptionHookingString_t callback)
 

Detailed Description

Registering the callbacks (hooks) that get the text and the caption commands while caption_closed_run() runs.

Author
Jorge Pereira jpere.nosp@m.iran.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Date
Thu Aug 12 13:49:21 BRT 2010

During caption_closed_run(), each text character is converted to UTF-8 and handed to the text hook, and each recognized C0/C1 control command is handed to the controls hook.

Example:

static void
on_string (CaptionClosed_t *cc, const char *utf8, const uint8_t len)
{
fwrite (utf8, 1, len, stdout);
}
static void
on_controls (CaptionClosed_t *cc, const uint8_t cmd)
{
if (cmd == CTRL_C0_APR) // Active Position Return: new line
putchar ('\n');
}
void caption_hooking_set_string(CaptionHookingString_t callback)
void caption_hooking_set_controls(CaptionHookingControls_t callback)
Warning
The hooks are global: there is only one of each kind for the whole process, and they must not be changed while another thread is running caption_closed_run(). Use CaptionClosed_t::userdata to find the context inside the hook.

Definition in file caption-hooking.h.

Typedef Documentation

◆ CaptionHookingControls_t

typedef void(* CaptionHookingControls_t) (CaptionClosed_t *cc, const uint8_t cmd)

Hook called for each recognized control command.

Parameters
ccCaption state, already updated by the command.
cmdCommand code: C0 (CaptionClosed_CtrlCodes_C0), C1 (CaptionClosed_CtrlCodes_C1) or, for the CSI, the code of the subcommand (CaptionClosed_CtrlCodes_C1_CSI).

Definition at line 50 of file caption-hooking.h.

◆ CaptionHookingString_t

typedef void(* CaptionHookingString_t) (CaptionClosed_t *cc, const char *string, const uint8_t len)

Hook called for each text character.

Parameters
ccCaption state (colors, size, position) at the time of the character.
stringUTF-8 character. Not '\0' terminated.
lenNumber of bytes in string (1 to 3).

Definition at line 60 of file caption-hooking.h.

Function Documentation

◆ caption_hooking_set_controls()

void caption_hooking_set_controls ( CaptionHookingControls_t  callback)

Registers the control commands hook (C0/C1).

Parameters
callbackThe hook, or NULL to turn it off.

◆ caption_hooking_set_string()

void caption_hooking_set_string ( CaptionHookingString_t  callback)

Registers the text hook.

Parameters
callbackThe hook, or NULL to turn it off.