VBIDecoder::~VBIDecoder() { // If there's a subtitle image that hasn't been written to the XML file, // do it now. flushPage(currTimestamp); vbi_decoder_delete(decoder); vbi_export_delete(exporter); // Write the xml closing tags, and close the file fprintf(fpxml, "</stream>\n</subpictures>\n"); fflush(fpxml); fclose(fpxml); if (fileIndex == 0) { // We didn't find any CC or Teletext data // Unlink the xml file, print an error message // and exit with non-zero exit code unlink(xmlfile); fflush(fplog); fprintf(stderr, "No CC or Teletext data found\n"); fflush(stderr); exit(1); } }
static void gst_teletextdec_zvbi_clear (GstTeletextDec * teletext) { g_return_if_fail (teletext != NULL); GST_LOG_OBJECT (teletext, "Clearing structures"); if (teletext->demux != NULL) { vbi_dvb_demux_delete (teletext->demux); teletext->demux = NULL; } if (teletext->decoder != NULL) { vbi_decoder_delete (teletext->decoder); teletext->decoder = NULL; } if (teletext->frame != NULL) { g_free (teletext->frame); teletext->frame = NULL; } g_mutex_lock (teletext->queue_lock); if (teletext->queue != NULL) { g_queue_free (teletext->queue); teletext->queue = NULL; } g_mutex_unlock (teletext->queue_lock); teletext->in_timestamp = GST_CLOCK_TIME_NONE; teletext->in_duration = GST_CLOCK_TIME_NONE; teletext->pageno = 0x100; teletext->subno = -1; teletext->last_ts = 0; }
/***************************************************************************** * Close: *****************************************************************************/ static void Close( vlc_object_t *p_this ) { decoder_t *p_dec = (decoder_t*) p_this; decoder_sys_t *p_sys = p_dec->p_sys; var_DelCallback( p_dec, "vbi-opaque", Opaque, p_sys ); var_DelCallback( p_dec, "vbi-page", RequestPage, p_sys ); vlc_mutex_destroy( &p_sys->lock ); if( p_sys->p_vbi_dec ) vbi_decoder_delete( p_sys->p_vbi_dec ); free( p_sys ); }
int main (void) { char *errstr; vbi_bool success; setlocale (LC_ALL, ""); services = (VBI_SLICED_TELETEXT_B | VBI_SLICED_VPS | VBI_SLICED_CAPTION_525); cap = vbi_capture_v4l2_new ("/dev/vbi", /* buffers */ 5, &services, /* strict */ 0, &errstr, /* verbose */ FALSE); if (NULL == cap) { fprintf (stderr, "Cannot capture VBI data with V4L2 interface:\n" "%s\n", errstr); free (errstr); exit (EXIT_FAILURE); } dec = vbi_decoder_new (); assert (NULL != dec); success = vbi_event_handler_add (dec, (VBI_EVENT_NETWORK | VBI_EVENT_NETWORK_ID), handler, /* user_data */ NULL); assert (success); mainloop (); vbi_decoder_delete (dec); vbi_capture_delete (cap); exit (EXIT_SUCCESS); }
/***************************************************************************** * Close: *****************************************************************************/ static void Close( vlc_object_t *p_this ) { decoder_t *p_dec = (decoder_t*) p_this; decoder_sys_t *p_sys = p_dec->p_sys; var_DelCallback( p_dec, "vbi-position", Position, p_sys ); var_DelCallback( p_dec, "vbi-opaque", Opaque, p_sys ); var_DelCallback( p_dec, "vbi-page", RequestPage, p_sys ); var_DelCallback( p_dec->p_libvlc, "key-pressed", EventKey, p_dec ); vlc_mutex_destroy( &p_sys->lock ); if( p_sys->p_vbi_dec ) vbi_decoder_delete( p_sys->p_vbi_dec ); if( p_sys->p_dvb_demux ) vbi_dvb_demux_delete( p_sys->p_dvb_demux ); free( p_sys ); }
int main (int argc, char ** argv) { vbi_bool success; if (!init_window (argc, argv)) exit (EXIT_FAILURE); vbi = vbi_decoder_new (); assert (NULL != vbi); success = vbi_event_handler_add (vbi, VBI_EVENT_CAPTION, cc_handler, /* used_data */ NULL); assert (success); if (isatty (STDIN_FILENO)) { hello_world (); } else { struct stream *st; st = read_stream_new (/* filename: stdin */ NULL, FILE_FORMAT_SLICED, /* ts_pid */ 0, decode_frame); stream_loop (st); stream_delete (st); } printf ("Done.\n"); for (;;) xevent (33333); vbi_decoder_delete (vbi); exit (EXIT_SUCCESS); }
int main (int argc, char ** argv) { const char *module_name; unsigned int n_pages; vbi_bool all_pages; init_helpers (argc, argv); option_in_file_format = FILE_FORMAT_SLICED; option_default_fg = (vbi_rgba) 0xFFFFFF; option_default_bg = (vbi_rgba) 0x000000; all_pages = FALSE; for (;;) { int c; c = getopt_long (argc, argv, short_options, long_options, &option_index); if (-1 == c) break; switch (c) { case 0: /* getopt_long() flag */ break; case '1': /* Compatibility (used to be pgno -1). */ all_pages = TRUE; break; case 'a': /* For debugging. */ assert (NULL != optarg); option_target = strtoul (optarg, NULL, 0); break; case 'c': option_dcc = TRUE; break; case 'd': option_padding = TRUE; break; case 'e': option_pdc_enum = TRUE; break; case 'f': option_fast = TRUE; break; case 'g': option_dump_pg = TRUE; break; case 'h': usage (stdout); exit (EXIT_SUCCESS); case 'i': assert (NULL != optarg); option_in_file_name = optarg; break; case 'l': option_hyperlinks = TRUE; break; case 'm': list_modules (); exit (EXIT_SUCCESS); case 'n': option_navigation = TRUE; break; case 'o': parse_output_option (); break; case 'p': option_pdc_links = TRUE; break; case 'q': parse_option_quiet (); break; case 'r': option_row_update = TRUE; break; case 's': option_subtitles = TRUE; break; case 'v': parse_option_verbose (); break; case 'w': option_delay += 1; break; case 'A': option_panels = TRUE; break; case 'B': assert (NULL != optarg); option_default_bg = strtoul (optarg, NULL, 0); break; case 'C': assert (NULL != optarg); option_default_cs = strtoul (optarg, NULL, 0); have_option_default_cs = TRUE; break; case 'F': assert (NULL != optarg); option_default_fg = strtoul (optarg, NULL, 0); break; case 'H': option_header_only = TRUE; break; case 'O': assert (NULL != optarg); option_override_cs = strtoul (optarg, NULL, 0); break; case 'P': option_in_file_format = FILE_FORMAT_DVB_PES; break; case 'T': option_in_ts_pid = parse_option_ts (); option_in_file_format = FILE_FORMAT_DVB_TS; break; case 'V': printf (PROGRAM_NAME " " VERSION "\n"); exit (EXIT_SUCCESS); default: usage (stderr); exit (EXIT_FAILURE); } } option_pdc_links |= option_pdc_enum; if (argc - optind < 1) { usage (stderr); exit (EXIT_FAILURE); } module_name = argv[optind++]; pt = vbi_page_table_new (); if (NULL == pt) no_mem_exit (); if (all_pages) { /* Compatibility. */ out_file_name_prefix = strdup ("test"); if (NULL == out_file_name_prefix) no_mem_exit (); } else { parse_page_numbers (argc - optind, &argv[optind]); } n_pages = vbi_page_table_num_pages (pt); if (1 != n_pages && option_delay > 0) { error_exit (_("The --wait option requires " "a single page number.")); } if (NULL == out_file_name_prefix) { switch (n_pages) { case 0: /* all pages? */ error_exit (_("No page number or " "output file name specified.")); break; case 1: /* one page to stdout */ break; default: /* multiple pages */ error_exit (_("No output file name specified.")); break; } } init_export_module (module_name); init_vbi_decoder (); cr = isatty (STDERR_FILENO) ? '\r' : '\n'; rst = read_stream_new (option_in_file_name, option_in_file_format, option_in_ts_pid, decode_frame); stream_loop (rst); stream_delete (rst); rst = NULL; vbi_decoder_delete (vbi); vbi = NULL; finalize (); free (out_file_name_prefix); out_file_name_prefix = NULL; free (out_file_name_suffix); out_file_name_suffix = NULL; if (!option_subtitles) { n_pages = vbi_page_table_num_pages (pt); if (1 == n_pages) { vbi_pgno pgno = 0; vbi_page_table_next_page (pt, &pgno); error_exit (_("End of stream. Page %03x not found."), pgno); } else if (n_pages > 0) { error_exit (_("End of stream. %u pages not found.")); } } vbi_page_table_delete (pt); pt = NULL; vbi_export_delete (ex); ex = NULL; exit (EXIT_SUCCESS); }