www.久久久久|狼友网站av天堂|精品国产无码a片|一级av色欲av|91在线播放视频|亚洲无码主播在线|国产精品草久在线|明星AV网站在线|污污内射久久一区|婷婷综合视频网站

當前位置:首頁 > 嵌入式 > 嵌入式軟件
[導讀] Android 系統(tǒng)整體架構(gòu):我們先看一下多媒體框架在整個Android系統(tǒng)所處的位置從框架圖可以看出Media Framework處于Libraries這一層,這層的Library不是用Java實現(xiàn),一般是

 Android 系統(tǒng)整體架構(gòu):

我們先看一下多媒體框架在整個Android系統(tǒng)所處的位置

從框架圖可以看出Media Framework處于Libraries這一層,這層的Library不是用Java實現(xiàn),一般是C/C++實現(xiàn),它們通過Java的JNI方式調(diào)用。

多媒體架構(gòu):

基于第三方PacketVideo 公司的OpenCORE platform來實現(xiàn)

支持所有通用的音頻,視頻,靜態(tài)圖像格式

CODEC(編解碼器)使用OpenMAX 1L interface 接口進行擴展,可以方便得支持hardware / software codec plug-ins

支持的格式包括:MPEG4、H.264、MP3、AAC、AMR、JPG、PNG、GIF等。

l Open Core多媒體框架有一套通用可擴展的接口針對第三方的多媒體遍解碼器,輸入,輸出設備等等 。

l 多媒體文件的播放,下載,包括3GPP, MPEG-4,AAC and MP3 containers

l 流媒體文件的下載,實時播放,包括:3GPP, HTTP and RTSP/RTP

l 動態(tài)視頻和靜態(tài)圖像的編碼,解碼,例如:MPEG-4, H.263 and AVC (H.264), JPEG

l 語音編碼格式: AMR-NB and AMR-WB

l 音樂編碼格式: MP3, AAC, AAC+

l 視頻和圖像格式: 3GPP, MPEG-4 and JPEG

l 視頻會議:基于H324-M standard

圖中用黃線圈出的是Media Framework

Open Core介紹:

Open Core是Android 多媒體框架的核心,所有Android平臺的音視頻采集,播放的操作都是通過它來實現(xiàn)。它也被稱為PV(Packet Video), Packet Video是一家專門提供多媒體解決方案的公司。

通過Open Core程序員可以方便快速的開發(fā)出想要的多媒體應用程序,例如:音視頻的采集,回放,視頻會議,實時的流媒體播放等等應用。

Open Core 框架

代碼結(jié)構(gòu):

Open Core的代碼在Android代碼的External/Opencore目錄中。這個目錄是OpenCore的根目錄,其中包含的子目錄如下所示:

android:這里面是一個上層的庫,它實現(xiàn)了一個為Android使用的音視頻采集,播放的接口,和DRM數(shù)字版權管理的接口實現(xiàn)。

baselibs:包含數(shù)據(jù)結(jié)構(gòu)和線程安全等內(nèi)容的底層庫

codecs_v2:音視頻的編解碼器,基于OpenMAX實現(xiàn)

engines:核心部分,多媒體引擎的實現(xiàn)

extern_libs_v2:包含了khronos的OpenMAX的頭文件

fileformats:文件格式的解析(parser)工具

nodes:提供一些PVMF的NODE,主要是編解碼和文件解析方面的。

oscl:操作系統(tǒng)兼容庫

pvmi: 輸入輸出控制的抽象接口

protocols:主要是與網(wǎng)絡相關的RTSP、RTP、HTTP等協(xié)議的相關內(nèi)容

pvcommon:pvcommon庫文件的Android.mk文件,沒有源文件。

pvplayer:pvplayer庫文件的Android.mk文件,沒有源文件。

pvauthor:pvauthor庫文件的Android.mk文件,沒有源文件。

tools_v2:編譯工具以及一些可注冊的模塊。

Open Core 上層代碼結(jié)構(gòu)

在實際開發(fā)中我們并不會過多的研究Open Core的實現(xiàn),Android提供了上層的Media API給開發(fā)人員使用,MediaPlayer和MediaRecorder

Android Media APIs

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.

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 Methods

static MediaPlayer create(Context context, Uri uri)

Convenience method to create a MediaPlayer for a given Uri.

int getCurrentPosition()

Gets the current playback position.

int getDuration()

Gets the duration of the file.

int getVideoHeight()

Returns the height of the video.

int getVideoWidth()

