日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android StageFrightMediaScanner源码解析

發布時間:2025/3/14 Android 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android StageFrightMediaScanner源码解析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. 簡單介紹

Android中在StageFrightMediaScanner實現對多媒體文件的處理。


此外在StageFrightMediaScanner定義了支持的多媒體文件類型。
文件位置
frameworks\av\media\libstagefright\StagefrightMediaScanner.cpp
編譯目標
libstagefright.so

2. processFile

processFile并沒有做什么處理。主要是調用processFileInternal。
另外能夠看到在processFile中調用MediaScannerClient的beginFile和endFile方法,時間上google并沒有實現beginFile和endFile方法。
(說實話Android5.0 真的非常爛,非常多功能根本就沒有開發全然)

MediaScanResult StagefrightMediaScanner::processFile(const char *path, const char *mimeType,MediaScannerClient &client) {//MediaScannerClient根本就沒有實現。所以不用關心client.setLocale(locale());client.beginFile();MediaScanResult result = processFileInternal(path, mimeType, client);client.endFile();return result; }

3. processFileInternal

processFileInternal能夠說是MediaScanner處理多媒體文件終于節點
在此函數中通過調用MediaMetadataRetriever獲取多媒體信息。


調用MediaMetadataRetriever獲取媒體文件信息步驟例如以下:
(1) MediaMetadataRetriever.setDataSource(file)
(2) MediaMetadataRetriever.extractMetadata(key)

MediaScanResult StagefrightMediaScanner::processFileInternal(const char *path, const char * /* mimeType */,MediaScannerClient &client) {const char *extension = strrchr(path, '.');///check file type if (!extension) {return MEDIA_SCAN_RESULT_SKIPPED;}if (!FileHasAcceptableExtension(extension)) {return MEDIA_SCAN_RESULT_SKIPPED;}//----------------------------------------///Init & setDataSource MediaMetadataRetrieversp<MediaMetadataRetriever> mRetriever(new MediaMetadataRetriever);int fd = open(path, O_RDONLY | O_LARGEFILE);status_t status;if (fd < 0) {// couldn't open it locally, maybe the media server can?status = mRetriever->setDataSource(NULL /* httpService */, path);} else {status = mRetriever->setDataSource(fd, 0, 0x7ffffffffffffffL);close(fd);}//----------------------------------------///get MIMETYPEconst char *value;if ((value = mRetriever->extractMetadata(METADATA_KEY_MIMETYPE)) != NULL) {status = client.setMimeType(value);if (status) {return MEDIA_SCAN_RESULT_ERROR;}}//----------------------------------------.........///get metadatafor (size_t i = 0; i < kNumEntries; ++i) {const char *value;if ((value = mRetriever->extractMetadata(kKeyMap[i].key)) != NULL) {status = client.addStringTag(kKeyMap[i].tag, value);if (status != OK) {return MEDIA_SCAN_RESULT_ERROR;}}}return MEDIA_SCAN_RESULT_OK; }

轉載于:https://www.cnblogs.com/yfceshi/p/7365750.html

總結

以上是生活随笔為你收集整理的Android StageFrightMediaScanner源码解析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。