Пример #1
0
SMActionVideoVLC::SMActionVideoVLC(QWidget *parent):
    SMAction(parent)
{
    poller = new QTimer(0);
    connect(poller, SIGNAL(timeout()), SLOT(slotTimeout()));

    //preparation of the vlc command
    const char * const vlc_args[] = {
              "--verbose=2", //be much more verbose then normal for debugging purpose
    };
    _vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);

    // Create a media player playing environement
    _mp = libvlc_media_player_new (_vlcinstance);
    _m = NULL;

    setRepeat(0);
    setVolume(1.0);

    getContextMenu()->addSeparator();
    QAction* setRepeatAction = getContextMenu()->addAction("set repeat");
    connect(setRepeatAction, SIGNAL(triggered(bool)), SLOT(slotSetRepeat()));

    QAction* setVolumeAction = getContextMenu()->addAction("set volume");
    connect(setVolumeAction, SIGNAL(triggered(bool)), SLOT(slotSetVolume()));
}
Пример #2
0
void NPlaybackEngineVlc::init()
{
    int argc;
    const char **argv;
    NCore::cArgs(&argc, &argv);

    QVector<const char *> argVector;
    for (int i = 0; i < argc; ++i)
        argVector << argv[i];

    argVector << "-I" << "dummy"
              << "--ignore-config"
              << "--no-xlib";

    m_vlcInstance = libvlc_new(argVector.size(), &argVector[0]);
    m_mediaPlayer = libvlc_media_player_new(m_vlcInstance);
    m_eventManager = libvlc_media_player_event_manager(m_mediaPlayer);
    libvlc_event_attach(m_eventManager, libvlc_MediaPlayerEndReached, _eventHandler, this);

    m_oldVolume = -1;
    m_oldPosition = -1;
    m_oldState = N::PlaybackStopped;

    m_timer = new QTimer(this);
    connect(m_timer, SIGNAL(timeout()), this, SLOT(checkStatus()));
    m_timer->start(100);

    m_init = true;
}
Пример #3
0
	VLCWrapper::VLCWrapper (QObject *parent)
	: QObject (parent)
	, CurrentItem_ (-1)
	, IsPlayedFromQueue_ (false)
	{
		Instance_ = libvlc_instance_ptr (libvlc_new (sizeof (vlc_args)
				/ sizeof (vlc_args[0]), vlc_args), libvlc_release);
		LPlayer_ = libvlc_media_list_player_ptr (libvlc_media_list_player_new (Instance_.get ()),
				libvlc_media_list_player_release);
		Player_ = libvlc_media_player_ptr (libvlc_media_player_new (Instance_.get ()),
				libvlc_media_player_release);
		List_ = libvlc_media_list_ptr (libvlc_media_list_new (Instance_.get ()),
				libvlc_media_list_release);

		libvlc_media_list_player_set_media_player (LPlayer_.get (), Player_.get ());
		libvlc_media_list_player_set_media_list (LPlayer_.get (), List_.get ());

		auto listEventManager = libvlc_media_list_player_event_manager (LPlayer_.get ());
		libvlc_event_attach (listEventManager, libvlc_MediaListPlayerNextItemSet,
				ListEventCallback, this);

		auto playerEventManager = libvlc_media_player_event_manager (Player_.get ());
		libvlc_event_attach (playerEventManager, libvlc_MediaPlayerPlaying,
				ListEventCallback, this);

		libvlc_event_attach (playerEventManager, libvlc_MediaPlayerStopped,
				ListEventCallback, this);
		libvlc_event_attach (playerEventManager, libvlc_MediaPlayerPaused,
				ListEventCallback, this);
		libvlc_event_attach (playerEventManager, libvlc_MediaPlayerEndReached,
				ListEventCallback, this);
	}
