Exemplo n.º 1
0
void VideoDataOutput::addToMedia(libvlc_media_t *media)
{
    const int width = 300;
    const int height = width;
//    videoSizeChanged(width, height);
    libvlc_media_add_option_flag(media, ":vmem-chroma=RV24", libvlc_media_option_trusted);
    libvlc_video_set_callbacks(p_vlc_player, lock, unlock, 0, this);
}
Exemplo n.º 2
0
int VlcPlugin::playlist_add_extended_untrusted( const char *mrl, const char *name,
                    int optc, const char **optv, libvlc_exception_t *ex )
{
    libvlc_media_t *p_m = libvlc_media_new(libvlc_instance, mrl,ex);
    int item = -1;
    if( libvlc_exception_raised(ex) )
        return -1;

    for( int i = 0; i < optc; ++i )
        libvlc_media_add_option_flag(p_m, optv[i], libvlc_media_option_unique);

    libvlc_media_list_lock(libvlc_media_list);
    libvlc_media_list_add_media(libvlc_media_list,p_m,ex);
    if( !libvlc_exception_raised(ex) )
        item = libvlc_media_list_count(libvlc_media_list,ex)-1;
    libvlc_media_list_unlock(libvlc_media_list);
    libvlc_media_release(p_m);

    return item;
}
Exemplo n.º 3
0
/**************************************************************************
 * Add an option to the media descriptor,
 * that will be used to determine how the media_player will read the
 * media. This allow to use VLC advanced reading/streaming
 * options in a per-media basis
 *
 * The options are detailled in vlc --long-help, for instance "--sout-all"
 **************************************************************************/
void libvlc_media_add_option( libvlc_media_t * p_md,
                              const char * psz_option )
{
    libvlc_media_add_option_flag( p_md, psz_option,
                          VLC_INPUT_OPTION_UNIQUE|VLC_INPUT_OPTION_TRUSTED );
}
Exemplo n.º 4
0
void
AudioOutput::setCurrentSource( MediaStream* stream )
{
    tDebug() << Q_FUNC_INFO;

    setState( Loading );

    if ( m_vlcMedia != nullptr )
    {
        // Ensure playback is stopped, then release media
        libvlc_media_player_stop( m_vlcPlayer );
        libvlc_media_release( m_vlcMedia );
        m_vlcMedia = nullptr;
    }
    if ( m_autoDelete && m_currentStream != nullptr )
    {
        delete m_currentStream;
    }

    m_currentStream = stream;
    m_totalTime = 0;
    m_currentTime = 0;
    m_justSeeked = false;
    m_seekable = true;

    QByteArray url;
    switch ( stream->type() )
    {
        case MediaStream::Unknown:
            tDebug() << Q_FUNC_INFO << "MediaStream Type is Invalid:" << stream->type();
            break;

        case MediaStream::Empty:
            tDebug() << Q_FUNC_INFO << "MediaStream is empty.";
            break;

        case MediaStream::Url:
            tDebug() << Q_FUNC_INFO << "MediaStream::Url:" << stream->url();
            if ( stream->url().scheme().isEmpty() )
            {
                url = "file:///";
                if ( stream->url().isRelative() )
                {
                    url.append( QFile::encodeName( QDir::currentPath() ) + '/' );
                }
            }
            url += stream->url().toEncoded();
            break;

        case MediaStream::Stream:
        case MediaStream::IODevice:
            url = QByteArray( "imem://" );
            break;
    }

    tDebug() << Q_FUNC_INFO << "MediaStream::Final Url:" << url;

    m_vlcMedia = libvlc_media_new_location( m_vlcInstance, url.constData() );
    libvlc_event_manager_t* manager = libvlc_media_event_manager( m_vlcMedia );
    libvlc_event_type_t events[] = {
        libvlc_MediaDurationChanged,
    };
    const int eventCount = sizeof(events) / sizeof( *events );
    for ( int i = 0; i < eventCount; i++ )
    {
        libvlc_event_attach( manager, events[ i ], &AudioOutput::vlcEventCallback, this );
    }

    libvlc_media_player_set_media( m_vlcPlayer, m_vlcMedia );

    if ( stream->type() == MediaStream::Url )
    {
        m_totalTime = libvlc_media_get_duration( m_vlcMedia );
    }
    else if ( stream->type() == MediaStream::Stream || stream->type() == MediaStream::IODevice )
    {
        libvlc_media_add_option_flag(m_vlcMedia, "imem-cat=4", libvlc_media_option_trusted);
        const char* imemData = QString( "imem-data=%1" ).arg( (uintptr_t)stream ).toLatin1().constData();
        libvlc_media_add_option_flag(m_vlcMedia, imemData, libvlc_media_option_trusted);
        const char* imemGet = QString( "imem-get=%1" ).arg( (uintptr_t)&readCallback ).toLatin1().constData();
        libvlc_media_add_option_flag(m_vlcMedia, imemGet, libvlc_media_option_trusted);
        const char* imemRelease = QString( "imem-release=%1" ).arg( (uintptr_t)&readDoneCallback ).toLatin1().constData();
        libvlc_media_add_option_flag(m_vlcMedia, imemRelease, libvlc_media_option_trusted);
        const char* imemSeek = QString( "imem-seek=%1" ).arg( (uintptr_t)&MediaStream::seekCallback ).toLatin1().constData();
        libvlc_media_add_option_flag(m_vlcMedia, imemSeek, libvlc_media_option_trusted);
    }
    if ( qApp->arguments().contains( "--chromecast-ip" ) )
    {
        // This is very basic chromecast support through VLC 3+.
        // Totally unstable, unusable and will suck more CPU than you can think of.
        // If you want to improve this, please talk to the guys in #videolan and
        // support them.
        //
        // Knonw problems:
        // 1. It does not work eventhough the IP is correct.
        //    -> Open vlc with the same commandline and accept the Certificate in the VLC UI.
        if ( qApp->arguments().length() > qApp->arguments().indexOf( "--chromecast-ip" ) + 1 )
        {
            QString castIP = qApp->arguments().at( qApp->arguments().indexOf( "--chromecast-ip" ) + 1 );
            QString sout( ":sout=#transcode{vcodec=none,acodec=vorb,ab=320,channels=2,samplerate=44100}:chromecast{ip=%1,mux=webm}" );
            libvlc_media_add_option( m_vlcMedia, sout.arg( castIP ).toLatin1().constData() );
        }
        else
        {
            tLog() << Q_FUNC_INFO << "Chromecast option but no IP supplied.";
        }
    }

//    setState( Stopped );
}