Returns the width of the video.

boolean isPlaying()

Checks whether 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 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 SurfaceHolder 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.[!--empirenews.page--]

void stop()

Stops playback after playback has been stopped or paused.

我們可以看出MediaPlayer類提供了一個多媒體播放器的基本操作,播放,暫停,停止,設置音量等等。

簡單的例子:

Playing a File

MediaPlayer mp = new MediaPlayer();

mp.setDataSource(PATH_TO_FILE);

mp.prepare();

mp.start();

Playing a Raw Resource

MediaPlayer mp = MediaPlayer.create(context, R.raw.sound_file_1);

mp.start();

Media Recorder

提供的基本接口如下:

Public Method:

void prepare()

Prepares the recorder to begin capturing and 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 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 start()

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.setAudioEncoder(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 to

setAudioSource() step

recorder.release(); // Now the object cannot be reused

整體的結(jié)構(gòu)如下圖所示:

l MediaPlayer JNI

代碼位置 /frameworks/base/media/jni

l MediaPlayer (Native)

代碼位置 /frameworks/base/media/libmedia

l MediaPlayerService (Server)

代碼位置 /frameworks/base/media/libmediaplayerservice

l MediaPlayerService Host Process

代碼位置 /frameworks/base/media/mediaserver/main_mediaserver.cpp

l PVPlayer

代碼位置 /external/opencore/android/

實際調(diào)用過程如下圖所示:

本站聲明: 本文章由作者或相關機構(gòu)授權發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

柏林2025年9月9日 /美通社/ -- 柏林當?shù)貢r間9月6日,在2025德國柏林國際電子消費品展覽會(International Funkausstellung...

關鍵字: 掃地機器人 耳機 PEN BSP

- ‘Match Chat' AI助手可在所有254場單打比賽期間及結(jié)束后實時回答問題 - 升級版IBM SlamTracker將提供實時獲勝概率預測,而‘Key Poin...

關鍵字: IBM AI PEN AN

在全球范圍內(nèi)提供實時性能、低成本服務,并在沙特提供本地支持 加利福尼亞州帕洛阿爾托和沙特阿拉伯利雅得2025年8月6日 /美通社/ -- 快速推理領域的先驅(qū)企業(yè)Groq與PIF(沙特阿拉伯公共投資基金)旗下、沙特領先A...

關鍵字: AI 模型 PEN OS

客戶現(xiàn)可通過Amazon Bedrock和Amazon SageMaker AI使用OpenAI開放權重模型,實現(xiàn)將先進的開放權重模型與全球最廣泛云服務的深度集成。亞馬遜云科技首次上線OpenAI開放權重模型,向數(shù)百萬亞...

關鍵字: 亞馬遜 模型 PEN AI

其他電腦(比如安卓手機/平板電腦)的屏幕壞了,你可能想在安排維修之前緊急訪問一些東西。你可以使用android的USB OTG功能(是的,幾乎每個android都支持這個功能,你可以將鼠標和鍵盤連接到它)。

關鍵字: USB 鼠標 Android 樹莓派

上海 2025年6月18日 /美通社/ -- 在商超的果蔬區(qū)、散裝零食區(qū)或烘焙面包柜前,消費者只需將商品放置在秤盤上,攝像頭隨即捕捉圖像,AI算法即刻完成商品識別、計價與結(jié)...

關鍵字: 移遠通信 PEN AI 智能識別

Google 宣布與中國 AR 科技公司 XREAL 達成深度戰(zhàn)略合作,聯(lián)合推出全球首款專為 Android XR 平臺打造的旗艦級 AR 眼鏡 Project Aura。

關鍵字: Google XREAL Android XR眼鏡 AR

上海 2025年4月30日 /美通社/ -- 4月29日,在2025上海國際汽車工業(yè)展覽會期間,全球領先的物聯(lián)網(wǎng)和車聯(lián)網(wǎng)整體解決方案供應商移遠通信宣布,正式發(fā)布自主研發(fā)的N...

關鍵字: 移遠通信 汽車安全 PEN 測試

繼停止維護AOSP開源項目后,谷歌母公司Alphabet近日被曝在其安卓系統(tǒng)(Android)、Pixel手機以及Chrome瀏覽器等部門裁員數(shù)百人。這一舉措引發(fā)了業(yè)界的廣泛關注,也引發(fā)了對谷歌未來業(yè)務布局的諸多猜測。

關鍵字: 谷歌 AOSP Android 裁員
關閉