Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi All,
I am trying to access the Camera of KX2 using ICamera Interface and when ever i download the code on to the KX2,the device is resetting.
What is the basic coding flow of previw mode.i used the coding example as given in the BREW SDK.where i may be gng wrong..
i have also treid to display error messages onto the screen,so that i can know where i may be gng wrong.this is the first time that i m using ICamera interface.i read the articles priviously,in this forum,but cant make out ..y kx2 is resetting.i read the data sheet of KX2,and the camera is accesible to the user.i think i m ggn wrong in the coding...any pointers..??

static int test_camera(test *pMe)
{

int nErr;
//IStatic* pIStatic;
AECHAR buf1[4] = {'e','1','\0'};
AECHAR buf2[4] = {'e','2','\0'};
AECHAR buf3[4] = {'e','3','\0'};
AECHAR buf4[4] = {'e','4','\0'};

//AEERect arect;
//AECHAR *wszBuff1;
//unsigned int wtsize;
//boolean b;
nErr = ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_CAMERA,(void **)(&pMe->pICamera));
if (nErr)
{

IDISPLAY_DrawText(pMe->a.m_pIDisplay,AEE_FONT_BOLD,buf1,-1,0,0,NULL,IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
IDISPLAY_Update (pMe->a.m_pIDisplay);
return nErr;

pMe->pn->nStatus=CAM_STATUS_FRAME;
pMe->pn->nCmd=CAM_CMD_START;
pMe->pn->nSubCmd=CAM_MODE_PREVIEW;

if(ICAMERA_RegisterNotify(pMe->pICamera,CApp_CameraNotify,pMe)!=SUCCESS)
{
IDISPLAY_DrawText(pMe->a.m_pIDisplay,AEE_FONT_BOLD,buf2,-1,0,0,NULL,IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
IDISPLAY_Update (pMe->a.m_pIDisplay);
return FALSE;

pMe->pSize->cx=640;
pMe->pSize->cy=480;

nErr=ICAMERA_SetDisplaySize(pMe->pICamera,&pMe->pSize);
if (nErr)
{
IDISPLAY_DrawText(pMe->a.m_pIDisplay,AEE_FONT_BOLD,buf3,-1,0,0,NULL,IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
IDISPLAY_Update (pMe->a.m_pIDisplay);
return nErr;

nErr=ICAMERA_Preview(pMe->pICamera);

if (nErr)
{
IDISPLAY_DrawText(pMe->a.m_pIDisplay,AEE_FONT_BOLD,buf4,-1,0,0,NULL,IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
IDISPLAY_Update (pMe->a.m_pIDisplay);

return nErr;

return SUCCESS;

}

static void CApp_CameraNotify(void * pUser, AEECameraNotify * pn)

{
AECHAR buf5[4] = {'e','5','\0'};
test *pMe = (test *)pUser;

if (!pMe || !pn)

return;

switch (pn->nStatus)

{

case CAM_STATUS_START:

// Preview has begun...
//ICAMERA_Preview(pMe->pICamera);
break;

case CAM_STATUS_FRAME:

{

if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_PREVIEW)
{
//IBitmap * pFrame;
AEEBitmapInfo bi;
if (SUCCESS == ICAMERA_GetFrame(pMe->pICamera, &pMe->pFrame))
{
IDISPLAY_DrawText(pMe->a.m_pIDisplay,AEE_FONT_BOLD,buf5,-1,0,0,NULL,IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
IDISPLAY_Update (pMe->a.m_pIDisplay);
return;
}
IBITMAP_GetInfo(pMe->pFrame, &bi, sizeof(bi));
IDISPLAY_BitBlt(pMe->pIDisplay, 0, 0, bi.cx, bi.cy, pMe->pFrame, 0, 0, AEE_RO_COPY);
IBITMAP_Release(pMe->pFrame);
break;
}

case CAM_STATUS_DONE:

// ICAMERA_Stop() was called and preview operation stopped.

break;

case CAM_STATUS_ABORT:

// Preview got aborted.

break;

}

}

Cant seem to make out where you are going wrong.. but in ur code u dont have to set
pMe->pn->nStatus=CAM_STATUS_FRAME;
pMe->pn->nCmd=CAM_CMD_START;
pMe->pn->nSubCmd=CAM_MODE_PREVIEW;
in the test Camera function. Infact I am not sure u even need a cameranotify structure in ur applet. But I dont think thats causing the error.
The code below works for me .. hope it helps.
Applet structure
typedef struct _cameratest{
AEEApplet a;// First element of this structure must be AEEApplet
IDisplay *pIDisplay;
IShell *pIShell;
EAppStateType m_eAppState; // Current Application State
EAppStateType m_ePrevState;
uint16 cxScreen;// Width of the handset screen
uint16 cyScreen;// Height of the handset screen
IMenuCtl *m_pMainMenu;
ICamera *m_pICamera; // ptr to the camera
cameratest;
The function to start the camera
static void cameratest_DisplayCameraPreview(cameratest * pMe)
{
int nErr;
AEESize az;
pMe->m_eAppState = APP_STATE_CAM_PREVIEW;
if (ISHELL_CreateInstance(pMe->pIShell, AEECLSID_CAMERA , (void**)(&pMe->m_pICamera)) != SUCCESS)
return;
// Register callback notification function.
nErr = ICAMERA_RegisterNotify(pMe->m_pICamera, cameratest_CameraNotify, pMe);
if (nErr)
{
DBGPRINTF("ERROR IN REGISTERING CALL BACK %d", nErr);
Cameratest_goBack(pMe->m_eAppState);
return;

az.cx = pMe->cxScreen;
az.cy = pMe->cyScreen;
ICAMERA_SetDisplaySize(pMe->m_pICamera, &az);
nErr = ICAMERA_Preview(pMe->m_pICamera);
if (nErr)
{
DBGPRINTF("ERROR in initiating preview %d", nErr);
return;

And the callback function
static void cameratest_CameraNotify(void * pUser, AEECameraNotify * pn)
{
cameratest * pMe = (cameratest *)pUser;
if (!pMe !pn)
return;
switch (pn->nStatus)
{
case CAM_STATUS_START:
// Preview has begun...
break;
case CAM_STATUS_FRAME:
{
IBitmap * pFrame;
AEEBitmapInfo bi; // // IMPORTANT NOTE: You need to do IBITMAP_Release(pFrame) after you're done with pFrame.
pFrame = ICAMERA_GetFrame(pMe->m_pICamera, &pFrame);
if (!pFrame)
{
DBGPRINTF("DID not get FRAME");
break;

// Get the bitmap info...this can be saved in app global structure.
IBITMAP_GetInfo(pFrame, &bi, sizeof(bi));
// Display the frame at (0, 0) location of the screen
IDISPLAY_BitBlt(pMe->pIDisplay, 2, 2, bi.cx, bi.cy, pFrame, 0, 0, AEE_RO_COPY);
IBITMAP_Release(pFrame);
IDISPLAY_Update(pMe->pIDisplay);

break;
case CAM_STATUS_DONE:
break;
case CAM_STATUS_ABORT:
// Preview got aborted.
break;

Cant seem to make out where you are going wrong.. but in ur code u dont have to set
pMe->pn->nStatus=CAM_STATUS_FRAME;
pMe->pn->nCmd=CAM_CMD_START;
pMe->pn->nSubCmd=CAM_MODE_PREVIEW;
in the test Camera function. Infact I am not sure u even need a cameranotify structure in ur applet. But I dont think thats causing the error.
The code below works for me .. hope it helps.
Applet structure
typedef struct _cameratest{
AEEApplet a;// First element of this structure must be AEEApplet
IDisplay *pIDisplay;
IShell *pIShell;
EAppStateType m_eAppState; // Current Application State
EAppStateType m_ePrevState;
uint16 cxScreen;// Width of the handset screen
uint16 cyScreen;// Height of the handset screen
IMenuCtl *m_pMainMenu;
ICamera *m_pICamera; // ptr to the camera
cameratest;
The function to start the camera
static void cameratest_DisplayCameraPreview(cameratest * pMe)
{
int nErr;
AEESize az;
pMe->m_eAppState = APP_STATE_CAM_PREVIEW;
if (ISHELL_CreateInstance(pMe->pIShell, AEECLSID_CAMERA , (void**)(&pMe->m_pICamera)) != SUCCESS)
return;
// Register callback notification function.
nErr = ICAMERA_RegisterNotify(pMe->m_pICamera, cameratest_CameraNotify, pMe);
if (nErr)
{
DBGPRINTF("ERROR IN REGISTERING CALL BACK %d", nErr);
Cameratest_goBack(pMe->m_eAppState);
return;

az.cx = pMe->cxScreen;
az.cy = pMe->cyScreen;
ICAMERA_SetDisplaySize(pMe->m_pICamera, &az);
nErr = ICAMERA_Preview(pMe->m_pICamera);
if (nErr)
{
DBGPRINTF("ERROR in initiating preview %d", nErr);
return;

And the callback function
static void cameratest_CameraNotify(void * pUser, AEECameraNotify * pn)
{
cameratest * pMe = (cameratest *)pUser;
if (!pMe !pn)
return;
switch (pn->nStatus)
{
case CAM_STATUS_START:
// Preview has begun...
break;
case CAM_STATUS_FRAME:
{
IBitmap * pFrame;
AEEBitmapInfo bi; // // IMPORTANT NOTE: You need to do IBITMAP_Release(pFrame) after you're done with pFrame.
pFrame = ICAMERA_GetFrame(pMe->m_pICamera, &pFrame);
if (!pFrame)
{
DBGPRINTF("DID not get FRAME");
break;

// Get the bitmap info...this can be saved in app global structure.
IBITMAP_GetInfo(pFrame, &bi, sizeof(bi));
// Display the frame at (0, 0) location of the screen
IDISPLAY_BitBlt(pMe->pIDisplay, 2, 2, bi.cx, bi.cy, pFrame, 0, 0, AEE_RO_COPY);
IBITMAP_Release(pFrame);
IDISPLAY_Update(pMe->pIDisplay);

break;
case CAM_STATUS_DONE:
break;
case CAM_STATUS_ABORT:
// Preview got aborted.
break;

hi,
thanks for the reply,the camera is working in preview mode now.i have a problem nw,i m using KX2 handset and i want to take snap shot and encode it,or save it in .jpeg format.i have found this functuion in BREW called IMEDIAUTIL_EncodeJPEG().but,there aint any document in this.how do i use this function IMEDIAUTIL_EncodeJPEG() so that i can encode the image in jpeg format.
the camera frame returns IBITMAP pointer.????
thanks
ibrew

hi,
thanks for the reply,the camera is working in preview mode now.i have a problem nw,i m using KX2 handset and i want to take snap shot and encode it,or save it in .jpeg format.i have found this functuion in BREW called IMEDIAUTIL_EncodeJPEG().but,there aint any document in this.how do i use this function IMEDIAUTIL_EncodeJPEG() so that i can encode the image in jpeg format.
the camera frame returns IBITMAP pointer.????
thanks
ibrew

Check out ICAMERA_RecordSnapshot() function .... It allows you to encode and save the snapshot in JPEG format.

Check out ICAMERA_RecordSnapshot() function .... It allows you to encode and save the snapshot in JPEG format.

hi,
thanks for the reply,
regarding ICAMERA_RecordSnapshot,i m trying the same thru the morning,and getting some errors.i am attaching the snippet of the code below..
in the sdk, for Snapshot Mode:
Before you do snapshot operation, you need to perform the following operations:
(1) ICAMERA_SetMediaData()
(2) ICAMERA_SetSize()
and i m following the same steps..where i may be gng wrong...???
static int test_camera(test *pMe)
{
int nErr;
AEESize az;
//uint32 dwFPS;
uint32 dwParam;
//AEECameraNotify * pn;
nErr = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_CAMERA, (void **)&pMe->m_pICamera);
if (nErr==3)
{
test_err(pMe,"CAMERA INSTANCE FAILURE");
return;

//pn->nCmd = CAM_CMD_START;
//pn->nSubCmd = CAM_MODE_SNAPSHOT;
nErr = ICAMERA_RegisterNotify(pMe->m_pICamera,(PFNCAMERANOTIFY) CApp_CameraNotify,pMe);
if (nErr==EBADSTATE)
{
test_err(pMe,"CAMERA REGISTER NOTIFY FAILURE EBADSTATE");
return ;

az.cx = pMe->cxScreen+30;
az.cy = pMe->cyScreen+100;
nErr=ICAMERA_SetDisplaySize(pMe->m_pICamera,&az);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET DISPLAY FAILURE ");
return;

//dwFPS=0x0001000a;
//nErr=ICAMERA_SetFramesPerSecond(pMe->m_pICamera,dwFPS);
//if (nErr!=SUCCESS)
//{
//test_err(pMe,"CAMERA SET FRAME FAILURE");
//return ;
//}
//for dng in snapshot mode
//nErr=ICAMERA_Start(pMe->m_pICamera,CAM_MODE_SNAPSHOT,dwParam);
//if(nErr!=SUCCESS)
//{
//test_err(pMe,"CAMERA START FAILURE ");
//return;
//}
//az.cx = pMe->cxScreen;
//az.cy = pMe->cyScreen;
pMe->md.clsData=MMD_FILE_NAME;
pMe->md.pData="\brew\shared\test.jpg";
pMe->md.dwSize=0;
nErr=ICAMERA_SetMediaData(pMe->m_pICamera,&pMe->md,AEECLSID_JPEG);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET Media Data FAILURE ");
return;

nErr=ICAMERA_SetSize(pMe->m_pICamera,&az);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET SIZE FAILURE ");
return;

nErr = ICAMERA_Preview(pMe->m_pICamera);
if (nErr!=SUCCESS)
{
test_err(pMe,"CAMERA PREVIEW FAILURE");
return ;

nErr=ICAMERA_RecordSnapshot(pMe->m_pICamera);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA RECORD SNAPSHOT FAILURE ");
return;

return SUCCESS;
}
static void CApp_CameraNotify(void * pUser,AEECameraNotify * pn)
{
AEESize az;
int nErr;
test *pMe = (test *)pUser;
if (!pMe || !pn)
return;
pn->nCmd = CAM_CMD_START;
pn->nSubCmd = CAM_MODE_SNAPSHOT;
switch (pn->nStatus)
{
case CAM_STATUS_START:
// Preview has begun...
break;
case CAM_STATUS_FRAME:
{
/*IBitmap * pFrame;
AEEBitmapInfo bi;
int nErr;
ICAMERA_GetFrame(pMe->m_pICamera, &pFrame);
if (!pFrame)
{
test_err(pMe,"CAMERA GETFRAME FAILURE");
break;

// Get the bitmap info...this can be saved in app global structure.
IBITMAP_GetInfo(pFrame, &bi, sizeof(bi));
// Display the frame at (0, 0) location of the screen
IDISPLAY_BitBlt(pMe->pIDisplay, 0, 0, bi.cx, bi.cy, pFrame, 0, 0, AEE_RO_COPY);
IBITMAP_Release(pFrame);
IDISPLAY_Update(pMe->pIDisplay);
*/
}
break;
case CAM_STATUS_DONE:
break;
case CAM_STATUS_ABORT:
//ICAMERA_Stop(pMe->m_pICamera);
break;

}

hi,
thanks for the reply,
regarding ICAMERA_RecordSnapshot,i m trying the same thru the morning,and getting some errors.i am attaching the snippet of the code below..
in the sdk, for Snapshot Mode:
Before you do snapshot operation, you need to perform the following operations:
(1) ICAMERA_SetMediaData()
(2) ICAMERA_SetSize()
and i m following the same steps..where i may be gng wrong...???
static int test_camera(test *pMe)
{
int nErr;
AEESize az;
//uint32 dwFPS;
uint32 dwParam;
//AEECameraNotify * pn;
nErr = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_CAMERA, (void **)&pMe->m_pICamera);
if (nErr==3)
{
test_err(pMe,"CAMERA INSTANCE FAILURE");
return;

//pn->nCmd = CAM_CMD_START;
//pn->nSubCmd = CAM_MODE_SNAPSHOT;
nErr = ICAMERA_RegisterNotify(pMe->m_pICamera,(PFNCAMERANOTIFY) CApp_CameraNotify,pMe);
if (nErr==EBADSTATE)
{
test_err(pMe,"CAMERA REGISTER NOTIFY FAILURE EBADSTATE");
return ;

az.cx = pMe->cxScreen+30;
az.cy = pMe->cyScreen+100;
nErr=ICAMERA_SetDisplaySize(pMe->m_pICamera,&az);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET DISPLAY FAILURE ");
return;

//dwFPS=0x0001000a;
//nErr=ICAMERA_SetFramesPerSecond(pMe->m_pICamera,dwFPS);
//if (nErr!=SUCCESS)
//{
//test_err(pMe,"CAMERA SET FRAME FAILURE");
//return ;
//}
//for dng in snapshot mode
//nErr=ICAMERA_Start(pMe->m_pICamera,CAM_MODE_SNAPSHOT,dwParam);
//if(nErr!=SUCCESS)
//{
//test_err(pMe,"CAMERA START FAILURE ");
//return;
//}
//az.cx = pMe->cxScreen;
//az.cy = pMe->cyScreen;
pMe->md.clsData=MMD_FILE_NAME;
pMe->md.pData="\brew\shared\test.jpg";
pMe->md.dwSize=0;
nErr=ICAMERA_SetMediaData(pMe->m_pICamera,&pMe->md,AEECLSID_JPEG);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET Media Data FAILURE ");
return;

nErr=ICAMERA_SetSize(pMe->m_pICamera,&az);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET SIZE FAILURE ");
return;

nErr = ICAMERA_Preview(pMe->m_pICamera);
if (nErr!=SUCCESS)
{
test_err(pMe,"CAMERA PREVIEW FAILURE");
return ;

nErr=ICAMERA_RecordSnapshot(pMe->m_pICamera);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA RECORD SNAPSHOT FAILURE ");
return;

return SUCCESS;
}
static void CApp_CameraNotify(void * pUser,AEECameraNotify * pn)
{
AEESize az;
int nErr;
test *pMe = (test *)pUser;
if (!pMe || !pn)
return;
pn->nCmd = CAM_CMD_START;
pn->nSubCmd = CAM_MODE_SNAPSHOT;
switch (pn->nStatus)
{
case CAM_STATUS_START:
// Preview has begun...
break;
case CAM_STATUS_FRAME:
{
/*IBitmap * pFrame;
AEEBitmapInfo bi;
int nErr;
ICAMERA_GetFrame(pMe->m_pICamera, &pFrame);
if (!pFrame)
{
test_err(pMe,"CAMERA GETFRAME FAILURE");
break;

// Get the bitmap info...this can be saved in app global structure.
IBITMAP_GetInfo(pFrame, &bi, sizeof(bi));
// Display the frame at (0, 0) location of the screen
IDISPLAY_BitBlt(pMe->pIDisplay, 0, 0, bi.cx, bi.cy, pFrame, 0, 0, AEE_RO_COPY);
IBITMAP_Release(pFrame);
IDISPLAY_Update(pMe->pIDisplay);
*/
}
break;
case CAM_STATUS_DONE:
break;
case CAM_STATUS_ABORT:
//ICAMERA_Stop(pMe->m_pICamera);
break;

}

Hi ,
It will be a lot easier if you can dump your code in the post enclosed in "[Code]" tags .. makes it easier to read.
Also, to actually run the camera in the Snapshot Mode you will have to stop the Preview Mode. In the camera notify function when you get the CAM_STATUS_DONE for the preview mode then call the record snaphot function.
This will return CAM_STATUS_DONE for the snapshot and also encodesnapsot.
Go through the PDF document of the SDK.. it has the steps outlined.

Hi ,
It will be a lot easier if you can dump your code in the post enclosed in "[Code]" tags .. makes it easier to read.
Also, to actually run the camera in the Snapshot Mode you will have to stop the Preview Mode. In the camera notify function when you get the CAM_STATUS_DONE for the preview mode then call the record snaphot function.
This will return CAM_STATUS_DONE for the snapshot and also encodesnapsot.
Go through the PDF document of the SDK.. it has the steps outlined.

hi ,
thanks for the suggestion..i read the sdk..and still i m not able to get things right...
pls find the code snippet ....
this is my funtion..which has the ICAMERA_RegisterNotify function.
static int test_camera(test *pMe)
{
int nErr;
AEESize az;
//uint32 dwFPS;
uint32 dwParam;
//AEECameraNotify * pn;
nErr = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_CAMERA, (void **)&pMe->m_pICamera);
if (nErr==3)
{
test_err(pMe,"CAMERA INSTANCE FAILURE");
return;
nErr = ICAMERA_RegisterNotify(pMe->m_pICamera,CApp_CameraNotify,pMe);
if (nErr==EBADSTATE)
{
test_err(pMe,"CAMERA REGISTER NOTIFY FAILURE EBADSTATE");
return ;

az.cx = pMe->cxScreen;
az.cy = pMe->cyScreen;
nErr=ICAMERA_SetDisplaySize(pMe->m_pICamera,&az);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET DISPLAY FAILURE ");
return;

nErr = ICAMERA_Preview(pMe->m_pICamera);
if (nErr!=SUCCESS)
{
test_err(pMe,"CAMERA PREVIEW FAILURE");
return ;

test_err(pMe,"CAMERA RECORD SNAPSHOT DONE");
return SUCCESS;
and i m calling the notify function as here,in the sdk ..its given that in ICAMERA_RecordSnapshot function
In the callback, AEECameraNotify, if nCmd = CAM_CMD_START, then nSubCmd = CAM_MODE_SNAPSHOT.
so in my code snippet,m dng it..still m getting blank screen..this is my call back function
static void CApp_CameraNotify(void * pUser,AEECameraNotify * pn)
{
AEESize az;
int nErr;
uint32 dwParam;
test *pMe = (test *)pUser;
if (!pMe || !pn)
{
test_err(pMe,"pMe pn err ");
return;

if(pn->nCmd==CAM_CMD_START)
pn->nSubCmd=CAM_MODE_SNAPSHOT;
switch (pn->nStatus)
{
case CAM_STATUS_START:
break;
case CAM_STATUS_FRAME:
break;
case CAM_STATUS_DONE:
{
az.cx = pMe->cxScreen;
az.cy = pMe->cyScreen;
pMe->md.clsData=MMD_FILE_NAME;
pMe->md.pData="/brew/shared/campics/test.jpg";
pMe->md.dwSize=0;
nErr=ICAMERA_SetMediaData(pMe->m_pICamera,&pMe->md,AEECLSID_JPEG);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET Media Data FAILURE ");
return;

nErr=ICAMERA_SetSize(pMe->m_pICamera,&az);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET SIZE FAILURE ");
return;

nErr=ICAMERA_SetVideoEncode(pMe->m_pICamera,AEECLSID_JPEG,dwParam);
if (nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET VIDEO ENCODE FAILURE");
return ;

nErr=ICAMERA_RecordSnapshot(pMe->m_pICamera);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA RECORD SNAPSHOT FAILURE ");
return;

break;
case CAM_STATUS_ABORT:
break;

}
where can i stop the preview mode...shld i stop the preview mode in the STATUS_DONE ...???
thanks
ibrew

hi ,
thanks for the suggestion..i read the sdk..and still i m not able to get things right...
pls find the code snippet ....
this is my funtion..which has the ICAMERA_RegisterNotify function.
static int test_camera(test *pMe)
{
int nErr;
AEESize az;
//uint32 dwFPS;
uint32 dwParam;
//AEECameraNotify * pn;
nErr = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_CAMERA, (void **)&pMe->m_pICamera);
if (nErr==3)
{
test_err(pMe,"CAMERA INSTANCE FAILURE");
return;
nErr = ICAMERA_RegisterNotify(pMe->m_pICamera,CApp_CameraNotify,pMe);
if (nErr==EBADSTATE)
{
test_err(pMe,"CAMERA REGISTER NOTIFY FAILURE EBADSTATE");
return ;

az.cx = pMe->cxScreen;
az.cy = pMe->cyScreen;
nErr=ICAMERA_SetDisplaySize(pMe->m_pICamera,&az);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET DISPLAY FAILURE ");
return;

nErr = ICAMERA_Preview(pMe->m_pICamera);
if (nErr!=SUCCESS)
{
test_err(pMe,"CAMERA PREVIEW FAILURE");
return ;

test_err(pMe,"CAMERA RECORD SNAPSHOT DONE");
return SUCCESS;
and i m calling the notify function as here,in the sdk ..its given that in ICAMERA_RecordSnapshot function
In the callback, AEECameraNotify, if nCmd = CAM_CMD_START, then nSubCmd = CAM_MODE_SNAPSHOT.
so in my code snippet,m dng it..still m getting blank screen..this is my call back function
static void CApp_CameraNotify(void * pUser,AEECameraNotify * pn)
{
AEESize az;
int nErr;
uint32 dwParam;
test *pMe = (test *)pUser;
if (!pMe || !pn)
{
test_err(pMe,"pMe pn err ");
return;

if(pn->nCmd==CAM_CMD_START)
pn->nSubCmd=CAM_MODE_SNAPSHOT;
switch (pn->nStatus)
{
case CAM_STATUS_START:
break;
case CAM_STATUS_FRAME:
break;
case CAM_STATUS_DONE:
{
az.cx = pMe->cxScreen;
az.cy = pMe->cyScreen;
pMe->md.clsData=MMD_FILE_NAME;
pMe->md.pData="/brew/shared/campics/test.jpg";
pMe->md.dwSize=0;
nErr=ICAMERA_SetMediaData(pMe->m_pICamera,&pMe->md,AEECLSID_JPEG);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET Media Data FAILURE ");
return;

nErr=ICAMERA_SetSize(pMe->m_pICamera,&az);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET SIZE FAILURE ");
return;

nErr=ICAMERA_SetVideoEncode(pMe->m_pICamera,AEECLSID_JPEG,dwParam);
if (nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET VIDEO ENCODE FAILURE");
return ;

nErr=ICAMERA_RecordSnapshot(pMe->m_pICamera);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA RECORD SNAPSHOT FAILURE ");
return;

break;
case CAM_STATUS_ABORT:
break;

}
where can i stop the preview mode...shld i stop the preview mode in the STATUS_DONE ...???
thanks
ibrew

hi,
i am getting confused in getting the best flow for getting into the snap shot mode.
as per the sdk,it says,...
Before you do snapshot operation, you need to perform the following operations:
(1) ICAMERA_SetMediaData()
(2) ICAMERA_SetSize()
(3) [Optional] ICAMERA_SetVideoEncode()
(4) [Optional] ICAMERA_SetQuality()
(5) [Optional] ICAMERA_SetFramesPerSecond()
since i would like my camera to take snap,i have done the option 1),2),3)(for jpeg) n left the 4) and 5) option,since its optional.
now i m getting confued in the following.
option 1
1)ISHELL_CreateInstance for ICAMERA
2)ICAMERA_SetMediaData
3)ICAMERA_SetSize
4)ICAMERA_SetVideoEncode
5)ICAMERA_RecordSnapshot
then
ICAMERA_RegisterNotify
option 2
1)ISHELL_CreateInstance for ICAMERA
2)ICAMERA_RegisterNotify
3)preview
in the callback
fr the CAM_STATUS_DONE
1)ICAMERA_SetMediaData
2)ICAMERA_SetSize
3)ICAMERA_SetVideoEncode
4)ICAMERA_RecordSnapshot
hmm...hope,u guys can help me in getting to the correct way around this.
i would appreciate if sm1 could give me the correct flow of the callback notification function.i reffered to the sdk ..but i cant make out.
thanks
ibrew

hi,
i am getting confused in getting the best flow for getting into the snap shot mode.
as per the sdk,it says,...
Before you do snapshot operation, you need to perform the following operations:
(1) ICAMERA_SetMediaData()
(2) ICAMERA_SetSize()
(3) [Optional] ICAMERA_SetVideoEncode()
(4) [Optional] ICAMERA_SetQuality()
(5) [Optional] ICAMERA_SetFramesPerSecond()
since i would like my camera to take snap,i have done the option 1),2),3)(for jpeg) n left the 4) and 5) option,since its optional.
now i m getting confued in the following.
option 1
1)ISHELL_CreateInstance for ICAMERA
2)ICAMERA_SetMediaData
3)ICAMERA_SetSize
4)ICAMERA_SetVideoEncode
5)ICAMERA_RecordSnapshot
then
ICAMERA_RegisterNotify
option 2
1)ISHELL_CreateInstance for ICAMERA
2)ICAMERA_RegisterNotify
3)preview
in the callback
fr the CAM_STATUS_DONE
1)ICAMERA_SetMediaData
2)ICAMERA_SetSize
3)ICAMERA_SetVideoEncode
4)ICAMERA_RecordSnapshot
hmm...hope,u guys can help me in getting to the correct way around this.
i would appreciate if sm1 could give me the correct flow of the callback notification function.i reffered to the sdk ..but i cant make out.
thanks
ibrew

Hi all,
regarding the snapshot mode,i read the following thread,
http://brewforums.qualcomm.com/showthread.php?t=6939&highlight=icamera
i had my camera (KX2) in preview mode,and when user selects the buttons,i m stopping the camera n in the CAMERA_STATUS_DONE,i m calling the record snapshot .the record snapshot is returing SUCCESS,but the image is not getting stored in the directory,whre i may be gng wrong..???
here is the code snippet.
case CAM_STATUS_DONE:
{
pn->nSubCmd = CAM_MODE_SNAPSHOT;
test_err(pMe,"in the cam status done");
az.cx = pMe->cxScreen;
az.cy = pMe->cyScreen;
pMe->md.clsData=MMD_FILE_NAME;
pMe->md.pData="/brew/shared/campics/test.jpg";
pMe->md.dwSize=0;
nErr=ICAMERA_SetMediaData(pMe->m_pICamera,&pMe->md,AEECLSID_JPEG);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET Media Data FAILURE ");
return;

if(nErr==CAM_PENDING)
{
test_err(pMe,"CAMERA PENDING ");
}
nErr=ICAMERA_SetSize(pMe->m_pICamera,&az);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET SIZE FAILURE ");
return;

nErr=ICAMERA_SetVideoEncode(pMe->m_pICamera,AEECLSID_JPEG,dwParam);
if (nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET VIDEO ENCODE FAILURE");
return ;

test_err(pMe,"b4 recordsnap shot");
nErr=ICAMERA_RecordSnapshot(pMe->m_pICamera);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA RECORD SNAPSHOT FAILURE ");
return;

if(nErr==SUCCESS)
{
test_err(pMe,"CAMERA RECORD SNAPSHOT sucess ");
return;

if(nErr==EFAILED)
{
test_err(pMe,"EFAILED: General failure ");
//return;

if(nErr==EBADPARM)
{
test_err(pMe,"EBADPARM: Bad parm is passed ");
//return;

if(nErr==ENOMEMORY)
{
test_err(pMe,"ENOMEMORY: Not enough memory ");
//return;

if(nErr==EBADSTATE)
{
test_err(pMe,"EBADSTATE: RecordSnapshot() cannot be done in current state ");
//return;

}
i m thinking that the media data is not set properly...????
any pointers..??

Hi all,
regarding the snapshot mode,i read the following thread,
http://brewforums.qualcomm.com/showthread.php?t=6939&highlight=icamera
i had my camera (KX2) in preview mode,and when user selects the buttons,i m stopping the camera n in the CAMERA_STATUS_DONE,i m calling the record snapshot .the record snapshot is returing SUCCESS,but the image is not getting stored in the directory,whre i may be gng wrong..???
here is the code snippet.
case CAM_STATUS_DONE:
{
pn->nSubCmd = CAM_MODE_SNAPSHOT;
test_err(pMe,"in the cam status done");
az.cx = pMe->cxScreen;
az.cy = pMe->cyScreen;
pMe->md.clsData=MMD_FILE_NAME;
pMe->md.pData="/brew/shared/campics/test.jpg";
pMe->md.dwSize=0;
nErr=ICAMERA_SetMediaData(pMe->m_pICamera,&pMe->md,AEECLSID_JPEG);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET Media Data FAILURE ");
return;

if(nErr==CAM_PENDING)
{
test_err(pMe,"CAMERA PENDING ");
}
nErr=ICAMERA_SetSize(pMe->m_pICamera,&az);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET SIZE FAILURE ");
return;

nErr=ICAMERA_SetVideoEncode(pMe->m_pICamera,AEECLSID_JPEG,dwParam);
if (nErr!=SUCCESS)
{
test_err(pMe,"CAMERA SET VIDEO ENCODE FAILURE");
return ;

test_err(pMe,"b4 recordsnap shot");
nErr=ICAMERA_RecordSnapshot(pMe->m_pICamera);
if(nErr!=SUCCESS)
{
test_err(pMe,"CAMERA RECORD SNAPSHOT FAILURE ");
return;

if(nErr==SUCCESS)
{
test_err(pMe,"CAMERA RECORD SNAPSHOT sucess ");
return;

if(nErr==EFAILED)
{
test_err(pMe,"EFAILED: General failure ");
//return;

if(nErr==EBADPARM)
{
test_err(pMe,"EBADPARM: Bad parm is passed ");
//return;

if(nErr==ENOMEMORY)
{
test_err(pMe,"ENOMEMORY: Not enough memory ");
//return;

if(nErr==EBADSTATE)
{
test_err(pMe,"EBADSTATE: RecordSnapshot() cannot be done in current state ");
//return;

}
i m thinking that the media data is not set properly...????
any pointers..??

try setting as
pMe->md.pData="test.jpg";
This will save the file in ur application directory....If this works then you know your code is working and the reason the file was not getting saved earlier was because you did not have access to the shared directory.
Also in ur code .. in the callback function you should be calling snapshot when the
status is CAM_STATUS_DONE
case CAM_STATUS_DONE://
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_PREVIEW)
{
//Preview Mode has stopped .. call snapshot here
}
I dont think you should be setting pn->nSubCmd = CAM_MODE_SNAPSHOT explicitly.
R@i

try setting as
pMe->md.pData="test.jpg";
This will save the file in ur application directory....If this works then you know your code is working and the reason the file was not getting saved earlier was because you did not have access to the shared directory.
Also in ur code .. in the callback function you should be calling snapshot when the
status is CAM_STATUS_DONE
case CAM_STATUS_DONE://
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_PREVIEW)
{
//Preview Mode has stopped .. call snapshot here
}
I dont think you should be setting pn->nSubCmd = CAM_MODE_SNAPSHOT explicitly.
R@i

hi,
thanks for the reply,
well,i m able to save the image in the shared directory,as i m using kx2,m able to save the image in the shared director /brew/shared/campics/test.jpg.i have also seen the known issue of the kx2 and they say the following
The application would have to explicitly set the mode to snapshot before invoking the API as follows:
ICAMERA_SetParm(pme->m_pCam, CAM_PARM_RED_EYE_REDUCTION + 4 , 0 /* CAM_PREVIEW_SNAPSHOT*/ , 0);
nErr = ICAMERA_RecordSnapshot(pme->m_pCam);
well,i treid this also,and m getting a black screen smtimes, or gray screen,my camera shutter is ON.
what i would like to ask is that.
as per my previous post,what is the best flow for calling the record snap shot mode.
1)shld i have the camera in preview mode and when a user presses a EVENT KEY,i shld stop the camera and then in the CAM_STATUS_DONE callback,shld i call the
ICAMERA_SetMediaData,ICAMERA_SetSize,ICAMERA_SetVideoEncode,ICAMERA_SetParm and then ICAMERA_RecordSnapshot????
thanks..
ibrew

hi,
thanks for the reply,
well,i m able to save the image in the shared directory,as i m using kx2,m able to save the image in the shared director /brew/shared/campics/test.jpg.i have also seen the known issue of the kx2 and they say the following
The application would have to explicitly set the mode to snapshot before invoking the API as follows:
ICAMERA_SetParm(pme->m_pCam, CAM_PARM_RED_EYE_REDUCTION + 4 , 0 /* CAM_PREVIEW_SNAPSHOT*/ , 0);
nErr = ICAMERA_RecordSnapshot(pme->m_pCam);
well,i treid this also,and m getting a black screen smtimes, or gray screen,my camera shutter is ON.
what i would like to ask is that.
as per my previous post,what is the best flow for calling the record snap shot mode.
1)shld i have the camera in preview mode and when a user presses a EVENT KEY,i shld stop the camera and then in the CAM_STATUS_DONE callback,shld i call the
ICAMERA_SetMediaData,ICAMERA_SetSize,ICAMERA_SetVideoEncode,ICAMERA_SetParm and then ICAMERA_RecordSnapshot????
thanks..
ibrew

Yup the flow u described ..works for me ... In the CAM_STATUS_DONE for the preview ..call the snapshot functions... when u call the record snapshot... you again will be sent the CAM_STATUS_DONE twice... once when the snapshot is recorded and the second one when the snapshot encoding is done.

Yup the flow u described ..works for me ... In the CAM_STATUS_DONE for the preview ..call the snapshot functions... when u call the record snapshot... you again will be sent the CAM_STATUS_DONE twice... once when the snapshot is recorded and the second one when the snapshot encoding is done.

hi,
thanks for the reply and pointers.
its working now.appreciate ur help.
thanks
ibrew

hi,
thanks for the reply and pointers.
its working now.appreciate ur help.
thanks
ibrew

Thanks for posting the interesting fact ant KX2...

Thanks for posting the interesting fact ant KX2...

Hi,
Here i am also trying for the same.which device you are using for testing.here i checked with kx5 but i am not getting any result.still i am getting create instance problem.how can i resolve this one,please help me out.
Thanks in advance
Muthukumaran.S
r@I wrote:Cant seem to make out where you are going wrong.. but in ur code u dont have to set
pMe->pn->nStatus=CAM_STATUS_FRAME;
pMe->pn->nCmd=CAM_CMD_START;
pMe->pn->nSubCmd=CAM_MODE_PREVIEW;
in the test Camera function. Infact I am not sure u even need a cameranotify structure in ur applet. But I dont think thats causing the error.
The code below works for me .. hope it helps.
Applet structure
typedef struct _cameratest{
AEEApplet a;// First element of this structure must be AEEApplet
IDisplay *pIDisplay;
IShell *pIShell;
EAppStateType m_eAppState; // Current Application State
EAppStateType m_ePrevState;
uint16 cxScreen;// Width of the handset screen
uint16 cyScreen;// Height of the handset screen
IMenuCtl *m_pMainMenu;
ICamera *m_pICamera; // ptr to the camera
cameratest;
The function to start the camera
static void cameratest_DisplayCameraPreview(cameratest * pMe)
{
int nErr;
AEESize az;
pMe->m_eAppState = APP_STATE_CAM_PREVIEW;
if (ISHELL_CreateInstance(pMe->pIShell, AEECLSID_CAMERA , (void**)(&pMe->m_pICamera)) != SUCCESS)
return;
// Register callback notification function.
nErr = ICAMERA_RegisterNotify(pMe->m_pICamera, cameratest_CameraNotify, pMe);
if (nErr)
{
DBGPRINTF("ERROR IN REGISTERING CALL BACK %d", nErr);
Cameratest_goBack(pMe->m_eAppState);
return;

az.cx = pMe->cxScreen;
az.cy = pMe->cyScreen;
ICAMERA_SetDisplaySize(pMe->m_pICamera, &az);
nErr = ICAMERA_Preview(pMe->m_pICamera);
if (nErr)
{
DBGPRINTF("ERROR in initiating preview %d", nErr);
return;

And the callback function
static void cameratest_CameraNotify(void * pUser, AEECameraNotify * pn)
{
cameratest * pMe = (cameratest *)pUser;
if (!pMe !pn)
return;
switch (pn->nStatus)
{
case CAM_STATUS_START:
// Preview has begun...
break;
case CAM_STATUS_FRAME:
{
IBitmap * pFrame;
AEEBitmapInfo bi; // // IMPORTANT NOTE: You need to do IBITMAP_Release(pFrame) after you're done with pFrame.
pFrame = ICAMERA_GetFrame(pMe->m_pICamera, &pFrame);
if (!pFrame)
{
DBGPRINTF("DID not get FRAME");
break;

// Get the bitmap info...this can be saved in app global structure.
IBITMAP_GetInfo(pFrame, &bi, sizeof(bi));
// Display the frame at (0, 0) location of the screen
IDISPLAY_BitBlt(pMe->pIDisplay, 2, 2, bi.cx, bi.cy, pFrame, 0, 0, AEE_RO_COPY);
IBITMAP_Release(pFrame);
IDISPLAY_Update(pMe->pIDisplay);

break;
case CAM_STATUS_DONE:
break;
case CAM_STATUS_ABORT:
// Preview got aborted.
break;

Hi,
Here i am also trying for the same.which device you are using for testing.here i checked with kx5 but i am not getting any result.still i am getting create instance problem.how can i resolve this one,please help me out.
Thanks in advance
Muthukumaran.S
r@I wrote:Cant seem to make out where you are going wrong.. but in ur code u dont have to set
pMe->pn->nStatus=CAM_STATUS_FRAME;
pMe->pn->nCmd=CAM_CMD_START;
pMe->pn->nSubCmd=CAM_MODE_PREVIEW;
in the test Camera function. Infact I am not sure u even need a cameranotify structure in ur applet. But I dont think thats causing the error.
The code below works for me .. hope it helps.
Applet structure
typedef struct _cameratest{
AEEApplet a;// First element of this structure must be AEEApplet
IDisplay *pIDisplay;
IShell *pIShell;
EAppStateType m_eAppState; // Current Application State
EAppStateType m_ePrevState;
uint16 cxScreen;// Width of the handset screen
uint16 cyScreen;// Height of the handset screen
IMenuCtl *m_pMainMenu;
ICamera *m_pICamera; // ptr to the camera
cameratest;
The function to start the camera
static void cameratest_DisplayCameraPreview(cameratest * pMe)
{
int nErr;
AEESize az;
pMe->m_eAppState = APP_STATE_CAM_PREVIEW;
if (ISHELL_CreateInstance(pMe->pIShell, AEECLSID_CAMERA , (void**)(&pMe->m_pICamera)) != SUCCESS)
return;
// Register callback notification function.
nErr = ICAMERA_RegisterNotify(pMe->m_pICamera, cameratest_CameraNotify, pMe);
if (nErr)
{
DBGPRINTF("ERROR IN REGISTERING CALL BACK %d", nErr);
Cameratest_goBack(pMe->m_eAppState);
return;

az.cx = pMe->cxScreen;
az.cy = pMe->cyScreen;
ICAMERA_SetDisplaySize(pMe->m_pICamera, &az);
nErr = ICAMERA_Preview(pMe->m_pICamera);
if (nErr)
{
DBGPRINTF("ERROR in initiating preview %d", nErr);
return;

And the callback function
static void cameratest_CameraNotify(void * pUser, AEECameraNotify * pn)
{
cameratest * pMe = (cameratest *)pUser;
if (!pMe !pn)
return;
switch (pn->nStatus)
{
case CAM_STATUS_START:
// Preview has begun...
break;
case CAM_STATUS_FRAME:
{
IBitmap * pFrame;
AEEBitmapInfo bi; // // IMPORTANT NOTE: You need to do IBITMAP_Release(pFrame) after you're done with pFrame.
pFrame = ICAMERA_GetFrame(pMe->m_pICamera, &pFrame);
if (!pFrame)
{
DBGPRINTF("DID not get FRAME");
break;

// Get the bitmap info...this can be saved in app global structure.
IBITMAP_GetInfo(pFrame, &bi, sizeof(bi));
// Display the frame at (0, 0) location of the screen
IDISPLAY_BitBlt(pMe->pIDisplay, 2, 2, bi.cx, bi.cy, pFrame, 0, 0, AEE_RO_COPY);
IBITMAP_Release(pFrame);
IDISPLAY_Update(pMe->pIDisplay);

break;
case CAM_STATUS_DONE:
break;
case CAM_STATUS_ABORT:
// Preview got aborted.
break;

I personally have tried Moto V265, LG Vx8000 and KZ850 T ... the code works ok on those devices.
Did u check the specs for KX5 ? does it support camera access to BREW ? If it does and you are getting EPRIVLEVEL return code while calling createinstance then it could be that you have to add a dependency in the MIF.
R@I

I personally have tried Moto V265, LG Vx8000 and KZ850 T ... the code works ok on those devices.
Did u check the specs for KX5 ? does it support camera access to BREW ? If it does and you are getting EPRIVLEVEL return code while calling createinstance then it could be that you have to add a dependency in the MIF.
R@I

hi,
yeah,r@I is right.first check the DDS for a particular device.and it supports camera,then u can go ahead with ur problem.on emulator,it wonnt work.i thnk u need to create ur own classid in the MIF file.see some previoud post by r@I to help u in this.
HTH
ibrew

hi,
yeah,r@I is right.first check the DDS for a particular device.and it supports camera,then u can go ahead with ur problem.on emulator,it wonnt work.i thnk u need to create ur own classid in the MIF file.see some previoud post by r@I to help u in this.
HTH
ibrew

I've followed the previous examples, but can't get the picture to save.
It allows the Preview, but when I click a picture, it doesn't actually save to a jpg file. I get a success all the way through, even in RecordSnapshot.
Can anyone tell what I am doing wrong?
static void cDisplayCameraPreview(CApp * pme)
{
int nErr;
AEESize az;
AEEDeviceInfo di;
boolean pbSupport;
nErr = ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_CAMERA , (void**)(&pme->m_pICamera));
if (nErr)
{
DBGPRINTF("ERROR CREATING ICAMERA INSTANCE %d", nErr);
return;
}
// Register callback notification function.
nErr = ICAMERA_RegisterNotify(pme->m_pICamera, CameraNotify, pme);
if (nErr)
{
DBGPRINTF("ERROR IN REGISTERING CALL BACK %d", nErr);
return;
}
ISHELL_GetDeviceInfo(pme->a.m_pIShell, &di);
az.cx = di.cxScreen;
az.cy = di.cyScreen;
ICAMERA_SetDisplaySize(pme->m_pICamera, &az);
nErr = ICAMERA_Preview(pme->m_pICamera);
if (nErr)
{
DBGPRINTF("ERROR in initiating preview %d", nErr);
return;
}
}
static void CameraNotify(void * pUser, AEECameraNotify * pn)
{
CApp * pme = (CApp *)pUser;
AEESize az;
int nErr;
uint32 dwParam;
AEEDeviceInfo di;
if ((!pme) || (!pn))
return;
switch (pn->nStatus)
{
case CAM_STATUS_START:
// Preview has begun...
break;
case CAM_STATUS_FRAME:
{
IBitmap * pFrame;
AEEBitmapInfo bi; // // IMPORTANT NOTE: You need to do IBITMAP_Release(pFrame) after you're done with pFrame.
nErr = ICAMERA_GetFrame(pme->m_pICamera, &pFrame);
if (!pFrame)
{
DBGPRINTF("DID not get FRAME");
break;
}
// Get the bitmap info...this can be saved in app global structure.
nErr = IBITMAP_GetInfo(pFrame, &bi, sizeof(bi));
if (nErr!=SUCCESS)
{
DBGPRINTF("IBITMAP_GetInfo %d", nErr);
break;
}
// Display the frame at (0, 0) location of the screen
IDISPLAY_BitBlt(pme->a.m_pIDisplay, 0, 0, bi.cx, bi.cy, pFrame, 0, 0, AEE_RO_COPY);
IDISPLAY_Update(pme->a.m_pIDisplay);
break;
}
case CAM_STATUS_DONE:
{
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_PREVIEW)
{
// Get device screen rect
ISHELL_GetDeviceInfo(pme->a.m_pIShell, &di);
az.cx = di.cxScreen;
az.cy = di.cyScreen;
pme->md.clsData=MMD_FILE_NAME;
pme->md.pData="test.jpg";
pme->md.dwSize=0;
nErr=ICAMERA_SetMediaData(pme->m_pICamera,&pme->md,AEECLSID_JPEG);
if(nErr!=SUCCESS)
{
DBGPRINTF("CAMERA SET Media Data FAILURE");
return;
}
nErr=ICAMERA_SetSize(pme->m_pICamera,&az);
if(nErr!=SUCCESS)
{
DBGPRINTF("CAMERA SET SIZE FAILURE ");
return;
}
nErr=ICAMERA_SetVideoEncode(pme->m_pICamera,AEECLSID_JPEG,dwParam);
if (nErr!=SUCCESS)
{
DBGPRINTF("CAMERA SET VIDEO ENCODE FAILURE");
return ;
}
nErr=ICAMERA_RecordSnapshot(pme->m_pICamera);
if(nErr!=SUCCESS)
{
DBGPRINTF("CAMERA RECORD SNAPSHOT FAILURE ");
return;
}
}
break;
}
case CAM_STATUS_ABORT:
// Preview got aborted.
break;
}

I've followed the previous examples, but can't get the picture to save.
It allows the Preview, but when I click a picture, it doesn't actually save to a jpg file. I get a success all the way through, even in RecordSnapshot.
Can anyone tell what I am doing wrong?
static void cDisplayCameraPreview(CApp * pme)
{
int nErr;
AEESize az;
AEEDeviceInfo di;
boolean pbSupport;
nErr = ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_CAMERA , (void**)(&pme->m_pICamera));
if (nErr)
{
DBGPRINTF("ERROR CREATING ICAMERA INSTANCE %d", nErr);
return;
}
// Register callback notification function.
nErr = ICAMERA_RegisterNotify(pme->m_pICamera, CameraNotify, pme);
if (nErr)
{
DBGPRINTF("ERROR IN REGISTERING CALL BACK %d", nErr);
return;
}
ISHELL_GetDeviceInfo(pme->a.m_pIShell, &di);
az.cx = di.cxScreen;
az.cy = di.cyScreen;
ICAMERA_SetDisplaySize(pme->m_pICamera, &az);
nErr = ICAMERA_Preview(pme->m_pICamera);
if (nErr)
{
DBGPRINTF("ERROR in initiating preview %d", nErr);
return;
}
}
static void CameraNotify(void * pUser, AEECameraNotify * pn)
{
CApp * pme = (CApp *)pUser;
AEESize az;
int nErr;
uint32 dwParam;
AEEDeviceInfo di;
if ((!pme) || (!pn))
return;
switch (pn->nStatus)
{
case CAM_STATUS_START:
// Preview has begun...
break;
case CAM_STATUS_FRAME:
{
IBitmap * pFrame;
AEEBitmapInfo bi; // // IMPORTANT NOTE: You need to do IBITMAP_Release(pFrame) after you're done with pFrame.
nErr = ICAMERA_GetFrame(pme->m_pICamera, &pFrame);
if (!pFrame)
{
DBGPRINTF("DID not get FRAME");
break;
}
// Get the bitmap info...this can be saved in app global structure.
nErr = IBITMAP_GetInfo(pFrame, &bi, sizeof(bi));
if (nErr!=SUCCESS)
{
DBGPRINTF("IBITMAP_GetInfo %d", nErr);
break;
}
// Display the frame at (0, 0) location of the screen
IDISPLAY_BitBlt(pme->a.m_pIDisplay, 0, 0, bi.cx, bi.cy, pFrame, 0, 0, AEE_RO_COPY);
IDISPLAY_Update(pme->a.m_pIDisplay);
break;
}
case CAM_STATUS_DONE:
{
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_PREVIEW)
{
// Get device screen rect
ISHELL_GetDeviceInfo(pme->a.m_pIShell, &di);
az.cx = di.cxScreen;
az.cy = di.cyScreen;
pme->md.clsData=MMD_FILE_NAME;
pme->md.pData="test.jpg";
pme->md.dwSize=0;
nErr=ICAMERA_SetMediaData(pme->m_pICamera,&pme->md,AEECLSID_JPEG);
if(nErr!=SUCCESS)
{
DBGPRINTF("CAMERA SET Media Data FAILURE");
return;
}
nErr=ICAMERA_SetSize(pme->m_pICamera,&az);
if(nErr!=SUCCESS)
{
DBGPRINTF("CAMERA SET SIZE FAILURE ");
return;
}
nErr=ICAMERA_SetVideoEncode(pme->m_pICamera,AEECLSID_JPEG,dwParam);
if (nErr!=SUCCESS)
{
DBGPRINTF("CAMERA SET VIDEO ENCODE FAILURE");
return ;
}
nErr=ICAMERA_RecordSnapshot(pme->m_pICamera);
if(nErr!=SUCCESS)
{
DBGPRINTF("CAMERA RECORD SNAPSHOT FAILURE ");
return;
}
}
break;
}
case CAM_STATUS_ABORT:
// Preview got aborted.
break;
}

hi mcho,
which handset ur using..?cause,in my previous reply,as u can see,i was using KX2 and that had a issue,u can refer to device DDS and known issue.
HTH
ibrew

hi mcho,
which handset ur using..?cause,in my previous reply,as u can see,i was using KX2 and that had a issue,u can refer to device DDS and known issue.
HTH
ibrew

I'm using the Audiovox CDM8940. I tried adding the ICAMERA_SetParm statement that is required for KX2, but it still didn't save the file.
Any other ideas?

I'm using the Audiovox CDM8940. I tried adding the ICAMERA_SetParm statement that is required for KX2, but it still didn't save the file.
Any other ideas?

Glad to know that ICamera works on Audivox 8940 ....
Can u try setting the media data for BMP format and see if it saves the file ... I havent really tested the JPEG format anytime. Also try setting the size of the snap to some standard size like VGA (640 *480) or QVGA (320*240). Check the specs of the device to see what Mime Types it supports
You can set Media data
//Setting the Media Data params
pMe->md.clsData = MMD_FILE_NAME;
pMe->md.pData = (void *)"image.bmp";
pMe->md.dwSize = 0;
//Set the Media Data
nRet = ICAMERA_SetMediaData(pMe->m_pICamera, &pMe->md, MT_BMP);
//Set Video Encode
nRet = ICAMERA_SetVideoEncode(pMe->m_pICamera, AEECLSID_WINBMP, 0);
Also since you are taking a snapshot .. I believe u should be getting 2 status_done messages in ur camera callback function
The callback function
case CAM_STATUS_DONE:
if(pn->nCmd == CAM_CMD_ENCODESNAPSHOT)
{
DBGPRINTF("ENCODING SNAPSHOT DONE - Check the App Folder for the image");
}
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_SNAPSHOT)
{
DBGPRINTF("FRAME CAPTURED ... INITIATING THE ENCODING");
}
Check your call back function and see if you are getting these messages after you take a snapshot.
R@I

Glad to know that ICamera works on Audivox 8940 ....
Can u try setting the media data for BMP format and see if it saves the file ... I havent really tested the JPEG format anytime. Also try setting the size of the snap to some standard size like VGA (640 *480) or QVGA (320*240). Check the specs of the device to see what Mime Types it supports
You can set Media data
//Setting the Media Data params
pMe->md.clsData = MMD_FILE_NAME;
pMe->md.pData = (void *)"image.bmp";
pMe->md.dwSize = 0;
//Set the Media Data
nRet = ICAMERA_SetMediaData(pMe->m_pICamera, &pMe->md, MT_BMP);
//Set Video Encode
nRet = ICAMERA_SetVideoEncode(pMe->m_pICamera, AEECLSID_WINBMP, 0);
Also since you are taking a snapshot .. I believe u should be getting 2 status_done messages in ur camera callback function
The callback function
case CAM_STATUS_DONE:
if(pn->nCmd == CAM_CMD_ENCODESNAPSHOT)
{
DBGPRINTF("ENCODING SNAPSHOT DONE - Check the App Folder for the image");
}
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_SNAPSHOT)
{
DBGPRINTF("FRAME CAPTURED ... INITIATING THE ENCODING");
}
Check your call back function and see if you are getting these messages after you take a snapshot.
R@I

I added the code to change to .bmp, but am getting the same result.
All success, but no file. After the picture is snapped, it goes to CAM_STATUS_DONE and executes the snapshot code. It then goes to CAM_STATUS_START, then to CAM_STATUS_ABORT.
It never gets back to CAM_STATUS_DONE, as I was expecting.
Thus, the DBG statements for CAM_CMD_ENCODESNAPSHOT and
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_SNAPSHOT)
are not getting hit.
Maybe I'm not sending a valid frame to save? Is there anyway to check?

I added the code to change to .bmp, but am getting the same result.
All success, but no file. After the picture is snapped, it goes to CAM_STATUS_DONE and executes the snapshot code. It then goes to CAM_STATUS_START, then to CAM_STATUS_ABORT.
It never gets back to CAM_STATUS_DONE, as I was expecting.
Thus, the DBG statements for CAM_CMD_ENCODESNAPSHOT and
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_SNAPSHOT)
are not getting hit.
Maybe I'm not sending a valid frame to save? Is there anyway to check?

CAM STATUS ABORT is why the snapshot is failing.... The device isnt able to capture the frame.
Did you make the changes to the size ?? ... can you also check the MIME types supported by the device in the specs ....
You do not need to pass any Frame.. it all happens on its own.
R@I

CAM STATUS ABORT is why the snapshot is failing.... The device isnt able to capture the frame.
Did you make the changes to the size ?? ... can you also check the MIME types supported by the device in the specs ....
You do not need to pass any Frame.. it all happens on its own.
R@I

In your previous code you have:
az.cx = pMe->cxScreen;
az.cy = pMe->cyScreen;
Where did you get the pMe->cxScreen and pMe->cyScreen values?
In my code I am doing the following:
ISHELL_GetDeviceInfo(pme->a.m_pIShell, &di);
az.cx = di.cxScreen;
az.cy = di.cyScreen;
I also tried hardcoding the values to 32x32, 100x100, etc. but it still ABORTS for some reason?!?!
As for the media formats, the CDM8940 supports BMP, BCI, PNG, and JPEG.

In your previous code you have:
az.cx = pMe->cxScreen;
az.cy = pMe->cyScreen;
Where did you get the pMe->cxScreen and pMe->cyScreen values?
In my code I am doing the following:
ISHELL_GetDeviceInfo(pme->a.m_pIShell, &di);
az.cx = di.cxScreen;
az.cy = di.cyScreen;
I also tried hardcoding the values to 32x32, 100x100, etc. but it still ABORTS for some reason?!?!
As for the media formats, the CDM8940 supports BMP, BCI, PNG, and JPEG.

That size was for Preview Mode ... and its basically the same as what you are doing now. For snapshot mode when you are setting the size ... can you try using QVGA resolution
az.cx =320;
az.cy = 240;
I am not sure if this will help but it's worth a try
R@I

That size was for Preview Mode ... and its basically the same as what you are doing now. For snapshot mode when you are setting the size ... can you try using QVGA resolution
az.cx =320;
az.cy = 240;
I am not sure if this will help but it's worth a try
R@I

Hi R@l,
Setting the size to
az.cx = 320;
az.cy = 240;
has the same behaviour as before, where I then see it go to CAM_STATUS_START then CAM_STATUS_ABORT.
Any other ideas?
Anybody?

Hi R@l,
Setting the size to
az.cx = 320;
az.cy = 240;
has the same behaviour as before, where I then see it go to CAM_STATUS_START then CAM_STATUS_ABORT.
Any other ideas?
Anybody?

hi mcho,
try saving it in the path as given in DDS,brew/shared/jpeg
HTH
ibrew

hi mcho,
try saving it in the path as given in DDS,brew/shared/jpeg
HTH
ibrew

Thanks, for the advice.
Still getting the same result, where I succeed on recordshapshot, go to start, then abort.
I'm wondering if I'm capturing a valid frame in the CAM_STATUS_FRAME state.
Here's the current frame capture code:
case CAM_STATUS_FRAME:
{
IBitmap * pFrame;
// // IMPORTANT NOTE: You need to do IBITMAP_Release(pFrame) after you're done with pFrame.
LogToFile("CAM_STATUS_FRAME0");
nErr = ICAMERA_GetFrame(pme->m_pICamera, &pFrame);
if (!pFrame)
{
LogToFile("DID not get FRAME");
DBGPRINTF("DID not get FRAME");
break;
}
// Get the bitmap info...this can be saved in app global structure.
nErr = IBITMAP_GetInfo(pFrame, &pme->bi, sizeof(pme->bi));
if (nErr!=SUCCESS)
{
LogToFile("ERROR GETTING BITMAP INFO.");
DBGPRINTF("IBITMAP_GetInfo %d", nErr);
break;
}
// SPRINTF(logtext,"%s%d%s%d","X:",pme->bi.cx," Y:",pme->bi.cy);
// LogToFile(logtext);
// Display the frame at (0, 0) location of the screen
IDISPLAY_BitBlt(pme->a.m_pIDisplay, 0, 0, pme->bi.cx, pme->bi.cy, pFrame, 0, 0, AEE_RO_COPY);
LogToFile("CAM_STATUS_FRAME2");
IBITMAP_Release(pFrame);
LogToFile("CAM_STATUS_FRAME3");
IDISPLAY_Update(pme->a.m_pIDisplay);
break;
}

Thanks, for the advice.
Still getting the same result, where I succeed on recordshapshot, go to start, then abort.
I'm wondering if I'm capturing a valid frame in the CAM_STATUS_FRAME state.
Here's the current frame capture code:
case CAM_STATUS_FRAME:
{
IBitmap * pFrame;
// // IMPORTANT NOTE: You need to do IBITMAP_Release(pFrame) after you're done with pFrame.
LogToFile("CAM_STATUS_FRAME0");
nErr = ICAMERA_GetFrame(pme->m_pICamera, &pFrame);
if (!pFrame)
{
LogToFile("DID not get FRAME");
DBGPRINTF("DID not get FRAME");
break;
}
// Get the bitmap info...this can be saved in app global structure.
nErr = IBITMAP_GetInfo(pFrame, &pme->bi, sizeof(pme->bi));
if (nErr!=SUCCESS)
{
LogToFile("ERROR GETTING BITMAP INFO.");
DBGPRINTF("IBITMAP_GetInfo %d", nErr);
break;
}
// SPRINTF(logtext,"%s%d%s%d","X:",pme->bi.cx," Y:",pme->bi.cy);
// LogToFile(logtext);
// Display the frame at (0, 0) location of the screen
IDISPLAY_BitBlt(pme->a.m_pIDisplay, 0, 0, pme->bi.cx, pme->bi.cy, pFrame, 0, 0, AEE_RO_COPY);
LogToFile("CAM_STATUS_FRAME2");
IBITMAP_Release(pFrame);
LogToFile("CAM_STATUS_FRAME3");
IDISPLAY_Update(pme->a.m_pIDisplay);
break;
}

Just to close out my line of questions, the solution for my problem was to add an ICAMERA_Stop in the program's main event handler, when in preview mode.
This is what was preventing the save from happening successfully.
Thanks to everyone that tried to help!
Regards,
Mark

Just to close out my line of questions, the solution for my problem was to add an ICAMERA_Stop in the program's main event handler, when in preview mode.
This is what was preventing the save from happening successfully.
Thanks to everyone that tried to help!
Regards,
Mark

Great to see it working for u

Great to see it working for u

Hi,
I'm using Motorola V710. Also encountering the same problem in V265.
After i encode my file in snapshot mode, opening the file using IFLEMGR interface returns a NULL file handle.
I guess the reason is that data is not completely flushed to the EFS. I'm able to view the file via Apploader , but the file CANNOT be viewed in the handset media gallery.
In my BREW application , "IFILEMGR_OpenFile" returns NULL; Below i've attached my code for Preview and snapshot mode.
static int camera_test(camera_moto* pMe){
int nErr;
AEESize pSize;
nErr = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_CAMERA, (void **)&pMe->m_pICamera);
if (nErr)
test_err(pMe,"Camera Instance failed");
// Register callback notification function.
nErr = ICAMERA_RegisterNotify(pMe->m_pICamera, CApp_CameraNotify, pMe);
if (nErr)
test_err(pMe,"Camera Register Notify failed");
pSize.cx = DEVICE_WIDTH; // DEVICE_WIDTH = 176
pSize.cy = DEVICE_HEIGHT; //DEVICE_HEIGHT = 204
nErr = ICAMERA_SetDisplaySize(pMe->m_pICamera, &pSize);
if (nErr)
test_err(pMe,"Camera SetDisplay size failed");
nErr = ICAMERA_Preview(pMe->m_pICamera);
if (nErr)
test_err(pMe,"Camera Preview mode failed");
return SUCCESS;

static void CApp_CameraNotify(void * pUser, AEECameraNotify * pn)
{
camera_moto* pMe = (camera_moto*)pUser;
int nErr;
AEESize asize;
//if (!pMe || !pn)
//return;
switch (pn->nStatus)
{
case CAM_STATUS_START:
//Below code executed when ICamera_RecordSnapshot called
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_SNAPSHOT)
test_err(pMe,"Record Snapshot started");
break;
case CAM_STATUS_FRAME:
// IMPORTANT NOTE: You need to do IBITMAP_Release(pFrame) after you're done with pFrame.
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_PREVIEW ){
nErr = ICAMERA_GetFrame(pMe->m_pICamera, &pMe->pFrame);
if(nErr != SUCCESS)
test_err(pMe,"Camera Get frame failed");
// Get the bitmap info...this can be saved in app global structure.
pMe->bi = MALLOC(sizeof(AEEBitmapInfo));
IBITMAP_GetInfo(pMe->pFrame, pMe->bi, sizeof(AEEBitmapInfo));
// Display the frame at (0, 0) location of the screen
IDISPLAY_BitBlt(pMe->a.m_pIDisplay, 0, 0, DEVICE_WIDTH, DEVICE_HEIGHT, pMe->pFrame, 0, 0, AEE_RO_COPY);
IDISPLAY_Update(pMe->a.m_pIDisplay);
if(pMe->pFrame){
IBITMAP_Release(pMe->pFrame);
pMe->pFrame = NULL;

FREEIF(pMe->bi);
pMe->key_camera = 1; // ICamera_Stop is called in the EVENT Handler under //AVK_SELECT when pMe->key_camera = 1
}
break;
case CAM_STATUS_DONE:
// ICAMERA_Stop() was called and preview operation stopped.
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_PREVIEW){
pMe->key_camera = 10;
// 1. SetMediaData()
pMe->mdata.clsData = MMD_FILE_NAME;
//
pMe->mdata.pData = "motorola/shared/picture/test144.jpg"; pMe->mdata.dwSize = 0;
nErr = ICAMERA_SetMediaData(pMe->m_pICamera, &pMe->mdata, MT_JPEG);
if(nErr != SUCCESS)
test_err(pMe, "SetMediaData failed");
asize.cx = 160;
asize.cy = 120;
nErr = ICAMERA_SetSize(pMe->m_pICamera, &asize);
if(nErr != SUCCESS)
test_err(pMe, "Camera SetSize Failure");
nErr = ICAMERA_SetVideoEncode(pMe->m_pICamera, AEECLSID_JPEG, 0);
if(nErr != SUCCESS)
test_err(pMe, "Camera SetVideoEncode Failure");
nErr = ICAMERA_RecordSnapshot(pMe->m_pICamera);
if(nErr != SUCCESS)
test_err(pMe, "Camera RecordSnapshot Failure");
}
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_SNAPSHOT){
test_err(pMe,"Record Snapshot started");
// nErr = ICAMERA_EncodeSnapshot(pMe->m_pICamera);
// if(nErr == SUCCESS )
// test_err(pMe,"Encode snapshot");
}
if(pn->nCmd == CAM_CMD_ENCODESNAPSHOT){
pMe->key_camera = 2;
pMe->cam_state = IMAGE_SAVED;
test_err(pMe,"Encode snapshot complete");
}
break;
case CAM_STATUS_ABORT:
// Preview got aborted.
break;
}
}
//My function for JPEG Decoder
//the fucntion "image" gets called when "pMe->key_camera == 2" and
"pMe->cam_state == IMAGE_SAVED"
static boolean image(camera_moto* pMe)
{
uint32 pnBufSize;
uint32 bytesread;
FileInfo fInfo;
uint32 fsize;
if(pMe->cam_state == IMAGE_SAVED){
if(pMe->m_pICamera){
ICAMERA_Release(pMe->m_pICamera);
pMe->m_pICamera = NULL;

pMe->pIImage = NULL;
pnBufSize = NULL;
if(pMe->key_camera == 2 && pMe->cam_state == IMAGE_SAVED){
pMe->key_camera = 100;
pMe->pIImage = NULL;
if(ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_JPEG,(void**)&pMe->pIImage)!=SUCCESS){
return FALSE;

pMe->pFileMgr = NULL;
if(ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_FILEMGR,(void **)&pMe->pFileMgr)!= SUCCESS){
if(pMe->pIImage){
IIMAGE_Release(pMe->pIImage);
pMe->pIImage = NULL;
}
return FALSE;

pMe->my_IMemAStream = NULL;
if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_MEMASTREAM, (void **)&pMe->my_IMemAStream) != SUCCESS){
if(pMe->pIImage){
IIMAGE_Release(pMe->pIImage);
pMe->pIImage = NULL;
}
if(pMe->pFileMgr){
IFILEMGR_Release(pMe->pFileMgr);
pMe->pFileMgr = NULL;
}
return FALSE;

pMe->file_handle=NULL;
pMe->file_handle = IFILEMGR_OpenFile(pMe->pFileMgr,"motorola/shared/picture/test144.jpg",_OFM_READ);
if (!pMe->file_handle)
{
if(pMe->pIImage){
IIMAGE_Release(pMe->pIImage);
pMe->pIImage = NULL;
}
if(pMe->pFileMgr){
IFILEMGR_Release(pMe->pFileMgr);
pMe->pFileMgr = NULL;
}
if(pMe->my_IMemAStream){
IMEMASTREAM_Release(pMe->my_IMemAStream);
pMe->my_IMemAStream = NULL;
}
test_err(pMe,"file handle failed"); // THIS MESSAGE GEETING DISPLAYED ON HANDSET,.file handle returned is NULL
return FALSE;

IFILE_GetInfo(pMe->file_handle, &fInfo);
fsize = fInfo.dwSize;
pMe->imgsrc = (byte*)MALLOC(fsize * sizeof(char));
if(pMe->file_handle){
bytesread = IFILE_Read(pMe->file_handle , pMe->imgsrc ,fsize);
if(pMe->file_handle){
IFILE_Release(pMe->file_handle);
pMe->file_handle = NULL;

IMEMASTREAM_Set(pMe->my_IMemAStream,pMe->imgsrc ,fsize,0,FALSE);
IIMAGE_SetStream(pMe->pIImage,(IAStream*)pMe->my_IMemAStream);
IIMAGE_Notify((IImage*)pMe->pIImage, (PFNIMAGEINFO) display_jpeg, (void*) pMe);
if(pMe->pFileMgr){
IFILEMGR_Release(pMe->pFileMgr);
pMe->pFileMgr = NULL;

}
}

return TRUE;
}
// JPEG Decoder Callback
static boolean display_jpeg(void * pUser, IImage* pIImage, AEEImageInfo* pi,int nErr)
{
camera_moto* pMe = (camera_moto*)pUser;
if(pMe->pFileMgr){
IFILEMGR_Release(pMe->pFileMgr);
pMe->pFileMgr = NULL;

if(pMe->file_handle){
IFILE_Release(pMe->file_handle);
pMe->file_handle = NULL;

if(!nErr){
if(pi->cx == 160 && pi->cy == 120 ){
IDISPLAY_ClearScreen(pMe->a.m_pIDisplay);
IIMAGE_Draw(pMe->pIImage, 8, 42);
IDISPLAY_Update(pMe->a.m_pIDisplay);
if(pMe->pIImage){
IIMAGE_Release(pMe->pIImage);
pMe->pIImage = NULL;
}
if(pMe->pFileMgr){
IFILEMGR_Release(pMe->pFileMgr);
pMe->pFileMgr = NULL;
}
}
}
return TRUE;
}
//MY EVENT HANDLER FOR AVK_SELECT:
case AVK_SELECT :
switch(pMe->key_camera ){
case 1:
nErr = ICAMERA_Stop(pMe->m_pICamera);
if(nErr != SUCCESS){
test_err(pMe,"ICAMERA_Stop failure");
}
break;
case 2:
if(pMe->cam_state == IMAGE_SAVED){
image(pMe);
}
break;
}
break;
I have also tried the following:
1] Tried saving the image as a 640 x 480 image
2] Saved the image as a ".bmp" image in the shared directory and reading the image from shared directory
But got the same error in both the cases. If Anybody has encountered a similar issue please let me know have could this be solved

Hi,
I'm using Motorola V710. Also encountering the same problem in V265.
After i encode my file in snapshot mode, opening the file using IFLEMGR interface returns a NULL file handle.
I guess the reason is that data is not completely flushed to the EFS. I'm able to view the file via Apploader , but the file CANNOT be viewed in the handset media gallery.
In my BREW application , "IFILEMGR_OpenFile" returns NULL; Below i've attached my code for Preview and snapshot mode.
static int camera_test(camera_moto* pMe){
int nErr;
AEESize pSize;
nErr = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_CAMERA, (void **)&pMe->m_pICamera);
if (nErr)
test_err(pMe,"Camera Instance failed");
// Register callback notification function.
nErr = ICAMERA_RegisterNotify(pMe->m_pICamera, CApp_CameraNotify, pMe);
if (nErr)
test_err(pMe,"Camera Register Notify failed");
pSize.cx = DEVICE_WIDTH; // DEVICE_WIDTH = 176
pSize.cy = DEVICE_HEIGHT; //DEVICE_HEIGHT = 204
nErr = ICAMERA_SetDisplaySize(pMe->m_pICamera, &pSize);
if (nErr)
test_err(pMe,"Camera SetDisplay size failed");
nErr = ICAMERA_Preview(pMe->m_pICamera);
if (nErr)
test_err(pMe,"Camera Preview mode failed");
return SUCCESS;

static void CApp_CameraNotify(void * pUser, AEECameraNotify * pn)
{
camera_moto* pMe = (camera_moto*)pUser;
int nErr;
AEESize asize;
//if (!pMe || !pn)
//return;
switch (pn->nStatus)
{
case CAM_STATUS_START:
//Below code executed when ICamera_RecordSnapshot called
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_SNAPSHOT)
test_err(pMe,"Record Snapshot started");
break;
case CAM_STATUS_FRAME:
// IMPORTANT NOTE: You need to do IBITMAP_Release(pFrame) after you're done with pFrame.
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_PREVIEW ){
nErr = ICAMERA_GetFrame(pMe->m_pICamera, &pMe->pFrame);
if(nErr != SUCCESS)
test_err(pMe,"Camera Get frame failed");
// Get the bitmap info...this can be saved in app global structure.
pMe->bi = MALLOC(sizeof(AEEBitmapInfo));
IBITMAP_GetInfo(pMe->pFrame, pMe->bi, sizeof(AEEBitmapInfo));
// Display the frame at (0, 0) location of the screen
IDISPLAY_BitBlt(pMe->a.m_pIDisplay, 0, 0, DEVICE_WIDTH, DEVICE_HEIGHT, pMe->pFrame, 0, 0, AEE_RO_COPY);
IDISPLAY_Update(pMe->a.m_pIDisplay);
if(pMe->pFrame){
IBITMAP_Release(pMe->pFrame);
pMe->pFrame = NULL;

FREEIF(pMe->bi);
pMe->key_camera = 1; // ICamera_Stop is called in the EVENT Handler under //AVK_SELECT when pMe->key_camera = 1
}
break;
case CAM_STATUS_DONE:
// ICAMERA_Stop() was called and preview operation stopped.
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_PREVIEW){
pMe->key_camera = 10;
// 1. SetMediaData()
pMe->mdata.clsData = MMD_FILE_NAME;
//
pMe->mdata.pData = "motorola/shared/picture/test144.jpg"; pMe->mdata.dwSize = 0;
nErr = ICAMERA_SetMediaData(pMe->m_pICamera, &pMe->mdata, MT_JPEG);
if(nErr != SUCCESS)
test_err(pMe, "SetMediaData failed");
asize.cx = 160;
asize.cy = 120;
nErr = ICAMERA_SetSize(pMe->m_pICamera, &asize);
if(nErr != SUCCESS)
test_err(pMe, "Camera SetSize Failure");
nErr = ICAMERA_SetVideoEncode(pMe->m_pICamera, AEECLSID_JPEG, 0);
if(nErr != SUCCESS)
test_err(pMe, "Camera SetVideoEncode Failure");
nErr = ICAMERA_RecordSnapshot(pMe->m_pICamera);
if(nErr != SUCCESS)
test_err(pMe, "Camera RecordSnapshot Failure");
}
if(pn->nCmd == CAM_CMD_START && pn->nSubCmd == CAM_MODE_SNAPSHOT){
test_err(pMe,"Record Snapshot started");
// nErr = ICAMERA_EncodeSnapshot(pMe->m_pICamera);
// if(nErr == SUCCESS )
// test_err(pMe,"Encode snapshot");
}
if(pn->nCmd == CAM_CMD_ENCODESNAPSHOT){
pMe->key_camera = 2;
pMe->cam_state = IMAGE_SAVED;
test_err(pMe,"Encode snapshot complete");
}
break;
case CAM_STATUS_ABORT:
// Preview got aborted.
break;
}
}
//My function for JPEG Decoder
//the fucntion "image" gets called when "pMe->key_camera == 2" and
"pMe->cam_state == IMAGE_SAVED"
static boolean image(camera_moto* pMe)
{
uint32 pnBufSize;
uint32 bytesread;
FileInfo fInfo;
uint32 fsize;
if(pMe->cam_state == IMAGE_SAVED){
if(pMe->m_pICamera){
ICAMERA_Release(pMe->m_pICamera);
pMe->m_pICamera = NULL;

pMe->pIImage = NULL;
pnBufSize = NULL;
if(pMe->key_camera == 2 && pMe->cam_state == IMAGE_SAVED){
pMe->key_camera = 100;
pMe->pIImage = NULL;
if(ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_JPEG,(void**)&pMe->pIImage)!=SUCCESS){
return FALSE;

pMe->pFileMgr = NULL;
if(ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_FILEMGR,(void **)&pMe->pFileMgr)!= SUCCESS){
if(pMe->pIImage){
IIMAGE_Release(pMe->pIImage);
pMe->pIImage = NULL;
}
return FALSE;

pMe->my_IMemAStream = NULL;
if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_MEMASTREAM, (void **)&pMe->my_IMemAStream) != SUCCESS){
if(pMe->pIImage){
IIMAGE_Release(pMe->pIImage);
pMe->pIImage = NULL;
}
if(pMe->pFileMgr){
IFILEMGR_Release(pMe->pFileMgr);
pMe->pFileMgr = NULL;
}
return FALSE;

pMe->file_handle=NULL;
pMe->file_handle = IFILEMGR_OpenFile(pMe->pFileMgr,"motorola/shared/picture/test144.jpg",_OFM_READ);
if (!pMe->file_handle)
{
if(pMe->pIImage){
IIMAGE_Release(pMe->pIImage);
pMe->pIImage = NULL;
}
if(pMe->pFileMgr){
IFILEMGR_Release(pMe->pFileMgr);
pMe->pFileMgr = NULL;
}
if(pMe->my_IMemAStream){
IMEMASTREAM_Release(pMe->my_IMemAStream);
pMe->my_IMemAStream = NULL;
}
test_err(pMe,"file handle failed"); // THIS MESSAGE GEETING DISPLAYED ON HANDSET,.file handle returned is NULL
return FALSE;

IFILE_GetInfo(pMe->file_handle, &fInfo);
fsize = fInfo.dwSize;
pMe->imgsrc = (byte*)MALLOC(fsize * sizeof(char));
if(pMe->file_handle){
bytesread = IFILE_Read(pMe->file_handle , pMe->imgsrc ,fsize);
if(pMe->file_handle){
IFILE_Release(pMe->file_handle);
pMe->file_handle = NULL;

IMEMASTREAM_Set(pMe->my_IMemAStream,pMe->imgsrc ,fsize,0,FALSE);
IIMAGE_SetStream(pMe->pIImage,(IAStream*)pMe->my_IMemAStream);
IIMAGE_Notify((IImage*)pMe->pIImage, (PFNIMAGEINFO) display_jpeg, (void*) pMe);
if(pMe->pFileMgr){
IFILEMGR_Release(pMe->pFileMgr);
pMe->pFileMgr = NULL;

}
}

return TRUE;
}
// JPEG Decoder Callback
static boolean display_jpeg(void * pUser, IImage* pIImage, AEEImageInfo* pi,int nErr)
{
camera_moto* pMe = (camera_moto*)pUser;
if(pMe->pFileMgr){
IFILEMGR_Release(pMe->pFileMgr);
pMe->pFileMgr = NULL;

if(pMe->file_handle){
IFILE_Release(pMe->file_handle);
pMe->file_handle = NULL;

if(!nErr){
if(pi->cx == 160 && pi->cy == 120 ){
IDISPLAY_ClearScreen(pMe->a.m_pIDisplay);
IIMAGE_Draw(pMe->pIImage, 8, 42);
IDISPLAY_Update(pMe->a.m_pIDisplay);
if(pMe->pIImage){
IIMAGE_Release(pMe->pIImage);
pMe->pIImage = NULL;
}
if(pMe->pFileMgr){
IFILEMGR_Release(pMe->pFileMgr);
pMe->pFileMgr = NULL;
}
}
}
return TRUE;
}
//MY EVENT HANDLER FOR AVK_SELECT:
case AVK_SELECT :
switch(pMe->key_camera ){
case 1:
nErr = ICAMERA_Stop(pMe->m_pICamera);
if(nErr != SUCCESS){
test_err(pMe,"ICAMERA_Stop failure");
}
break;
case 2:
if(pMe->cam_state == IMAGE_SAVED){
image(pMe);
}
break;
}
break;
I have also tried the following:
1] Tried saving the image as a 640 x 480 image
2] Saved the image as a ".bmp" image in the shared directory and reading the image from shared directory
But got the same error in both the cases. If Anybody has encountered a similar issue please let me know have could this be solved

I want to have direct access from the pixel data.Direct from get frame or p frame.No more steps api functions.direct data acces.
Please !!!!
Regards.
Renato.

I want to have direct access from the pixel data.Direct from get frame or p frame.No more steps api functions.direct data acces.
Please !!!!
Regards.
Renato.