Esempio n. 1
0
VBIDecoder::VBIDecoder()
{
    char* errstr = 0;
    firstTimestamp.base = 0;
    currTimestamp.base = 0;
    decoder = vbi_decoder_new();
    decoderTimestamp = 0.0;
    exporter = vbi_export_new("png", &errstr);
    if (!decoder || !exporter)
    {
        fflush(fplog);
        fprintf(stderr, "Cannot initialize libzvbi: %s\n",
           errstr);
        fflush(stderr);
        exit(1);
    } 
    vbi_event_handler_add(decoder, -1, eventHandler, this);

    fileName = new char[strlen(prefix)+64];
    *fileName = 0;
    fileIndex = 0;
    vbi_page page;
    textSize = sizeof(page.text)/sizeof(vbi_char)*4;
    textBuf = new char[textSize];

    // Write the xml opening tags
    fprintf(fpxml, "<subpictures>\n<stream>\n");

    checkPageSize = 1;

    memset(&lastPage, 0, sizeof(lastPage));
}
Esempio n. 2
0
static GstFlowReturn
gst_teletextdec_export_html_page (GstTeletextDec * teletext, vbi_page * page,
    GstBuffer ** buf)
{
  GstCaps *caps;
  GstFlowReturn ret;
  gchar *html;
  gssize size;
  vbi_export *ex;
  gchar *err;

  if (!(ex = vbi_export_new ("html", &err))) {
    GST_ELEMENT_ERROR (teletext, LIBRARY, SETTINGS,
        ("Can't open the HTML export module: %s", err), (NULL));
    g_free (err);
    return GST_FLOW_ERROR;
  }

  /* export to NULL to get size of the memory needed to allocate the page */
  size = vbi_export_mem (ex, NULL, 0, page);
  if (size < 0)
    return GST_FLOW_ERROR;
  html = g_malloc (size);
  vbi_export_mem (ex, html, size, page);

  /* Allocate new buffer */
  caps = gst_caps_new_simple ("text/html", NULL);
  ret = gst_pad_alloc_buffer (teletext->srcpad, GST_BUFFER_OFFSET_NONE,
      size, caps, &(*buf));
  if (G_LIKELY (ret == GST_FLOW_OK))
    GST_BUFFER_DATA (*buf) = GST_BUFFER_MALLOCDATA (*buf) = (guint8 *) html;

  gst_caps_unref (caps);
  return ret;
}
Esempio n. 3
0
static void
init_export_module		(const char *		module_name)
{
	const vbi_export_info *xi;
	char *errstr;

	errstr = NULL; /* just in case */

	ex = vbi_export_new (module_name, &errstr);
	if (NULL == ex) {
		error_exit (_("Cannot open export module '%s': %s"),
			    module_name, errstr);
		/* NB. free (errstr); here if you don't exit(). */
	}

	if (0 == strncmp (module_name, "html", 4)) {
		if (option_hyperlinks)
			vbi_export_set_link_cb (ex, export_link,
						 /* user_data */ NULL);

		if (option_pdc_links)
			vbi_export_set_pdc_cb (ex, export_pdc,
						/* user_data */ NULL);
	}

	xi = vbi_export_info_from_export (ex);

	if (NULL == xi)
		no_mem_exit ();

	if (NULL == out_file_name_suffix) {
		char *end = NULL;

		out_file_name_suffix = strdup (xi->extension);
		if (NULL == out_file_name_suffix)
			no_mem_exit ();

		out_file_name_suffix = strtok_r (out_file_name_suffix,
						 ",", &end);
	}

#if 3 == VBI_VERSION_MINOR
	if (xi->open_format)
		option_subtitles ^= TRUE;
#endif
}
Esempio n. 4
0
static void
list_modules			(void)
{
	const vbi_export_info *xi;
	unsigned int i;

	for (i = 0; (xi = vbi_export_info_enum (i)); ++i) {
		vbi_export *ex;

		printf ("'%s' - %s\n",
			_(xi->keyword),
			_(xi->tooltip));

		ex = vbi_export_new (xi->keyword, /* errstr */ NULL);
		if (NULL == ex)
			no_mem_exit ();

		list_options (ex);

		vbi_export_delete (ex);
		ex = NULL;
	}
}