Пример #4
0
VlcMediaPlayer::VlcMediaPlayer(VlcInstance *instance)
    : QObject(instance)
{
    _vlcMediaPlayer = libvlc_media_player_new(instance->core());
    _vlcEvents = libvlc_media_player_event_manager(_vlcMediaPlayer);

    /* Disable mouse and keyboard events */
    libvlc_video_set_key_input(_vlcMediaPlayer, false);
    libvlc_video_set_mouse_input(_vlcMediaPlayer, false);

    VlcError::showErrmsg();

    _vlcAudio = new VlcAudio(this);
    _vlcVideo = new VlcVideo(this);
#if LIBVLC_VERSION >= 0x020200
    _vlcEqualizer = new VlcEqualizer(this);
#endif

    _videoWidget = 0;
    _media = 0;

    createCoreConnections();

    VlcError::showErrmsg();
}
Пример #5
0
bool VlcMediaWidget::init()
{
	const char *arguments[] = { "--no-video-title-show" };
	vlcInstance = libvlc_new(sizeof(arguments) / sizeof(arguments[0]), arguments);

	if (vlcInstance == NULL) {
		Log("VlcMediaWidget::init: cannot create vlc instance") << QLatin1String(libvlc_errmsg());
		return false;
	}

	vlcMediaPlayer = libvlc_media_player_new(vlcInstance);

	if (vlcMediaPlayer == NULL) {
		Log("VlcMediaWidget::init: cannot create vlc media player") << QLatin1String(libvlc_errmsg());
		return false;
	}

	libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager(vlcMediaPlayer);
	libvlc_event_e eventTypes[] = { libvlc_MediaPlayerEncounteredError,
		libvlc_MediaPlayerEndReached, libvlc_MediaPlayerLengthChanged,
		libvlc_MediaPlayerSeekableChanged, libvlc_MediaPlayerStopped,
		libvlc_MediaPlayerTimeChanged };

	for (uint i = 0; i < (sizeof(eventTypes) / sizeof(eventTypes[0])); ++i) {
		if (libvlc_event_attach(eventManager, eventTypes[i], vlcEventHandler, this) != 0) {
			Log("VlcMediaWidget::init: cannot attach event handler") << eventTypes[i];
			return false;
		}
	}

	libvlc_media_player_set_xwindow(vlcMediaPlayer, quint32(winId()));
	setAttribute(Qt::WA_NativeWindow);
	setAttribute(Qt::WA_PaintOnScreen);
	return true;
}
Пример #6
0
VlcVideoPlayer::VlcVideoPlayer(wxWindow* win, const VideoID& id, wxPoint pt, wxSize size)
    : wxPanel(win, wxID_ANY, pt, size), videoID_(id), firstPlay_(1)
{
	SetBackgroundColour(axColor(0, 0, 0));

	_DEBUG_ nb_time_callback = 0;

    // Create new VLC instance.
    char const* vlcOptions[] = {"--no-video-title-show"}; //Hide filename.

	vlcInstance = NULL;
	vlcPlayer = NULL;

    // Create VLC instance
	vlcInstance = libvlc_new(1, vlcOptions);

    if( vlcInstance )
	{
		vlcPlayer = libvlc_media_player_new(vlcInstance);

		// Create VLC player
		if( vlcPlayer )
		{
			// Create VLC EventManager
			vlcEventManager = libvlc_media_player_event_manager(vlcPlayer);

			if( !vlcEventManager )
			{
				_DEBUG_ DSTREAM << "Can't create VLC Event Manager" << endl;
				wxMessageDialog (this, "Can't create VLC Event Manager");
			}
		}
		else // vlcPlayer
		{
			_DEBUG_ DSTREAM << "Can't create player from vlcMedia" << endl;
			wxMessageDialog (this, "Can't create player from vlcMedia");
		}
	}

    else // vlcInstance.
	{
		_DEBUG_ DSTREAM << "Can't Open VLC instance" << endl;
		wxMessageDialog (this, "Can't Open VLC instance");
	}

    // libVLC events and callback
	if( vlcInstance && vlcPlayer && vlcEventManager )
	{
		libvlc_event_attach(vlcEventManager, 
							libvlc_MediaPlayerPositionChanged, 
							VlcVideoPlayer::vlcPositionChanged, 
							this);
		
		libvlc_event_attach(vlcEventManager, 
							libvlc_MediaPlayerTimeChanged, 
							VlcVideoPlayer::vlcTimeChanged, 
							this);
	}
}
Пример #7
0
CameraWnd::CameraWnd()
: QWidget()
{
    setMinimumSize( 160, 120 );
    //preparation of the vlc command
    const char * const vlc_args[] = {
              "-I", "dummy", /* Don't use any interface */
              "--ignore-config", /* Don't use VLC's config */
              "--extraintf=logger", //log anything
              "--verbose=2", //be much more verbose then normal for debugging purpose
              "--plugin-path=./plugins/" };

#ifdef Q_WS_X11
    _videoWidget=new QX11EmbedContainer(this);
#else
    _videoWidget=new QFrame(this);
#endif
    // [20101215 JG] If KDE is used like unique desktop environment, only use _videoWidget=new QFrame(this);

    _volumeSlider=new QSlider(Qt::Horizontal,this);
    _volumeSlider->setMaximum(100); //the volume is between 0 and 100
    _volumeSlider->setToolTip("Audio slider");
    _volumeSlider->setVisible( false );

    // Note: if you use streaming, there is no ability to use the position slider
    _positionSlider=new QSlider(Qt::Horizontal,this);
    _positionSlider->setMaximum(POSITION_RESOLUTION);
    _positionSlider->setVisible( false );

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(_videoWidget);
    layout->addWidget(_positionSlider);
    layout->addWidget(_volumeSlider);
    setLayout(layout);

    _isPlaying=false;
    poller=new QTimer(this);

    //Initialize an instance of vlc
    //a structure for the exception is neede for this initalization
    //libvlc_exception_init(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    //create a new libvlc instance
    _vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);  //tricky calculation of the char space used
    //_vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args,&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //raise (&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    // Create a media player playing environement
    _mp = libvlc_media_player_new (_vlcinstance);
    //_mp = libvlc_media_player_new (_vlcinstance, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //raise (&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    //connect the two sliders to the corresponding slots (uses Qt's signal / slots technology)
    connect(poller, SIGNAL(timeout()), this, SLOT(updateInterface()));
    connect(_positionSlider, SIGNAL(sliderMoved(int)), this, SLOT(changePosition(int)));
    connect(_volumeSlider, SIGNAL(sliderMoved(int)), this, SLOT(changeVolume(int)));

    poller->start(100); //start timer to trigger every 100 ms the updateInterface slot
}
Player::Player()
: QWidget()
{
    //preparation of the vlc command
    const char * const vlc_args[] = {
      "--sout=#transcode{vcodec=DIV3,vb=800,scale=1,acodec=mp3,ab=128,channels=2,samplerate=44100}:duplicate{dst=http{mux=asf,dst=:8983/},dst=display}",// to stream video with codec div3 & mp3 on port number 8983
              "--sout-keep",
      "sout-all"}; //output each stream

//#ifdef Q_WS_X11
   // _videoWidget=new QX11EmbedContainer(this);
//#else
    _videoWidget=new QFrame(this);
//#endif
    // [20101215 JG] If KDE is used like unique desktop environment, only use _videoWidget=new QFrame(this);

    _volumeSlider=new QSlider(Qt::Horizontal,this);
    _volumeSlider->setMaximum(100); //the volume is between 0 and 100
    _volumeSlider->setToolTip("Audio slider");

    // Note: if you use streaming, there is no ability to use the position slider
    _positionSlider=new QSlider(Qt::Horizontal,this);
    _positionSlider->setMaximum(POSITION_RESOLUTION);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(_videoWidget);
    layout->addWidget(_positionSlider);
    layout->addWidget(_volumeSlider);
    setLayout(layout);

    _isPlaying=false;
    poller=new QTimer(this);

    //Initialize an instance of vlc
    //a structure for the exception is neede for this initalization
    //libvlc_exception_init(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    //create a new libvlc instance
    _vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);  //tricky calculation of the char space used
    //_vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args,&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //raise (&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    // Create a media player playing environement
    _mp = libvlc_media_player_new (_vlcinstance);
    //_mp = libvlc_media_player_new (_vlcinstance, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //raise (&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    //connect the two sliders to the corresponding slots (uses Qt's signal / slots technology)
    connect(poller, SIGNAL(timeout()), this, SLOT(updateInterface()));
    connect(_positionSlider, SIGNAL(sliderMoved(int)), this, SLOT(changePosition(int)));
    connect(_volumeSlider, SIGNAL(sliderMoved(int)), this, SLOT(changeVolume(int)));

    poller->start(100); //start timer to trigger every 100 ms the updateInterface slot
}
Пример #9
0
/**************************************************************************
 * Create a Media Instance object with a media descriptor.
 **************************************************************************/
