SlideShare una empresa de Scribd logo
1 de 27
Descargar para leer sin conexión
Android Camera  Architecture Author: Picker
Architecture
 
Architecture Path of the Source Code  frameworks/base/core/java/android/hardware/ frameworks/base/core/jni/ frameworks/base/libs/camera/ frameworks/base/services/camera/libcameraservice/ vendor/nvidia/tegra/hal/libnvomxcamera/
Proxy Pattern
Reference to:  Design Patterns  by Gamma, Helm, Johnson, Vlissides
A Possible Object Diagram of Proxy Structure at Run-Time Proxy Structure Reference to:  Design Patterns  by Gamma, Helm, Johnson, Vlissides
Implementation - Design a Abstract Class for Proxy and Server to Extend it. - Give an RealObject Instance for Proxy. Execute these Methods by Proxy.  - The Client just Need to Face the Proxy.
Singleton Pattern
Reference to:  Design Patterns  by Gamma, Helm, Johnson, Vlissides Singleton Structure
Reference to:  Design Patterns  by Gamma, Helm, Johnson, Vlissides Singleton* Singleton::_instance = 0; Singleton* Singleton::Instance () { if (_instance == 0) { _instance = new Singleton; } return _instance; } Implementation
Architecture Diagram
Proxy Pattern Singleton Pattern
33 // client singleton for camera service binder interface 34 Mutex Camera::mLock; 35  sp<ICameraService> Camera::mCameraService; 36 sp<Camera::DeathNotifier> Camera::mDeathNotifier; Singleton Pattern Camera.cpp frameworks/base/libs/camera/
38 // establish binder interface to camera service 39 const sp<ICameraService>& Camera::getCameraService() 40 {  41  Mutex::Autolock _l(mLock); 42  if (mCameraService.get() == 0) { 43  sp<IServiceManager> sm = defaultServiceManager(); 44  sp<IBinder> binder; 45  do { 46  binder = sm->getService(String16(&quot;media.camera&quot;)); 47  if (binder != 0) 48  break; 49  LOGW(&quot;CameraService not published, waiting...&quot;); 50  usleep(500000); // 0.5 s  51  } while(true); 52  if (mDeathNotifier == NULL) {  53  mDeathNotifier = new DeathNotifier(); 54  } 55  binder->linkToDeath(mDeathNotifier); 56  mCameraService = interface_cast<ICameraService>(binder); 57  } 58  LOGE_IF(mCameraService==0, &quot;no CameraService!?&quot;); 59  return mCameraService; 60 }  Camera.cpp frameworks/base/libs/camera/
53  class BpCamera: public BpInterface<ICamera> 54 { 55 public: 56  BpCamera(const sp<IBinder>& impl) 57  : BpInterface<ICamera>(impl) 58  { 59  } 60  61  // disconnect from camera service 62  void disconnect() 63  { 64  LOGV(&quot;disconnect&quot;); 65  Parcel data, reply; 66  data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); 67  remote()->transact(DISCONNECT, data, &reply); 68  } ICamera.cpp frameworks/base/libs/camera/ Proxy Pattern - Sender
34 class CameraService : 35  public BinderService<CameraService>, 36  public BnCameraService 37 { 38  class Client; 39  friend class BinderService<CameraService>; 82  class Client : public BnCamera 83  { 84  public: 85  // ICamera interface (see ICamera for details) 86  virtual void  disconnect(); 87  virtual status_t  connect(const sp<ICameraClient>& client); 88  virtual status_t  lock(); 89  virtual status_t  unlock(); … … … 206 } Proxy Pattern - Receiver CameraService.h frameworks/base/services/camera/libcameraservice/
A Simple Workflow of  Starting the Camera Preview
 
An Example: Set the Preview Display
349  public final void  setPreviewDisplay (SurfaceHolder holder) throws IOException { 350  if (holder != null) { 351  setPreviewDisplay (holder.getSurface()); 352  } else { 353  setPreviewDisplay ((Surface)null); 354  } 355  } Camera.java frameworks/base/core/java/android/hardware/
android_hardware_Camera.cpp 381 static void  android_hardware_Camera_setPreviewDisplay ( JNIEnv *env, jobject thiz, jobject jSurface) 382 { 383  LOGV(&quot;setPreviewDisplay&quot;); 384  sp<Camera> camera = get_native_camera(env, thiz, NULL); 385  if (camera == 0) return; 386  387  sp<Surface> surface = NULL;  388  if (jSurface != NULL) { 389  surface = reinterpret_cast<Surface*>( env->GetIntField(jSurface, fields.surface)); 390  } 391  if ( camera->setPreviewDisplay (surface) != NO_ERROR) { 392  jniThrowException(env, &quot;java/io/IOException&quot;, &quot;setPreviewDisplay failed&quot;); 393  } 394 }  frameworks/base/core/jni/
Camera.cpp frameworks/base/libs/camera/ 171 // pass the buffered ISurface to the camera service 172 status_t  Camera::setPreviewDisplay (const sp<Surface>& surface) 173 {  174  LOGV(&quot;setPreviewDisplay&quot;); 175  sp <ICamera> c = mCamera; 176  if (c == 0) return NO_INIT;  177  if (surface != 0) { 178  return  c->setPreviewDisplay (surface->getISurface()); 179  } else { 180  LOGD(&quot;app passed NULL surface&quot;); 181  return  c->setPreviewDisplay (0); 182  } 183 }
ICamera.cpp 70  // pass the buffered ISurface to the camera service 71  status_t  setPreviewDisplay (const sp<ISurface>& surface) 72  { 73  LOGV(&quot;setPreviewDisplay&quot;);  74  Parcel data, reply; 75  data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); 76  data.writeStrongBinder(surface->asBinder()); 77  remote()->transact (SET_PREVIEW_DISPLAY, data, &reply); 78  return reply.readInt32();  79  } frameworks/base/libs/camera/
CameraService.cpp frameworks/base/libs/camera/ 485 status_t  CameraService::Client::setPreviewDisplay (const sp<ISurface>& surface) { 486  LOG1(&quot;setPreviewDisplay(%p) (pid %d)&quot;, surface.get(), getCallingPid());  … … … 510  mSurface = surface; 511  mOverlayRef = 0; 512  // If preview has been already started, set overlay or register preview 513  // buffers now. 514  if ( mHardware->previewEnabled() ) {  515  if (mUseOverlay) { 516  result = setOverlay();  517  } else if (mSurface != 0) {  518  result = registerPreviewBuffers(); 519  } 520  }
frameworks/base/libs/camera/ CameraService.cpp 525 status_t  CameraService::Client::registerPreviewBuffers () { 526  int w, h; 527  CameraParameters params(mHardware->getParameters()); 528  params.getPreviewSize(&w, &h); 529  530  // FIXME: don't use a hardcoded format here. 531  ISurface::BufferHeap buffers(w, h, w, h, 532  HAL_PIXEL_FORMAT_YCrCb_420_SP, 533  mOrientation, 534  0, 535  mHardware->getPreviewHeap ()); 536  537  status_t result = mSurface->registerBuffers(buffers); 538  if (result != NO_ERROR) { 539  LOGE(&quot;registerBuffers failed with status %d&quot;, result); 540  } 541  return result; 542 }
frameworks/base/libs/camera/ CameraHardwareStub.cpp 104 sp<IMemoryHeap>  CameraHardwareStub::getPreviewHeap()  const 105 {  106  return mPreviewHeap; 107 }

Más contenido relacionado

La actualidad más candente

Android Multimedia Framework
Android Multimedia FrameworkAndroid Multimedia Framework
Android Multimedia FrameworkPicker Weng
 
Project meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture OverviewProject meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture OverviewYu-Hsin Hung
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debuggingUtkarsh Mankad
 
Intro to react native
Intro to react nativeIntro to react native
Intro to react nativeModusJesus
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System ServerOpersys inc.
 
ExoPlayer for Application developers
ExoPlayer for Application developersExoPlayer for Application developers
ExoPlayer for Application developersHassan Abid
 
Building a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootBuilding a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootOmri Spector
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationKumar Y
 
Java servlets
Java servletsJava servlets
Java servletslopjuan
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask PresentationParag Mujumdar
 

La actualidad más candente (20)

Express js
Express jsExpress js
Express js
 
Android Multimedia Framework
Android Multimedia FrameworkAndroid Multimedia Framework
Android Multimedia Framework
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Project meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture OverviewProject meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture Overview
 
Flask
FlaskFlask
Flask
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Intro to react native
Intro to react nativeIntro to react native
Intro to react native
 
Embedded Android : System Development - Part IV
Embedded Android : System Development - Part IVEmbedded Android : System Development - Part IV
Embedded Android : System Development - Part IV
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
 
ExoPlayer for Application developers
ExoPlayer for Application developersExoPlayer for Application developers
ExoPlayer for Application developers
 
Building a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootBuilding a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring Boot
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Java servlets
Java servletsJava servlets
Java servlets
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Express JS
Express JSExpress JS
Express JS
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
 
Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
 

Similar a Android Camera Architecture

Capture image on eye blink
Capture image on eye blinkCapture image on eye blink
Capture image on eye blinkInnovationM
 
Analyzing the Performance of Mobile Web
Analyzing the Performance of Mobile WebAnalyzing the Performance of Mobile Web
Analyzing the Performance of Mobile WebAriya Hidayat
 
Inversion Of Control
Inversion Of ControlInversion Of Control
Inversion Of Controlbhochhi
 
2016 W3C Conference #4 : ANGULAR + ES6
2016 W3C Conference #4 : ANGULAR + ES62016 W3C Conference #4 : ANGULAR + ES6
2016 W3C Conference #4 : ANGULAR + ES6양재동 코드랩
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Davide Cerbo
 
Non Conventional Android Programming En
Non Conventional Android Programming EnNon Conventional Android Programming En
Non Conventional Android Programming Enguest9bcef2f
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Eliran Eliassy
 
Android camera2
Android camera2Android camera2
Android camera2Takuma Lee
 
Angular 1 + es6
Angular 1 + es6Angular 1 + es6
Angular 1 + es6장현 한
 
Naive application development
Naive application developmentNaive application development
Naive application developmentShaka Huang
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...DroidConTLV
 
Integrating Angular js & three.js
Integrating Angular js & three.jsIntegrating Angular js & three.js
Integrating Angular js & three.jsJosh Staples
 
Synchronizing without internet - Multipeer Connectivity (iOS)
Synchronizing without internet - Multipeer Connectivity (iOS)Synchronizing without internet - Multipeer Connectivity (iOS)
Synchronizing without internet - Multipeer Connectivity (iOS)Jorge Maroto
 
JUDCon London 2011 - Bin packing with drools planner by example
JUDCon London 2011 - Bin packing with drools planner by exampleJUDCon London 2011 - Bin packing with drools planner by example
JUDCon London 2011 - Bin packing with drools planner by exampleGeoffrey De Smet
 

Similar a Android Camera Architecture (20)

Learning Dtrace
Learning DtraceLearning Dtrace
Learning Dtrace
 
Capture image on eye blink
Capture image on eye blinkCapture image on eye blink
Capture image on eye blink
 
Analyzing the Performance of Mobile Web
Analyzing the Performance of Mobile WebAnalyzing the Performance of Mobile Web
Analyzing the Performance of Mobile Web
 
FLAR Workflow
FLAR WorkflowFLAR Workflow
FLAR Workflow
 
WebXR if X = how?
WebXR if X = how?WebXR if X = how?
WebXR if X = how?
 
Inversion Of Control
Inversion Of ControlInversion Of Control
Inversion Of Control
 
2016 W3C Conference #4 : ANGULAR + ES6
2016 W3C Conference #4 : ANGULAR + ES62016 W3C Conference #4 : ANGULAR + ES6
2016 W3C Conference #4 : ANGULAR + ES6
 
[W3C HTML5 2016] Angular + ES6
[W3C HTML5 2016] Angular + ES6[W3C HTML5 2016] Angular + ES6
[W3C HTML5 2016] Angular + ES6
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)
 
Non Conventional Android Programming En
Non Conventional Android Programming EnNon Conventional Android Programming En
Non Conventional Android Programming En
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 
Android camera2
Android camera2Android camera2
Android camera2
 
my accadanic project ppt
my accadanic project pptmy accadanic project ppt
my accadanic project ppt
 
Angular 1 + es6
Angular 1 + es6Angular 1 + es6
Angular 1 + es6
 
Naive application development
Naive application developmentNaive application development
Naive application development
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 
Integrating Angular js & three.js
Integrating Angular js & three.jsIntegrating Angular js & three.js
Integrating Angular js & three.js
 
Synchronizing without internet - Multipeer Connectivity (iOS)
Synchronizing without internet - Multipeer Connectivity (iOS)Synchronizing without internet - Multipeer Connectivity (iOS)
Synchronizing without internet - Multipeer Connectivity (iOS)
 
JUDCon London 2011 - Bin packing with drools planner by example
JUDCon London 2011 - Bin packing with drools planner by exampleJUDCon London 2011 - Bin packing with drools planner by example
JUDCon London 2011 - Bin packing with drools planner by example
 

Más de Picker Weng

Introduction to Agile & Scrum
Introduction to Agile & ScrumIntroduction to Agile & Scrum
Introduction to Agile & ScrumPicker Weng
 
The Theory and Implementation of DVFS on Linux
The Theory and Implementation of DVFS on LinuxThe Theory and Implementation of DVFS on Linux
The Theory and Implementation of DVFS on LinuxPicker Weng
 
Tutorial for Installing eclox
Tutorial for Installing ecloxTutorial for Installing eclox
Tutorial for Installing ecloxPicker Weng
 
Chromium OS - User Accounts and Management
Chromium OS - User Accounts and ManagementChromium OS - User Accounts and Management
Chromium OS - User Accounts and ManagementPicker Weng
 
[C++ GUI Programming with Qt4] chap8
[C++ GUI Programming with Qt4] chap8[C++ GUI Programming with Qt4] chap8
[C++ GUI Programming with Qt4] chap8Picker Weng
 
[C++ GUI Programming with Qt4] chap6
[C++ GUI Programming with Qt4] chap6[C++ GUI Programming with Qt4] chap6
[C++ GUI Programming with Qt4] chap6Picker Weng
 
OpenCV 2.2.0 for Android
OpenCV 2.2.0 for AndroidOpenCV 2.2.0 for Android
OpenCV 2.2.0 for AndroidPicker Weng
 
Vim+cscope+ctags+taglist
Vim+cscope+ctags+taglistVim+cscope+ctags+taglist
Vim+cscope+ctags+taglistPicker Weng
 

Más de Picker Weng (9)

Introduction to Agile & Scrum
Introduction to Agile & ScrumIntroduction to Agile & Scrum
Introduction to Agile & Scrum
 
The Theory and Implementation of DVFS on Linux
The Theory and Implementation of DVFS on LinuxThe Theory and Implementation of DVFS on Linux
The Theory and Implementation of DVFS on Linux
 
Tutorial for Installing eclox
Tutorial for Installing ecloxTutorial for Installing eclox
Tutorial for Installing eclox
 
Chromium OS - User Accounts and Management
Chromium OS - User Accounts and ManagementChromium OS - User Accounts and Management
Chromium OS - User Accounts and Management
 
[C++ GUI Programming with Qt4] chap8
[C++ GUI Programming with Qt4] chap8[C++ GUI Programming with Qt4] chap8
[C++ GUI Programming with Qt4] chap8
 
[C++ GUI Programming with Qt4] chap6
[C++ GUI Programming with Qt4] chap6[C++ GUI Programming with Qt4] chap6
[C++ GUI Programming with Qt4] chap6
 
OpenCV 2.2.0 for Android
OpenCV 2.2.0 for AndroidOpenCV 2.2.0 for Android
OpenCV 2.2.0 for Android
 
Uml
UmlUml
Uml
 
Vim+cscope+ctags+taglist
Vim+cscope+ctags+taglistVim+cscope+ctags+taglist
Vim+cscope+ctags+taglist
 

Último

Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 

Último (20)

Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 

Android Camera Architecture

  • 1. Android Camera Architecture Author: Picker
  • 3.  
  • 4. Architecture Path of the Source Code frameworks/base/core/java/android/hardware/ frameworks/base/core/jni/ frameworks/base/libs/camera/ frameworks/base/services/camera/libcameraservice/ vendor/nvidia/tegra/hal/libnvomxcamera/
  • 6. Reference to: Design Patterns by Gamma, Helm, Johnson, Vlissides
  • 7. A Possible Object Diagram of Proxy Structure at Run-Time Proxy Structure Reference to: Design Patterns by Gamma, Helm, Johnson, Vlissides
  • 8. Implementation - Design a Abstract Class for Proxy and Server to Extend it. - Give an RealObject Instance for Proxy. Execute these Methods by Proxy. - The Client just Need to Face the Proxy.
  • 10. Reference to: Design Patterns by Gamma, Helm, Johnson, Vlissides Singleton Structure
  • 11. Reference to: Design Patterns by Gamma, Helm, Johnson, Vlissides Singleton* Singleton::_instance = 0; Singleton* Singleton::Instance () { if (_instance == 0) { _instance = new Singleton; } return _instance; } Implementation
  • 14. 33 // client singleton for camera service binder interface 34 Mutex Camera::mLock; 35 sp<ICameraService> Camera::mCameraService; 36 sp<Camera::DeathNotifier> Camera::mDeathNotifier; Singleton Pattern Camera.cpp frameworks/base/libs/camera/
  • 15. 38 // establish binder interface to camera service 39 const sp<ICameraService>& Camera::getCameraService() 40 { 41 Mutex::Autolock _l(mLock); 42 if (mCameraService.get() == 0) { 43 sp<IServiceManager> sm = defaultServiceManager(); 44 sp<IBinder> binder; 45 do { 46 binder = sm->getService(String16(&quot;media.camera&quot;)); 47 if (binder != 0) 48 break; 49 LOGW(&quot;CameraService not published, waiting...&quot;); 50 usleep(500000); // 0.5 s 51 } while(true); 52 if (mDeathNotifier == NULL) { 53 mDeathNotifier = new DeathNotifier(); 54 } 55 binder->linkToDeath(mDeathNotifier); 56 mCameraService = interface_cast<ICameraService>(binder); 57 } 58 LOGE_IF(mCameraService==0, &quot;no CameraService!?&quot;); 59 return mCameraService; 60 } Camera.cpp frameworks/base/libs/camera/
  • 16. 53 class BpCamera: public BpInterface<ICamera> 54 { 55 public: 56 BpCamera(const sp<IBinder>& impl) 57 : BpInterface<ICamera>(impl) 58 { 59 } 60 61 // disconnect from camera service 62 void disconnect() 63 { 64 LOGV(&quot;disconnect&quot;); 65 Parcel data, reply; 66 data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); 67 remote()->transact(DISCONNECT, data, &reply); 68 } ICamera.cpp frameworks/base/libs/camera/ Proxy Pattern - Sender
  • 17. 34 class CameraService : 35 public BinderService<CameraService>, 36 public BnCameraService 37 { 38 class Client; 39 friend class BinderService<CameraService>; 82 class Client : public BnCamera 83 { 84 public: 85 // ICamera interface (see ICamera for details) 86 virtual void disconnect(); 87 virtual status_t connect(const sp<ICameraClient>& client); 88 virtual status_t lock(); 89 virtual status_t unlock(); … … … 206 } Proxy Pattern - Receiver CameraService.h frameworks/base/services/camera/libcameraservice/
  • 18. A Simple Workflow of Starting the Camera Preview
  • 19.  
  • 20. An Example: Set the Preview Display
  • 21. 349 public final void setPreviewDisplay (SurfaceHolder holder) throws IOException { 350 if (holder != null) { 351 setPreviewDisplay (holder.getSurface()); 352 } else { 353 setPreviewDisplay ((Surface)null); 354 } 355 } Camera.java frameworks/base/core/java/android/hardware/
  • 22. android_hardware_Camera.cpp 381 static void android_hardware_Camera_setPreviewDisplay ( JNIEnv *env, jobject thiz, jobject jSurface) 382 { 383 LOGV(&quot;setPreviewDisplay&quot;); 384 sp<Camera> camera = get_native_camera(env, thiz, NULL); 385 if (camera == 0) return; 386 387 sp<Surface> surface = NULL; 388 if (jSurface != NULL) { 389 surface = reinterpret_cast<Surface*>( env->GetIntField(jSurface, fields.surface)); 390 } 391 if ( camera->setPreviewDisplay (surface) != NO_ERROR) { 392 jniThrowException(env, &quot;java/io/IOException&quot;, &quot;setPreviewDisplay failed&quot;); 393 } 394 } frameworks/base/core/jni/
  • 23. Camera.cpp frameworks/base/libs/camera/ 171 // pass the buffered ISurface to the camera service 172 status_t Camera::setPreviewDisplay (const sp<Surface>& surface) 173 { 174 LOGV(&quot;setPreviewDisplay&quot;); 175 sp <ICamera> c = mCamera; 176 if (c == 0) return NO_INIT; 177 if (surface != 0) { 178 return c->setPreviewDisplay (surface->getISurface()); 179 } else { 180 LOGD(&quot;app passed NULL surface&quot;); 181 return c->setPreviewDisplay (0); 182 } 183 }
  • 24. ICamera.cpp 70 // pass the buffered ISurface to the camera service 71 status_t setPreviewDisplay (const sp<ISurface>& surface) 72 { 73 LOGV(&quot;setPreviewDisplay&quot;); 74 Parcel data, reply; 75 data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); 76 data.writeStrongBinder(surface->asBinder()); 77 remote()->transact (SET_PREVIEW_DISPLAY, data, &reply); 78 return reply.readInt32(); 79 } frameworks/base/libs/camera/
  • 25. CameraService.cpp frameworks/base/libs/camera/ 485 status_t CameraService::Client::setPreviewDisplay (const sp<ISurface>& surface) { 486 LOG1(&quot;setPreviewDisplay(%p) (pid %d)&quot;, surface.get(), getCallingPid()); … … … 510 mSurface = surface; 511 mOverlayRef = 0; 512 // If preview has been already started, set overlay or register preview 513 // buffers now. 514 if ( mHardware->previewEnabled() ) { 515 if (mUseOverlay) { 516 result = setOverlay(); 517 } else if (mSurface != 0) { 518 result = registerPreviewBuffers(); 519 } 520 }
  • 26. frameworks/base/libs/camera/ CameraService.cpp 525 status_t CameraService::Client::registerPreviewBuffers () { 526 int w, h; 527 CameraParameters params(mHardware->getParameters()); 528 params.getPreviewSize(&w, &h); 529 530 // FIXME: don't use a hardcoded format here. 531 ISurface::BufferHeap buffers(w, h, w, h, 532 HAL_PIXEL_FORMAT_YCrCb_420_SP, 533 mOrientation, 534 0, 535 mHardware->getPreviewHeap ()); 536 537 status_t result = mSurface->registerBuffers(buffers); 538 if (result != NO_ERROR) { 539 LOGE(&quot;registerBuffers failed with status %d&quot;, result); 540 } 541 return result; 542 }
  • 27. frameworks/base/libs/camera/ CameraHardwareStub.cpp 104 sp<IMemoryHeap> CameraHardwareStub::getPreviewHeap() const 105 { 106 return mPreviewHeap; 107 }