版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Android多媒体框架初步分析Android 系统整体架构:我们先看一下多媒体框架在整个Android系统所处的位置从框架图可以看出Media Framework处于Libraries这一层,这层的Library不是用Java实现,一般是C/C+实现,它们通过Java的JNI方式调用。多媒体架构:基于第三方PacketVideo 公司的OpenCORE platform来实现支持所有通用的音频,视频,静态图像格式CODEC(编解码器)使用OpenMAX 1L interface 接口进行扩展,可以方便得支持hardware / software codec plug-ins支持的格式包括:M
2、PEG4、H.264、MP3、AAC、AMR、JPG、PNG、GIF等。l Open Core多媒体框架有一套通用可扩展的接口针对第三方的多媒体遍解码器,输入,输出设备等等 。l 多媒体文件的播放,下载,包括3GPP, MPEG-4,AAC and MP3 containersl 流媒体文件的下载,实时播放,包括:3GPP, HTTP and RTSP/RTPl 动态视频和静态图像的编码,解码,例如:MPEG-4, H.263 and AVC (H.264), JPEGl 语音编码格式: AMR-NB and AMR-WBl 音乐编码格式: MP3, AAC, AAC+l 视频和图像格式: 3
3、GPP, MPEG-4 and JPEGl 视频会议:基于H324-M standard图中用黄线圈出的是Media FrameworkOpen Core介绍:Open Core是Android 多媒体框架的核心,所有Android平台的音视频采集,播放的操作都是通过它来实现。它也被称为PV(Packet Video), Packet Video是一家专门提供多媒体解决方案的公司。通过Open Core程序员可以方便快速的开发出想要的多媒体应用程序,例如:音视频的采集,回放,视频会议,实时的流媒体播放等等应用。Open Core 框架代码结构:Open Core的代码在Android代码的Ex
4、ternal/Opencore目录中。这个目录是OpenCore的根目录,其中包含的子目录如下所示: android:这里面是一个上层的库,它实现了一个为Android使用的音视频采集,播放的接口,和DRM数字版权管理的接口实现。 baselibs:包含数据结构和线程安全等内容的底层库 codecs_v2:音视频的编解码器,基于OpenMAX实现 engines:核心部分,多媒体引擎的实现 extern_libs_v2:包含了khronos的OpenMAX的头文件 fileformats:文件格式的解析(parser)工具 nodes:提供一些PVMF的NODE,主要是编解码和文件解析方面的。
5、 oscl:操作系统兼容库 pvmi: 输入输出控制的抽象接口 protocols:主要是与网络相关的RTSP、RTP、HTTP等协议的相关内容 pvcommon:pvcommon库文件的Android.mk文件,没有源文件。 pvplayer:pvplayer库文件的Android.mk文件,没有源文件。 pvauthor:pvauthor库文件的Android.mk文件,没有源文件。 tools_v2:编译工具以及一些可注册的模块。 Open Core 上层代码结构在实际开发中我们并不会过多的研究Open Core的实现,Android提供了上层的Media API给开发人员使用,Medi
6、aPlayer和MediaRecorderAndroid Media APIsl The Android platform is capable of playing both audio and video media. It is also capable of playing media contained in the resources for an application, or a standalone file in the filesystem, or even streaming media over a data connection. Playback is achie
7、ved through the android.media.MediaPlayer class.l The Android platform can also record audio. Video recording capabilities are coming in the future. This is achieved through the android.media.MediaRecorder class.Media Player提供的基本接口如下:Public Methodsstatic MediaPlayer create(Context context, Uri uri)C
8、onvenience method to create a MediaPlayer for a given U getCurrentPosition()Gets the current playback getDuration()Gets the duration of the getVideoHeight()Returns the height of the getVideoWidth()Returns the width of the video.boolean isPlaying()Checks whether
9、the MediaPlayer is playing.void pause()Pauses playback.void prepare()Prepares the player for playback, synchronously.void prepareAsync()Prepares the player for playback, asynchronously.void release()Releases resources associated with this MediaPlayer object.void reset()Resets the MediaPlayer to its
10、uninitialized state.void seekTo(int msec)Seeks to specified time position.void setAudioStreamType(int streamtype)Sets the audio stream type for this MediaPlayer.void setDataSource(String path)Sets the data source (file-path or http/rtsp URL) to use.void setDisplay(SurfaceHolder sh)Sets the SurfaceHo
11、lder to use for displaying the video portion of the media.void setVolume(float leftVolume, float rightVolume)Sets the volume on this player.void start()Starts or resumes playback.void stop()Stops playback after playback has been stopped or paused.我们可以看出MediaPlayer类提供了一个多媒体播放器的基本操作,播放,暂停,停止,设置音量等等。简单
12、的例子:Playing a FileMediaPlayer mp = new MediaPlayer();mp.setDataSource(PATH_TO_FILE);mp.prepare();mp.start();Playing a Raw ResourceMediaPlayer mp = MediaPlayer.create(context, R.raw.sound_file_1);mp.start();Media Recorder提供的基本接口如下:Public Method:void prepare()Prepares the recorder to begin capturing a
13、nd encoding data.void release()Releases resources associated with this MediaRecorder object.void reset()Restarts the MediaRecorder to its idle state.void setAudioEncoder(int audio_encoder)Sets the audio encoder to be used for recording.void setAudioSource(int audio_source)Sets the audio source to be
14、 used for recording.void setOutputFile(String path)Sets the path of the output file to be produced.void setOutputFormat(int output_format)Sets the format of the output file produced during recording.void setPreviewDisplay(Surface sv)Sets a Surface to show a preview of recorded media (video).void sta
15、rt()Begins capturing and encoding data to the file specified with setOutputFile().void stop()Stops recording.简单的例子:Example:MediaRecorder recorder = new MediaRecorder();recorder.setAudioSource(MediaRecorder.AudioSource.MIC);recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);recorder.setAu
16、dioEncoder(MediaRecorder.AudioEncoder.AMR_NB);recorder.setOutputFile(PATH_NAME);recorder.prepare();recorder.start(); / Recording is now started . recorder.stop();recorder.reset(); / You can reuse the object by going back tosetAudioSource() steprecorder.release(); / Now the object cannot be reused整体的结构如下图所示:l MediaPlayer JNI代码位置 /frameworks/base/media/jnil MediaPlayer (Native)代码位置 /frameworks/base/media/libmed
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- Photoshop期末考试试题及详细答案
- (2026)国家事业单位政治理论知识答题题库及答案
- 矿石筛分清洗操作工规程
- 2026年砌筑工(高级)考试真题及答案
- 2026安全培训考试题及答案
- 输尿管支架相关不适综合干预共识
- PCB设计面试题+威海科目一试题(含详细答案)
- 肿瘤脊髓压迫大小便功能重建方案共识
- 2026年高级项目管理师考试例题理论模拟题及答案
- 2026年急救护士招聘面试题库及参考答案
- 2027届高考生物复习备考策略讲座
- 2026 年初级银行从业法律法规基础试卷及答案
- 2026年基金从业资格考试全套试题及详细答案解析
- 2026年家禽屠宰兽医卫生检验人员考试题库考试题库
- 水力旋流器岗位安全技术规程培训
- 气液两相流管道阻力降计算表自创软件供试用
- 满堂脚手架搭设拆除施工方案
- 中职高教版(2023)语文职业模块-第五单元:走近大国工匠(一)展示国家工程-了解工匠贡献【课件】
- 中国银行同业定期存款合同书
- 学校中层干部管理培训
- 江西祺利科技有限公司年产100万平方米HDI板生产项目 环境影响报告
评论
0/150
提交评论