当前位置: 首页 > news >正文

Android 13 - Media框架(24)- MediaCodecList

这一节我们要了解 MediaCodecList 中的信息是如何加载的,以及这些信息是如何使用到的。

// static
sp<IMediaCodecList> MediaCodecList::getLocalInstance() {Mutex::Autolock autoLock(sInitMutex);if (sCodecList == nullptr) {MediaCodecList *codecList = new MediaCodecList(GetBuilders());if (codecList->initCheck() == OK) {sCodecList = codecList;if (isProfilingNeeded()) {ALOGV("Codec profiling needed, will be run in separated thread.");pthread_t profiler;if (pthread_create(&profiler, nullptr, profilerThreadWrapper, nullptr) != 0) {ALOGW("Failed to create thread for codec profiling.");}}} else {// failure to initialize may be temporary. retry on next call.delete codecList;}}return sCodecList;
}sp<IMediaCodecList> MediaCodecList::sRemoteList;sp<MediaCodecList::BinderDeathObserver> MediaCodecList::sBinderDeathObserver;
sp<IBinder> MediaCodecList::sMediaPlayer;  // kept since linked to deathvoid MediaCodecList::BinderDeathObserver::binderDied(const wp<IBinder> &who __unused) {Mutex::Autolock _l(sRemoteInitMutex);sRemoteList.clear();sBinderDeathObserver.clear();
}// static
sp<IMediaCodecList> MediaCodecList::getInstance() {Mutex::Autolock _l(sRemoteInitMutex);if (sRemoteList == nullptr) {sMediaPlayer = defaultServiceManager()->getService(String16("media.player"));sp<IMediaPlayerService> service =interface_cast<IMediaPlayerService>(sMediaPlayer);if (service.get() != nullptr) {sRemoteList = service->getCodecList();if (sRemoteList != nullptr) {sBinderDeathObserver = new BinderDeathObserver();sMediaPlayer->linkToDeath(sBinderDeathObserver.get());}}if (sRemoteList == nullptr) {// if failed to get remote list, create local listsRemoteList = getLocalInstance();}}return sRemoteList;
}MediaCodecList::MediaCodecList(std::vector<MediaCodecListBuilderBase*> builders) {mGlobalSettings = new AMessage();mCodecInfos.clear();MediaCodecListWriter writer;for (MediaCodecListBuilderBase *builder : builders) {if (builder == nullptr) {ALOGD("ignored a null builder");continue;}auto currentCheck = builder->buildMediaCodecList(&writer);if (currentCheck != OK) {ALOGD("ignored failed builder");continue;} else {mInitCheck = currentCheck;}}writer.writeGlobalSettings(mGlobalSettings);writer.writeCodecInfos(&mCodecInfos);std::stable_sort(mCodecInfos.begin(),mCodecInfos.end(),[](const sp<MediaCodecInfo> &info1, const sp<MediaCodecInfo> &info2) {// null is lowestreturn info1 == nullptr|| (info2 != nullptr && info1->getRank() < info2->getRank());});// remove duplicate entriesbool dedupe = property_get_bool("debug.stagefright.dedupe-codecs", true);if (dedupe) {std::set<std::string> codecsSeen;for (auto it = mCodecInfos.begin(); it != mCodecInfos.end(); ) {std::string codecName = (*it)->getCodecName();if (codecsSeen.count(codecName) == 0) {codecsSeen.emplace(codecName);it++;} else {it = mCodecInfos.erase(it);}}}
}MediaCodecList::~MediaCodecList() {
}status_t MediaCodecList::initCheck() const {return mInitCheck;
}
http://www.lryc.cn/news/264887.html

相关文章:

  • 【稳定检索|投稿优惠】2024年交通运输与能源动力国际学术会议(IACTEP 2024)
  • React学习计划-React16--React基础(三)收集表单数据、高阶函数柯里化、类的复习
  • 研究生课程 |《数值分析》复习
  • 55 回溯算法解黄金矿工问题
  • [笔记]ByteBuffer垃圾回收
  • c++ opencv中unsigned char *、Mat、Qimage互相转换
  • 法线贴图实现衣服上皱褶特效
  • 2017年第六届数学建模国际赛小美赛B题电子邮件中的笔迹分析解题全过程文档及程序
  • CentOS安装Python解释,CentOS设置python虚拟环境,linux设置python虚拟环境
  • 在线智能防雷监控(检测)系统应用方案
  • flutter + firebase 云消息通知教程 (android-安卓、ios-苹果)
  • 2024年PMP考试新考纲-PMBOK第七版-项目管理原则真题解析
  • vscode开发python环境配置
  • 数据库客户案例:每个物种都需要一个数据库!
  • 数据分析思维导图
  • 网络基础【网线的制作、OSI七层模型、集线器、交换机介绍、路由器的配置】
  • C++中的继承(二)
  • sklearn多项式回归和线性回归
  • Postman报:400 Bad Request
  • apache poi_5.2.5 实现表格内某一段单元格的复制
  • Oracle重建索引详解
  • 众和策略证券开户首选:股票增持是好还是坏?大股东增持规定?
  • UE4移动端最小包优化实践
  • 用户管理第2节课--idea 2023.2 后端--实现基本数据库操作(操作user表) -- 自动生成
  • java开发面试:常见业务场景之单点登录SSO(JWT)、权限认证、上传数据的安全性的控制、项目中遇到的问题、日志采集(ELK)、快速定位系统的瓶颈
  • Java网络编程原理与实践--从Socket到BIO再到NIO
  • ARM GIC(三) gicv2架构
  • 第4章Netty第二节入门案例+channel,future,promise介绍
  • 【论文笔记】3D Gaussian Splatting for Real-Time Radiance Field Rendering
  • 【生物信息学】层次聚类过程