libvlc_media_player_t *
libvlc_media_player_new_from_media( libvlc_media_t * p_md )
{
    libvlc_media_player_t * p_mi;

    p_mi = libvlc_media_player_new( p_md->p_libvlc_instance );
    if( !p_mi )
        return NULL;

    libvlc_media_retain( p_md );
    p_mi->p_md = p_md;

    return p_mi;
}
void
Java_org_videolan_libvlc_MediaPlayer_nativeNewFromLibVlc(JNIEnv *env,
                                                         jobject thiz,
                                                         jobject libvlc,
                                                         jobject jwindow)
{
    vlcjni_object *p_obj = VLCJniObject_newFromJavaLibVlc(env, thiz, libvlc);
    if (!p_obj)
        return;

    /* Create a media player playing environment */
    p_obj->u.p_mp = libvlc_media_player_new(p_obj->p_libvlc);
    MediaPlayer_newCommon(env, thiz, p_obj, jwindow);
}
Пример #11
0
bool	VLCAudioPlayer::init(QStringList opt)
{
	handleOption(opt);
	const char * const vlc_args[] = {
              "-I", "dummy", "-A", optionValue["ao"].toString().toStdString().c_str(), /* Don't use any interface */
             "--ignore-config", "--no-video"}; /* Don't use VLC's config */

	libvlc_event_manager_t	*em;
	libvlc_exception_init(&vlc_ex);
	inst = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args, &vlc_ex);
	mediaPlayer = libvlc_media_player_new(inst, &vlc_ex);
	em = libvlc_media_player_event_manager(mediaPlayer, &vlc_ex);
	return true;
}
Пример #12
0
VLCWrapperImpl::VLCWrapperImpl(void)
:	m_pVLCInstance(0),
	m_pMediaPlayer(0),
	m_pMedia(0),
    m_pEvtManager(0),
    m_EH(0),
    m_EvtH(0)
{
	const char * const vlc_args[] = {
		"-I", "dummy",     // No special interface
		"--ignore-config", // Don't use VLC's config
		"--plugins-cache",
		"--no-reset-plugins-cache",
		"--plugin-path=./plugins",
#if defined(WIN32)
		"--one-instance", 
#endif
		"--ts-es-id-pid",
		"--video-on-top",
		"--vout-event=3",
		"--no-video-title-show",
		"--embedded-video",
		"--video-x=0",
		"--video-y=0",
		"--width=1", 
		"--height=1",
		"--scale=1.0",
		"--no-video-deco",
		"--video-title=VLC/VIDEO",
		"--loop",
		};

    // init the exception object.
	libvlc_exception_init (&m_VLCex);

	// init vlc modules, should be done only once
	m_pVLCInstance = libvlc_new (sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args, &m_VLCex);
    ProcessVLCException(&m_VLCex, m_EH);

    // Create a media player playing environement
    m_pMediaPlayer = libvlc_media_player_new(m_pVLCInstance, &m_VLCex);
    ProcessVLCException(&m_VLCex, m_EH);

    // Create an event manager for the player for handling e.g. time change events
    m_pEvtManager=libvlc_media_player_event_manager(m_pMediaPlayer, &m_VLCex);
    ProcessVLCException(&m_VLCex, m_EH);
}
Пример #13
0
void VLCPlayer::init(VLCHandler * handler) {
    VLCPlayer::mutex.lock();

    VLCPlayer::handler = handler;


    if (VLCPlayer::inst != NULL) {
        qDebug() << "VLCPlayer already initialized !";
        VLCPlayer::mutex.unlock();
        return ;
    }

    char smem_options[1000];

    // VLC options
    sprintf(smem_options
            , "#transcode{vcodec=I444,acodec=s16l}:smem{"
            "video-prerender-callback=%lld,"
            "video-postrender-callback=%lld,"
            "audio-prerender-callback=%lld,"
            "audio-postrender-callback=%lld,"
            "audio-data=%lld,"
            "video-data=%lld},"
            , (long long int)(intptr_t)(void*)&VLCPlayer::cbVideoPrerender
            , (long long int)(intptr_t)(void*)&VLCPlayer::cbVideoPostrender
            , (long long int)(intptr_t)(void*)&VLCPlayer::cbAudioPrerender
            , (long long int)(intptr_t)(void*)&VLCPlayer::cbAudioPostrender
            , (long long int)100		//This would normally be useful data, 100 is just test data
            , (long long int)200);	//Test data

    const char * const vlc_args[] = {
        "-I", "dummy", // Don't use any interface
        "--ignore-config", // Don't use VLC's config
        "--extraintf=logger", // Log anything
        "--verbose=1", // Be verbose
        "--sout", smem_options // Stream to memory
    };

    //initialize the VLC context
    VLCPlayer::inst = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);

    //Generate a new Media Player
    VLCPlayer::media_player = libvlc_media_player_new(VLCPlayer::inst);

    VLCPlayer::mutex.unlock();
}
Пример #14
0
/**************************************************************************
 *         new (Public)
 **************************************************************************/
