jint Java_org_videolan_libvlc_LibVLC_getAudioTracksCount(JNIEnv *env, jobject thiz) { libvlc_media_player_t *mp = getMediaPlayer(env, thiz); if (mp) return (jint) libvlc_audio_get_track_count(mp); return -1; }
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); }
RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVariant &result) { /* is plugin still running */ if( isPluginRunning() ) { VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); libvlc_exception_t ex; libvlc_exception_init(&ex); switch( index ) { case ID_audio_mute: { bool muted = libvlc_audio_get_mute(p_plugin->getVLC(), &ex); RETURN_ON_EXCEPTION(this,ex); BOOLEAN_TO_NPVARIANT(muted, result); return INVOKERESULT_NO_ERROR; } case ID_audio_volume: { int volume = libvlc_audio_get_volume(p_plugin->getVLC(), &ex); RETURN_ON_EXCEPTION(this,ex); INT32_TO_NPVARIANT(volume, result); return INVOKERESULT_NO_ERROR; } case ID_audio_track: { libvlc_media_player_t *p_md = p_plugin->getMD(&ex); RETURN_ON_EXCEPTION(this,ex); int track = libvlc_audio_get_track(p_md, &ex); RETURN_ON_EXCEPTION(this,ex); INT32_TO_NPVARIANT(track, result); return INVOKERESULT_NO_ERROR; } case ID_audio_count: { libvlc_media_player_t *p_md = p_plugin->getMD(&ex); RETURN_ON_EXCEPTION(this,ex); // get the number of audio track available int i_track = libvlc_audio_get_track_count(p_md, &ex); RETURN_ON_EXCEPTION(this,ex); // return it INT32_TO_NPVARIANT(i_track, result); return INVOKERESULT_NO_ERROR; } case ID_audio_channel: { int channel = libvlc_audio_get_channel(p_plugin->getVLC(), &ex); RETURN_ON_EXCEPTION(this,ex); INT32_TO_NPVARIANT(channel, result); return INVOKERESULT_NO_ERROR; } default: ; } } return INVOKERESULT_GENERIC_ERROR; }
int VlcAudio::trackCount() const { int count = -1; if (_vlcMediaPlayer) { count = libvlc_audio_get_track_count(_vlcMediaPlayer); VlcError::showErrmsg(); } return count; }
jint Java_org_videolan_libvlc_MediaPlayer_nativeGetAudioTracksCount(JNIEnv *env, jobject thiz) { vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz); if (!p_obj) return 0; return libvlc_audio_get_track_count(p_obj->u.p_mp); }
STDMETHODIMP VLCAudio::get_count(long* trackNumber) { if( NULL == trackNumber ) return E_POINTER; libvlc_media_player_t* p_md; HRESULT hr = getMD(&p_md); if( SUCCEEDED(hr) ) { // get the number of audio track available and return it *trackNumber = libvlc_audio_get_track_count(p_md); } return hr; };
STDMETHODIMP VLCAudio::description(long trackID, 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_trackDesc; // get tracks description p_trackDesc = libvlc_audio_get_track_description(p_md); if( !p_trackDesc ) return E_FAIL; //get the number of available track i_limit = libvlc_audio_get_track_count(p_md); if( i_limit < 0 ) return E_FAIL; // check if the number given is a good one if ( ( trackID > ( i_limit -1 ) ) || ( trackID < 0 ) ) return E_FAIL; // get the good trackDesc for( i = 0 ; i < trackID ; i++ ) { p_trackDesc = p_trackDesc->p_next; } // get the track name psz_name = p_trackDesc->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; };
jobject Java_org_videolan_libvlc_LibVLC_getAudioTrackDescription(JNIEnv *env, jobject thiz) { libvlc_media_player_t *mp = getMediaPlayer(env, thiz); if (!mp) return NULL; int i_nbTracks = libvlc_audio_get_track_count(mp) - 1; if (i_nbTracks < 0) i_nbTracks = 0; 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 audioTrackMap = (*env)->NewObject(env, hashMapClass, mapInit); libvlc_track_description_t *first = libvlc_audio_get_track_description(mp); libvlc_track_description_t *desc = first != NULL ? first->p_next : NULL; 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, audioTrackMap, 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 audioTrackMap; }
bool VLCVideoWrapper::hasAudio(void) const { int Result = libvlc_audio_get_track_count(_MediaPlayer); checkVLCError("Checking if video has audio"); return (Result > 0); }
RuntimeNPObject::InvokeResult LibvlcAudioNPObject::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); switch( index ) { case ID_audio_togglemute: if( argCount == 0 ) { libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex); RETURN_ON_EXCEPTION(this,ex); VOID_TO_NPVARIANT(result); return INVOKERESULT_NO_ERROR; } return INVOKERESULT_NO_SUCH_METHOD; case ID_audio_description: { if( argCount == 1) { char *psz_name; int i_trackID, i_limit, i; libvlc_track_description_t *p_trackDesc; libvlc_media_player_t *p_md = p_plugin->getMD(&ex); RETURN_ON_EXCEPTION(this,ex); /* get tracks description */ p_trackDesc = libvlc_audio_get_track_description(p_md, &ex); RETURN_ON_EXCEPTION(this,ex); if( !p_trackDesc ) return INVOKERESULT_GENERIC_ERROR; /* get the number of track available */ i_limit = libvlc_audio_get_track_count(p_md, &ex); RETURN_ON_EXCEPTION(this,ex); /* check if a number is given by the user * and get the track number */ if( isNumberValue(args[0]) ) i_trackID = numberValue(args[0]); else return INVOKERESULT_INVALID_VALUE; /* if bad number is given return invalid value */ if ( ( i_trackID > ( i_limit - 1 ) ) || ( i_trackID < 0 ) ) return INVOKERESULT_INVALID_VALUE; /* get the good trackDesc */ for( i = 0 ; i < i_trackID ; i++ ) { p_trackDesc = p_trackDesc->p_next; } psz_name = p_trackDesc->psz_name; /* display the name of the track chosen */ return invokeResultString( psz_name, result ); } return INVOKERESULT_NO_SUCH_METHOD; } default: ; } } return INVOKERESULT_GENERIC_ERROR; }
bool VLCVideoTextureObjChunk::createVLCInstance(libvlc_time_t start_time, bool play) { libvlc_media_t *m; char const *vlc_argv[] = { "-I", "dumy", // No special interface "--ignore-config", // Don't use VLC's config "--quiet", // deactivates VLCs console outputs "--no-xlib", // tell VLC to not use Xlib "--no-video-title-show", // no titles }; int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv); // Initialize libVLC if (libvlc == NULL) { libvlc = libvlc_new(vlc_argc, vlc_argv); } else { if (vlcmediaplayer != NULL) { ctx.idstr = NULL; libvlc_media_player_stop(vlcmediaplayer); libvlc_media_player_release(vlcmediaplayer); vlcmediaplayer = NULL; if (ctx.videothread != NULL) { ctx.videothread->runFunction(NULL, NULL); // reset thread structure: isInititialized=false } ctx.videothread = NULL; } } if (libvlc == NULL) { SFATAL << "libvlc creation failed (plugin folder?)" << std::endl; return false; } m = libvlc_media_new_path(libvlc, getUrl().c_str()); vlcmediaplayer = libvlc_media_player_new_from_media(m); libvlc_media_release(m); ctx.idstr = strdup((std::string("video") + getVideoID()).c_str()); ctx.videothread = NULL; ctx.img = Image::create(); ctx.img->set(OSG::Image::OSG_BGR_PF, getWidth(), getHeight()); ctx.lock = Lock::create(); this->setImage(ctx.img); this->setTarget(GL_TEXTURE_2D); ctx.self = this; vlceventmgr = libvlc_media_player_event_manager(vlcmediaplayer); // attach event to defined event handler callback libvlc_event_attach(vlceventmgr, libvlc_MediaPlayerEndReached, vlc_event, &ctx); libvlc_video_set_callbacks(vlcmediaplayer, vlc_lock, vlc_unlock, vlc_display, &ctx); libvlc_video_set_format(vlcmediaplayer, "RV24", getWidth(), getHeight(), getWidth() * 3); if (getIsMaster() == false) { libvlc_audio_set_mute(vlcmediaplayer, 1); SLOG << "audiotracks:" << libvlc_audio_get_track_count(vlcmediaplayer) << std::endl; libvlc_audio_set_track(vlcmediaplayer, -1); // this may only work when media is playing! needsUpdate = true; SLOG << "not master, setting audio to mute!" << std::endl; } else SLOG << "this is handled as master!" << std::endl; #if 0 { SLOG << "available filters:" << std::endl; libvlc_module_description_t *list = libvlc_video_filter_list_get(libvlc); libvlc_module_description_t *iter = list; while (iter != NULL) { SLOG << iter->psz_name << std::endl; iter = iter->p_next; } libvlc_module_description_list_release(list); } #endif libvlc_media_player_play(vlcmediaplayer); libvlc_media_player_set_time(vlcmediaplayer, start_time); if (!play) libvlc_media_player_pause(vlcmediaplayer); //not working? // add to static list //allVideoTextures.push_back(&ctx); lastSync = OSG::getTimeStamp(); return true; }