【android 更改三方相机配流size】

前言

强制修改三方相机配流size, 拍照和预览都可以

声明:

本帖用的是安卓开源代码:
http://aospxref.com/android-14.0.0_r2/xref/frameworks/av/services/camera/libcameraservice/api2/CameraDeviceClient.cpp#867

修改方案

cpp 复制代码
867  binder::Status CameraDeviceClient::createStream(
868          const hardware::camera2::params::OutputConfiguration &outputConfiguration,
869          /*out*/
870          int32_t* newStreamId) {
871      ATRACE_CALL();
872  
     ... ...
917      OutputStreamInfo streamInfo;//用这个对象可以修改配流size
918      bool isStreamInfoValid = false;
919      const std::vector<int32_t> &sensorPixelModesUsed =
920              outputConfiguration.getSensorPixelModesUsed();
921      for (auto& bufferProducer : bufferProducers) {
922          // Don't create multiple streams for the same target surface
923          sp<IBinder> binder = IInterface::asBinder(bufferProducer);
924          ssize_t index = mStreamMap.indexOfKey(binder);
925          if (index != NAME_NOT_FOUND) {
926              String8 msg = String8::format("Camera %s: Surface already has a stream created for it "
927                      "(ID %zd)", mCameraIdStr.string(), index);
928              ALOGW("%s: %s", __FUNCTION__, msg.string());
929              return STATUS_ERROR(CameraService::ERROR_ALREADY_EXISTS, msg.string());
930          }
     ... ...
983      } else {
            //if(String8(mClientPackageName) == "com.xxx.xxx")
            //{
            //   直接修改streamInfo.width 、streamInfo.height即可
            //}
984          err = mDevice->createStream(surfaces, deferredConsumer, streamInfo.width,
985                  streamInfo.height, streamInfo.format, streamInfo.dataSpace,
986                  static_cast<camera_stream_rotation_t>
     ... ...
1031  
1032      return res;
1033  }
相关推荐
my_power5201 小时前
车载安卓面试题汇总
android
csj501 小时前
安卓基础之《(15)—内容提供者(1)在应用之间共享数据》
android
yeziyfx2 小时前
kotlin中 ?:的用法
android·开发语言·kotlin
2501_915918413 小时前
只有 Flutter IPA 文件,通过多工具组合完成有效混淆与保护
android·flutter·ios·小程序·uni-app·iphone·webview
robotx4 小时前
AOSP 设置-提示音和振动 添加一个带有开关(Switch)的设置项
android
青莲8434 小时前
RecyclerView 完全指南
android·前端·面试
青莲8434 小时前
Android WebView 混合开发完整指南
android·前端·面试
龙之叶4 小时前
【Android Monkey源码解析三】- 运行解析
android
KevinWang_5 小时前
Android 的 assets 资源和 raw 资源有什么区别?
android
码农幻想梦6 小时前
2021Android从零入门到实战(慕课网官方账号)
android