libvlc_media_list_player_t *
libvlc_media_list_player_new(libvlc_instance_t * p_instance)
{
    libvlc_media_list_player_t * p_mlp;
    p_mlp = calloc( 1, sizeof(libvlc_media_list_player_t) );
    if (unlikely(p_mlp == NULL))
    {
        libvlc_printerr("Not enough memory");
        return NULL;
    }

    p_mlp->i_refcount = 1;
    p_mlp->seek_offset = 0;
    vlc_mutex_init(&p_mlp->object_lock);
    vlc_mutex_init(&p_mlp->mp_callback_lock);
    vlc_cond_init(&p_mlp->seek_pending);

    p_mlp->p_event_manager = libvlc_event_manager_new(p_mlp);
    if (unlikely(p_mlp->p_event_manager == NULL))
        goto error;

    /* Create the underlying media_player */
    p_mlp->p_mi = libvlc_media_player_new(p_instance);
    if( p_mlp->p_mi == NULL )
    {
        libvlc_event_manager_release(p_mlp->p_event_manager);
        goto error;
    }
    install_media_player_observer(p_mlp);

    if (vlc_clone(&p_mlp->thread, playlist_thread, p_mlp,
                  VLC_THREAD_PRIORITY_LOW))
    {
        libvlc_media_player_release(p_mlp->p_mi);
        libvlc_event_manager_release(p_mlp->p_event_manager);
        goto error;
    }

    return p_mlp;
error:
    vlc_cond_destroy(&p_mlp->seek_pending);
    vlc_mutex_destroy(&p_mlp->mp_callback_lock);
    vlc_mutex_destroy(&p_mlp->object_lock);
    free(p_mlp);
    return NULL;
}
Пример #15
0
mediacontrol_Instance* mediacontrol_new( int argc, char** argv, mediacontrol_Exception *exception )
{
    mediacontrol_Instance* retval;
    libvlc_exception_t ex;

    libvlc_exception_init( &ex );
    mediacontrol_exception_init( exception );

    retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
    if( !retval )
        RAISE_NULL( mediacontrol_InternalException, "Out of memory" );

    retval->p_instance = libvlc_new( argc, (const char**)argv, &ex );
    HANDLE_LIBVLC_EXCEPTION_NULL( &ex );
    retval->p_media_player = libvlc_media_player_new( retval->p_instance, &ex );
    HANDLE_LIBVLC_EXCEPTION_NULL( &ex );
    return retval;
}
Пример #16
0
VlcMediaPlayer::VlcMediaPlayer(VlcInstance *instance)
    : QObject(instance)
{
    _vlcMediaPlayer = libvlc_media_player_new(instance->core());

    /* Disable mouse and keyboard events */
    libvlc_video_set_key_input(_vlcMediaPlayer, false);
    libvlc_video_set_mouse_input(_vlcMediaPlayer, false);

    VlcError::errmsg();

    _vlcAudio = new VlcAudio(this);
    _vlcVideo = new VlcVideo(this);

    _check = new QTimer(this);
    connect(_check, SIGNAL(timeout()), this, SLOT(emitStatus()));
    _check->start(300);
}
Пример #17
0
    VLCVideoWidgetDelegator::VLCVideoWidgetDelegator()
      :m_widgetInstance( Nullptr )
      ,m_instance( Nullptr )
      ,m_player( Nullptr )
      ,m_currentMedia( Nullptr )
      ,m_hasPaused( false )
      ,m_isPlaying( false ){ 

      const char * const vlc_args[] = {
      "--plugin-path=plugins\\"
      };

      m_instance= libvlc_new( sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args );

      if( m_instance != Nullptr ){
        m_player = libvlc_media_player_new (m_instance);
      }
    }
