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多媒體框架有一套通用可擴展的接口針對第三方的多媒體遍解碼器,輸入,輸出設(shè)備等等 。

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ā)出想要的多媒體應(yīng)用程序,例如:音視頻的采集,回放,視頻會議,實時的流媒體播放等等應(yīng)用。

Open Core 框架

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

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

android:這里面是一個上層的庫,它實現(xiàn)了一個為Android使用的音視頻采集,播放的接口,和DRM數(shù)字版權(quán)管理的接口實現(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)絡(luò)相關(guān)的RTSP、RTP、HTTP等協(xié)議的相關(guān)內(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類提供了一個多媒體播放器的基本操作,播放,暫停,停止,設(shè)置音量等等。

簡單的例子:

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)用過程如下圖所示:

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

9月2日消息,不造車的華為或?qū)⒋呱龈蟮莫毥谦F公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關(guān)鍵字: 阿維塔 塞力斯 華為

加利福尼亞州圣克拉拉縣2024年8月30日 /美通社/ -- 數(shù)字化轉(zhuǎn)型技術(shù)解決方案公司Trianz今天宣布,該公司與Amazon Web Services (AWS)簽訂了...

關(guān)鍵字: AWS AN BSP 數(shù)字化

倫敦2024年8月29日 /美通社/ -- 英國汽車技術(shù)公司SODA.Auto推出其旗艦產(chǎn)品SODA V,這是全球首款涵蓋汽車工程師從創(chuàng)意到認證的所有需求的工具,可用于創(chuàng)建軟件定義汽車。 SODA V工具的開發(fā)耗時1.5...

關(guān)鍵字: 汽車 人工智能 智能驅(qū)動 BSP

北京2024年8月28日 /美通社/ -- 越來越多用戶希望企業(yè)業(yè)務(wù)能7×24不間斷運行,同時企業(yè)卻面臨越來越多業(yè)務(wù)中斷的風險,如企業(yè)系統(tǒng)復雜性的增加,頻繁的功能更新和發(fā)布等。如何確保業(yè)務(wù)連續(xù)性,提升韌性,成...

關(guān)鍵字: 亞馬遜 解密 控制平面 BSP

8月30日消息,據(jù)媒體報道,騰訊和網(wǎng)易近期正在縮減他們對日本游戲市場的投資。

關(guān)鍵字: 騰訊 編碼器 CPU

8月28日消息,今天上午,2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會開幕式在貴陽舉行,華為董事、質(zhì)量流程IT總裁陶景文發(fā)表了演講。

關(guān)鍵字: 華為 12nm EDA 半導體

8月28日消息,在2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會上,華為常務(wù)董事、華為云CEO張平安發(fā)表演講稱,數(shù)字世界的話語權(quán)最終是由生態(tài)的繁榮決定的。

關(guān)鍵字: 華為 12nm 手機 衛(wèi)星通信

要點: 有效應(yīng)對環(huán)境變化,經(jīng)營業(yè)績穩(wěn)中有升 落實提質(zhì)增效舉措,毛利潤率延續(xù)升勢 戰(zhàn)略布局成效顯著,戰(zhàn)新業(yè)務(wù)引領(lǐng)增長 以科技創(chuàng)新為引領(lǐng),提升企業(yè)核心競爭力 堅持高質(zhì)量發(fā)展策略,塑強核心競爭優(yōu)勢...

關(guān)鍵字: 通信 BSP 電信運營商 數(shù)字經(jīng)濟

北京2024年8月27日 /美通社/ -- 8月21日,由中央廣播電視總臺與中國電影電視技術(shù)學會聯(lián)合牽頭組建的NVI技術(shù)創(chuàng)新聯(lián)盟在BIRTV2024超高清全產(chǎn)業(yè)鏈發(fā)展研討會上宣布正式成立。 活動現(xiàn)場 NVI技術(shù)創(chuàng)新聯(lián)...

關(guān)鍵字: VI 傳輸協(xié)議 音頻 BSP

北京2024年8月27日 /美通社/ -- 在8月23日舉辦的2024年長三角生態(tài)綠色一體化發(fā)展示范區(qū)聯(lián)合招商會上,軟通動力信息技術(shù)(集團)股份有限公司(以下簡稱"軟通動力")與長三角投資(上海)有限...

關(guān)鍵字: BSP 信息技術(shù)
關(guān)閉
關(guān)閉