|
libclosedcaption 1.0.3
ISDB-Tb/SBTVD (Brazilian DTV) closed caption extraction from MPEG-TS
|
Turns the caption PES packets into lines of text. More...
#include "caption-common.h"

Go to the source code of this file.
Data Structures | |
| struct | CaptionLine_t |
Macros | |
| #define | CAPTION_SCREEN_MAX_LINES 16 |
| #define | CAPTION_SCREEN_LINE_LEN 256 |
Typedefs | |
| typedef void(* | CaptionScreenLineCallback_t) (const CaptionLine_t *line, void *userdata) |
| typedef struct CaptionScreen_s | CaptionScreen_t |
Functions | |
| CaptionScreen_t * | caption_screen_new (CaptionScreenLineCallback_t callback, void *userdata) |
| void | caption_screen_free (CaptionScreen_t *screen) |
| bool | caption_screen_push_pes (CaptionScreen_t *screen, const uint8_t *pes, size_t len) |
| void | caption_screen_flush (CaptionScreen_t *screen) |
| bool | caption_screen_line_continues (const char *line, const char *prefix) |
Turns the caption PES packets into lines of text.
This is the easiest way to use the library: you give it the whole PES of the caption PID (see ts-demux.h), it does all the processing (packet_pes_load(), caption_data_load(), caption_management_load() and caption_closed_run()) and hands every ready caption line, in UTF-8, to a callback.
How the lines are built
Example:
Definition in file caption-screen.h.
| #define CAPTION_SCREEN_MAX_LINES 16 |
Max number of lines kept on the screen.
Definition at line 53 of file caption-screen.h.
| #define CAPTION_SCREEN_LINE_LEN 256 |
Max size of a line, in UTF-8 bytes (including the '\0').
Definition at line 56 of file caption-screen.h.
| typedef void(* CaptionScreenLineCallback_t) (const CaptionLine_t *line, void *userdata) |
Callback called for each finished caption line.
| line | The line. Only valid during the call. |
| userdata | Pointer given to caption_screen_new(). |
Definition at line 72 of file caption-screen.h.
| typedef struct CaptionScreen_s CaptionScreen_t |
Caption screen. Opaque struct, created by caption_screen_new().
Definition at line 78 of file caption-screen.h.
| CaptionScreen_t * caption_screen_new | ( | CaptionScreenLineCallback_t | callback, |
| void * | userdata | ||
| ) |
Creates a caption screen.
| callback | Called for each finished line. |
| userdata | Passed on to the callback. |
| void caption_screen_free | ( | CaptionScreen_t * | screen | ) |
Frees the screen. Does not call caption_screen_flush().
| screen | Screen created by caption_screen_new(). NULL is fine. |
| bool caption_screen_push_pes | ( | CaptionScreen_t * | screen, |
| const uint8_t * | pes, | ||
| size_t | len | ||
| ) |
Processes a whole PES from the caption PID.
Invalid PES, with a bad CRC, or that are not "caption statement data" (for example, the "caption management data") are ignored.
| screen | Screen created by caption_screen_new(). |
| pes | Whole PES, starting at the packet_start_code_prefix (00 00 01). |
| len | Size of pes in bytes. |
| void caption_screen_flush | ( | CaptionScreen_t * | screen | ) |
Delivers all the lines that are still on the screen and clears the screen. Call it at the end of the file.
| screen | Screen created by caption_screen_new(). |
| bool caption_screen_line_continues | ( | const char * | line, |
| const char * | prefix | ||
| ) |
Checks if line starts with prefix, ignoring the accents of the Latin-1 letters (U+00C0 to U+00FF). For example, "ESPECÍFICO" starts with "ESPECI".
| line | UTF-8 text. |
| prefix | UTF-8 prefix. |
line starts with prefix.