示例#1
0
int pipeline_container_negotiate (LVAVSPipelineContainer *container, VisVideo *video)
{
    VisListEntry *le = NULL;
    LVAVSPipelineElement *element;

    while ((element = visual_list_next (container->members, &le)) != NULL) {

        switch (element->type) {
            case LVAVS_PIPELINE_ELEMENT_TYPE_ACTOR:
                visual_actor_set_video (element->data.actor, video);
                visual_actor_video_negotiate (element->data.actor, VISUAL_VIDEO_DEPTH_NONE, FALSE, FALSE);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_TRANSFORM:
                visual_transform_set_video (element->data.transform, video);
                visual_transform_video_negotiate (element->data.transform);

                break;


            case LVAVS_PIPELINE_ELEMENT_TYPE_CONTAINER:

                pipeline_container_negotiate (LVAVS_PIPELINE_CONTAINER (element), video);

                break;

            default:

                break;
        }
    }

    return VISUAL_OK;
}
示例#2
0
文件: bglv.c 项目: Jheengut/gmerlin
static void size_changed(void * data, int width, int height)
  {
  lv_priv_t * priv;
  priv = (lv_priv_t*)data;
  visual_video_set_dimension(priv->video, width, height);
  visual_actor_set_video(priv->actor, priv->video);
  visual_actor_video_negotiate(priv->actor, 0, FALSE, FALSE);
  }
static gboolean
gst_visual_setup (GstAudioVisualizer * bscope)
{
  GstVisual *visual = GST_VISUAL (bscope);
  gint depth;

  gst_visual_clear_actors (visual);

  /* FIXME: we need to know how many bits we actually have in memory */
  depth = bscope->vinfo.finfo->pixel_stride[0];
  if (bscope->vinfo.finfo->bits >= 8) {
    depth *= 8;
  }

  visual->actor =
      visual_actor_new (GST_VISUAL_GET_CLASS (visual)->plugin->info->plugname);
  visual->video = visual_video_new ();
  visual->audio = visual_audio_new ();
  /* can't have a play without actors */
  if (!visual->actor || !visual->video)
    goto no_actors;

  if (visual_actor_realize (visual->actor) != 0)
    goto no_realize;

  visual_actor_set_video (visual->actor, visual->video);

  visual_video_set_depth (visual->video,
      visual_video_depth_enum_from_value (depth));
  visual_video_set_dimension (visual->video,
      GST_VIDEO_INFO_WIDTH (&bscope->vinfo),
      GST_VIDEO_INFO_HEIGHT (&bscope->vinfo));
  visual_actor_video_negotiate (visual->actor, 0, FALSE, FALSE);

  GST_DEBUG_OBJECT (visual, "WxH: %dx%d, bpp: %d, depth: %d",
      GST_VIDEO_INFO_WIDTH (&bscope->vinfo),
      GST_VIDEO_INFO_HEIGHT (&bscope->vinfo), visual->video->bpp, depth);

  return TRUE;
  /* ERRORS */
no_actors:
  {
    GST_ELEMENT_ERROR (visual, LIBRARY, INIT, (NULL),
        ("could not create actors"));
    gst_visual_clear_actors (visual);
    return FALSE;
  }
no_realize:
  {
    GST_ELEMENT_ERROR (visual, LIBRARY, INIT, (NULL),
        ("could not realize actor"));
    gst_visual_clear_actors (visual);
    return FALSE;
  }
}
示例#4
0
static int render_now(LVAVSPipelineContainer *container, VisVideo *video, VisAudio *audio, int s)
{
    LVAVSPipeline *pipeline = LVAVS_PIPELINE_ELEMENT(container)->pipeline;

    int i;
    int count = visual_list_count(container->members);
    for(i = 0; i < count; i++) {
        LVAVSPipelineElement *element = visual_list_get(container->members, i);
        VisVideo *tmpvid;

        if(s) {
            pipeline->framebuffer = visual_video_get_pixels(pipeline->dummy_vid);
            pipeline->fbout = visual_video_get_pixels(video);
        } else {
            pipeline->fbout = visual_video_get_pixels(pipeline->dummy_vid);
            pipeline->framebuffer = visual_video_get_pixels(video);
        }

        switch (element->type) {
            case LVAVS_PIPELINE_ELEMENT_TYPE_ACTOR:

                visual_actor_set_video (element->data.actor, video);
                visual_actor_run (element->data.actor, audio);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_TRANSFORM:

                visual_transform_set_video (element->data.transform, video);
                visual_transform_run (element->data.transform, audio);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_CONTAINER:

                pipeline_container_run (LVAVS_PIPELINE_CONTAINER (element), video, audio);

                break;

            default:

                break;
        }

        if(pipeline->swap&1) {
            s^=1;
            pipeline->swap = 0;
        }

    }

    return s;
}
示例#5
0
文件: bglv.c 项目: Jheengut/gmerlin
static int
open_ov_lv(void * data, gavl_audio_format_t * audio_format,
           gavl_video_format_t * video_format)
  {
  int depths, depth;
  lv_priv_t * priv;
  priv = (lv_priv_t*)data;
  adjust_audio_format(audio_format);
  
  /* Get the depth */
  depths = visual_actor_get_supported_depth(priv->actor);

  if(depths & VISUAL_VIDEO_DEPTH_32BIT)    /**< 32 bits surface flag. */
    {
    video_format->pixelformat = GAVL_BGR_32;
    depth = VISUAL_VIDEO_DEPTH_32BIT;
    }
  else if(depths & VISUAL_VIDEO_DEPTH_24BIT)    /**< 24 bits surface flag. */
    {
    video_format->pixelformat = GAVL_BGR_24;
    depth = VISUAL_VIDEO_DEPTH_24BIT;
    }
  else if(depths & VISUAL_VIDEO_DEPTH_16BIT)    /**< 16 bits 5-6-5 surface flag. */
    {
    video_format->pixelformat = GAVL_RGB_16;
    depth = VISUAL_VIDEO_DEPTH_16BIT;
    }
  else if(depths & VISUAL_VIDEO_DEPTH_8BIT)    /**< 8 bits indexed surface flag. */
    {
    video_format->pixelformat = GAVL_BGR_24;
    depth = VISUAL_VIDEO_DEPTH_24BIT;
    }
  else
    return 0;
  
  visual_video_set_depth(priv->video, depth);
  visual_video_set_dimension(priv->video,
                             video_format->image_width,
                             video_format->image_height);
  
  visual_actor_set_video(priv->actor, priv->video);
  visual_actor_video_negotiate(priv->actor,
                               0, FALSE, FALSE);
  return 1;
  }
