Exemple #1
0
bool
XineEngine::init()
{
   DEBUG_BLOCK

   debug() << "'Bringing joy to small mexican gerbils, a few weeks at a time.'\n";

   m_xine = xine_new();

   if( !m_xine ) {
      KMessageBox::error( 0, i18n("Pana could not initialize xine.") );
      return false;
   }

   #ifdef XINE_SAFE_MODE
   xine_engine_set_param( m_xine, XINE_ENGINE_PARAM_VERBOSITY, 99 );
   #endif

   xine_config_load( m_xine, configPath() );
   debug() << "w00t" << configPath() << endl;

   xine_init( m_xine );

   makeNewStream();

   #ifndef XINE_SAFE_MODE
   startTimer( 200 ); //prunes the scope
   #endif

   return true;
}
Exemple #2
0
        ReaderWriterXine()
        {
            supportsExtension("avi","");
            supportsExtension("db","");
            supportsExtension("ogv","");
            supportsExtension("flv","");
            supportsExtension("mov","");
            supportsExtension("m4v","");
            supportsExtension("mpg","Mpeg movie format");
            supportsExtension("mpv","Mpeg movie format");
            supportsExtension("wmv","");
            supportsExtension("xine","Xine plugin Pseduo plugin");

            _xine = xine_new();

            const char* user_home = xine_get_homedir();
            if(user_home)
            {
                std::string configFile(std::string(user_home)+"/.xine/config");
                xine_config_load(_xine, configFile.c_str());
            }

            xine_init(_xine);

            register_rgbout_plugin(_xine);
        }
Exemple #3
0
static int
Xine_PyObject__init(Xine_PyObject *self, PyObject *args, PyObject *kwds)
{
    char cfgfile[PATH_MAX];
    xine_t *xine;

    xine = xine_new();

    if (!xine) {
        PyErr_SetString(PyExc_RuntimeError, "Unknown error creating Xine object");
        return -1;
    }

    snprintf(cfgfile, PATH_MAX, "%s%s", xine_get_homedir(), "/.xine/config");
    xine_config_load(xine, cfgfile);
    xine_init(xine);
    xine_register_plugins(xine, xine_vo_kaa_plugin_info);
    xine_register_plugins(xine, xine_vo_dummy_plugin_info);
    // xine_register_plugins(xine, xine_vo_shm_plugin_info);
    self->xine = xine;
    xine_object_to_pyobject_register(xine, (PyObject *)self);

    // This isn't implemented in xine yet.
    //xine_register_log_cb(xine, _xine_log_callback, self);

    return 0;
}
Exemple #4
0
void Xine::init(){

  /* make sure options are loaded and updated */
  xine = xine_new();
  configfile = xine_get_homedir();
  configfile += "/.xine/config";
  S_Global::get_instance()->register_reconfigure(boost::bind(&AudioPlayer::reconfigure, this));
  xine_config_load(xine, configfile.c_str());
  xine_init(xine);
  cd_manager = S_Cd::get_instance();
  cd_device = cd_manager->get_device();
  make_new_stream();
  /* start run thread */
  pthread_create(&thread_loop, NULL, (void *(*)(void *))(pre_run), this);
  }
