Esempio n. 1
0
vbi_sliced_filter *
vbi_sliced_filter_new		(vbi_sliced_filter_cb *callback,
				 void *			user_data)
{
	vbi_sliced_filter *sf;

	sf = vbi_malloc (sizeof (*sf));
	if (NULL == sf) {
		return NULL;
	}

	CLEAR (*sf);

	sf->keep_ttx_pages = vbi_page_table_new ();
	if (NULL == sf->keep_ttx_pages) {
		vbi_free (sf);
		return NULL;
	}

	vbi_sliced_filter_reset (sf);

	sf->callback = callback;
	sf->user_data = user_data;

	return sf;
}
Esempio n. 2
0
vbi_capture *
vbi_capture_dvb_new2		(const char *		device_name,
				 unsigned int		pid,
				 char **		errstr,
				 vbi_bool		trace)
{
	char *error = NULL;
	int saved_errno;
	vbi_capture_dvb *dvb;

	pthread_once (&vbi_init_once, vbi_init);

	if (NULL == errstr)
		errstr = &error;
	*errstr = NULL;

	dvb = vbi_malloc (sizeof (*dvb));
	if (NULL == dvb)
		goto no_memory;

	CLEAR (*dvb);

	dvb->capture.read		= dvb_read;
	dvb->capture.sampling_point	= NULL;
	dvb->capture.debug		= NULL;
	dvb->capture.parameters		= dvb_parameters;
	dvb->capture.update_services	= dvb_update_services;
	dvb->capture.get_scanning	= NULL;
	dvb->capture.flush		= dvb_flush;
	dvb->capture.get_fd		= dvb_get_fd;
	dvb->capture.get_fd_flags	= dvb_get_fd_flags;
	dvb->capture.set_video_path	= NULL;
	dvb->capture._delete		= dvb_delete;

	dvb->fd = -1;

	dvb->do_trace = trace;

	dvb->demux = vbi_dvb_pes_demux_new (/* callback */ NULL,
					    /* user_data */ NULL);
	if (NULL == dvb->demux)
		goto no_memory;

	if (!open_device (dvb, device_name, errstr)) {
		saved_errno = errno;
		goto failed;
	}

	printv ("Opened device %s\n", device_name);

	if (0 != pid) {
		if (-1 == vbi_capture_dvb_filter (&dvb->capture, pid)) {
			saved_errno = errno;
			asprintf (errstr, _("DMX_SET_PES_FILTER failed: %s."),
				  strerror (errno));
			goto failed;
		}
	}

	dvb_flush (&dvb->capture);

	if (errstr == &error) {
		free (error);
		error = NULL;
	}

	return &dvb->capture;

 no_memory:
	asprintf (errstr, _("Virtual memory exhausted."));

	saved_errno = ENOMEM;

	/* fall through */

 failed:
	if (NULL != dvb) {
		dvb_delete (&dvb->capture);
		dvb = NULL;
	}

	if (errstr == &error) {
		free (error);
		error = NULL;
	}

	errno = saved_errno;

	return NULL;
}