【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  }
相关推荐
xvch2 小时前
Kotlin 2.1.0 入门教程(二十三)泛型、泛型约束、协变、逆变、不变
android·kotlin
ianozo3 小时前
BUU40 [安洵杯 2019]easy_serialize_php
android·开发语言·php
abs6253 小时前
uniapp使用uts插件启动原生安卓Service
android·uni-app·uniapp uts插件·uniapp 安卓服务
Evaporator Core3 小时前
MATLAB在投资组合优化中的应用:从基础理论到实践
android
Neo Evolution4 小时前
Flutter与移动开发的未来:谷歌的技术愿景与实现路径
android·人工智能·学习·ios·前端框架·webview·着色器
coooliang4 小时前
Flutter项目中设置安卓启动页
android·flutter
xianrenli384 小时前
android 使用 zstd算法压缩文件
android
九思x5 小时前
Android Studio安装配置及运行
android·ide·android studio
风浅月明16 小时前
[Android]如何判断当前APP是Debug还是Release环境?
android
freflying111916 小时前
使用jenkins构建Android+Flutter项目依赖自动升级带来兼容性问题及Jenkins构建速度慢问题解决
android·flutter·jenkins