Exemple #5
0
void
music_init ()
{
    char *configfile;

    if (!xine_check_version (XINE_MAJOR_VERSION, XINE_MINOR_VERSION,
                             XINE_SUB_VERSION)) {
        g_critical (_("Incompatible version of Xine-lib found."));
        exit (EXIT_FAILURE);
    }

    xine = xine_new ();

    configfile = g_build_filename (g_get_home_dir (), ".xine", "config", NULL);
    xine_config_load (xine, configfile);
    g_free (configfile);

    xine_init (xine);

    if (!(ao = xine_open_audio_driver (xine, NULL, NULL))) {
        g_critical (_("Unable to open audio driver from Xine."));
        exit (EXIT_FAILURE);
    }

    if (!(vo = xine_open_video_driver (xine, NULL, XINE_VISUAL_TYPE_NONE,
                                       NULL))) {
        g_critical (_("Unable to open video driver from Xine."));
        exit (EXIT_FAILURE);
    }

    if (!(stream = xine_stream_new (xine, ao, vo))) {
        g_critical (_("Unable to open a Xine stream."));
        exit (EXIT_FAILURE);
    }

    events = xine_event_new_queue (stream);
    xine_event_create_listener_thread (events, music_events, NULL);
}
Exemple #6
0
static int icvOpenAVI_XINE( CvCaptureAVI_XINE* capture, const char* filename )
{
#ifndef NDEBUG
    fprintf( stderr, "(DEBUG) icvOpenAVI_XINE ... start\n" );
#endif

    char configfile[ 2048 ];

    capture->xine = xine_new();
    sprintf( configfile, "%s%s", xine_get_homedir(), "/.xine/config" );

    xine_config_load( capture->xine, configfile );
    xine_init( capture->xine );

    xine_engine_set_param( capture->xine, 0, 0 );
    capture->vo_port = xine_new_framegrab_video_port( capture->xine );
    if ( capture->vo_port == NULL )
    {
        printf( "(ERROR)icvOpenAVI_XINE(): Unable to initialize video driver.\n" );
        return 0;
    }

    capture->stream = xine_stream_new( capture->xine, NULL, capture->vo_port );

    if ( !xine_open( capture->stream, filename ) )
    {
        printf( "(ERROR)icvOpenAVI_XINE(): Unable to open source '%s'\n", filename );
        return 0;
    }
    // reset stream...
    xine_play( capture->stream, 0, 0 );


    // initialize some internals...
    capture->frame_number = 0;

    if ( !xine_get_next_video_frame( capture->vo_port, &capture->xine_frame ) )
    {
#ifndef NDEBUG
        fprintf( stderr, "(DEBUG) icvOpenAVI_XINE ... failed!\n" );
#endif
        return 0;
    }

    capture->size = cvSize( capture->xine_frame.width, capture->xine_frame.height );
    capture->yuv_frame = cvCreateImage( capture->size, IPL_DEPTH_8U, 3 );
    capture->bgr_frame = cvCreateImage( capture->size, IPL_DEPTH_8U, 3 );

    xine_free_video_frame( capture->vo_port, &capture->xine_frame );
    capture->xine_frame.data[ 0 ] = 0;

    icvCheckSeekAVI_XINE( capture );

    capture->frame_duration = xine_get_stream_info( capture->stream, XINE_STREAM_INFO_FRAME_DURATION ) / 90.;
    capture->frame_rate = 1000 / capture->frame_duration;

#ifndef NDEBUG
    fprintf( stderr, "(DEBUG) frame_duration = %f, framerate = %f\n", capture->frame_duration, capture->frame_rate );
#endif

    OPENCV_ASSERT ( capture->yuv_frame,
                        "icvOpenAVI_XINE( CvCaptureAVI_XINE *, const char *)", "couldn't create yuv frame");

    OPENCV_ASSERT ( capture->bgr_frame,
                        "icvOpenAVI_XINE( CvCaptureAVI_XINE *, const char *)", "couldn't create bgr frame");

#ifndef NDEBUG
    fprintf( stderr, "(DEBUG) icvOpenAVI_XINE ... end\n" );
#endif
    return 1;
}
static Epsilon_Image *
epsilon_generate_thumb (Epsilon * e)
{
  int ret = XINE_THUMB_SUCCESS;
  Epsilon_Image *img = NULL;
  unsigned char *buf = NULL;
  int cnt, attempts = 0, length = -1, pos_perc, pos_time, new_perc, new_time,
  req_perc = 500, req_time = 500;
  static int old_length = -1;
  char cfg[PATH_MAX];
  epsilon_xine_param *param;

  param = calloc (1, sizeof (epsilon_xine_param));
  if (!(param->xine = xine_new ()))
    {
      return NULL;
    }
  snprintf (cfg, PATH_MAX, "%s%s", xine_get_homedir (), ".xine/config");
  xine_config_load (param->xine, cfg);
  xine_init (param->xine);

  /* opening xine output ports */
  if (!
      (param->vo_port =
       xine_open_video_driver (param->xine, "none", XINE_VISUAL_TYPE_NONE,
			       (void *) NULL)))
    {
      goto done;
    }

  param->ao_port = xine_open_audio_driver (param->xine, "none", NULL);

  /* open a xine stream connected to these ports */
  if (!
      (param->stream =
       xine_stream_new (param->xine, param->ao_port, param->vo_port)))
    {
      goto done;
    }


  if (!xine_open (param->stream, e->src))
    {
      ret = XINE_THUMB_FAIL;
      goto done;
    }

    if (XINE_THUMBNAILER_DEBUG) printf("Starting xine thumbnail process..\n");

try_get_chance:
  new_perc = -1;
  new_time = req_time;

  if (!xine_play (param->stream, 0, new_time))
    {
      new_time = -1;
      new_perc = req_perc;	/* 0..65535 */
      if (!xine_play (param->stream, new_perc, 0))
	{
	  ret = XINE_THUMB_FAIL;
	  if (XINE_THUMBNAILER_DEBUG) printf("Coudln't play video %s..\n", e->src);
	  goto close_stream;
	}
    }

  /* get position */
  for (cnt = 0; ((cnt < 50) &&
		 (!xine_get_pos_length
		  (param->stream, &pos_perc, &pos_time, &length)
		  || (length == old_length))); cnt++)
    usleep (1000);

  if (length < 0)
    {
      if (XINE_THUMBNAILER_DEBUG) printf("Video is 0 length!..\n");
      ret = XINE_THUMB_FAIL;
      goto close_stream;
    }

  /* wait till position changes */
  for (cnt = 0;
       (cnt < 50) &&
       (!xine_get_pos_length (param->stream, &new_perc, &new_time, &length) ||
	((new_perc == pos_perc) && (new_time == pos_time))); cnt++)
    {
      usleep (1000);
    }

  /* get snapshot */
  int w, h, ratio, format;

  old_length = length;

  /* ask what size a snapshot would be (if we can make one) */
  if (!xine_get_current_frame (param->stream, &w, &h, &ratio, &format, NULL))
    {
      attempts++;
      if (attempts < 10)
	{
	  if (req_time < 10000)
	    req_time += 1000;
	  if (req_perc < 10000)
	    req_perc += 1000;
	  goto try_get_chance;

	}
      else
	{
	  if (XINE_THUMBNAILER_DEBUG) printf("Exhausted attempts to thumbnail..\n");
	  ret = XINE_THUMB_FAIL;
	  goto close_stream;
	}
    }
  else if ((w <= 0) || (h <= 0))
    {
      if (XINE_THUMBNAILER_DEBUG) printf("Width/Height of video invalid: %d:%d..\n", w,h);
      ret = XINE_THUMB_FAIL;
      goto close_stream;
    }
  else
    {
      /* know we know the size, get a buffer for the snapshot */
      if (!(buf = malloc (w * h * 2)))
	{
	  if (XINE_THUMBNAILER_DEBUG) printf("Couldn't allocate memory for thumbnail buffer..\n");
	  ret = XINE_THUMB_FAIL;
	  goto close_stream;
	}

      /* make a snapshot! */
      if (!xine_get_current_frame
	  (param->stream, &w, &h, &ratio, &format, buf))
	{
	  if (XINE_THUMBNAILER_DEBUG) printf("Couldn't retrieve current video frame..\n");
	  ret = XINE_THUMB_FAIL;
	  goto close_stream;
	}

      else if ((w <= 0) || (h <= 0))
	{
	  if (XINE_THUMBNAILER_DEBUG) printf("Width/height of video invalid: %d:%d..\n",w,h);
	  ret = XINE_THUMB_FAIL;
	  goto close_stream;
	}

      if (format == XINE_IMGFMT_YUY2)
	{
	  unsigned char *buf2 = malloc (w * h * 2);
	  unsigned char *tmp = buf;
	  i_yuy2_to_yv12 (buf, buf2, w, h);

	  buf = buf2;
	  free (tmp);

	  format = XINE_IMGFMT_YV12;
	}

      if (format == XINE_IMGFMT_YV12)
	{
	  ret = yv12_to_rgb (e->src, w, h, &buf, &img);

	  if (ret != XINE_THUMB_SUCCESS)
	    {
	      if (img)
		{
		  if (++attempts > 10)
		    goto close_stream;
		  free(img->data);
		  free(img);
		  img = NULL;
		  if (ret == XINE_THUMB_RETRY)
		    {
		      if (buf)
			{
			  free (buf);
			  buf = NULL;
			  if ((req_perc += (attempts * 1000)) > 65535)
			    req_perc = 1000;
			  if ((req_time += (attempts * 2500)) > length)
			    req_time = 3000;
			  goto try_get_chance;
			}

	              if (XINE_THUMBNAILER_DEBUG) printf("Exhausted attempts to thumbnail pos 2..\n");
		      ret = XINE_THUMB_FAIL;
		      goto close_stream;
		    }
		}

	      else
		{
		  if (XINE_THUMBNAILER_DEBUG) printf("Couldn't complete yv12_to_rgb..\n");
		  ret = XINE_THUMB_FAIL;
		  goto close_stream;
		}
	    }
	}

      ret = XINE_THUMB_SUCCESS;

    close_stream:
      if (buf)
	{
	  free (buf);
	  buf = NULL;
	}
      xine_close (param->stream);

    done:
      if (ret != XINE_THUMB_SUCCESS)
	{
	  if (img)
	    {
	      free(img->data);
	      free(img);
	      img = NULL;
	    }
	}

      if (param->stream)
	{
	  xine_dispose (param->stream);
	  param->stream = NULL;
	}
      if (param->ao_port)
	{
	  xine_close_audio_driver (param->xine, param->ao_port);
	  param->ao_port = NULL;
	}
      if (param->vo_port)
	{
	  xine_close_video_driver (param->xine, param->vo_port);
	  param->vo_port = NULL;
	}

      free (param);

      return img;
    }
   return NULL;
}