hi, we are trying to modify the android filesystem.we are trying to use the camera service from a c++ code.we are using the cameralistner class present in /root/Desktop/froyo/frameworks/base/include/camera/ Camera.h .
the cameralistner class consists of only 3 pure virtual functions when i try compiling the the .so i get the following error : defined reference to `typeinfo for android::RefBase' when investigated we got know that cameralistner inherits from refbase (cameralistner:virtual public refbase). we also got to that the refbase is part libutils.so we have then added all the libraries but still have the same problem.I have send my C++ files and the makefile. please help!!!!! thanks and regards, Ajay -- unsubscribe: android-porting+unsubscr...@googlegroups.com website: http://groups.google.com/group/android-porting
#include <testcameralistner.h> #include <qdebug.h> // provides persistent context for calls from native code to Java int main(int argc, char *argv[]) { sp<Camera> camera=Camera::connect(); if (camera->getStatus() != NO_ERROR) { qDebug()<<"an error has occured"<<"\n"; return 1; } TestCameraListner *context = new TestCameraListner(camera); // camera->setListener(context); sleep(10); camera->takePicture(); return 0; }
Makefile
Description: Binary data
#include <testcameralistner.h> //#include <utils/RefBase.h> extern "C" { #include <fcntl.h> } static void dump_to_file(const char *fname, uint8_t *buf, uint32_t size); TestCameraListner::TestCameraListner(const sp<Camera>& camera) { mCamera = camera; // mManualBufferMode = false; // mManualCameraCallbackSet = false; } TestCameraListner::~TestCameraListner() { release (); } void TestCameraListner::postData(int32_t msgType, const sp<IMemory>& dataPtr) { // VM pointer will be NULL if object is released //Mutex::Autolock _l(mLock); ssize_t offset; size_t size; sp<IMemoryHeap> heap = dataPtr->getMemory(&offset, &size); // return data based on callback type switch(msgType) { case CAMERA_MSG_COMPRESSED_IMAGE: LOGV("rawCallback"); dump_to_file("/data/photo.jpg",(uint8_t *)heap->base() + offset, size); break; default: break; } } void TestCameraListner::notify(int32_t msgType, int32_t ext1, int32_t ext2) { } void TestCameraListner::postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) { } void TestCameraListner::release() { LOGV("release"); //Mutex::Autolock _l(mLock); mCamera.clear(); } static void dump_to_file(const char *fname, uint8_t *buf, uint32_t size) { int nw, cnt = 0; uint32_t written = 0; LOGV("opening file [%s]\n", fname); int fd = open(fname, O_RDWR | O_CREAT); if (fd < 0) { LOGE("failed to create file [%s]: %s", fname, strerror(errno)); return; } LOGV("writing %d bytes to file [%s]\n", size, fname); while (written < size) { nw = ::write(fd, buf + written, size - written); if (nw < 0) { LOGE("failed to write to file [%s]: %s", fname, strerror(errno)); break; } written += nw; cnt++; } LOGV("done writing %d bytes to file [%s] in %d passes\n", size, fname, cnt); ::close(fd); }
#ifndef TESTCAMERALISTNER_H #define TESTCAMERALISTNER_H #include <camera/Camera.h> #include <binder/IMemory.h> #include <utils/threads.h> //#include <utils/RefBase.h> using namespace android; class RefBase; class TestCameraListner: public CameraListener { public: TestCameraListner(const sp<Camera>& camera); virtual ~ TestCameraListner (); virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2); virtual void postData(int32_t msgType, const sp<IMemory>& dataPtr); virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr); //void addCallbackBuffer(QByteArray cbb); //void setCallbackMode(JNIEnv *env, bool installed, bool manualMode); //sp<Camera> getCamera() {/* Mutex::Autolock _l(mLock);*/ return mCamera; } void release(); private: //void copyAndPost(const sp<IMemory>& dataPtr, int msgType); sp<Camera> mCamera; // strong reference to native object //Mutex mLock; //Vector<jbyteArray> mCallbackBuffers; // Global reference application managed byte[] //bool mManualBufferMode; // Whether to use application managed buffers. //bool mManualCameraCallbackSet; // Whether the callback has been set, used to reduce unnecessary calls to set the callback. }; #endif // TESTCAMERALISTNER_H