VLC Android/iOS开发指南
1.环境配置、源代码获取及编译
2.截图功能扩展
3.录像功能扩展
4.vlc目录结构分析
5.重要配置参数
6.Android Release
7.资料
1.配置环境、获取源代码及编译
A) Android
•环境配置
a)使用virtualbox安装ubuntu-32bit虚拟机,详情见7资料
b)安装基本工具:
sudo apt-get install ant autoconf automake autopoint libtool gawk gcc g++ pkg-config cmake patch subversion git
c)下载Android SDK,链接:
developer.android/sdk/index.html
d)下载Android NDK,链接:
developer.android/tools/sdk/ndk/index.html
e)下载java-linux-32bit,链接:
acle/otn-pub/java/jdk/7/jdk-7-linux-i
f)解压并配置Android SDK和NDK环境变量
打开命令行终端
mv ~
tar zxvf
mv ~
tar zxvf android-sdk
mv ~
tar zxvf android-ndk
gedit ~/.bashrc
export JA V A_HOME=~/jdk1.7.0
export JRE_HOME=${JA V A_HOME}/jre
export CLASSPATH=${JA V A_HOME}/bin
export ANDROID_SDK=~/android-sdk
export ANDROID_NDK=~/android-ndk
export PATH=$ANDROID_SDK/tools:
$ANDROID_SDK/platform-tools:$ ANDROID_NDK:
$JA V A_HOME/bin:$PATH
保存,并退出gedit
•获取源代码
重新开发一个命令行终端
git clone git:///vlc-ports/android.git
•编译
cd android
export ANDROID_ABI=armeabi # 编译armv5版本或者export ANDROID_ABI=armeabi-v7a# 编译armv7a版本sh compile.sh release
如果你按照步骤做的话,最后将在android/vlc-android/libs 目录下生成armeabi目录或者armeabi-v7a目录
把armeabi目录及android/vlc-android/src/org/videolan/libvlc 目录组合使用,就可以调用vlc作为播放器,具体实现请参考android/vlc-android/src目录
B) iOS
•环境配置
a)下载xcode 5.2,并安装,详情见7 资料
b)安装Command Line Tools
打开xcode,在菜单> Xcode > Preferences > Downloads
在Components列表中,安装Command Line Tools
c)安装git,详见:blog.maxiang/install-git-on-mac/63/
•获取源代码
打开命令行终端
git clone git:///vlc-ports/ios.git
•编译
androidsdk安装步骤cd ios
sh compileVLCforiOS.sh
编译结束之后,将会在目录下
ios/ImportedSources/VLCKit/build/Release-iphoneos
生成对应的VLC SDK,包括头文件和libMobileVLCKit.a
关于如何使用的问题,请使用xcode打开ios/VLC deproj搜索对应的代码学习
2.截图功能扩展
编译的环境是ubuntu 12.04,要安装好java,配置好环境变量,按照/AndroidCompile配置好,就可以编译了。
要对android/configure.sh进行修改删掉其中的-disable-sout
另外保存图片为png格式,需要让ffmpeg增加-enable-encoder=png的编码器(在android/vlc/contrib/src/ffmpeg/rules.mak中修改)
在libvlcjni.c中增加函数:
jboolean Java_org_videolan_vlc_LibVLC_takeSnapShot(JNIEnv *env, jobject thiz,jint number, jstring path, jint width,jint height)
{
jboolean isCopy;
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
/
* Get C string */
const char* psz_path = (*env)->GetStringUTFChars(env, path, &isCopy);
if (mp)
if(libvlc_video_take_snapshot(mp, (int)number,psz_path , (int)width,(int)height)==0)
return JNI_TRUE;
return JNI_FALSE;
}
在LibVlc.java中增加native函数的接口
private native boolean takeSnapShot( int num, String file, int width, int height);
和调用方法
public boolean takeSnapShot(String file, int width, int height) {
return takeSnapShot(0, file, width, height);
}
3.录像功能扩展
以下为patch格式,+表示在对应文件中添加
diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index 2cfedbf..25a16ea 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -72,6 +72,8 @@ enum libvlc_event_e {
libvlc_MediaPlayerSnapshotTaken,
libvlc_MediaPlayerLengthChanged,
libvlc_MediaPlayerV out,
+ libvlc_MediaPlayerRecordableChanged,
+ libvlc_MediaPlayerRecordingFinished,
libvlc_MediaListItemAdded=0x200,
libvlc_MediaListWillAddItem,
@@ -165,6 +167,14 @@ typedef struct libvlc_event_t
} media_player_pausable_changed;
struct
{
+ int new_recordable;
+ } media_player_recordable_changed;
+ struct
+ {
+ char *psz_filename;
+ } media_player_recording_finished;
+ struct
+ {
int new_count;
} media_player_vout;
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index aefef02..8ddef37 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1628,6 +1628,121 @@ LIBVLC_API int libvlc_audio_set_delay( libvlc_media_player_t *p_mi, int64_t i_de /** @} audio */
+/**
+ * Can the media player record the current media?
+ *
+ * Media must be buffering or playing before it can be recorded.
+ *
+ * The media player event manager will emit a libvlc_MediaPlayerRecordableChanged event
+ * when the recordable state changes after starting media playback. The event data will
+ * describe the new recordable state, so invocation of this API method is not strictly
+ * necessary to determine when recording can be started.
+ *
+ * A libvlc_MediaPlayerRecordableChanged event will not be emitted if the media is
+ * stopped (notified by a libvlc_MediaPlayerStoppedEvent) or finishes normally (notified
+ * by a libvlc_MediaPlayerFinished event).
+ *
+ * A calling application should therefore register an event callback for those events
+ * so that it may query the new recordable state and manage recording at the appropriate
+ * time.
+ *
+ * \param p_mi media player
+ * \return true if the media player can record, false if it can not
+ * \version LibVLC 2.1.0 or later
+ */
+LIBVLC_API bool libvlc_media_player_is_recordable( libvlc_media_player_t *p_mi );
+
+/**
+ * Is the current media being recorded?
+ *
+ * \param p_mi media player
+ * \return true if recording, false if not
+ * \version LibVLC 2.1.0 or later
+ */
+LIBVLC_API bool libvlc_media_player_is_recording( libvlc_media_player_t *p_mi );
+
+/**
+ * Start recording the current media.
+ *
+ * Media must be buffering or playing before it can be recorded. A calling application
+ * can begin recording immediately on receipt of a libvlc_MediaPlayerRecordableChanged
+ * event sent via the media player event manager (if recording is possible for the
+ * currently playing media), and any time thereafter until the media stops.
+ *
+ * Media will be saved to the file path denoted by the psz_filename parameter if it is
+ * supplied. Any such supplied filename should not include a file extension as the
+ * correct file extension will automatically be appended when the file is created. This
+ * filename may denote a full path name, but each directory in the path must already
+ * exist or recording will silently fail. If the calling application chooses to specify
+ * the filename then it is the responsibility of that application to take account of
+ * this and itself make sure any needed directories are created.
+ *
+ * Alternatively, a calling application need not supply a filename and so instead let
+ * vlc automatically generate a unique filename. This will cause vlc to create a new
+ * file in the appropriate media directory for the user - for example "~/Videos". The
+ * actual filename used will be sent in an event when the recording is complete.
+ *
+ * When recording has finished and the new file has been completely saved, a
+ * libvlc_MediaPlayerRecordingFinished event will be sent via the media player event
+ * manager. The event data will contain the filename of the newly recorded file - this
+ * will either be the filename as specified by the calling application or a filename
+ * generated by vlc if the application did not supply a filename. In either case, this
+ * filename will include the automatically appended file extension.
+ *
+ * The saved media file will not be immediately available or visible until recording
+ * has completely finished and the libvlc_MediaPlayerRecordingFinished event has been
+ * received, or the media has stopped or finished normally.
+ *
+ * Recording can be stopped and started on-the-fly once the recordable state is set;
+ * each time recording is stopped and restarted a new file will be created so a calling
+ * application should take care to provide unique filenames, or defer to vlc to create
+ * unique filenames.
+ *
+ * Recording will be stopped when the media stops playing, and must be explicitly
+ * started again to restart recording, i.e. the recording state is not automatically
+ * preserved when playing media subsequently.
+ *
+ * Media player functionailty such as next/previous chapter, set time or position and
+ * so on are ineffective when recording is enabled. However, pausing the media is
+ * possible and will pause the recording; unpausing the media will resume playback and
+ * recording.
+ *
+ * Recording of the primary media or sub-items is possible.
+ *
+ * \param p_mi media player
+ * \param psz_filename name of the file to save the media to, not including any file extension,
+ * or NULL if vlc should generate the filename automatically
+ * \return 0 if recording was started, -1 on error
+ * \version LibVLC 2.1.0 or later
+ */
+LIBVLC_API int libvlc_media_player_record_start( libvlc_media_player_t *p_mi, const char *psz_filename ); +
+/**
+ * Stop recording the current media.
+ *
+ * This method requests that the recording stop, and will return immediately. Recording
+ * will not stop immediately.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论