1 page.title=Camera 2 pdk.version=1.0 3 doc.type=porting 4 @jd:body 5 6 <div id="qv-wrapper"> 7 <div id="qv"> 8 <h2>In this document</h2> 9 <a name="toc"/> 10 <ul> 11 <li><a href="#androidCameraBuildingDriver">Building a Camera Library</a></li> 12 <li><a href="#androidCameraSequenceDiagrams">Sequence Diagrams</a></li> 13 <li><a href="#androidCameraInterfaceIntro">Interface</a></li> 14 </ul> 15 </div> 16 </div> 17 18 <p>Android's camera subsystem connects the camera application to the application framework and user space libraries, which in turn communicate with the camera hardware layer that operates the physical camera.</p> 19 <p>The diagram below illustrates the structure of the camera subsystem.</p> 20 <p><img src="images/camera_video2.gif"></p> 21 22 23 <a name="androidCameraBuildingDriver"></a><h3>Building a Camera Library</h3> 24 25 <p>To implement a camera driver, create a shared library that implements the interface defined in <code>CameraHardwareInterface.h</code>. You must name your shared library <code>libcamera.so</code> so that it will get loaded from <code>/system/lib</code> at runtime. Place libcamera sources and <code>Android.mk</code> in <code>vendor/acme/chipset_or_board/libcamera/</code>.</p> 26 <p>The following stub <code>Android.mk</code> file ensures that <code>libcamera</code> compiles and links to the appropriate libraries:</p> 27 <pre class="prettify"> 28 LOCAL_PATH := $(call my-dir) 29 include $(CLEAR_VARS) 30 31 LOCAL_MODULE := libcamera 32 33 LOCAL_SHARED_LIBRARIES := \ 34 libutils \ 35 librpc \ 36 liblog 37 38 LOCAL_SRC_FILES += MyCameraHardware.cpp 39 40 LOCAL_CFLAGS += 41 42 LOCAL_C_INCLUDES += 43 44 LOCAL_STATIC_LIBRARIES += \ 45 libcamera-common \ 46 libclock-rpc \ 47 libcommondefs-rpc 48 49 include $(BUILD_SHARED_LIBRARY) 50 </pre> 51 52 53 <a name="androidCameraSequenceDiagrams"></a><h3>Sequence Diagrams</h3> 54 55 56 57 <a name="androidCameraSequenceDiagramsPreview"></a><h4>Preview</h4> 58 59 <p>The following diagram illustrates the sequence of function calls and actions necessary for your camera to preview.</p> 60 <img src="images/cameraPreview.jpg"> 61 62 63 <a name="androidCameraSequenceDiagramsTakePic"></a><h4>Taking a Picture</h4> 64 65 <p>The following diagram illustrates the sequence of function calls and actions necessary for your camera to take a picture.</p> 66 <img src="images/cameraTakePicture.jpg"> 67 68 69 <a name="androidCameraInterfaceIntro"></a><h3>Interface</h3> 70 71 72 73 <p class="note"><strong>Note</strong>: This document relies on some Doxygen-generated content that appears in an iFrame below. To return to the Doxygen default content for this page, <a href="camera.html">click here</a>.</p> 74 75 76 <iframe onLoad="resizeDoxFrameHeight();" src="CameraHardwareInterface_8h.html" scrolling="no" scroll="no" id="doxygen" marginwidth="0" marginheight="0" frameborder="0" style="width:100%;"></iframe> 77