Thanks Chetan I was wondering how to get the panic code.
Hey didster,
aStatus is of TRequeStatus * type.
Didster , can you show me any sample working code for bitmap to desc encoding using CimageEncoder or any links to documents or tutorials using CImageEncoder class.
But still there are some problems. The application is running , its encodeing, decoding & displaying the viewfinder also but a "stop" error keeps coming in between. It says: "Requsted object is used by another application -14".
And when I exit the application I get an "Alloc" Panic which as the documentation says is due to memory leak, but I can't figure out where memory is leaking.
I think the memory leak is bcoz the imageTypeArray is not deallocated properly. This is how I found them doing it in an "ImageConverter" application I got from forum.nokia.com
Forum posts: 187
than try to run ur app on emulator, it will give the panic number.
remember ErrRd file have no extention and no contents(means empty file).
Than try to find out the detail of that panic code in SDK Help.
----
Chetan Kulshrestha
Forum posts: 1379
didster
Forum posts: 27
Hey didster,
aStatus is of TRequeStatus * type.
Didster , can you show me any sample working code for bitmap to desc encoding using CimageEncoder or any links to documents or tutorials using CImageEncoder class.
If u have any working code with you plz send it to this address ihjazmohamed@hotmail.com.
Thanks in advance.
Forum posts: 1379
On completion contains KErrNone if the bitmap was encoded successfully, otherwise one of the other system-wide error codes.
"On Completion" - it doesn't complete immediatly!! i.e. Convert is a asynchronous function which needs to be wrapped up in an active object.
You're not waiting for it to complete.
didster
Forum posts: 27
Thanks for replying.
Can you tell me how am supposed to code to wait for the completion of encoding.
Thanks.
Forum posts: 1379
Note, if you class does derive from another C class, then it's sligtly different (you need to split the two classes up basically)
{
public:
CVideoRecorder(CMyAppView* aAppView);
~CVideoRecorder();
void ViewFinderFrameReadyL(const CFbsBitmap& aFrame);
protected:
void RunL();
void DoCancel();
private:
CMyAppView* iAppView;
enum TState
{
EUnknown,
EEncoding
EDecoding
};
TState iState;
.
.
.
};
CVideoRecorder::CVideoRecorder(CMyAppView* aAppView) :
iAppView(aAppView),
CActive(EPriorityNormal)
{
CActiveScheduler::Add(this);
}
CVideoRecorder::~CVideoRecorder()
{
Cancel();
}
void CVideoRecorder::ViewFinderFrameReadyL(const CFbsBitmap& aFrame)
{
if(IsActive())
{
User::Leave(KErrInUse);
}
delete iBuffer;
iBuffer=NULL;
delete iEncoder;
iEncoder=NULL;
delete iDecoder;
iDecoder=NULL;
iBuffer=HBufC8::NewL(500);
iEncoder=CImageEncoder::DataNewL(iBuffer,CImageEncoder::EOptionNone,imageType,imageSubType);
iState = EEncoding;
iEncoder->Convert(iStatus, aFrame);
SetActive();
}
void CVideoRecorder::RunL()
{
if(iStatus.Int() == KErrNone)
{
switch(iState)
{
case EEncoding:
{
delete iBitmap;
iBitmap=NULL;
iBitmap=new(ELeave)CFbsBitmap();
iDecoder=CImageDecoder::DataNewL(iFs,*iBuffer,CImageDecoder::EOptionNone,imageType,imageSubType,aDecoderUid);
iState = EDecoding;
iDecoder->Convert(iStatus,*iBitmap);
SetActive();
break;
}
case EDecoding:
{
iAppView->DrawImage(iBitmap);
break;
}
}
}
else
{
// error!
}
}
void CVideoRecorder::DoCancel()
{
switch(iState)
{
case EEncoding:
{
iEncoder->Cancel();
break;
}
case EDecoding:
{
iDecoder->Cancel();
break;
}
}
}
NOTE: the CFbsBitmap passed to ViewFinderFrameReadyL MUST remain in scope right up until the iAppView->DrawImage callback is made!!!
didster
Forum posts: 27
Thanks a lot for the code you have shown.
But am still having problems. This is my code right now:
void CVideoRecorder::ViewFinderFrameReady(CFbsBitmap& aFrame)
{
if(IsActive())
{
User::Leave(KErrInUse);
}
delete iBuffer;
iBuffer=NULL;
delete iEncoder;
iEncoder=NULL;
CFbsBitmap *iBitmap=&aFrame;
TSize iSize=iBitmap->SizeInPixels();
TInt intSize=((iSize.iHeight * iSize.iWidth)*3)+1024;
iBuffer=HBufC8::NewMaxL(intSize);
iEncoder=CImageEncoder::DataNewL(iBuffer,CImageEncoder::EOptionNone,imageType,imageSubType);
iState=EEncoding;
iEncoder->Convert(iStatus,aFrame);
SetActive();
}
void CVideoRecorder::RunL()
{
if(iStatus == KErrNone)
{
switch(iState)
{
case EEncoding:
{
delete iBitmap;
iBitmap=NULL;
iBitmap=new(ELeave)CFbsBitmap();
delete iDecoder;
iDecoder=NULL;
iDecoder=CImageDecoder::DataNewL(iFs,*iBuffer,CImageDecoder::EOptionNone,imageType,imageSubType,aDecoderUid);
iState = EDecoding;
iDecoder->Convert(iStatus,*iBitmap);
SetActive();
break;
}
case EDecoding:
{
iAppView->DrawImage(iBitmap);
break;
}
}
}
else
{
InfoNotifyL(_L("Encode error: "));
}
}
When I run this code I get Panic 17 i.e "The descriptor that is passed is not NULL".
When I comment this part and run leaving the ibuffer Null
/* CFbsBitmap *iBitmap=&aFrame;
TSize iSize=iBitmap->SizeInPixels();
TInt intSize=((iSize.iHeight * iSize.iWidth)*3)+1024;
iBuffer=HBufC8::NewMaxL(intSize);
*/
Then I get Panic 20 i.e "Illegal image type".
How do I solve this problem.
Plz help me.
Forum posts: 12
and then you can go ahead your program
good luck!
Forum posts: 1379
didster
Forum posts: 27
I have declared the imageType and imageSubType as follows:
TUid imageType;
TUid imageSubType;
I haven't set any value or initialised it.
Thanks
Forum posts: 1379
The image encoder is a generic system for encoding images to any number of supported formats.
If you don't tell the encoder what you want it to encode to, how the hell is it suppose to encode it
You can get a list of supported encoder plugins (and their UIDs) by calling GetImageTypesL.
Once you have done that, go through the list and select which one you want to use, and pass that to DataNewL
didster
Forum posts: 27
Its working now. Thanks a lot of your help.
But still there are some problems. The application is running , its encodeing, decoding & displaying the viewfinder also but a "stop" error keeps coming in between. It says: "Requsted object is used by another application -14".
And when I exit the application I get an "Alloc" Panic which as the documentation says is due to memory leak, but I can't figure out where memory is leaking.
This is the new working code:
void CleanupRArray( TAny* object )
{
((RImageTypeDescriptionArray*)object)->ResetAndDestroy();
}
void CVideoRecorder::ViewFinderFrameReady(CFbsBitmap& aFrame)
{
aBitmap=&aFrame;
StartEncodeL();
}
void CVideoRecorder::StartEncodeL()
{
if(IsActive())
{
User::Leave(KErrInUse);
}
CImageEncoder::GetImageTypesL(aImageTypeArray);
CleanupStack::PushL( TCleanupItem(CleanupRArray, &aImageTypeArray) );
delete iBuffer;
iBuffer=NULL;
delete iEncoder;
iEncoder=NULL;
iEncoder=CImageEncoder::DataNewL(iBuffer,CImageEncoder::EOptionNone,aImageTypeArray[imageId]->ImageType(),aImageTypeArray[imageId]->SubType());
iState=EEncoding;
iEncoder->Convert(&iStatus,*aBitmap);
SetActive();
CleanupStack::PopAndDestroy();
}
void CVideoRecorder::RunL()
{
if(iStatus == KErrNone)
{
switch(iState)
{
case EEncoding:
{
delete iBitmap;
iBitmap=NULL;
delete iDecoder;
iDecoder=NULL;
iBitmap=new(ELeave)CFbsBitmap();
iBitmap->Create( aBitmap->SizeInPixels(),
aBitmap->DisplayMode());
iDecoder=CImageDecoder::DataNewL(iFs,*iBuffer,CImageDecoder::EOptionNone);
iState = EDecoding;
iDecoder->Convert(&iStatus,*iBitmap);
SetActive();
break;
}
case EDecoding:
{
iAppView->DrawImage(aBitmap);
break;
}
}
}
else
{
InfoNotifyL(_L("Encode error: "));
}
}
I think the memory leak is bcoz the imageTypeArray is not deallocated properly. This is how I found them doing it in an "ImageConverter" application I got from forum.nokia.com
void CleanupRArray( TAny* object )
{
((RImageTypeDescriptionArray*)object)->ResetAndDestroy();
}
The above is a non-member funtion.
CImageEncoder::GetImageTypesL(aImageTypeArray);
CleanupStack::PushL( TCleanupItem(CleanupRArray, &aImageTypeArray) );
Using TCleanupItem() imageTypeArray is added to the CleanupStack.
It is popped at the end of the StartEncode() after calling setActive().
CleanUpStack::PopAndDestroy();
I feel there is something wrong in this.
Plz help me out with this didster.
Thanks
Forum posts: 1379
Change it to:
void CleanupRArray( TAny* object )
{
((RImageTypeDescriptionArray*)object)->ResetAndDestroy();
((RImageTypeDescriptionArray*)object)->Close();
}
And the leak should go away.
didster
Forum posts: 27
Thanks a lot for that.
Actually am trying stream the viewfinder via bluetooth.
In my appUi am creating
iClient=CmessageClient::NewL(*iAppView);
iServer=CmessageServer::NewL(*iAppView);
then in the HandleCommandL()
case Startstreaming: iVideoRecorder=new(ELeave)CVideoRecorder(iClient);
break;
In the CVideoRecorder after encoding in the RunL() am calling
iClient->SendMessageL(iBitmap);
But here I get an error:"Illegal use of incomplete struct/union/Class".
Thanks
Forum posts: 27
Thanks a lot for that.
Actually am trying stream the viewfinder via bluetooth.
In my appUi am creating
iClient=CmessageClient::NewL(*iAppView);
iServer=CmessageServer::NewL(*iAppView);
then in the HandleCommandL()
case Startstreaming: iVideoRecorder=new(ELeave)CVideoRecorder(iClient);
break;
In the CVideoRecorder after encoding in the RunL() am calling
iClient->SendMessageL(iBitmap);
But here I get an error:"Illegal use of incomplete struct/union/Class".
Thanks