Пример #18
0
 VLCImageStream( const char* const* vlc_argv=0 )
 :   osg::ImageStream(), _vlcMedia(0)
 {
     if ( !vlc_argv )
     {
         const char* vlc_args[] = {
             "--ignore-config",      // don't use VLC's config
             "--data-path="VLC_PLUGIN_PATH
         };
         _vlc = libvlc_new( sizeof(vlc_args)/sizeof(vlc_args[0]), vlc_args );
     }
     else
         _vlc = libvlc_new( sizeof(vlc_argv)/sizeof(vlc_argv[0]), vlc_argv );
     _vlcPlayer = libvlc_media_player_new( _vlc );
     
     libvlc_event_attach( libvlc_media_player_event_manager(_vlcPlayer), libvlc_MediaPlayerStopped,
                          &VLCImageStream::videoEndFunc, this );
     _status = INVALID;
 }
Пример #19
0
mediacontrol_Instance *
mediacontrol_new_from_instance( libvlc_instance_t* p_instance,
                mediacontrol_Exception *exception )
{
    mediacontrol_Instance* retval;
    libvlc_exception_t ex;

    libvlc_exception_init( &ex );

    retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
    if( ! retval )
    {
        RAISE_NULL( mediacontrol_InternalException, "Out of memory" );
    }
    retval->p_instance = p_instance;
    retval->p_media_player = libvlc_media_player_new( retval->p_instance, &ex );
    HANDLE_LIBVLC_EXCEPTION_NULL( &ex );
    return retval;
}
Пример #20
0
VLCWrapperImpl::VLCWrapperImpl(void)
:	pVLCInstance_(0),
	pMediaPlayer_(0),
	pMedia_(0),
    pEventManager_(0),
    eventHandler(0)
{
	const char * const vlc_args[] = {
		"-I", "dumy",      // No special interface
		"--ignore-config", // Don't use VLC's config
		"--plugin-path=./plugins" };

	// init vlc modules, should be done only once
	pVLCInstance_ = libvlc_new (sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
     
    // Create a media player playing environement
    pMediaPlayer_ = libvlc_media_player_new(pVLCInstance_);

    // Create an event manager for the player for handling e.g. time change events
    pEventManager_ = libvlc_media_player_event_manager(pMediaPlayer_);
}
Пример #21
0
    VLCVideoWidgetDelegator::VLCVideoWidgetDelegator( const QString& path)
      :m_widgetInstance( Nullptr )
      ,m_instance( Nullptr )
      ,m_player( Nullptr )
      ,m_currentMedia( Nullptr )
      ,m_hasPaused( false )
      ,m_isPlaying( false ){

      const char * const vlc_args[] = {
        "--plugin-path=plugins\\"
      };

      m_instance= libvlc_new( sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args );

      if( m_instance != Nullptr ){
        m_player = libvlc_media_player_new (m_instance);

        m_currentMedia = libvlc_media_new_path (m_instance, path.toAscii().data() );
        libvlc_media_player_set_media (m_player, m_currentMedia);      
      }
    }
Пример #22
0
TestVideo::TestVideo(QWidget *parent) :
    QWidget(parent)
{
    QString path = QString::fromAscii("file:///Volumes/UltraFat/Ted_Bundy.avi");
    const char * const vlcArgs[] = {
        "--intf", "macosx"
    };

    qDebug() << this->winId();
    ins = libvlc_new(sizeof(vlcArgs) / sizeof(*vlcArgs), vlcArgs);
    mp = libvlc_media_player_new(ins);
    libvlc_media_player_set_nsobject( mp, (void *) this->winId());
    libvlc_media_player_set_media(mp, libvlc_media_new_path(ins, path.toLocal8Bit()));
    libvlc_media_player_play(mp);

    // Kill the stuff in 5 seconds
    timer = new QTimer(this);
    timer->setInterval(10000);
    connect(timer,SIGNAL(timeout()),this,SLOT(scrapit()));
    timer->start();
}
Пример #23
0
JNIEXPORT void JNICALL NAME(nativeCreate)(JNIEnv *env, jobject thiz)
{
    initClasses(env, thiz);
    vlc_mutex_t *parse_lock = calloc(1, sizeof(vlc_mutex_t));
    vlc_mutex_init(parse_lock);
    setIntValue(env, thiz, "mNativeMediaParseLock", (jint) parse_lock);
    vlc_cond_t *parse_cond = calloc(1, sizeof(vlc_cond_t));
    vlc_cond_init(parse_cond);
    setIntValue(env, thiz, "mNativeMediaParseCond", (jint) parse_cond);
    setIntValue(env, thiz, "mNativeMediaBufferingCount", 0);
    const char *argv[] = {"-I", "dummy", "-vvv", "--no-plugins-cache", "--no-drop-late-frames", "--input-timeshift-path", "/data/local/tmp"};
    libvlc_instance_t *instance = libvlc_new_with_builtins(sizeof(argv) / sizeof(*argv), argv, vlc_builtins_modules);
    setIntValue(env, thiz, "mLibVlcInstance", (jint) instance);
    libvlc_media_player_t *mp = libvlc_media_player_new(instance);
    setIntValue(env, thiz, "mLibVlcMediaPlayer", (jint) mp);
    /* throw? */
    libvlc_event_manager_t *em = libvlc_media_player_event_manager(mp);
    for (int i = 0; i < sizeof(mp_listening) / sizeof(*mp_listening); i++)
    {
        libvlc_event_attach(em, mp_listening[i], vlc_event_callback, thiz);
    }
}
Пример #24
0
void Java_org_videolan_libvlc_MediaList_loadPlaylist(JNIEnv *env, jobject thiz, jobject libvlcJava, jstring mrl, jobject items) {
    const char* p_mrl = (*env)->GetStringUTFChars(env, mrl, NULL);

    libvlc_media_t *p_md = libvlc_media_new_location((libvlc_instance_t*)(intptr_t)getLong(env, libvlcJava, "mLibVlcInstance"), p_mrl);
    libvlc_media_add_option(p_md, ":demux=playlist,none");
    libvlc_media_add_option(p_md, ":run-time=1");

    struct stopped_monitor* monitor = malloc(sizeof(struct stopped_monitor));
    pthread_mutex_init(&monitor->doneMutex, NULL);
    pthread_cond_init(&monitor->doneCondVar, NULL);
    monitor->stopped = false;
    pthread_mutex_lock(&monitor->doneMutex);

    libvlc_media_player_t* p_mp = libvlc_media_player_new((libvlc_instance_t*)(intptr_t)getLong(env, libvlcJava, "mLibVlcInstance"));
    libvlc_media_player_set_video_title_display(p_mp, libvlc_position_disable, 0);
    libvlc_event_manager_t* ev = libvlc_media_player_event_manager(p_mp);
    libvlc_event_attach(ev, libvlc_MediaPlayerEndReached, stopped_callback, monitor);
    libvlc_media_player_set_media(p_mp, p_md);
    libvlc_media_player_play(p_mp);

    struct timespec deadline;
    clock_gettime(CLOCK_REALTIME, &deadline);
    deadline.tv_sec += 2; /* If "VLC can't open the file", return */
    int mp_alive = 1;
    while(!(monitor->stopped) && mp_alive) {
        pthread_cond_timedwait(&monitor->doneCondVar, &monitor->doneMutex, &deadline);
        mp_alive = libvlc_media_player_will_play(p_mp);
    }
    pthread_mutex_unlock(&monitor->doneMutex);
    pthread_mutex_destroy(&monitor->doneMutex);
    pthread_cond_destroy(&monitor->doneCondVar);
    free(monitor);

    libvlc_media_player_release(p_mp);

    expand_media_internal(env, (libvlc_instance_t*)(intptr_t)getLong(env, libvlcJava, "mLibVlcInstance"), items, p_md);

    (*env)->ReleaseStringUTFChars(env, mrl, p_mrl);
}
Пример #25
0
 VLC::VLC(asl::DLHandle theDLHandle) 
     : CaptureDevice(),
     PlugInBase(theDLHandle),
     _EOF(false),
     _curBuffer(NULL),
     _libvlc(NULL),
     _mediaPlayer(NULL),
     _playTime(0)
 {
     char const *vlc_argv[] =
     {
         "--no-osd",
         //"-vvv",
         "--reset-plugins-cache",
         "--no-xlib" // tell VLC to not use Xlib
     };
     int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);
     _libvlc = libvlc_new(vlc_argc, vlc_argv);
     _mediaPlayer = libvlc_media_player_new(_libvlc);
     libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager(_mediaPlayer);
     libvlc_event_attach(eventManager, libvlc_MediaPlayerEndReached, VLC::handle_vlc_event, this);
 }