示例#6
0
文件: bglv.c 项目: Jheengut/gmerlin
static int
open_gl_lv(void * data, gavl_audio_format_t * audio_format,
           const char * window_id)
  {
  int width, height;
  
  lv_priv_t * priv;
  priv = (lv_priv_t*)data;

  visual_video_set_depth(priv->video, VISUAL_VIDEO_DEPTH_GL);
  
  adjust_audio_format(audio_format);

    
  gavl_audio_format_copy(&priv->audio_format, audio_format);
  
  bg_x11_window_set_gl(priv->win);
  visual_actor_set_video(priv->actor, priv->video);
  bg_x11_window_unset_gl(priv->win);
  
  /* Set the size changed callback after initializing the libvisual stuff */
  bg_x11_window_set_callbacks(priv->win, &priv->window_callbacks);
  bg_x11_window_show(priv->win, 1);

  
  bg_x11_window_set_gl(priv->win);
  
  bg_x11_window_get_size(priv->win, &width, &height);
  
  /* We cannot use the size callback above since it's called before the
     actor is realized */
  visual_video_set_dimension(priv->video, width, height);
  visual_actor_video_negotiate(priv->actor, 0, FALSE, FALSE);
  
  bg_x11_window_unset_gl(priv->win);
  return 1;
  }
