vlc for android为啥没有串流功能

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vlc for android为啥没有串流功能相关的知识,希望对你有一定的参考价值。

参考技术A 做vlc-android移植的道友都应该知道,当编译完vlc-android源码后EventManager.java类中定义了许多事件,下面是源码一部分:publicclassEventManager/**BesuretosubscribetoeventsyouneedintheJNItoo.*///publicstaticfinalintMediaMetaChanged=0;//publicstaticfinalintMediaSubItemAdded=1;//publicstaticfinalintMediaDurationChanged=2;//publicstaticfinalintMediaParsedChanged=3;//publicstaticfinalintMediaFreed=4;//publicstaticfinalintMediaStateChanged=5;//publicstaticfinalintMediaPlayerMediaChanged=0x100;//publicstaticfinalintMediaPlayerNothingSpecial=0x101;//publicstaticfinalintMediaPlayerOpening=0x102;//publicstaticfinalintMediaPlayerBuffering=0x103;publicstaticfinalintMediaPlayerPlaying=0x104;publicstaticfinalintMediaPlayerPaused=0x105;publicstaticfinalintMediaPlayerStopped=0x106;可是对于这些事件有很多都被注释掉了,当我们需要被注释掉的事件时,就算把注释拿掉,再调用mEventManager.addHandler(EventManager.getInstance())添加事件之后,也不会在定义的mEventHandler的handleMessage()中监听到,下面为一个mEventHandler定义的demo:[java]viewplaincopyprivatefinalVideoEventHandlermEventHandler=newVideoEventHandler(this);privateclassVideoEventHandlerextendsWeakHandlerpublicVideoEventHandler(DtvPlayerowner)super(owner);@OverridepublicvoidhandleMessage(Messagemsg)DtvPlayeractivity=getOwner();if(activity==null)return;switch(msg.getData().getInt("event"))caseEventManager.MediaPlayerBuffering:Log.d(TAG,"MediaPlayerBuffering");break;caseEventManager.MediaPlayerEncounteredError:Log.d(TAG,"MediaPlayerEncounteredError");break;default:Log.e(TAG,String.format("Eventnothandled(0x%x)",msg.getData().getInt("event")));break;super.handleMessage(msg);那么如何才能够在mEventHandler中监听到我们需要的事件呢,下面将进入主题。在libvlcjni.c中有一个静态常量,其中指定了我们目前需要获取哪些事件:[html]viewplaincopystaticconstlibvlc_event_type_tmp_events[]=libvlc_MediaPlayerPlaying,libvlc_MediaPlayerPaused,libvlc_MediaPlayerEndReached,libvlc_MediaPlayerStopped,libvlc_MediaPlayerVout,libvlc_MediaPlayerPositionChanged;你可以将自己需要的事件添加在里面,然后将EventManager中响应的事件注释拿掉,之后重新编译源码就可以再mEventHandler中获取你刚添加的事件了。(例如:你要想获取MediaPlayerEncounteredError事件,先将libvlc_MediaPlayerEncounteredError添加在mp_events[]静态常量中(注意,这里前面多了libvlc_),然后把EventManager中的publicstaticfinalintMediaPlayerEncounteredError=0x10a;注释拿掉,重新编译源码之后就可以在你得mEventHandler的handleMessage()中获取到EventManger.MediaPlayerEncounteredError事件)。在vlc-android/vlc/lib/event.c中定义了所有事件:[cpp]viewplaincopy#defineDEF(a)libvlc_##a,#a,,typedefstructinttype;constcharname[40];event_name_t;staticconstevent_name_tevent_list[]=DEF(MediaMetaChanged)DEF(MediaSubItemAdded)DEF(MediaDurationChanged)DEF(MediaParsedChanged)DEF(MediaFreed)DEF(MediaStateChanged)DEF(MediaPlayerMediaChanged)DEF(MediaPlayerNothingSpecial)DEF(MediaPlayerOpening)DEF(MediaPlayerBuffering)DEF(MediaPlayerPlaying)DEF(MediaPlayerPaused)DEF(MediaPlayerStopped)DEF(MediaPlayerForward)DEF(MediaPlayerBackward)DEF(MediaPlayerEndReached)DEF(MediaPlayerEncounteredError)DEF(MediaPlayerTimeChanged)DEF(MediaPlayerPositionChanged)DEF(MediaPlayerSeekableChanged)DEF(MediaPlayerPausableChanged)DEF(MediaPlayerTitleChanged)DEF(MediaPlayerSnapshotTaken)DEF(MediaPlayerLengthChanged)DEF(MediaPlayerVout)DEF(MediaListItemAdded)DEF(MediaListWillAddItem)DEF(MediaListItemDeleted)DEF(MediaListWillDeleteItem)DEF(MediaListViewItemAdded)DEF(MediaListViewWillAddItem)DEF(MediaListViewItemDeleted)DEF(MediaListViewWillDeleteItem)DEF(MediaListPlayerPlayed)DEF(MediaListPlayerNextItemSet)DEF(MediaListPlayerStopped)DEF(MediaDiscovererStarted)DEF(MediaDiscovererEnded)DEF(VlmMediaAdded)DEF(VlmMediaRemoved)DEF(VlmMediaChanged)DEF(VlmMediaInstanceStarted)DEF(VlmMediaInstanceStopped)DEF(VlmMediaInstanceStatusInit)DEF(VlmMediaInstanceStatusOpening)DEF(VlmMediaInstanceStatusPlaying)DEF(VlmMediaInstanceStatusPause)DEF(VlmMediaInstanceStatusEnd)DEF(VlmMediaInstanceStatusError);#undefDEF其中DEF()将MediaPlayerEncounteredError定义为libvlc_MediaPlayerEncounteredError,当本地代码产生MediaPlayerEncounteredError事件时会将libvlc_MediaPlayerEncounteredError传递给jni,与此同时jni又会传递给java层。不管是本地libvlc_MediaPlayerEncounteredError还是java层MediaPlayerEncounteredError,对于同一个事件被定义的值都是相同的,传输的是同一个消息值。本地代码定义在vlc-android/vlc/include/libvlc_events.h,java代码定义在EventManager.java中。

以上是关于vlc for android为啥没有串流功能的主要内容,如果未能解决你的问题,请参考以下文章

用vlc串流推流?

如何用vlc播放器的网络串流

vlc的使用

vlc串流并同时本地播放视频问题

如何用vlc做串流服务端,往外串流本地的文件

ffmpeg.串流_资料(包含一些vlc)