Exemple #1
0
static void
init_vbi_decoder		(void)
{
	vbi_event_mask event_mask;
	vbi_bool success;

	/* XXX videostd? */
	vbi = vbi_decoder_new (/* cache: allocate one */ NULL,
				/* network: current */ NULL,
				VBI_VIDEOSTD_SET_625_50);
	if (NULL == vbi)
		no_mem_exit ();

	vbi_decoder_detect_channel_change (vbi, option_dcc);

	event_mask = (VBI_EVENT_TTX_PAGE |
		      VBI_EVENT_CC_PAGE);
	if (option_fast)
		event_mask |= VBI_EVENT_PAGE_TYPE;

	success = vbi_decoder_add_event_handler (vbi, event_mask,
						  event_handler,
						  /* user_data */ NULL);
	if (!success)
		no_mem_exit ();
}
Exemple #2
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));
}
/**
 * init the component, this must be done first
 */
void txt_init_lib()
{
  int error;
  txtdata = calloc(1, sizeof(*txtdata));
  assert(txtdata != NULL); 
  txtdata->m_decoder = vbi_decoder_new();
  assert(txtdata->m_decoder != NULL);
  error = vbi_event_handler_add(txtdata->m_decoder, VBI_EVENT_TTX_PAGE, event_handler, NULL);
  txtdata->m_demuxer = vbi_dvb_pes_demux_new( NULL , NULL );
  assert(txtdata->m_demuxer != NULL);
}
Exemple #4
0
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);
}
static void
gst_teletextdec_zvbi_init (GstTeletextDec * teletext)
{
  g_return_if_fail (teletext != NULL);

  GST_LOG_OBJECT (teletext, "Initializing structures");

  teletext->decoder = vbi_decoder_new ();

  vbi_event_handler_register (teletext->decoder,
      VBI_EVENT_TTX_PAGE | VBI_EVENT_CAPTION,
      gst_teletextdec_event_handler, teletext);

  g_mutex_lock (teletext->queue_lock);
  teletext->queue = g_queue_new ();
  g_mutex_unlock (teletext->queue_lock);
}
Exemple #6
0
static void
init_vbi_decoder		(void)
{
	vbi_bool success;

	vbi = vbi_decoder_new ();
	if (NULL == vbi)
		no_mem_exit ();

	if (have_option_default_cs) {
		vbi_teletext_set_default_region (vbi, option_default_cs);
	}

	success = vbi_event_handler_add (vbi,
					 VBI_EVENT_TTX_PAGE,
					 event_handler,
					 /* user_data */ NULL);
	if (!success)
		no_mem_exit ();
}
Exemple #7
0
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);
}
Exemple #8
0
/*****************************************************************************
 * Open: probe the decoder and return score
 *****************************************************************************
 * Tries to launch a decoder and return score so that the interface is able
 * to chose.
 *****************************************************************************/
static int Open( vlc_object_t *p_this )
{
    decoder_t     *p_dec = (decoder_t *) p_this;
    decoder_sys_t *p_sys = NULL;

    if( p_dec->fmt_in.i_codec != VLC_CODEC_TELETEXT )
        return VLC_EGENERIC;

    p_dec->pf_decode_sub = Decode;
    p_sys = p_dec->p_sys = calloc( 1, sizeof(decoder_sys_t) );
    if( p_sys == NULL )
        return VLC_ENOMEM;

    p_sys->i_key[0] = p_sys->i_key[1] = p_sys->i_key[2] = '*' - '0';
    p_sys->b_update = false;
    p_sys->p_vbi_dec = vbi_decoder_new();
    p_sys->p_dvb_demux = vbi_dvb_pes_demux_new( NULL, NULL );
    vlc_mutex_init( &p_sys->lock );

    if( (p_sys->p_vbi_dec == NULL) || (p_sys->p_dvb_demux == NULL) )
    {
        msg_Err( p_dec, "VBI decoder/demux could not be created." );
        Close( p_this );
        return VLC_ENOMEM;
    }

    /* Some broadcasters in countries with level 1 and level 1.5 still not send a G0 to do 
     * matches against table 32 of ETSI 300 706. We try to do some best effort guessing
     * This is not perfect, but might handle some cases where we know the vbi language 
     * is known. It would be better if people started sending G0 */
    for( int i = 0; ppsz_default_triplet[i] != NULL; i++ )
    {
        if( p_dec->fmt_in.psz_language && !strcasecmp( p_dec->fmt_in.psz_language, ppsz_default_triplet[i] ) )
        {
            vbi_teletext_set_default_region( p_sys->p_vbi_dec, pi_default_triplet[i]);
            msg_Dbg( p_dec, "overwriting default zvbi region: %d", pi_default_triplet[i] );
        }
    }

    vbi_event_handler_register( p_sys->p_vbi_dec, VBI_EVENT_TTX_PAGE | VBI_EVENT_NETWORK |
#ifdef ZVBI_DEBUG
                                VBI_EVENT_CAPTION | VBI_EVENT_TRIGGER |
                                VBI_EVENT_ASPECT | VBI_EVENT_PROG_INFO | VBI_EVENT_NETWORK_ID |
#endif
                                0 , EventHandler, p_dec );

    /* Create the var on vlc_global. */
    p_sys->i_wanted_page = var_CreateGetInteger( p_dec, "vbi-page" );
    var_AddCallback( p_dec, "vbi-page", RequestPage, p_sys );

    /* Check if the Teletext track has a known "initial page". */
    if( p_sys->i_wanted_page == 100 && p_dec->fmt_in.subs.teletext.i_magazine != -1 )
    {
        p_sys->i_wanted_page = 100 * p_dec->fmt_in.subs.teletext.i_magazine +
                               vbi_bcd2dec( p_dec->fmt_in.subs.teletext.i_page );
        var_SetInteger( p_dec, "vbi-page", p_sys->i_wanted_page );
    }
    p_sys->i_wanted_subpage = VBI_ANY_SUBNO;

    p_sys->b_opaque = var_CreateGetBool( p_dec, "vbi-opaque" );
    var_AddCallback( p_dec, "vbi-opaque", Opaque, p_sys );

    p_sys->i_align = var_CreateGetInteger( p_dec, "vbi-position" );
    var_AddCallback( p_dec, "vbi-position", Position, p_sys );

    p_sys->b_text = var_CreateGetBool( p_dec, "vbi-text" );
//    var_AddCallback( p_dec, "vbi-text", Text, p_sys );

    /* Listen for keys */
    var_AddCallback( p_dec->p_libvlc, "key-pressed", EventKey, p_dec );

    es_format_Init( &p_dec->fmt_out, SPU_ES, VLC_CODEC_SPU );
    if( p_sys->b_text )
        p_dec->fmt_out.video.i_chroma = VLC_CODEC_TEXT;
    else
        p_dec->fmt_out.video.i_chroma = VLC_CODEC_RGBA;
    return VLC_SUCCESS;
}