Beispiel #1
0
void VlcMediaWidget::updateSubtitles()
{
	subtitles.clear();
	libvlc_track_description_t *track = libvlc_video_get_spu_description(vlcMediaPlayer);

	if (track != NULL) {
		// skip the 'deactivate' subtitle
		track = track->p_next;
	}

	while (track != NULL) {
		QString subtitle = QString::fromUtf8(track->psz_name);
		int cutBegin = (subtitle.indexOf(QLatin1Char('[')) + 1);

		if (cutBegin > 0) {
			int cutEnd = subtitle.lastIndexOf(QLatin1Char(']'));

			if (cutEnd >= 0) {
				// remove unnecessary text
				subtitle = subtitle.mid(cutBegin, cutEnd - cutBegin);
			}
		}

		if (subtitle.isEmpty()) {
			subtitle = QString::number(subtitles.size() + 1);
		}

		subtitles.append(subtitle);
		track = track->p_next;
	}

	// skip the 'deactivate' subtitle
	currentSubtitle = (libvlc_video_get_spu(vlcMediaPlayer) - 1);
}
Beispiel #2
0
static void
_send_all_track_info(struct _App *app)
{
   int track_count, current;
   libvlc_track_description_t *desc;

   current = libvlc_audio_get_track(app->mp);
   track_count = libvlc_audio_get_track_count(app->mp);
   desc = libvlc_audio_get_track_description(app->mp);

   _send_track_info(app, EM_RESULT_AUDIO_TRACK_INFO,
		    current, track_count, desc);

   current = libvlc_video_get_track(app->mp);
   track_count = libvlc_video_get_track_count(app->mp);
   desc = libvlc_video_get_track_description(app->mp);

   _send_track_info(app, EM_RESULT_VIDEO_TRACK_INFO,
		    current, track_count, desc);

   current = libvlc_video_get_spu(app->mp);
   track_count = libvlc_video_get_spu_count(app->mp);
   desc = libvlc_video_get_spu_description(app->mp);

   _send_track_info(app, EM_RESULT_SPU_TRACK_INFO,
		    current, track_count, desc);
}
Beispiel #3
0
std::string FBVLCSubtitleAPI::description(unsigned int sID)
{
    FBVLCPtr plg = getPlugin();
    vlc_player& p = plg->get_player();

    std::string s_name;

    libvlc_track_description_t* root_s_desc =
        libvlc_video_get_spu_description(p.get_mp());
    if( !root_s_desc )
        return s_name;

    unsigned int sc = libvlc_video_get_spu_count(p.get_mp());
    if( sc && sID < sc ) {
        libvlc_track_description_t* s_desc = root_s_desc;
        for(; sID && s_desc ; --sID ){
            s_desc = s_desc->p_next;
        }

        if ( s_desc && s_desc->psz_name ) {
            s_name = s_desc->psz_name;
        }
    }
    libvlc_track_description_list_release(root_s_desc);

    return s_name;
}
jobject
Java_org_videolan_libvlc_MediaPlayer_nativeGetSpuTracks(JNIEnv *env,
                                                        jobject thiz)
{
    vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz);

    if (!p_obj)
        return NULL;

    return mediaplayer_tracklist_to_object(env,
                libvlc_video_get_spu_description(p_obj->u.p_mp));
}
Beispiel #5
0
void VLCMediaController::refreshSubtitles()
{
    current_subtitle = Phonon::SubtitleDescription();
    available_subtitles.clear();

    libvlc_track_description_t *p_info = libvlc_video_get_spu_description(
        p_vlc_media_player, p_vlc_exception );
    checkException();
    while(p_info)
    {
        subtitleAdded( p_info->i_id, p_info->psz_name, "" );
        p_info = p_info->p_next;
    }
    libvlc_track_description_release( p_info );
}
Beispiel #6
0
QStringList VPlayer::getSubtitles()
{
	if(mp&&subtitle.isEmpty()){
		auto list=libvlc_video_get_spu_description(mp);
		auto iter=list;
		while(iter){
			QString title=iter->psz_name;
			title.replace("Track"  ,tr("Track"));
			title.replace("Disable",tr("Disable"));
			subtitle[title]=iter->i_id;
			iter=iter->p_next;
		}
		libvlc_track_description_list_release(list);
	}
	return subtitle.keys();
}
Beispiel #7
0
STDMETHODIMP VLCSubtitle::description(long nameID, BSTR* name)
{
    if( NULL == name )
       return E_POINTER;

    libvlc_media_player_t* p_md;

    HRESULT hr = getMD(&p_md);
    if( SUCCEEDED(hr) )
    {
        int i, i_limit;
        const char *psz_name;
        libvlc_track_description_t *p_spuDesc;

        // get subtitles description
        p_spuDesc = libvlc_video_get_spu_description(p_md);
        if( !p_spuDesc )
            return E_FAIL;

        // get the number of available subtitle
        i_limit = libvlc_video_get_spu_count(p_md);
        if( i_limit < 0 )
            return E_FAIL;

        // check if the number given is a good one
        if ( ( nameID > ( i_limit -1 ) ) || ( nameID < 0 ) )
            return E_FAIL;

        // get the good spuDesc
        for( i = 0 ; i < nameID ; i++ )
        {
            p_spuDesc = p_spuDesc->p_next;
        }
        // get the subtitle name
        psz_name = p_spuDesc->psz_name;

        // return it
        if( psz_name != NULL )
        {
            *name = BSTRFromCStr(CP_UTF8, psz_name);
            return (NULL == *name) ? E_OUTOFMEMORY : NOERROR;
        }
        *name = NULL;
        return E_FAIL;
    }
    return hr;
};
QList<int> VlcVideo::subtitleIds() const
{
    QList<int> ids;

    if (_vlcMediaPlayer && libvlc_media_player_has_vout(_vlcMediaPlayer)) {
        libvlc_track_description_t *desc;
        desc = libvlc_video_get_spu_description(_vlcMediaPlayer);
        VlcError::errmsg();

        ids << desc->i_id;
        if (subtitleCount() > 1) {
            for(int i = 1; i < subtitleCount(); i++) {
                desc = desc->p_next;
                ids << desc->i_id;
            }
        }
    }

    return ids;
}
QStringList VlcVideo::subtitleDescription() const
{
    QStringList descriptions;

    if (_vlcMediaPlayer && libvlc_media_player_has_vout(_vlcMediaPlayer)) {
        libvlc_track_description_t *desc;
        desc = libvlc_video_get_spu_description(_vlcMediaPlayer);
        VlcError::errmsg();

        descriptions << QString().fromUtf8(desc->psz_name);
        if (subtitleCount() > 1) {
            for(int i = 1; i < subtitleCount(); i++) {
                desc = desc->p_next;
                descriptions << QString().fromUtf8(desc->psz_name);
            }
        }
    }

    return descriptions;
}
jobject Java_org_videolan_libvlc_LibVLC_getSpuTrackDescription(JNIEnv *env, jobject thiz)
{
    libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
    if (!mp)
        return NULL;

    int i_nbTracks = libvlc_video_get_spu_count(mp);
    jclass mapClass = (*env)->FindClass(env, "java/util/Map");
    jclass hashMapClass = (*env)->FindClass(env, "java/util/HashMap");
    jmethodID mapPut = (*env)->GetMethodID(env, mapClass, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
    /*
     * "What are you building? Lay your hand on it. Where is it?"
     * We need a concrete map to start
     */
    jmethodID mapInit = (*env)->GetMethodID(env, hashMapClass, "<init>", "()V");
    jclass integerCls = (*env)->FindClass(env, "java/lang/Integer");
    jmethodID integerConstructor = (*env)->GetMethodID(env, integerCls, "<init>", "(I)V");

    jobject spuTrackMap = (*env)->NewObject(env, hashMapClass, mapInit);

    libvlc_track_description_t *first = libvlc_video_get_spu_description(mp);
    libvlc_track_description_t *desc = first;
    unsigned i;
    for (i = 0; i < i_nbTracks; ++i)
    {
        // store audio track ID and name in a map as <ID, Track Name>
        jobject track_id = (*env)->NewObject(env, integerCls, integerConstructor, desc->i_id);
        jstring name = (*env)->NewStringUTF(env, desc->psz_name);
        (*env)->CallObjectMethod(env, spuTrackMap, mapPut, track_id, name);
        desc = desc->p_next;
    }
    libvlc_track_description_list_release(first);

    // Clean up local references
    (*env)->DeleteLocalRef(env, mapClass);
    (*env)->DeleteLocalRef(env, hashMapClass);
    (*env)->DeleteLocalRef(env, integerCls);

    return spuTrackMap;
}
Beispiel #11
0
QString QmlVlcSubtitle::description( unsigned int sID )
{
    QString s_name;

    libvlc_track_description_t* root_s_desc =
        libvlc_video_get_spu_description( m_player.get_mp() );
    if( !root_s_desc )
        return s_name;

    unsigned int sc = libvlc_video_get_spu_count( m_player.get_mp() );
    if( sc && sID < sc ) {
        libvlc_track_description_t* s_desc = root_s_desc;
        for( ; sID && s_desc ; --sID ){
            s_desc = s_desc->p_next;
        }

        if ( s_desc && s_desc->psz_name ) {
            s_name = s_desc->psz_name;
        }
    }
    libvlc_track_description_list_release( root_s_desc );

    return s_name;
}
Beispiel #12
0
RuntimeNPObject::InvokeResult
LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args,
                            uint32_t argCount, NPVariant &result)
{
    /* is plugin still running */
    if( isPluginRunning() )
    {
        VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
        libvlc_exception_t ex;
        libvlc_exception_init(&ex);

        libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
        RETURN_ON_EXCEPTION(this,ex);

        switch( index )
        {
            case ID_subtitle_description:
            {
                if( argCount == 1)
                {
                    char *psz_name;
                    int i_spuID, i_limit, i;
                    libvlc_track_description_t *p_spuDesc;

                    /* get subtitles description */
                    p_spuDesc = libvlc_video_get_spu_description(p_md, &ex);
                    RETURN_ON_EXCEPTION(this,ex);
                    if( !p_spuDesc )
                        return INVOKERESULT_GENERIC_ERROR;

                    /* get the number of subtitle available */
                    i_limit = libvlc_video_get_spu_count(p_md, &ex);
                    RETURN_ON_EXCEPTION(this,ex);

                    /* check if a number is given by the user
                     * and get the subtitle number */
                    if( isNumberValue(args[0]) )
                        i_spuID = numberValue(args[0]);
                    else
                        return INVOKERESULT_INVALID_VALUE;

                    /* if bad number is given return invalid value */
                    if ( ( i_spuID > ( i_limit -1 ) ) || ( i_spuID < 0 ) )
                        return INVOKERESULT_INVALID_VALUE;

                    /* get the good spuDesc */
                    for( i = 0 ; i < i_spuID ; i++ )
                    {
                        p_spuDesc = p_spuDesc->p_next;
                    }
                    psz_name = p_spuDesc->psz_name;

                    /* return the name of the track chosen */
                    return invokeResultString(psz_name, result);
                }
                return INVOKERESULT_NO_SUCH_METHOD;
            }
            default:
                return INVOKERESULT_NO_SUCH_METHOD;
        }
    }
    return INVOKERESULT_GENERIC_ERROR;
}