Пример #26
0
VlcControl::VlcControl(): vlcMedia(0)
{
    setlog("VlcControl constructor " + QString().sprintf("%08p", this));
    if(!vlcInstance)
    {
        for(int i = 0; i < numberVlcArgs; i++ )
        {
            if(strcmp(vlcArgs[i], "--video-title-show") == 0)
            {
                vlcArgs[i] = "--no-video-title-show";
            }
        }
        vlcInstance = libvlc_new(numberVlcArgs, vlcArgs);
        setStaticCallbacks();
    }
    if(!vlcInstance)
    {
        setlog("ERROR Create vlc instance. May be needs libvlc.dll" + QString().sprintf("%08p", this));
        exit(0);
    }
    vlcPlayer = libvlc_media_player_new(vlcInstance);
}
Пример #27
0
LiveWidget::LiveWidget(QWidget* parent)
    : QWidget(parent),
      collapsed(false), windowMode(false), deviceName(""), deviceChannel(""), useKey(false), vlcMedia(NULL), vlcInstance(NULL), vlcMediaPlayer(NULL)
{
    setupUi(this);
    setupMenus();

    this->liveDialog = new LiveDialog(this);
    QObject::connect(this->liveDialog, SIGNAL(rejected()), this, SLOT(toggleWindowMode()));

    QStringList arguments;
    arguments.append("--ignore-config");
    arguments.append(QString("--network-caching=%1").arg(DatabaseManager::getInstance().getConfigurationByName("NetworkCache").getValue().toInt()));

    bool disableAudioInStream = (DatabaseManager::getInstance().getConfigurationByName("DisableAudioInStream").getValue() == "true") ? true : false;
    if (disableAudioInStream)
        arguments.append("--no-audio");

    QString args;
    foreach (QString value, arguments)
        args += value + " ";

    qDebug() << QString("LiveWidget::LiveWidget: Using arguments: %1").arg(args.trimmed());

    char* vlcArguments[arguments.count()];
    for (int i = 0; i < arguments.count(); i++)
        vlcArguments[i] = (char*)qstrdup(arguments.at(i).toUtf8().data());

    this->vlcInstance = libvlc_new(sizeof(vlcArguments) / sizeof(vlcArguments[0]), vlcArguments);
    this->vlcMediaPlayer = libvlc_media_player_new(this->vlcInstance);

    this->vlcMedia = libvlc_media_new_location(this->vlcInstance, "udp://@0.0.0.0:5004");
    libvlc_media_player_set_media(this->vlcMediaPlayer, this->vlcMedia);

    setupRenderTarget(this->windowMode);

    QObject::connect(&EventManager::getInstance(), SIGNAL(closeApplication(const CloseApplicationEvent&)), this, SLOT(closeApplication(const CloseApplicationEvent&)));
}
Пример #28
0
void
Java_org_videolan_libvlc_MediaPlayer_nativeNewFromLibVlc(JNIEnv *env,
                                                         jobject thiz,
                                                         jobject libvlc)
{
    vlcjni_object *p_obj = VLCJniObject_newFromJavaLibVlc(env, thiz, libvlc);
    if (!p_obj)
        return;

    /* Create a media player playing environment */
    p_obj->u.p_mp = libvlc_media_player_new(p_obj->p_libvlc);
    if (!p_obj->u.p_mp)
    {
        VLCJniObject_release(env, thiz, p_obj);
        throw_IllegalStateException(env, "can't create MediaPlayer instance");
        return;
    }
    libvlc_media_player_set_video_title_display(p_obj->u.p_mp,
                                                libvlc_position_disable, 0);

    /* TODO NOT HERE */
    /* Connect the event manager */
    libvlc_event_manager_t *ev = libvlc_media_player_event_manager(p_obj->u.p_mp);
    static const libvlc_event_type_t mp_events[] = {
        libvlc_MediaPlayerPlaying,
        libvlc_MediaPlayerPaused,
        libvlc_MediaPlayerEndReached,
        libvlc_MediaPlayerStopped,
        libvlc_MediaPlayerVout,
        libvlc_MediaPlayerPositionChanged,
        libvlc_MediaPlayerTimeChanged,
        libvlc_MediaPlayerEncounteredError,
        libvlc_MediaPlayerESAdded,
        libvlc_MediaPlayerESDeleted,
    };
    for(int i = 0; i < (sizeof(mp_events) / sizeof(*mp_events)); i++)
        libvlc_event_attach(ev, mp_events[i], vlc_event_callback, NULL);
}
Пример #29
0
VideoPlayer::VideoPlayer( const char* const* vlc_argv )
:   osg::ImageStream(), _vlcMedia(0), _playedTime(0), _requiresReplay(false)
{
    if ( !vlc_argv )
    {
        const char* vlc_args[] = {
            "--ignore-config",      // don't use VLC's config
            "--quiet",//"--verbose=0",
            "--no-video-title-show",
            "--network-caching=120"
            //"--plugin-path=plugins/"
        };
        _vlc = libvlc_new( sizeof(vlc_args)/sizeof(vlc_args[0]), vlc_args );
    }
    else
        _vlc = libvlc_new( sizeof(vlc_argv)/sizeof(vlc_argv[0]), vlc_argv );
    _vlcPlayer = libvlc_media_player_new( _vlc );
    
    libvlc_event_manager_t* eventManager = libvlc_media_player_event_manager( _vlcPlayer );
    libvlc_event_attach( eventManager, libvlc_MediaPlayerStopped, &VideoPlayer::videoStoppedFunc, this );
    libvlc_event_attach( eventManager, libvlc_MediaPlayerEndReached, &VideoPlayer::videoEndFunc, this );
    _status = INVALID;
}
Пример #30
0
VideoSource::VideoSource()
{
    //preparation of the vlc command
    const char * const vlc_args[] = {
        "-I", "dummy", /* Don't use any interface */
        "--ignore-config", /* Don't use VLC's config */
        "--extraintf=logger", //log anything
        "--verbose=2", //be much more verbose then normal for debugging purpose
        "--plugin-path=C:\\vlc-0.9.9-win32\\plugins\\"
    };

    _isPlaying=false;

    //create a new libvlc instance
    //    _vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args,&_vlcexcep);  //tricky calculation of the char space used
    _vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
    //    raise (&_vlcexcep);

    // Create a media player playing environement
    //    _mp = libvlc_media_player_new (_vlcinstance, &_vlcexcep);
    _mp = libvlc_media_player_new (_vlcinstance);
    //    raise (&_vlcexcep);
}