示例#1
0
文件: video.c 项目: cgbarnwell/mvpmc
void
video_thumbnail(av_thumbnail_mode_t thumb_mode, vid_thumb_location_t loc)
{
	static int enable = 1;

	if (thumb_mode != AV_THUMBNAIL_OFF) {
		int x,y;
		if((loc & 1) == 0)
			x = VIEWPORT_LEFT;
		else
			x = VIEWPORT_RIGHT - av_thumbnail_width(thumb_mode);

		if((loc & 2) == 0)
			y = VIEWPORT_TOP;
		else
			y = VIEWPORT_BOTTOM - av_thumbnail_height(thumb_mode);
		av_move(x, y, thumb_mode);
		screensaver_enable();
		enable = 1;
	} else {
		av_wss_redraw();
		if (gui_state != MVPMC_STATE_EMULATE) {
			av_move(0, 0, 0);
		}
		if (enable)
			screensaver_disable();
		enable = 0;
	}
}
示例#2
0
文件: snappy.c 项目: Alex237/snappy
void
close_down (UserInterface * ui, GstEngine * engine)
{
  g_print ("closing snappy\n");

  // save position if file isn't finished playing
  add_uri_unfinished (engine);

  change_state (engine, "Null");

  screensaver_enable (ui->screensaver, TRUE);
  screensaver_free (ui->screensaver);

  gst_object_unref (G_OBJECT (engine->player));
}
示例#3
0
void
interface_start (UserInterface * ui, gchar * uri)
{
  ClutterColor stage_color = { 0x00, 0x00, 0x00, 0x00 };

  g_print ("Loading ui!\n");

  // Init UserInterface structure variables
  ui->fileuri = uri;
  ui->filename = g_path_get_basename (ui->fileuri);

  ui->media_width = ui->engine->media_width;
  ui->media_height = ui->engine->media_height;

  ui->stage_width = ui->engine->media_width;
  ui->stage_height = ui->engine->media_height;
  ui->stage = clutter_stage_get_default ();

  ui->controls_showing = FALSE;
  ui->keep_showing_controls = FALSE;
  ui->penalty_box_active = FALSE;
  ui->controls_timeout = -1;

  ui->seek_width = ui->stage_width / SEEK_WIDTH_RATIO;
  ui->seek_height = ui->stage_height / SEEK_HEIGHT_RATIO;

  ui->progress_id = -1;
  ui->title_length = TITLE_LENGTH;
  ui->duration_str = position_ns_to_str (ui->engine->media_duration);

  ui->rotated = FALSE;

  clutter_stage_set_color (CLUTTER_STAGE (ui->stage), &stage_color);
  clutter_stage_set_minimum_size (CLUTTER_STAGE (ui->stage),
      ui->stage_width, ui->stage_height);
  clutter_stage_set_title (CLUTTER_STAGE (ui->stage), ui->filename);

  clutter_actor_set_size (CLUTTER_ACTOR (ui->stage), ui->stage_width,
    ui->stage_height);

  if (ui->fullscreen) {
    clutter_stage_set_fullscreen (CLUTTER_STAGE (ui->stage), TRUE);
  }

  // Controls
  load_controls (ui);

  // Add video texture and control UI to stage
  clutter_container_add (CLUTTER_CONTAINER (ui->stage), ui->texture,
      ui->control_box, NULL);

  clutter_stage_hide_cursor (CLUTTER_STAGE (ui->stage));
  clutter_actor_animate (ui->control_box, CLUTTER_EASE_OUT_QUINT, SECOND,
      "opacity", 0, NULL);

  g_signal_connect (CLUTTER_STAGE (ui->stage), "fullscreen",
      G_CALLBACK (size_change), ui);
  g_signal_connect (CLUTTER_STAGE (ui->stage), "unfullscreen",
      G_CALLBACK (size_change), ui);
  g_signal_connect (ui->stage, "event", G_CALLBACK (event_cb), ui);

  clutter_actor_set_anchor_point_from_gravity (CLUTTER_ACTOR (ui->texture),
      CLUTTER_GRAVITY_CENTER);
  clutter_actor_set_position (CLUTTER_ACTOR (ui->texture), ui->stage_width / 2,
      ui->stage_height / 2);

  center_controls (ui);
  progress_timing (ui);

  ui->screensaver = screensaver_new (CLUTTER_STAGE (ui->stage));
  screensaver_enable (ui->screensaver, FALSE);

  g_timeout_add (SECOND, progress_update_text, ui);

  clutter_actor_show (ui->stage);
}
示例#4
0
文件: video.c 项目: cgbarnwell/mvpmc
void
video_callback(mvp_widget_t *widget, char key)
{
	int jump;
	long long offset, size;
	pts_sync_data_t async, vsync;
	av_state_t state;

	/*
	printf("**SSDEBUG: In video_callback and got key %d \n",key);
	*/

	if (!video_playing)
		return;

	if(showing_guide) {
		if(mvp_tvguide_callback(widget, key) == 1)
			return;
		}

	if ( video_functions->key != NULL ) {
		if ( video_functions->key(key) == 1 ) {
			return;
		}
	}

	switch (key) {
	case MVPW_KEY_GO:
	case MVPW_KEY_GUIDE:
		if(showing_guide == 0 && showing_guide == 0) {
			printf("In %s showing guide %d \n",__FUNCTION__, key);
			showing_guide = 1;
			mvp_tvguide_video_topright(1);
			mvp_tvguide_show(mythtv_livetv_program_list, mythtv_livetv_description,
											 mythtv_livetv_clock);
			break;
		}
	/* if the guide button is pressed while guide is active fall through to go back to remove guide and return to TV */
	case MVPW_KEY_TV:
		if(showing_guide == 1) {
			printf("In %s hiding guide %d \n", __FUNCTION__, key);
			showing_guide = 0;
			mvp_tvguide_video_topright(0);
			mvp_tvguide_hide(mythtv_livetv_program_list, mythtv_livetv_description,
											 mythtv_livetv_clock);
		}
		break;
	case MVPW_KEY_STOP:
	case MVPW_KEY_EXIT:
		back_to_guide_menu();
		new_live_tv = 0;
		break;
		
	case MVPW_KEY_PAUSE:
		if (av_pause()) {
			mvpw_show(pause_widget);
			mvpw_hide(ffwd_widget);
			paused = 1;
			if (pause_osd && !display_on && (display_on_alt < 2)) {
				display_on_alt = 2;
				enable_osd();
			}
			screensaver_enable();
		} else {
			if (pause_osd && !display_on &&
			    (display_on_alt == 2)) {
				display_on_alt = 0;
				disable_osd();
				mvpw_expose(root);
			}
			av_get_state(&state);
			if (state.mute)
				mvpw_show(mute_widget);
			else
				mvpw_hide(mute_widget);
			mvpw_hide(pause_widget);
			paused = 0;
			screensaver_disable();
		}
		break;
	case MVPW_KEY_PLAY:
		if ( paused ) {
			/*
			 * play key can be used to un-pause
			 */
			av_pause();
			if (pause_osd && !display_on &&
			    (display_on_alt == 2)) {
				display_on_alt = 0;
				disable_osd();
				mvpw_expose(root);
			}
			mvpw_hide(pause_widget);
			mvpw_hide(mute_widget);
			paused = 0;
			screensaver_disable();
		}
		break;
	case MVPW_KEY_REPLAY:
		seek_by(-30);
		timed_osd(seek_osd_timeout*1000);
		break;
	case MVPW_KEY_REWIND:
		seek_by(-10);
		timed_osd(seek_osd_timeout*1000);
		break;
	case MVPW_KEY_SKIP:
		if (mythtv_seek_amount == 0 ) {
			seek_by(30);
		}
		else if (mythtv_seek_amount == 1 ) {
			seek_by(60);
		}
		else {
			seek_by(30);
		}
		timed_osd(seek_osd_timeout*1000);
		break;
	case MVPW_KEY_FFWD:
		if (av_ffwd() == 0) {
			demux_flush(handle);
			demux_seek(handle);
			av_get_state(&state);
			av_stop();
			av_reset();
			if (state.mute) {
				av_set_mute(1);
			}
			av_play();
			mvpw_hide(ffwd_widget);
		} else {
			av_get_state(&state);
			mvpw_show(ffwd_widget);
			mvpw_hide(pause_widget);
			screensaver_disable();
		}
		timed_osd(seek_osd_timeout*1000);
		break;
	case MVPW_KEY_LEFT:
		if (video_functions->seek) {
			size = video_functions->size();
			jump_target = -1;
			jumping = 1;
                        if (video_write_thread) {
                            pthread_kill(video_write_thread, SIGURG);
                        }
                        if (audio_write_thread) {
                            pthread_kill(audio_write_thread, SIGURG);
                        }
			offset = video_functions->seek(0, SEEK_CUR);
			jump_target = ((-size / 100.0) + offset);
			pthread_cond_broadcast(&video_cond);
		}
		break;
	case MVPW_KEY_RIGHT:
		if (video_functions->seek) {
			size = video_functions->size();
			jump_target = -1;
			jumping = 1;
                        if (video_write_thread) {
                            pthread_kill(video_write_thread, SIGURG);
                        }
                        if (audio_write_thread) {
                            pthread_kill(audio_write_thread, SIGURG);
                        }
			offset = video_functions->seek(0, SEEK_CUR);
			jump_target = ((size / 100.0) + offset);
			pthread_cond_broadcast(&video_cond);
			timed_osd(seek_osd_timeout*1000);
		}
		break;
	case MVPW_KEY_ZERO ... MVPW_KEY_NINE:
		if(new_live_tv) {
			printf("In %s showing guide %d \n",__FUNCTION__, key);
			showing_guide = 1;
			mvp_tvguide_video_topright(1);
			mvp_tvguide_show(mythtv_livetv_program_list, mythtv_livetv_description,
											 mythtv_livetv_clock);
			mvp_tvguide_callback(widget, key);
		}
		else if (mythtv_livetv) {
			back_to_guide_menu();
			mythtv_key_callback(mythtv_browser,  key);
		}
		else {
			size = video_functions->size();
			jump_target = -1;
			jumping = 1;
                        if (video_write_thread) {
                            pthread_kill(video_write_thread, SIGURG);
                        }
                        if (audio_write_thread) {
                            pthread_kill(audio_write_thread, SIGURG);
                        }
			jump = key;
			jump_target = size * (jump / 10.0);
			pthread_cond_broadcast(&video_cond);
			timed_osd(seek_osd_timeout*1000);
		}
		break;
	case MVPW_KEY_MENU:
		mvpw_show(popup_menu);
		mvpw_focus(popup_menu);
		break;
	case MVPW_KEY_MUTE:
		if (mvpw_visible(ffwd_widget)) {
			mvpw_hide(mute_widget);
			break;
		}
		if (av_mute() == 1) {
			mvpw_show(mute_widget);
		} else {
			mvpw_hide(mute_widget);
		}
		break;
	case MVPW_KEY_BLANK:
	case MVPW_KEY_OK:
		if (display_on || display_on_alt) {
			disable_osd();
			mvpw_expose(root);
			display_on = 1;
			display_on_alt = 0;
		} else {
			enable_osd();
		}
		display_on = !display_on;
		break;
	case MVPW_KEY_FULL:
	case MVPW_KEY_PREV_CHAN:
		if(IS_4x3(av_get_tv_aspect())) {
			if(av_get_tv_aspect() == AV_TV_ASPECT_4x3_CCO)
				av_set_tv_aspect(AV_TV_ASPECT_4x3);
			else
				av_set_tv_aspect(AV_TV_ASPECT_4x3_CCO);
		}
		break;
	case MVPW_KEY_CHAN_UP:
	case MVPW_KEY_UP:
		if (mythtv_livetv)
			mythtv_channel_up();
		break;
	case MVPW_KEY_CHAN_DOWN:
	case MVPW_KEY_DOWN:
		if (mythtv_livetv)
			mythtv_channel_down();
		break;
	case MVPW_KEY_RECORD:
		/*
		 * XXX: This is a temporary hack until we figure out how
		 *      to tell when the audio and video are out of sync,
		 *      and correct it automatically.
		 */
		av_get_audio_sync(&async);
		av_get_video_sync(&vsync);
		printf("PRE  SYNC:  a 0x%"PRIx64" 0x%"PRIx64"  v 0x%"PRIx64" 0x%"PRIx64"\n",
		       async.stc, async.pts, vsync.stc, vsync.pts);
		av_delay_video(1000);
		av_get_audio_sync(&async);
		av_get_video_sync(&vsync);
		printf("POST SYNC:  a 0x%"PRIx64" 0x%"PRIx64"  v 0x%"PRIx64" 0x%"PRIx64"\n",
		       async.stc, async.pts, vsync.stc, vsync.pts);
		break;
	case MVPW_KEY_VOL_UP:
	case MVPW_KEY_VOL_DOWN:
		volume_key_callback(volume_dialog, key);
		mvpw_show(volume_dialog);
		mvpw_set_timer(volume_dialog, timer_hide, 3000);
		break;
	default:
		PRINTF("button %d\n", key);
		break;
	}
}