Tuesday, December 21, 2004

NFL.com - New England at Miami Game Recap

NFL.com - New England at Miami Game Recap

Amazing game ... a great football game after a long time. I am done with the first version of my App and treated myself to lying in bed and watching the entire game last night. Have 2 more days to get some shopping done so will get started today.

Sunday, December 12, 2004

Sunday Blues

Was working on creating a applet that allows the user to take pictures and store them in the application folder for sending them to a server at a later time. Everything works well and will post the code in the next few days ... feel tooo lazy to do it right now.

One thing I did notice though. I set the resolution to 640 * 480 for taking images and in defered encode mode i run out of memory very quickly. It works ok for 340 * 240 resolution ( I took 24 consecutive snapshots and then gave up). There must be something that I am doing wrong in my code ... cant put my finger on it. I really shouldnt be getting a ENOMEMORY error in this case. Hopefully tommorrow I will get some time in the evening to play around with the code.

Its been very frustrating the last couple of weeks and regular readers of my blog ( if there are any) might have noticed that I was slacking off on adding new posts. The project I am working on is interesting to say the least and its very challenging. For some reason i keep encountering issues everyday. Havent had a day when I didnt have to research on some topic or the other.

Hopefully, tommorrow will be a very productive day. I have always found that If I reach the office around 8:00 am the day becomes very productive. Will have to beat the cold weather and get up really early tommorrow.

Saturday, December 11, 2004

ICamera Interface - Preview Mode

The preview mode is well documented in the documentation provided along with the QualComm SDK. I prefer using the API documentation provided in the PDF format rather than the compiled help in .chm format. The sample code provided in the .chm file that came with my copy of the SDK(2.1) had some errors in it specially the ICAMERA_GetFrame() function.
To implement it in my applet I just the took the code from the SDK documentation to get started. I added a pointer to the ICamera interface in my Applet structure. I prefer not to have a AEEDeviceInfo structure in my applet so I just include the width and height of the screen in the applet.





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;

To Start the Camera I use a function that will initialize the parameters and start the camera in the preview mode. Most important thing is to initialize a callback and pass the AEECameraNotify structure. Since Camera access is done asynchronously in BREW (very much like other platforms) the callback serves an important role.




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;
}
}

Every display function must have a hide function. To stop the Preview mode all we need to do is call the ICAMERA_Stop() function.





static void cameratest_HideCameraPreview(cameratest * pMe)
{
if(ICAMERA_Stop(pMe->m_pICamera) == SUCCESS)
DBGPRINTF("STOP COMMAND ACCEPTED");
}

The call back function is where the real stuff happens. Once the Camera is ready the OS will call the callback function that we had registered earlier. The AEECameraNotify structure contains a bunch of info about the callback. In the preview mode the first callback will have the status CAM_STATUS_START with nCmd = CAM_CMD_START and nSubCmd = CAM_MODE_PREVIEW. The frames captured from the camera are sent to the callback at regular intervals ( depends on the fps) and you can capture the frame of data using ICAMERA_GetFrame() function. The interface does not display the frames on the screen much like the API in series 60 so you have to display them yourself.




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;
}
}

Off course in the production version of the code you will have to take care of some additional things. The documentation advises to make sure that when the applet receives a EVT_PAUSE event – make sure you shut down the preview mode. Also it would be a wise move to put in some code for the other status codes in the callback like CAM_STATUS_ABORT, CAM_STATUS_DATA_IO_DELAY etc.

ICamera Interface .....

ICamera interface provides access to the camera features of the handset. It is can be used in devices that support BREW version 2.1 and above. There is a catch to it though some devices are version 2.1 and above and have a onboard camera but the ICamera interface is blocked ( mostly due to carrier influence? don?t want to share the picture messaging revenue).

In States we recently have a few devices(Not all of them might be out)
Moto V265(This is the one that I have),LG VX7000,Moto V710 and LG VX8000. These do support the ICamera interface and are available with Verizon wireless? There might be others ..but haven?t had a chance to look at them.


Spent the last couple of days working on it. There are three modes that the ICamera interface can be used in Preview Mode, SnapShot Mode, Movie Mode. Havent tried out the movie mode .. but played around with the Preview mode and the snapshot mode and thanks to the some help by folks at the Qualcomm Brew forums have some code ready.


Namit starts Bloggin ....

Caught up with Namit yesterday and he told me that he too has started bloggin at blogger. I have included a link to his Blog in the side panel.

This is nice ... I wonder how many of my old school buddies are on the blogosphere ...

Friday, December 10, 2004

Blogs gettin famous ...


My Blog is famous Posted by Hello

This is a interesting page ... You can enter any text in the query string and it will be displayed in the banner these guys are carrying. Neat idea ... Make sure you enter the text in the variable 'teksti' ( I guess its russian )

Saturday, December 04, 2004

Hulchul - My take on the movie

Saw the movie Hulchul on Friday night. Its been a long time since I saw a hindi movie. I think my last one was "Masti". Bottom line - I liked but its not the kinda movie I would like to see again specially not in Regal cinemas on route 1 :-).

The story line is nothing new and follows the same old pattern. Two families that are sworn enemies of each other. Like QSQT the enemity stems from a love affair that went bad and resulted in blood being spilt. The movie revolves around Akshaye khanna and Kareena kapoor who fall in love despite the opposition of their families.

I went to see the movie with a couple of old friends and I had got decent reviews of the movie. In the beginning I was really cursing the people who told me the movie was good. It started out with the same old melodrama. Arshad Waarsi and Paresh Rawal added the much needed spark to the movie.

The first half of the movie was kinda boring though it did have some funny stuff in it. I specially liked the dialogs in the movie. I wish I had a pen and paper so that I could have written them out. :-). The second half of the movie was a different story all together.






All in all the best part of the movie was the wedding scene in the end and the acting of Arshad Waarsi and Paresh Rawal. Though the others also acted their parts out pretty well.



The part that I did not cherish about my movie experience last night was that there was no interval. I can never watch a hindi movie at a strech ...3 hours ... in that cramped seat.