示例#7
0
/* Main stuff */
int main (int argc, char *argv[])
{
	int width = 1000, height = 600;
	int i, j;
	int freeze = 0;
	int depthflag = 0;
	int alpha = 190;
	int xoff = 0, yoff = -90;
	int sxsize = 1000;
	int sysize = 700;
	int interpol = VISUAL_VIDEO_SCALE_NEAREST;
        int frames = 0;
	VisTime start, end;
		
	bpp = 4;
	sdl_init (width, height);

	scrbuf = malloc (screen->pitch * screen->h);
	memset (scrbuf, 0, screen->pitch * screen->h);

	SDL_Event event;

	visual_init (&argc, &argv);
	
	if (argc > 1)
		actor = visual_actor_new (argv[1]);
	else
		actor = visual_actor_new ("corona");

	visual_actor_realize (actor);

	video = visual_video_new ();

	if (argc > 2)
		video = visual_bitmap_load_new_video (argv[2]);
	else
		video = visual_bitmap_load_new_video ("bg.bmp");

	actvid = visual_video_new ();
	visual_actor_set_video (actor, actvid);
	visual_video_set_depth (actvid, visual_video_depth_get_highest (visual_actor_get_supported_depth (actor)));
	visual_video_set_dimension (actvid, width, height);
	visual_video_allocate_buffer (actvid);

	visual_actor_video_negotiate (actor, 0, FALSE, FALSE);

	video32 = visual_video_new ();
	visual_video_set_depth (video32, VISUAL_VIDEO_DEPTH_32BIT);
	visual_video_set_dimension (video32, video->width, video->height);
	visual_video_allocate_buffer (video32);
	
	scalevid = visual_video_new ();
	visual_video_set_depth (scalevid, VISUAL_VIDEO_DEPTH_32BIT);
	visual_video_set_dimension (scalevid, sxsize, sysize);
	visual_video_allocate_buffer (scalevid);

	sdlvid = visual_video_new ();
	visual_video_set_depth (sdlvid, VISUAL_VIDEO_DEPTH_32BIT);
	visual_video_set_dimension (sdlvid, screen->w, screen->h);
	visual_video_set_pitch (sdlvid, screen->pitch);
	visual_video_set_buffer (sdlvid, scrbuf);
	
	input = visual_input_new ("xmms2");
	visual_input_realize (input);

	SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
        
	visual_time_get (&start);
	
	while (1) {
		visual_input_run (input);
		visual_actor_run (actor, input->audio);
	
		/* place on screen */
//		visual_video_blit_overlay (sdlvid, video, 0, 0, FALSE);
	
		if (sxsize < 0)
			sxsize = 0;

		if (sysize < 0)
			sysize = 0;
		
		if (sxsize != scalevid->width || sysize != scalevid->height) {
			visual_video_set_dimension (scalevid, sxsize, sysize);
			visual_video_allocate_buffer (scalevid);
		}

		visual_video_depth_transform (video32, video);


//		visual_video_alpha_fill (sdlvid, 0);
		
//		visual_video_alpha_fill (video32, alpha);
//		visual_video_alpha_color (video32, 0, 0, 0, 255);
	

		do_alpha (video32, alpha);
		visual_video_scale (scalevid, video32, interpol);

		
		visual_video_blit_overlay (sdlvid, actvid, 0, 0, FALSE);
		visual_video_blit_overlay (sdlvid, scalevid, xoff, yoff, TRUE);

		sdl_draw_buf ();
		frames++;
		
		while (SDL_PollEvent (&event)) {
			switch (event.type) {
				case SDL_KEYDOWN:
					switch (event.key.keysym.sym) {
						case SDLK_F11:
							SDL_WM_ToggleFullScreen (screen);
							break;

						case SDLK_UP:
							yoff -= 10;

							break;

						case SDLK_DOWN:
							yoff += 10;

							break;
						
						case SDLK_LEFT:
							xoff -= 10;

							break;

						case SDLK_RIGHT:
							xoff += 10;

							break;
						
						case SDLK_q:
							sysize -= 10;

							break;

						case SDLK_a:
							sysize += 10;

							break;
						
						case SDLK_z:
							sxsize -= 10;

							break;

						case SDLK_x:
							sxsize += 10;

							break;

						case SDLK_i:
							if (interpol == VISUAL_VIDEO_SCALE_NEAREST)
								interpol = VISUAL_VIDEO_SCALE_BILINEAR;
							else
								interpol = VISUAL_VIDEO_SCALE_NEAREST;
							
							break;

						case SDLK_o:
							alpha -= 8;
							if (alpha < 0)
								alpha = 0;

							break;

						case SDLK_p:
							alpha += 8;
							if (alpha > 255)
								alpha = 255;

							break;
							
						case SDLK_ESCAPE:
							goto out;
							break;
					}
					break;

				case SDL_VIDEORESIZE:
					sdl_size_request (event.resize.w, event.resize.h);
					break;

				case SDL_QUIT:
					goto out;
					break;
			}
		}
	}
out:
	visual_time_get (&end);
	
	VisTime diff;

	visual_time_difference (&diff, &start, &end);


	printf ("Ran: %d:%d, drawn %d frames\n",
			diff.tv_sec, diff.tv_usec, frames);

	SDL_Quit ();
}
示例#8
0
int visual_bin_switch_finalize (VisBin *bin)
{
	int depthflag;

	visual_log_return_val_if_fail (bin != NULL, -1);

	visual_log (VISUAL_LOG_DEBUG, "Entering...");
	if (bin->managed == TRUE)
		visual_object_unref (VISUAL_OBJECT (bin->actor));

	/* Copy over the depth to be sure, and for GL plugins */
/*	bin->actvideo->depth = bin->actmorphvideo->depth;
	visual_video_set_depth (bin->actvideo, bin->actmorphvideo->depth); */

	if (bin->actmorphmanaged == TRUE) {
		visual_object_unref (VISUAL_OBJECT (bin->actmorphvideo));

		bin->actmorphvideo = NULL;
	}

	if (bin->privvid != NULL) {
		visual_object_unref (VISUAL_OBJECT (bin->privvid));
		
		bin->privvid = NULL;
	}

	bin->actor = bin->actmorph;
	bin->actmorph = NULL;
	
	visual_actor_set_video (bin->actor, bin->actvideo);
	
	bin->morphing = FALSE;

	if (bin->morphmanaged == TRUE) {
		visual_object_unref (VISUAL_OBJECT (bin->morph));
		bin->morph = NULL;
	}

	visual_log (VISUAL_LOG_DEBUG, " - in finalize - fscking depth from actvideo: %d %d", bin->actvideo->depth, bin->actvideo->bpp);

	
/*	visual_bin_set_depth (bin, bin->actvideo->depth); */

	depthflag = visual_actor_get_supported_depth (bin->actor);
	fix_depth_with_bin (bin, bin->actvideo, bin_get_depth_using_preferred (bin, depthflag));
	visual_bin_set_depth (bin, bin->actvideo->depth);

	bin->depthforcedmain = bin->actvideo->depth;
	visual_log (VISUAL_LOG_DEBUG, "bin->depthforcedmain in finalize %d", bin->depthforcedmain);

	/* FIXME replace with a depth fixer */
	if (bin->depthchanged == TRUE) {
		visual_log (VISUAL_LOG_INFO, _("negotiate without event"));
		visual_actor_video_negotiate (bin->actor, bin->depthforcedmain, TRUE, TRUE);
		visual_log (VISUAL_LOG_INFO, _("end negotiate without event"));
	/*	visual_bin_sync (bin); */
	}

	visual_log (VISUAL_LOG_DEBUG, "Leaving...");

	return 0;
}
示例#9
0
int visual_bin_switch_actor (VisBin *bin, VisActor *actor)
{
	VisVideo *privvid;

	visual_log_return_val_if_fail (bin != NULL, -1);
	visual_log_return_val_if_fail (actor != NULL, -1);

	/* Set the new actor */
	bin->actmorph = actor;

	visual_log (VISUAL_LOG_DEBUG, "entering...");
	
	/* Free the private video */
	if (bin->privvid != NULL) {
		visual_object_unref (VISUAL_OBJECT (bin->privvid));
		
		bin->privvid = NULL;
	}

	visual_log (VISUAL_LOG_INFO, _("depth of the main actor: %d"), bin->actor->video->depth);

	/* Starting the morph, but first check if we don't have anything todo with openGL */
	if (bin->morphstyle == VISUAL_SWITCH_STYLE_MORPH &&
			bin->actor->video->depth != VISUAL_VIDEO_DEPTH_GL &&
			bin->actmorph->video->depth != VISUAL_VIDEO_DEPTH_GL &&
			bin->depthfromGL != TRUE) {

		if (bin->morph != NULL && bin->morph->plugin != NULL) {
			visual_morph_set_rate (bin->morph, 0);
		
			visual_morph_set_video (bin->morph, bin->actvideo);

			if (bin->morphautomatic == TRUE)
				visual_morph_set_mode (bin->morph, bin->morphmode);
			else
				visual_morph_set_mode (bin->morph, VISUAL_MORPH_MODE_SET);
			
			visual_morph_set_time (bin->morph, &bin->morphtime);
			visual_morph_set_steps (bin->morph, bin->morphsteps);
		}

		bin->morphrate = 0;
		bin->morphstepsdone = 0;

		visual_log (VISUAL_LOG_DEBUG, "phase 1");
		/* Allocate a private video for the main actor, so the morph
		 * can draw to the framebuffer */
		privvid = visual_video_new ();

		visual_log (VISUAL_LOG_DEBUG, "actvideo->depth %d actmorph->video->depth %d",
				bin->actvideo->depth, bin->actmorph->video->depth);

		visual_log (VISUAL_LOG_DEBUG, "phase 2");
		visual_video_clone (privvid, bin->actvideo);
		visual_log (VISUAL_LOG_DEBUG, "phase 3 pitch privvid %d actvideo %d", privvid->pitch, bin->actvideo->pitch);

		visual_video_allocate_buffer (privvid);

		visual_log (VISUAL_LOG_DEBUG, "phase 4");
		/* Initial privvid initialize */
	
		visual_log (VISUAL_LOG_DEBUG, "actmorph->video->depth %d %p", bin->actmorph->video->depth,
				visual_video_get_pixels (bin->actvideo));
		
		if (visual_video_get_pixels (bin->actvideo) != NULL && visual_video_get_pixels (privvid) != NULL)
			visual_mem_copy (visual_video_get_pixels (privvid), visual_video_get_pixels (bin->actvideo),
					visual_video_get_size (privvid));
		else if (visual_video_get_pixels (privvid) != NULL)
			visual_mem_set (visual_video_get_pixels (privvid), 0, visual_video_get_size (privvid));

		visual_actor_set_video (bin->actor, privvid);
		bin->privvid = privvid;
	} else {
		visual_log (VISUAL_LOG_DEBUG, "Pointer actvideo->pixels %p", visual_video_get_pixels (bin->actvideo));
		if (bin->actor->video->depth != VISUAL_VIDEO_DEPTH_GL &&
				visual_video_get_pixels (bin->actvideo) != NULL) {
			visual_mem_set (visual_video_get_pixels (bin->actvideo), 0, visual_video_get_size (bin->actvideo));
		}
	}

	visual_log (VISUAL_LOG_DEBUG, "Leaving, actor->video->depth: %d actmorph->video->depth: %d",
			bin->actor->video->depth, bin->actmorph->video->depth);

	bin->morphing = TRUE;

	return 0;
}
示例#10
0
int visual_bin_switch_actor_by_name (VisBin *bin, char *actname)
{
	VisActor *actor;
	VisVideo *video;
	int depthflag;
	int depth;

	visual_log_return_val_if_fail (bin != NULL, -1);
	visual_log_return_val_if_fail (actname != NULL, -1);

	visual_log (VISUAL_LOG_DEBUG, "switching to a new actor: %s, old actor: %s", actname, bin->actor->plugin->info->name);

	/* Destroy if there already is a managed one */
	if (bin->actmorphmanaged == TRUE) {
		if (bin->actmorph != NULL) {
			visual_object_unref (VISUAL_OBJECT (bin->actmorph));

			if (bin->actmorphvideo != NULL)
				visual_object_unref (VISUAL_OBJECT (bin->actmorphvideo));
		}
	}

	/* Create a new managed actor */
	actor = visual_actor_new (actname);
	visual_log_return_val_if_fail (actor != NULL, -1);

	video = visual_video_new ();

	visual_video_clone (video, bin->actvideo);

	depthflag = visual_actor_get_supported_depth (actor);
	if (visual_video_depth_is_supported (depthflag, VISUAL_VIDEO_DEPTH_GL) == TRUE) {
		visual_log (VISUAL_LOG_INFO, _("Switching to Gl mode"));

		bin->depthforced = VISUAL_VIDEO_DEPTH_GL;
		bin->depthforcedmain = VISUAL_VIDEO_DEPTH_GL;
	
		visual_video_set_depth (video, VISUAL_VIDEO_DEPTH_GL);

		visual_bin_set_depth (bin, VISUAL_VIDEO_DEPTH_GL);
		bin->depthchanged = TRUE;

	} else {
		visual_log (VISUAL_LOG_INFO, _("Switching away from Gl mode -- or non Gl switch"));

		
		/* Switching from GL */
		depth = bin_get_depth_using_preferred (bin, depthflag);

		fix_depth_with_bin (bin, video, depth);

		visual_log (VISUAL_LOG_DEBUG, "after depth fixating");
		
		/* After a depth change, the pitch value needs an update from the client
		 * if it's different from width * bpp, after a visual_bin_sync
		 * the issues are fixed again */
		visual_log (VISUAL_LOG_INFO, _("video depth (from fixate): %d"), video->depth);

		/* FIXME check if there are any unneeded depth transform environments and drop these */
		visual_log (VISUAL_LOG_DEBUG, "checking if we need to drop something: depthforcedmain: %d actvideo->depth %d",
				bin->depthforcedmain, bin->actvideo->depth);

		/* Drop a transformation environment when not needed */
		if (bin->depthforcedmain != bin->actvideo->depth) {
			visual_actor_video_negotiate (bin->actor, bin->depthforcedmain, TRUE, TRUE);
			visual_log (VISUAL_LOG_DEBUG, "[[[[optionally a bogus transform environment, dropping]]]]\n");
		}

		if (bin->actvideo->depth > video->depth
				&& bin->actvideo->depth != VISUAL_VIDEO_DEPTH_GL
				&& bin->morphstyle == VISUAL_SWITCH_STYLE_MORPH) {

			visual_log (VISUAL_LOG_INFO, _("old depth is higher, video depth %d, depth %d, bin depth %d"), video->depth, depth,
					bin->depth);
			
			bin->depthforced = depth;
			bin->depthforcedmain = bin->depth;
			
			visual_bin_set_depth (bin, bin->actvideo->depth);

			visual_video_set_depth (video, bin->actvideo->depth);

		} else if (bin->actvideo->depth != VISUAL_VIDEO_DEPTH_GL) {

			visual_log (VISUAL_LOG_INFO, _("new depth is higher, or equal: video depth %d, depth %d bin depth %d"), video->depth, depth,
					bin->depth);

			visual_log (VISUAL_LOG_DEBUG, "depths i can locate: actvideo: %d   bin: %d   bin-old: %d", bin->actvideo->depth,
					bin->depth, bin->depthold);
			
			bin->depthforced = video->depth;
			bin->depthforcedmain = bin->depth;

			visual_log (VISUAL_LOG_DEBUG, "depthforcedmain in switch by name: %d", bin->depthforcedmain);
			visual_log (VISUAL_LOG_DEBUG, "visual_bin_set_depth %d", video->depth);
			visual_bin_set_depth (bin, video->depth);

		} else {
			/* Don't force ourself into a GL depth, seen we do a direct
			 * switch in the run */
			bin->depthforced = video->depth;
			bin->depthforcedmain = video->depth;
			
			visual_log (VISUAL_LOG_INFO, _("Switching from Gl TO framebuffer for real, framebuffer depth: %d"), video->depth);
		}

		visual_log (VISUAL_LOG_INFO, _("Target depth selected: %d"), depth);
		visual_video_set_dimension (video, video->width, video->height);

		visual_log (VISUAL_LOG_INFO, _("Switch to new pitch: %d"), bin->actvideo->pitch);
		if (bin->actvideo->depth != VISUAL_VIDEO_DEPTH_GL)
			visual_video_set_pitch (video, bin->actvideo->pitch);
		
		visual_log (VISUAL_LOG_DEBUG, "before allocating buffer");
		visual_video_allocate_buffer (video);
		visual_log (VISUAL_LOG_DEBUG, "after allocating buffer");
	}

	visual_log (VISUAL_LOG_INFO, _("video pitch of that what connects to the new actor %d"), video->pitch);
	visual_actor_set_video (actor, video);

	bin->actmorphvideo = video;
	bin->actmorphmanaged = TRUE;

	visual_log (VISUAL_LOG_INFO, _("switching... ******************************************"));
	visual_bin_switch_actor (bin, actor);

	visual_log (VISUAL_LOG_INFO, _("end switch actor by name function ******************"));
	return 0;
}
示例#11
0
int visual_bin_sync (VisBin *bin, int noevent)
{
	VisVideo *video;
	VisVideo *actvideo;

	visual_log_return_val_if_fail (bin != NULL, -1);

	visual_log (VISUAL_LOG_DEBUG, "starting sync");

	/* Sync the actor regarding morph */
	if (bin->morphing == TRUE && bin->morphstyle == VISUAL_SWITCH_STYLE_MORPH &&
			bin->actvideo->depth != VISUAL_VIDEO_DEPTH_GL &&
			bin->depthfromGL != TRUE) {
		visual_morph_set_video (bin->morph, bin->actvideo);
	
		video = bin->privvid;
		if (video == NULL) {
			visual_log (VISUAL_LOG_DEBUG, "Private video data NULL");
			return -1;
		}

		visual_video_free_buffer (video);
		visual_video_clone (video, bin->actvideo);

		visual_log (VISUAL_LOG_DEBUG, "pitches actvideo %d, new video %d", bin->actvideo->pitch, video->pitch);

		visual_log (VISUAL_LOG_DEBUG, "phase1 bin->privvid %p", bin->privvid);
		if (bin->actmorph->video->depth == VISUAL_VIDEO_DEPTH_GL) {
			visual_video_set_buffer (video, NULL);
			video = bin->actvideo;
		} else
			visual_video_allocate_buffer (video);
		
		visual_log (VISUAL_LOG_DEBUG, "phase2");
	} else {
		video = bin->actvideo;
		if (video == NULL) {
			visual_log (VISUAL_LOG_DEBUG, "Actor video is NULL");
			return -1;
		}

		visual_log (VISUAL_LOG_DEBUG, "setting new video from actvideo %d %d", video->depth, video->bpp);
	}

	/* Main actor */
/*	visual_actor_realize (bin->actor); */
	visual_actor_set_video (bin->actor, video);

	visual_log (VISUAL_LOG_DEBUG, "one last video pitch check %d depth old %d forcedmain %d noevent %d",
			video->pitch, bin->depthold,
			bin->depthforcedmain, noevent);

	if (bin->managed == TRUE) {
		if (bin->depthold == VISUAL_VIDEO_DEPTH_GL)
			visual_actor_video_negotiate (bin->actor, bin->depthforcedmain, FALSE, TRUE);
		else
			visual_actor_video_negotiate (bin->actor, bin->depthforcedmain, noevent, TRUE);
	} else {
		if (bin->depthold == VISUAL_VIDEO_DEPTH_GL)
			visual_actor_video_negotiate (bin->actor, 0, FALSE, TRUE);
		else
			visual_actor_video_negotiate (bin->actor, 0, noevent, FALSE);
	}
	
	visual_log (VISUAL_LOG_DEBUG, "pitch after main actor negotiate %d", video->pitch);

	/* Morphing actor */
	if (bin->actmorphmanaged == TRUE && bin->morphing == TRUE &&
			bin->morphstyle == VISUAL_SWITCH_STYLE_MORPH) {

		actvideo = bin->actmorphvideo;
		if (actvideo == NULL) {
			visual_log (VISUAL_LOG_DEBUG, "Morph video is NULL");
			return -1;
		}

		visual_video_free_buffer (actvideo);

		visual_video_clone (actvideo, video);

		if (bin->actor->video->depth != VISUAL_VIDEO_DEPTH_GL)
			visual_video_allocate_buffer (actvideo);

		visual_actor_realize (bin->actmorph);

		visual_log (VISUAL_LOG_DEBUG, "phase3 pitch of real framebuffer %d", bin->actvideo->pitch);
		if (bin->actmorphmanaged == TRUE)
			visual_actor_video_negotiate (bin->actmorph, bin->depthforced, FALSE, TRUE);
		else
			visual_actor_video_negotiate (bin->actmorph, 0, FALSE, FALSE);
	}

	visual_log (VISUAL_LOG_DEBUG, "end sync function");

	return 0;
}
示例#12
0
static GstStateChangeReturn
gst_visual_change_state (GstElement * element, GstStateChange transition)
{
  GstVisual *visual = GST_VISUAL (element);
  GstStateChangeReturn ret;

  switch (transition) {
    case GST_STATE_CHANGE_NULL_TO_READY:
      visual->actor =
          visual_actor_new (GST_VISUAL_GET_CLASS (visual)->plugin->
          info->plugname);
      visual->video = visual_video_new ();
      visual->audio = visual_audio_new ();
      /* can't have a play without actors */
      if (!visual->actor || !visual->video)
        goto no_actors;

      if (visual_actor_realize (visual->actor) != 0)
        goto no_realize;

      visual_actor_set_video (visual->actor, visual->video);
      break;
    case GST_STATE_CHANGE_READY_TO_PAUSED:
      gst_visual_reset (visual);
      break;
    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
      break;
    default:
      break;
  }

  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);

  switch (transition) {
    case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
      break;
    case GST_STATE_CHANGE_PAUSED_TO_READY:
      break;
    case GST_STATE_CHANGE_READY_TO_NULL:
      gst_visual_clear_actors (visual);
      break;
    default:
      break;
  }

  return ret;

  /* ERRORS */
