- 注册时间
- 2011-10-23
- 最后登录
- 2011-10-31
- 阅读权限
- 30
- 积分
- 416
- 精华
- 0
- 帖子
- 133
 
升级   72%
|
Sets the audio encoder to be used for recording.
Stops recording.
l 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 achieved through the android.media.MediaPlayer class.
void setOutputFormat(int output_format)
Media Recorder
我们可以看出MediaPlayer类提供了一个多媒体播放器的根本操作,播放,暂停,结束,设置音量等等。
l MediaPlayer (Native)
setAudioSource() step
recorder.prepare();
Starts or resumes playback.
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
l MediaPlayerService Host Process
void prepare()
Pauses playback.
l 动态视频和静态图像的编码,解码,例如:MPEG-4, H.263 and AVC (H.264), JPEG
Example:
void seekTo(int msec)
mp.setDataSource(PATH_TO_FILE);
提供的基本接口如下:
代码位置 /frameworks/base/media/mediaserver/main_mediaserver.cpp
l Open Core多媒体框架有一套通用可
扩展的接口针对第三方的多媒体遍解码器,输入,输出装备等等 。
void setAudioStreamType(int streamtype)
recorder.reset(); // You can reuse the object by going back to
Media Player
多
媒体架构:
Sets the format of the output file produced during recording.
Sets the audio stream type for this MediaPlayer.
l 音乐编码格式: MP3, AAC, AAC+
在实际开发中我们并不会过多的研讨Open Core的
实现,Android提供了上层的Media API给
开发职员使用,MediaPlayer和MediaRecorder
Restarts the MediaRecorder to its idle state.
Sets the SurfaceHolder to use for displaying the video portion of the media.
l 语音编码格式: AMR-NB and AMR-WB
简略的例子:
Open Core先容:
MediaPlayer mp = MediaPlayer.create(context, R.raw.sound_file_1);
MediaRecorder recorder = new MediaRecorder();
recorder.release(); // Now the object cannot be reused
void reset()
static MediaPlayer create(Context context, Uri uri)
void pause()
int getCurrentPosition()
l MediaPlayerService (Server)
Releases resources associated with this MediaPlayer object.
代码位置 /frameworks/base/media/libmediaplayerservice
基于第三方PacketVideo 公司的OpenCORE platform来实现
void stop()
recorder.setOutputFile(PATH_NAME);
Open Core是Android 多媒体框架的核心,所有Android平台的音视频采集,播放的操作
都是通过它来实现。它也被称为PV(Packet Video), Packet Video是一家专门提供多媒体解决计划的公司。
CODEC(编解码器)应用OpenMAX 1L interface 接口进行扩大,能够便利得支持hardware / software codec plug-ins
mp.start();
代码地位 /frameworks/base/media/libmedia
void setVolume(float leftVolume, float rightVolume)
boolean isPlaying()
void setOutputFile(String path)
l PVPlayer
通过Open Core程序员可以方便疾速的开发出想要的多媒体利用程序,例如:音视频的采集,回放,视频会议,实时的流
媒体播放等等运用。
Sets the path of the output file to be produced.
l MediaPlayer JNI
整体的结构如下图所示:
void setAudioEncoder(int audio_encoder)
l 流媒体文件的下载,实时播放,包括:3GPP, HTTP and RTSP/RTP
void release()
android:这里面是一个上层的库,它实现了一个为Android使
用的音视频采集,播放的接口,跟DRM数字版权治理的接口实现。 baselibs:包含数据构造和线程保险等
内容的底层库 codecs_v2:音视频的编解码器,基于OpenMAX实现 engines:中心局部,多媒体引擎的实
现 extern_libs_v2:包括了khronos的OpenMAX的头文件 fileformats:文件格式的解析(parser)工具 nodes:供给一些PVMF的NODE,重要是编解码和文件解析方面的。 oscl:操作体系兼容库 pvmi: 输入输出把持的形象接口 protocols:主要是与网络相关的RTSP、RTP、HTTP等协定的相干内容 pvcommon:pvcommon库文件的Android.mk文件,没有源文件。 pvplayer:pvplayer库文件的Android.mk文件,没有源文件。 pvauthor:pvauthor库文件的Android.mk文件,不源文件。 tools_v2:编译工具以及一些可注册的
模块。
Prepares the recorder to begin capturing and encoding data.
mp.prepare();
Open Core 框架
Gets the duration of the file.
Stops playback after playback has been stopped or paused.
mp.start();
从框架图可以看出Media Framework处于Libraries这一层,这层的Library不是用Java实现,个别是C/C++实现,它们通过Java的JNI方法调用。
l 视频会议:基于H324-M standard
Prepares the player for playback, synchronously.
代码位置 /frameworks/base/media/jni
Public Methods
Returns the height of the video.
Gets the current playback position.
Prepares the player for playback, asynchronously.
Seeks to specified time position.
Sets the volume on this player.
Convenience method to create a MediaPlayer for a given Uri.
void start()
图顶用黄线圈出的是Media Framework
咱们先看一下多媒体框架在全部Android系统所处的位置
void setDataSource(String path)
void start()
int getVideoHeight()
Android Media APIs
int getVideoWidth()
实际调用进程如下图所示:
Returns the width of the video.
Begins capturing and encoding data to the file specified with setOutputFile().
提供的基础接口如下:
简单的例子:
void setAudioSource(int audio_source)
Android 系统整体架
构:
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.
支持所有通用的音频,视频,静态图像格式
l 多媒体文件的播放,下载,包括3GPP, MPEG-4,AAC and MP3 containers
void stop()
代码位置 /external/opencore/android/
Checks whether the MediaPlayer is playing.
void setDisplay(SurfaceHolder sh)
Resets the MediaPlayer to its uninitialized state.
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
void prepare()
Playing a Raw Resource
Releases resources associated with this MediaRecorder object.
MediaPlayer mp = new MediaPlayer();
Sets the audio source to be used for recording.
int getDuration()
void setPreviewDisplay(Surface sv)
recorder.start(); // Recording is now started ... recorder.stop();
Sets a Surface to show a preview of recorded media (video).
void prepareAsync()
支撑的格局包含:MPEG4、H.264、MP3、AAC、AMR、JPG、PNG、GIF等。
Open Core 上层代码结构
Sets the data source (file-path or http/rtsp URL) to use.
代码结构:
Open Core的代码在Android代
码的External/Opencore目录中。这个目录是OpenCore的
根目录,其中包含的子目录如下所示:
void release()
void reset()
Public Method:
l 视频和图像格式: 3GPP, MPEG-4 and JPEG
Playing a File |
|