Exemplo n.º 1
0
Arquivo: fb.c Projeto: gettler/mvpmc
static void
fb_osd_update(mvp_widget_t *widget)
{
	av_stc_t stc;
	char buf[256];
	struct stat64 sb;
	long long offset;
	int percent;

	if (fstat64(fd, &sb) < 0)
		return;

	av_current_stc(&stc);
	snprintf(buf, sizeof(buf), "%.2d:%.2d:%.2d",
		 stc.hour, stc.minute, stc.second);
	mvpw_set_text_str(fb_time, buf);

	snprintf(buf, sizeof(buf), "Bytes: %lld", (long long)sb.st_size);
	mvpw_set_text_str(fb_size, buf);

	offset = lseek(fd, 0, SEEK_CUR);
	percent = (int)((double)(offset/1000) /
		    (double)(sb.st_size/1000) * 100.0);

	snprintf(buf, sizeof(buf), "%d%%", percent);
	mvpw_set_text_str(fb_offset_widget, buf);
	mvpw_set_graph_current(fb_offset_bar, percent);
	mvpw_expose(fb_offset_bar);
}
Exemplo n.º 2
0
void
osd_callback(mvp_widget_t *widget)
{
	struct stat64 sb;
	long long offset = 0;
	int off, Mb;
	char buf[32];
	av_stc_t stc;
	demux_attr_t *attr;

	fstat64(fd, &sb);
	if (video_functions->seek)
		offset = video_functions->seek(0, SEEK_CUR);
	off = (int)((double)(offset/1000) /
		    (double)(sb.st_size/1000) * 100.0);
	snprintf(buf, sizeof(buf), "%d", off);
	mvpw_set_text_str(offset_widget, buf);

	mvpw_set_graph_current(offset_bar, off);

	attr = demux_get_attr(handle);
	av_current_stc(&stc);
	Mb = (attr->Bps * 8) / (1024 * 1024);
	snprintf(buf, sizeof(buf), "Mbps: %d.%.2d   Time: %.2d:%.2d:%.2d",
		 Mb, (attr->Bps * 8) / (1024 * 1024 / 100) - (Mb * 100),
		 stc.hour, stc.minute, stc.second);
	mvpw_set_text_str(bps_widget, buf);
}
Exemplo n.º 3
0
void
video_timecode(mvp_widget_t *widget)
{
	demux_attr_t *attr;
	char buf[32];
	av_stc_t stc;

	attr = demux_get_attr(handle);
	av_current_stc(&stc);
	snprintf(buf, sizeof(buf), "%.2d:%.2d:%.2d",
		 stc.hour, stc.minute, stc.second);
	if (running_mythtv && !mythtv_livetv) {
		int seconds = 0, minutes = 0, hours = 0;

		seconds = mythtv_program_runtime();

		if (seconds > 0) {
			hours = seconds / (60 * 60);
			minutes = (seconds / 60) % 60;
			seconds = seconds % 60;

			snprintf(buf, sizeof(buf),
				 "%.2d:%.2d:%.2d / %.2d:%.2d:%.2d",
				 stc.hour, stc.minute, stc.second,
				 hours, minutes, seconds);
		}
	}
	if (using_vlc) {
		vlc_timecode(buf);
	}
	mvpw_set_text_str(time_widget, buf);
}
Exemplo n.º 4
0
void
video_bitrate(mvp_widget_t *widget)
{
	demux_attr_t *attr;
	av_stc_t stc;
	char buf[32];
	int Mb;

	attr = demux_get_attr(handle);
	av_current_stc(&stc);
	Mb = (attr->Bps * 8) / (1024 * 1024);
	snprintf(buf, sizeof(buf), "%d.%.2d Mbps",
		 Mb, (attr->Bps * 8) / (1024 * 1024 / 100) - (Mb * 100));
	mvpw_set_text_str(bps_widget, buf);
}
Exemplo n.º 5
0
static void
seek_by(int seconds)
{
	demux_attr_t *attr = demux_get_attr(handle);
	int delta;
	int stc_time, gop_time, pts_time;
	long long offset, size;

	if (video_functions->seek == NULL) {
		fprintf(stderr, "cannot seek on this video!\n");
		return;
	}

        if (video_write_thread) {
            pthread_kill(video_write_thread, SIGURG);
        }
        if (audio_write_thread) {
            pthread_kill(audio_write_thread, SIGURG);
        }

	if (mvpw_visible(ffwd_widget)) {
		mvpw_hide(ffwd_widget);
		av_ffwd();
	}

	gop_seek_attempts = 0;
	pts_seek_attempts = 0;

	av_current_stc(&seek_stc);

	seek_Bps = ((1024*1024) * 4) / 8;  /* default to 4 megabits per second */
	gop_time = 0;
	if ( attr->gop_valid ) {
		gop_time = (attr->gop.hour*60 + attr->gop.minute)*60 +
			attr->gop.second;
		if (attr->Bps)
			seek_Bps = attr->Bps;
	}
	pts_time = attr->gop.pts/PTS_HZ;
	stc_time = (seek_stc.hour*60 + seek_stc.minute)*60 + seek_stc.second;

	/*
	 * If the STC and GOP timestamps are close, use the STC timestamp as
	 * the starting point, because it is the timestamp for the frame the
	 * hardware is currently playing. If GOP time not set use STC anyway.
	 */
	if (abs(gop_time - stc_time) < 10) {
		printf("STC SEEK from: %d, (%d)\n", stc_time, gop_time);
		seek_start_seconds = stc_time;
		gop_seek_attempts = 4;
	} else if (gop_time) {
		printf("GOP SEEK from: %d, (%d)\n", gop_time, pts_time);
		seek_start_seconds = gop_time;
		gop_seek_attempts = 4;
	} else {
		printf("PTS SEEK from: %d, (%d)\n", pts_time, gop_time);
		seek_start_seconds = pts_time;
		pts_seek_attempts = 4;
	}
	seek_start_pos = video_functions->seek(0, SEEK_CUR);
	size = video_functions->size();

	seek_seconds = seek_start_seconds + seconds;

	/* The mvpmc hardware can only handle 12Mbps and some off-air DVB/ATSC
	 * SD broadcasts appear to some way result in huge (200+Mbps) values
	 * to appear in the seeks and cause 30 seconds seeks to go for a lot
	 * longer */
	if ( seek_Bps > (12/8)*1024*1024) {
		printf("Calculated Seek Bps was %d kbps, which is too high " \
		       "- set to 4Mbps\n",8*seek_Bps/1024);
		seek_Bps = (4/8) * 1024 * 1024;
	}

	delta = seek_Bps * seconds;

	/*
	 * Abort the seek if near the end of the file
	 */
	if ((size < 0) || (seek_start_pos + delta > size)) {
		fprintf(stderr, "near end of file, seek aborted\n");
		return;
	}

	PRINTF("%d Bps, currently %lld + %d\n",
	       seek_Bps, seek_start_pos, delta);

	gettimeofday((struct timeval*)&seek_timeval, NULL);
	seek_attempts = 16;
	seeking = 1;
	
	offset = video_functions->seek(delta, SEEK_CUR);

	PRINTF("-> %lld\n", offset);

	pthread_cond_broadcast(&video_cond);
}