/******************************************************************************
* test capture
*******************************************************************************/
static MUINT32 u4Capture_Cmd(int argc, char** argv)
{
    // init sensor first
    SensorHal *pSensorHal = SensorHal:: createInstance();

    if (NULL == pSensorHal)
    {
        MY_LOGE("pSensorHal is NULL");
        return 0;
    }
    // search sensor
    pSensorHal->searchSensor();

    //
    // (1). init main sensor
    //
    printf("init main sensor\n");
    pSensorHal->sendCommand(SENSOR_DEV_MAIN,
                                    SENSOR_CMD_SET_SENSOR_DEV,
                                    0,
                                    0,
                                    0);
    //
    printf("pSensorHal->init\n");
    pSensorHal->init();

    //insert HDR
    printf("insert HDR\n");
    //sp<HdrShot> pShot = NULL;
    HdrShot *pShot = NULL;
    pShot = new HdrShot("HdrShot", 0, 0);
	pShot->mTestMode = 1;	//test only
	//for ImpShit interface
    printf("pShot->onCmd_capture\n");
	pShot->sendCommand(eCmd_capture, 0, 0);

    printf("delete pShot\n");
	delete pShot;
    //
    printf("pSensorHal->destroyInstance\n");
    pSensorHal->destroyInstance();

    return 0;
}
Esempio n. 2
0
bool
ImpShot::
makeExifHeader(MUINT32 const u4CamMode, 
    			   MUINT8* const puThumbBuf, 
				   MUINT32 const u4ThumbSize, 
				   MUINT8* puExifBuf, 
				   MUINT32 &u4FinalExifSize, 
				   MUINT32 u4ImgIndex, 
				   MUINT32 u4GroupId,
                   MUINT32 u4FocusValH,
                   MUINT32 u4FocusValL)
{
    //
    MY_LOGD("[ImpShot]+ (u4CamMode, puThumbBuf, u4ThumbSize, puExifBuf) = (%d, %p, %d, %p)", 
                            u4CamMode,  puThumbBuf, u4ThumbSize, puExifBuf); 

    if (u4ThumbSize > 63 * 1024) 
    {
        MY_LOGW("The thumbnail size is large than 63K, the exif header will be broken"); 
    }
    bool ret = true;
    uint32_t u4App1HeaderSize = 0; 
    uint32_t u4AppnHeaderSize = 0; 

    uint32_t exifHeaderSize = 0;
    CamExif rCamExif;
    CamExifParam rExifParam;
    CamDbgParam rDbgParam;

    // ExifParam (for Gps)
    if (! mJpegParam.ms8GpsLatitude.isEmpty() && !mJpegParam.ms8GpsLongitude.isEmpty()) 
    {
        rExifParam.u4GpsIsOn = 1; 
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSLatitude), mJpegParam.ms8GpsLatitude.string(), mJpegParam.ms8GpsLatitude.length()); 
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSLongitude), mJpegParam.ms8GpsLongitude.string(), mJpegParam.ms8GpsLongitude.length()); 
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSTimeStamp), mJpegParam.ms8GpsTimestamp.string(), mJpegParam.ms8GpsTimestamp.length()); 
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSProcessingMethod), mJpegParam.ms8GpsMethod.string(), mJpegParam.ms8GpsMethod.length()); 
        rExifParam.u4GPSAltitude = ::atoi(mJpegParam.ms8GpsAltitude.string()); 
    } 
    // the bitstream already rotated. rotation should be 0
    //Add for JPEG-Sensor	
    MBOOL outputJPEGFile, bFixedOrientation; 
    SensorHal* pSensorHal = SensorHal::createInstance(); 
    MUINT32 u4DeviceID = 0;

    if (NULL != pSensorHal)
    {
        u4DeviceID = static_cast<MUINT32>(MtkCamUtils::DevMetaInfo::queryHalSensorDev(getOpenId()));	
        MY_LOGW("[shot][makeExifHeader] u4DeviceID=%d\n", u4DeviceID); 
        
    	pSensorHal->init(); 	
    	//get sensor format info
    	pSensorHal->sendCommand(static_cast<halSensorDev_e>(u4DeviceID),
    							  SENSOR_CMD_GET_YUV_SENSOR_CAPTURE_OUTPUT_JPEG,
    							  (MBOOL)&outputJPEGFile,
    							  0,
    							  0
    							 );
    	pSensorHal->sendCommand(static_cast<halSensorDev_e>(u4DeviceID),
    							  SENSOR_CMD_GET_YUV_SENSOR_FIXED_JPEG_ORIENTATION,
    							  (MBOOL)&bFixedOrientation,
    							  0,
    							  0
    							 );
    }
    else
    {
        outputJPEGFile = 0;
        bFixedOrientation = 0;
    }


    if (outputJPEGFile && bFixedOrientation)
    {
        rExifParam.u4Orientation = mShotParam.mi4Rotation; 
        MY_LOGW("[shot][makeExifHeader] u4Orientation=%d, bFixedOrientation=%d, outputJPEGFile=%d\n", mShotParam.mi4Rotation, bFixedOrientation, outputJPEGFile); 
    }
    else
    {
        rExifParam.u4Orientation = 0; 
        MY_LOGW("[shot][makeExifHeader] nonJpegSensor, u4Orientation=0\n"); 
    }
	
    rExifParam.u4ZoomRatio = mShotParam.mu4ZoomRatio; 
    //
    camera_info rCameraInfo = MtkCamUtils::DevMetaInfo::queryCameraInfo(getOpenId()); 
    rExifParam.u4Facing = rCameraInfo.facing; 
    //
    rExifParam.u4ImgIndex = u4ImgIndex;
    rExifParam.u4GroupId = u4GroupId;
    //
    rExifParam.u4FocusH = u4FocusValH;
    rExifParam.u4FocusL = u4FocusValL;
    // 
    //! CamDbgParam (for camMode, shotMode)
    rDbgParam.u4CamMode = u4CamMode; 
    rDbgParam.u4ShotMode = getShotMode();    
    //
    rCamExif.init(rExifParam,  rDbgParam);
    //    
    Hal3ABase* p3AHal = Hal3ABase::createInstance(MtkCamUtils::DevMetaInfo::queryHalSensorDev(getOpenId())); 
    p3AHal->set3AEXIFInfo(&rCamExif); 
    // the bitstream already rotated. it need to swap the width/height
    
    if ((!outputJPEGFile) && (90 == mShotParam.mi4Rotation || 270 == mShotParam.mi4Rotation))
    {
        rCamExif.makeExifApp1(mShotParam.mi4PictureHeight,  mShotParam.mi4PictureWidth, u4ThumbSize, puExifBuf,  &u4App1HeaderSize);
    }
    else 
    {
        rCamExif.makeExifApp1(mShotParam.mi4PictureWidth, mShotParam.mi4PictureHeight, u4ThumbSize, puExifBuf,  &u4App1HeaderSize);
    }
    // copy thumbnail image after APP1 
    MUINT8 *pdest = puExifBuf + u4App1HeaderSize; 
    ::memcpy(pdest, puThumbBuf, u4ThumbSize) ; 
    // 
    // 3A Debug Info 
    p3AHal->setDebugInfo(&rCamExif); 
    //
    // Sensor Debug Info 
    pSensorHal->setDebugInfo(&rCamExif); 
    pdest = puExifBuf + u4App1HeaderSize + u4ThumbSize; 
    //
    rCamExif.appendDebugExif(pdest, &u4AppnHeaderSize);
    rCamExif.uninit();

    u4FinalExifSize = u4App1HeaderSize + u4ThumbSize + u4AppnHeaderSize; 
    p3AHal->destroyInstance(); 
    pSensorHal->destroyInstance(); 

    MY_LOGD("- (app1Size, appnSize, exifSize) = (%d, %d, %d)", 
                          u4App1HeaderSize, u4AppnHeaderSize, u4FinalExifSize); 
    return ret;
}