no_actors:
  {
    GST_ELEMENT_ERROR (visual, LIBRARY, INIT, (NULL),
        ("could not create actors"));
    gst_visual_clear_actors (visual);
    return GST_STATE_CHANGE_FAILURE;
  }
no_realize:
  {
    GST_ELEMENT_ERROR (visual, LIBRARY, INIT, (NULL),
        ("could not realize actor"));
    gst_visual_clear_actors (visual);
    return GST_STATE_CHANGE_FAILURE;
  }
}
示例#13
0
int main (int argc, char **argv)
{
	SADisplay *display;
	VisVideo *video;

	VisInput *input;
	VisActor *actor;
	VisEventQueue *localqueue;
	VisVideoAttributeOptions *vidoptions;

	int running = TRUE;
	int fullscreen = FALSE;
	int visible = TRUE;

	int depth;

	//visual_mem_alloc_install_vtable (visual_mem_alloc_vtable_profile ());

	visual_init (&argc, &argv);

	display = display_new (sdl_driver_new ());

	/* Libvisual stuff */
	if (argc > 1)
		actor = visual_actor_new (argv[1]);
	else
		actor = visual_actor_new ("projectM");


	if (argc > 3) {
		depth = visual_video_depth_enum_from_value (atoi (argv[3]));
	} else
		depth = visual_video_depth_get_highest (visual_actor_get_supported_depth (actor));

	vidoptions = visual_actor_get_video_attribute_options (actor);

	display_create (display, depth, vidoptions, 480, 360, TRUE);

	visual_actor_realize (actor);

	video = display_get_video (display);

        visual_actor_set_video (actor, video);
	visual_actor_video_negotiate (actor, 0, FALSE, FALSE);

	if (argc > 2)
		input = visual_input_new (argv[2]);
	else
		input = visual_input_new ("alsa");

	visual_input_realize (input);

	localqueue = visual_event_queue_new ();

	while (running) {
		VisEventQueue *pluginqueue;
		VisEvent *ev;

		/* Handle all events */
		display_drain_events (display, localqueue);

		pluginqueue = visual_plugin_get_eventqueue (visual_actor_get_plugin (actor));
		while (visual_event_queue_poll_by_reference (localqueue, &ev)) {

			if (ev->type != VISUAL_EVENT_RESIZE)
				visual_event_queue_add (pluginqueue, ev);

			switch (ev->type) {
				case VISUAL_EVENT_RESIZE:
					video = display_get_video (display);
					visual_actor_set_video (actor, video);

					visual_actor_video_negotiate (actor, depth, FALSE, FALSE);
					break;

				case VISUAL_EVENT_MOUSEMOTION:
					break;

				case VISUAL_EVENT_MOUSEBUTTONDOWN:

					break;

				case VISUAL_EVENT_MOUSEBUTTONUP:
					break;

				case VISUAL_EVENT_KEYDOWN:
					switch (ev->event.keyboard.keysym.sym) {
						case VKEY_ESCAPE:
							running = FALSE;
							break;

						case VKEY_TAB:
							fullscreen = !fullscreen;

							display_set_fullscreen (display, fullscreen, TRUE);

							/* Resync video */
							video = display_get_video (display);
							visual_actor_set_video (actor, video);

							visual_actor_video_negotiate (actor, depth, FALSE, FALSE);

							break;

						default:
							printf ("key: %c\n", ev->event.keyboard.keysym.sym);
							break;
					}

					break;

				case VISUAL_EVENT_KEYUP:
					break;

				case VISUAL_EVENT_QUIT:
					running = FALSE;
					break;

				case VISUAL_EVENT_VISIBILITY:
					visible = ev->event.visibility.is_visible;
					break;

				default:
					break;
			}
		}

		if (visible == FALSE) {
			visual_input_run (input);

			visual_time_usleep (10000);

			continue;
		}

		/* Do a run cycle */
		visual_input_run (input);

		display_lock (display);
		visual_actor_run (actor, input->audio);
		display_unlock (display);

		display_update_all (display);

		display_fps_limit (display, 30);
	}

	/* Termination procedure */
	display_set_fullscreen (display, FALSE, TRUE);
	display_close (display);

	visual_quit ();

	//visual_mem_alloc_profile ();

	printf ("Total frames: %d, average fps: %f\n", display_fps_total (display), display_fps_average (display));

	return 0;
}
示例#14
0
static GstStateChangeReturn
gst_visual_gl_change_state (GstElement * element, GstStateChange transition)
{
  GstVisualGL *visual = GST_VISUAL_GL (element);
  GstStateChangeReturn ret;

  switch (transition) {
    case GST_STATE_CHANGE_NULL_TO_READY:
      break;
    case GST_STATE_CHANGE_READY_TO_PAUSED:
    {
      GstElement *parent = GST_ELEMENT (gst_element_get_parent (visual));
      GstStructure *structure = NULL;
      GstQuery *query = NULL;
      gboolean isPerformed = FALSE;
      gchar *name;

      if (!parent) {
        GST_ELEMENT_ERROR (visual, CORE, STATE_CHANGE, (NULL),
            ("A parent bin is required"));
        return FALSE;
      }

      name = gst_element_get_name (visual);
      structure = gst_structure_new (name, NULL);
      query = gst_query_new_application (GST_QUERY_CUSTOM, structure);
      g_free (name);

      isPerformed = gst_element_query (parent, query);

      if (isPerformed) {
        const GValue *id_value =
            gst_structure_get_value (structure, "gstgldisplay");
        if (G_VALUE_HOLDS_POINTER (id_value))
          /* at least one gl element is after in our gl chain */
          visual->display =
              gst_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value)));
        else {
          /* this gl filter is a sink in terms of the gl chain */
          visual->display = gst_gl_display_new ();
          gst_gl_display_create_context (visual->display, 0);
          //TODO visual->external_gl_context);
        }

        gst_visual_gl_reset (visual);

        visual->actor =
            visual_actor_new (GST_VISUAL_GL_GET_CLASS (visual)->plugin->info->
            plugname);
        visual->video = visual_video_new ();
        visual->audio = visual_audio_new ();

        if (!visual->actor || !visual->video)
          goto actor_setup_failed;

        gst_gl_display_thread_add (visual->display,
            (GstGLDisplayThreadFunc) actor_setup, visual);

        if (visual->actor_setup_result != 0)
          goto actor_setup_failed;
        else
          visual_actor_set_video (visual->actor, visual->video);
      }

      gst_query_unref (query);
      gst_object_unref (GST_OBJECT (parent));

      if (!isPerformed)
        return GST_STATE_CHANGE_FAILURE;
    }
      break;
    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
      break;
    default:
      break;
  }

  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);

  switch (transition) {
    case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
      break;
    case GST_STATE_CHANGE_PAUSED_TO_READY:
    {
      if (visual->fbo) {
        gst_gl_display_del_fbo (visual->display, visual->fbo,
            visual->depthbuffer);
        visual->fbo = 0;
        visual->depthbuffer = 0;
      }
      if (visual->midtexture) {
        gst_gl_display_del_texture (visual->display, visual->midtexture,
            visual->width, visual->height);
        visual->midtexture = 0;
      }
      if (visual->display) {
        gst_object_unref (visual->display);
        visual->display = NULL;
      }

      gst_visual_gl_clear_actors (visual);
    }
      break;
    case GST_STATE_CHANGE_READY_TO_NULL:
      break;
    default:
      break;
  }

  return ret;

  /* ERRORS */
