void CameraClient::dataCallback(int32_t msgType,
        const sp<IMemory>& dataPtr, camera_frame_metadata_t *metadata, void* user) {
    LOG2("dataCallback(%d)", msgType);

    Mutex* lock = getClientLockFromCookie(user);
    if (lock == NULL) return;
    Mutex::Autolock alock(*lock);

    CameraClient* client =
            static_cast<CameraClient*>(getClientFromCookie(user));
    if (client == NULL) return;

    if (!client->lockIfMessageWanted(msgType)) return;
    if (dataPtr == 0 && metadata == NULL) {
        ALOGE("Null data returned in data callback");
        client->handleGenericNotify(CAMERA_MSG_ERROR, UNKNOWN_ERROR, 0);
        return;
    }

    switch (msgType & ~CAMERA_MSG_PREVIEW_METADATA) {
//!++
#if 1
        case MTK_CAMERA_MSG_EXT_DATA:
            client->handleMtkExtData(dataPtr, metadata);
            break;
#endif
//!--
        case CAMERA_MSG_PREVIEW_FRAME:
            client->handlePreviewData(msgType, dataPtr, metadata);
            break;
        case CAMERA_MSG_POSTVIEW_FRAME:
            client->handlePostview(dataPtr);
            break;
        case CAMERA_MSG_RAW_IMAGE:
            client->handleRawPicture(dataPtr);
            break;
        case CAMERA_MSG_COMPRESSED_IMAGE:
            client->handleCompressedPicture(dataPtr);
            break;
        default:
            client->handleGenericData(msgType, dataPtr, metadata);
            break;
    }
}
Beispiel #2
0
void CameraClient::dataCallback(int32_t msgType,
        const sp<IMemory>& dataPtr, camera_frame_metadata_t *metadata, void* user) {
    LOG2("dataCallback(%d)", msgType);

    Mutex* lock = getClientLockFromCookie(user);
    if (lock == NULL) return;
    Mutex::Autolock alock(*lock);

    CameraClient* client =
            static_cast<CameraClient*>(getClientFromCookie(user));
    if (client == NULL) return;

    if (!client->lockIfMessageWanted(msgType)) return;
    if (dataPtr == 0 && metadata == NULL) {
        ALOGE("Null data returned in data callback");
        client->handleGenericNotify(CAMERA_MSG_ERROR, UNKNOWN_ERROR, 0);
        return;
    }

#ifdef MTK_HARDWARE
    if (msgType == 0x80000000) { //MTK_CAMERA_MSG_EXT_DATA
        struct DataHeader {
            uint32_t        extMsgType;
        } dataHeader;
        sp<IMemoryHeap> heap = 0;
        ssize_t         offset = 0;
        size_t          size = 0;

        if (dataPtr.get()) {

            heap = dataPtr->getMemory(&offset, &size);
            if  ( NULL != heap.get() && NULL != heap->base() )
                ::memcpy(&dataHeader, ((uint8_t*)heap->base()) + offset, sizeof(DataHeader));

            if (dataHeader.extMsgType == 0x10) { //MTK_CAMERA_MSG_EXT_DATA_COMPRESSED_IMAGE
                msgType = CAMERA_MSG_COMPRESSED_IMAGE;
                sp<MemoryBase> image = new MemoryBase(heap,
                        (offset + sizeof(DataHeader) + sizeof(uint_t) * 1),
                        (size - sizeof(DataHeader) - sizeof(uint_t) * 1));
                client->handleCompressedPicture(image);
                return;
            }
        }
        LOG2("MtkDataCallback(0x%x)", dataHeader.extMsgType);
    }
#endif

    switch (msgType & ~CAMERA_MSG_PREVIEW_METADATA) {
        case CAMERA_MSG_PREVIEW_FRAME:
            client->handlePreviewData(msgType, dataPtr, metadata);
            break;
        case CAMERA_MSG_POSTVIEW_FRAME:
            client->handlePostview(dataPtr);
            break;
        case CAMERA_MSG_RAW_IMAGE:
            client->handleRawPicture(dataPtr);
            break;
        case CAMERA_MSG_COMPRESSED_IMAGE:
            client->handleCompressedPicture(dataPtr);
            break;
#if defined(OMAP_ICS_CAMERA) || defined(OMAP_ENHANCEMENT_BURST_CAPTURE)
        case CAMERA_MSG_COMPRESSED_BURST_IMAGE:
            client->handleCompressedBurstPicture(dataPtr);
            break;
#endif
        default:
            client->handleGenericData(msgType, dataPtr, metadata);
            break;
    }
}