Android Camera Framework Stream(三)

AndroidCameraFrameworkStream(三)

7.那么现在的关键就是Client类了·进一步跟进:

   CameraService::Client::Client(const sp<CameraService>& cameraService, const sp<ICameraClient>& cameraClient, pid_t clientPid)
   {
         …..
         mCameraService = cameraService;
         mCameraClient = cameraClient;
         mClientPid = clientPid;
         mHardware = openCameraHardware();
    }
将 cameraService 和 cameraClient 的实例分别赋值给了 Client 的类成员变量。

另外openCameraHardware()是值得注意的地方,也就是连接上层应用和底层驱动的关键,通过调用openCameraHardware()得到了一个CameraHardwareInterface实例对象,并赋值给自己的类成员:`

sp<CameraHardwareInterface>mHardware;

对hardware的操作就是通过该对象完成的,所以说真正意义上的功能实现其实就是在这里,即client类的函数接口调用。

对于hardware的东东咱们暂时不去关注吧。

那么我们再次仔细研究下Client类的继承关系(这些继承关系很容易混乱,涉及到较多的多态类型转换),这个其实往往都很关键:


Client继承于BnCamera,而BnCamera则继承于ICamera,也就是说Client继承了ICamera,实现了ICamera中的函数。

进而发现,原来绕一个大圈,把最开始的图简化下:


8.除此之外还有两个步骤或许需要去研究下:

先从单一函数去跟进,看具体一些callback的实现流程:

   // callback from camera service
   void Camera::notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)
   {
       sp<CameraListener> listener;
       {
           Mutex::Autolock _l(mLock);
           listener = mListener;
        }
        if (listener != NULL) {
           listener->notify(msgType, ext1, ext2);
        }
    }

这是Camera类中一个callback函数实现,但其本质在哪?先看camera类的继承关系:


通过以上的继承关系,继续跟进其父类ICameraClient:

    class ICameraClient: public IInterface
    {
        public:
            DECLARE_META_INTERFACE(CameraClient);
 
            virtual void  notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2) = 0;
            virtual void  dataCallback(int32_t msgType, const sp<IMemory>& data) = 0;
            virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const     sp<IMemory>& data) = 0;
     };

其中 notifyCallback() 又是纯虚函数 , 则同样说明实现在其子类 BpCameraClient 中:

   // generic callback from camera service to app
   void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)
   {
        LOGV("notifyCallback");
        Parcel data, reply;
        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
        data.writeInt32(msgType);
        data.writeInt32(ext1);
        data.writeInt32(ext2);
        remote()->transact(NOTIFY_CALLBACK,data, &reply, IBinder::FLAG_ONEWAY);
    }

然后通过Binder通讯调用到BnCameraClient中实现:

   status_t BnCameraClient::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
   {
       switch(code) {
       case NOTIFY_CALLBACK: {
            LOGV("NOTIFY_CALLBACK");
            CHECK_INTERFACE(ICameraClient, data, reply);
            int32_t msgType = data.readInt32();
            int32_t ext1 = data.readInt32();
            int32_t ext2 = data.readInt32();
            notifyCallback(msgType, ext1, ext2);
            return NO_ERROR;
        } break;
        ….
    }

进而调用到了Camera.cpp中的函数实现了,但或许你有疑问,这些callback是涉及到一些驱动的callback,哪怎么跟驱动联系起来那?

结合之前对hardware接口调用的类Client,进一步可以发现callback的处理同样是在Client类实例化的时候:

    CameraService::Client::Client(const sp<CameraService>& cameraService, const sp<ICameraClient>& cameraClient, pid_t clientPid)
   {
         …..
         mHardware->setCallbacks(notifyCallback,
                               dataCallback,
                               dataCallbackTimestamp,
                               mCameraService.get());
          …..
    }

调用了mHardware将callback传入,但此处的notifyCallback并不是camera.cpp中的函数,而是client类的notifyCallback函数。

再继续看client类中的notifyCallback函数实现:

     void CameraService::Client::notifyCallback(int32_t msgType, int32_t ext1,int32_t ext2, void* user)
     {
         …..
        default:
            sp<ICameraClient> c = client->mCameraClient;
            if (c != NULL) {
                c->notifyCallback(msgType, ext1, ext2);
            }
            break;
         …..
      }

通过得到ICameraClient实例进而调用到了具体的对象Camera的notifyCallback()函数。这个地方估计会遇见跟ICameraService函数调用一样的问题,ICameraClient函数调用所需要的函数实例在哪?

记得上述ICameraService讲到的connect()函数嘛?其中有一个参数不能被忽略掉的,就是ICameraClient,但它在真正传入的时候却是一个ICameraClient子类camera的实例对象。

    CameraService:
         sp<ICamera> CameraService::connect(const sp<ICameraClient>& cameraClient)
          {
                   …..
         // create a new Client object
             client = new Client(this, cameraClient, callingPid);
                   …..
          }
        
    Client:
         CameraService::Client::Client(const sp<CameraService>& cameraService,const sp<ICameraClient>& cameraClient, pid_t clientPid)
        {
              ….
             mCameraService = cameraService;
             mCameraClient = cameraClient;
             ….
        }

这样就清楚了,其实Client在调用设置callback的调用最终还是调用到了camera.cpp中的callback函数,进而将具体内容通过callback反馈给上层应用做出相应的处理。

原文地址:http://blog.163.com/shawpin@126/blog/static/11666375220109231035974/

【Unity】YooAsset与HybridCLR:高效资源管理与代码热更的黄金组合 本文深入探讨了Unity开发中YooAsset与HybridCLR的组合应用,为需要长期运营的项目提供了完整的资源与代码热更新解决方案。YooAsset作为高效的资源管理框架,简化了AssetBundle的打包、加载与热更流程;而HybridCLR则攻克了IL2CPP模式下C#代码无法热更的难题。两者结合,实现了从资源到逻辑的平滑在线更新,极大提升了开发迭代与线上维护的效率。 阅读详情

相关推荐

华为HCIP-001:PPPOE配置模拟实验

华为HCIP01:PPPOE配置模拟实验 实验环境 pppoe-client上面的接口信息 [AR1]dis ip interface brief *down: administratively down ^down: standby (l): loopback (s): spoofing The number of interface that is UP in Physical is 2 The number of interface that is DOWN in Physical is 1 Th

兔子乖乖 1810

android Camera 数据流程分析

上一篇文章  android Camera --- 架构简介          地址: http://blog.csdn.net/andyhuabing/article/details/7229557   对其层次结构进行了简要的介绍, 这篇文章主要针对其数据流程进行分析。Camera一般用于图像浏览、拍照和视频录制。这里先对图像浏览和拍照的数据流进行分析,后面再对视频电话部分进行分析。

andyhuabing的专栏 2万+

手把手教你用Multisim仿真ADC接口电路(附峰值采样与电平抬升实战)

本文通过Multisim软件,手把手教学如何构建高保真ADC前端信号调理电路。核心实战内容包括峰值采样保持电路与电平抬升电路的设计、仿真与调试,旨在解决模拟信号接入ADC时遇到的幅度不匹配、负电压等问题,帮助电子设计者快速掌握关键接口电路的实现技巧。

ooo22的博客 269

Android 10 Camera学习笔记:Camera Framework架构

CameraFramework架构 又是很久没有写了,这几天一直在看camera framework相关源码,于是乎整理出了这个架构图。Camera API2比较好整理,反而是Camera API1花了我不少时间。好了,现在开始正文吧。本文主要是基于Android 10源码分析得出。 横向看:Camera从上到下,主要分为三层:APP client 、CameraFramework、CameraHal。这三层分别运行在不同的进程,APP client运行在APP用户进程中,CameraFramework运行

biandan1231的专栏 6436

华为擎云W515 PGUV-WBY0安装银河麒麟V10全流程解析

本文详细解析了华为擎云W515 PGUV-WBY0安装银河麒麟V10系统的全流程,包括准备工作、镜像下载与校验、启动盘制作、BIOS设置、安装过程关键选择、系统初始化及常见问题排查。特别针对ARM架构设备提供了实用技巧,帮助用户顺利完成国产化系统的部署与优化。

weixin_28725949的博客 718

基于单片机自行车码表控制系统设计

*单片机设计介绍,基于单片机自行车码表控制系统设计。

QQ2193276455的博客 1495

Android Camera Framework Stream(一)

现在我们尝试从最开始的启动流程来熟悉android camera的整体framework流程:首先从上图的各个步骤来逐一分析流程,后续会根据具体的一些点进行内容的添加和扩充:?Camera.javapackages/apps/camera/src/com/android/最上层的应用就是从这个文件开始。该文件集中了整个android上层应用的所有相关内容,当然更多的则为界面的代码实现。如果出现了camera应用界面的问题(当然除了camera拍摄区域内容外),可以从android的代码入手。?Camera.

zwj0403的专栏 2166

Unreal 从入门到进阶 之 如何实现Pixel Streaming

Unreal Engine 5 (UE5) 的 Pixel Streaming 是一项基于云端的实时流媒体技术,允许将 UE5 应用的高质量图形渲染结果通过 WebRTC 协议传输到用户的浏览器或轻量级设备,同时将用户输入(如鼠标、键盘、触控)回传到服务器处理。UE的插件相对比较好用,但是就是环境下载总是失败。希望这篇文章对你有所帮助。

TxNet 1381

Camera APP层分析之对camera framework层封装解析

Android4.4版本的camera和4.0版本的设计差距还是很大的,4.0版本以前的camera在是camera 主activity中直接调用camera hal层的的接口(如android.hardware.camera.open(), android.hardware.camera.setPreviewDisplay(),android.hardware.camera..startPrev

liuwg1226的专栏 1436

【补充篇】三万字了解AUTOSAR软件架构(一)

主要讲解了AUTOSAR软件架构的分层及各个栈的作用

weixin_47571898的博客 1127

Nuvoton NPCM845X SoC

摘要:NPCM845X是Nuvoton推出的第四代BMC片上系统,专为服务器管理设计。采用四核Arm Cortex-A35架构,集成安全启动机制和硬件级安全组件,支持OP-TEE可信执行环境。提供完整的信任链设计,从Boot ROM到Linux内核分层验证。具备丰富外设接口和管理功能,支持OpenBMC、IPMI 2.0等标准,适用于数据中心安全管控需求。

Linux内核架构师 110

Android Camera模块(一)

Android Camera模块(一) 一、Android Camera架构 1.1 整体架构 架构参考Android Camera简单整理(一)-Camera Android架构(基于Q) google 官方图: 从上图得知,Android手机中Camera软件主要有大体上有4层: 1.应用层: 应用开发者调用AOSP提供的接口即可,AOSP的接口即Android提供的相机应用的通用接口,这些接口将通过Binder与Framework层的相机服务进行操作与数据传递; 2.Framework层: 位于 f

weixin_44205232的博客 6213

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Android O 的camera framework-hal层框架笔记(基于高通845平台)

Android O 的camera framework/hal层框架笔记(基于高通845平台) tags: android camera 文章目录Android O 的camera framework/hal层框架笔记(基于高通845平台)@[toc]**0 前言** **1 CameraServer的启动** **2 打开一个Camera** **3 为Camera创建stream** **4...

whshiyun的专栏 2635

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

Android Camera Framework Stream

转自 http://blog.163.com/shawpin@126/blog/static/116663752201092394147937/   现在我们尝试从最开始的启动流程来熟悉android camera的整体framework流程: 首先从上图的各个步骤来逐一分析流程,后续会根据具体的一些点进行内容的添加和扩充:   Camera.java packages/apps/

hupuxiang的专栏 728

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

Camera Framework Service流程总结

文章目 前言 本文主要记录些Camera Servie的一些问题的理解,对几个问题进行讨论,一些参考Camera Service 一、代码位置 向上暴露的接口 具体实现 二、关系类图 三、问题讨论 1.Buffer是在哪分配的,它是怎么轮转的 1.Buffer的数量 status_t Camera3Device::HalInterface::configureStreams(const came.........

zhangxinjieli3的专栏 1276

Android Camera Framework Stream(二)

接下来,我们通过对流程的步步分析来将 camera 整体串接起来 : 1.     首先则看看 camera.java 的 onCreate 函数入口,针对 android 的所有应用, onCreate 函数入口作为跟踪和了解应用架构的首选。              @O

158
上一篇: Android Camera Framework Stream(三)
下一篇: 常用的一些正则表达式写法
iteye_2829
博客等级 码龄8年 55粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值