reading file header into a descriptor

Login to reply to this topic.
Fri, 2005-08-05 04:33
Joined: 2005-02-16
Forum posts: 70
Hi,
I am trying to read the header of a AMR (6 bytes total) or WAV (2 or 4 bytes at a time) file into a descriptor, but I can't seem to get it working. I have tried usinh a HBufC, but this only works (sort of) with the WAV file.

Basically I need to extract the information contained in the file header, 2, 4 or 6 bytes at a time.

Does anyone know how I could do this?

Thanks,
Miranda

Fri, 2005-08-05 04:45
Joined: 2003-04-01
Forum posts: 142
Re: reading file header into a descriptor
you could just use TBuf8<6> as a buffer and use RFile to read the bytes into it. Which approach are you currently using, and what is the excat problem you are facing with it ?

yucca
Fri, 2005-08-05 04:57
Joined: 2005-02-16
Forum posts: 70
Re: reading file header into a descriptor
thanks for the response yucca!

I have tried a number of different ways but they mainly look something liek this:
Code:
_LIT(KAMR, "#!AMR\n");

RFileReadStream fRead;

TInt err = fRead.Open(aFs, KFileName, EFileRead);
if(err == KErrNone) {
RDebug::Print(_L("!!! file open successful!"));
}

CleanupClosePushL(fRead);

HBufC* header = HBufC::NewL(fRead, 6);

if(header->Compare(KAMR) == 0) {
RDebug::Print(_L("AMR header"));
} else {
RDebug::Print(_L("not AMR header"));
}

I think the problem with this is the max length (6) in the NewL...

How would I do it using TBuf8<6>?

Thanks again,
Miranda
Fri, 2005-08-05 06:36
Joined: 2005-02-16
Forum posts: 70
Re: reading file header into a descriptor
Ok, I've got it working with a .wav file like this:
Code:
_LIT8(KRIFF, "RIFF");

TBuf8<4> header;
fRead.ReadL(header);

if(header.Compare(KRIFF) == 0) {
RDebug::Print(_L("RIFF header"));
} else {
RDebug::Print(_L("not RIFF header"));
}

and for an AMR file like this:
Code:
_LIT8(KAMR, "#!AMR\n");

TBuf8<6> header;
fRead.ReadL(header);

if(header.Compare(KAMR) == 0) {
RDebug::Print(_L("AMR header"));
} else {
RDebug::Print(_L("not AMR header"));
}

Thanks for your help!
  • Login to reply to this topic.