actor_setup_failed:
  {
    GST_ELEMENT_ERROR (visual, LIBRARY, INIT, (NULL),
        ("could not set up actor"));
    gst_visual_gl_clear_actors (visual);
    return GST_STATE_CHANGE_FAILURE;
  }
}
示例#15
0
/* Main stuff */
int main (int argc, char *argv[])
{
	int width = 1000, height = 600;
	int i, j;
	int freeze = 0;
	int depthflag = 0;
	int alpha = 128;

	bpp = 4;
	sdl_init (width, height);

	scrbuf = malloc (screen->pitch * screen->h);
	memset (scrbuf, 0, screen->pitch * screen->h);

	SDL_Event event;

	visual_init (&argc, &argv);
	
	if (argc > 1)
		actor = visual_actor_new (argv[1]);
	else
		actor = visual_actor_new ("G-Force");

	visual_actor_realize (actor);

	video = visual_video_new ();
	
	visual_actor_set_video (actor, video);
	visual_video_set_depth (video, VISUAL_VIDEO_DEPTH_32BIT);
	visual_video_set_dimension (video, 256, 256);
	visual_video_allocate_buffer (video);

	visual_actor_video_negotiate (actor, 0, FALSE, FALSE);

	scalevid = visual_video_new ();
	visual_video_set_depth (scalevid, VISUAL_VIDEO_DEPTH_32BIT);
	visual_video_set_dimension (scalevid, 300, 400);
	visual_video_allocate_buffer (scalevid);

	sdlvid = visual_video_new ();
	visual_video_set_depth (sdlvid, VISUAL_VIDEO_DEPTH_32BIT);
	visual_video_set_dimension (sdlvid, screen->w, screen->h);
	visual_video_set_pitch (sdlvid, screen->pitch);
	visual_video_set_buffer (sdlvid, scrbuf);
	
	input = visual_input_new ("alsa");
	visual_input_realize (input);
	
	while (1) {
		visual_input_run (input);
		visual_actor_run (actor, input->audio);
		
		/* place on screen */
		visual_video_blit_overlay (sdlvid, video, 0, 0, FALSE);

		visual_video_set_palette (scalevid, visual_actor_get_palette (actor));	

		visual_video_scale (scalevid, video, VISUAL_VIDEO_SCALE_BILINEAR);

		visual_video_blit_overlay (sdlvid, scalevid, 256, 0, FALSE);

		sdl_draw_buf ();
		
		usleep (5000);
		
		while (SDL_PollEvent (&event)) {
			switch (event.type) {
				case SDL_KEYDOWN:
					switch (event.key.keysym.sym) {
						case SDLK_F11:
							sdl_fullscreen_toggle ();
							break;

						case SDLK_q:
							alpha -= 8;
							if (alpha < 0)
								alpha = 0;

							break;

						case SDLK_a:
							alpha += 8;
							if (alpha > 255)
								alpha = 255;

							break;
						
						case SDLK_ESCAPE:
							goto out;
							break;
					}
					break;

				case SDL_VIDEORESIZE:
					sdl_size_request (event.resize.w, event.resize.h);
					break;

				case SDL_QUIT:
					goto out;
					break;
			}
		}
	}
out:
	SDL_Quit ();
}