It’s my first day

As previously stated, I’m working with the QuickTime API’s. Well, one thing I want to do is display a QuickTime compression settings dialog and be able to get some information about what the user selected. Today I wanted to get the selected compressions codec in the nice, human readable, string. First stop, the docs. Oh nice, a GetCompressionName function. That has to be what I need. Whip up a quick test, run it. Results? Error, -223. What!? Quick error code lookup says -223 is “siInvalidCompression“. Odd, I passed in a codec I know exists on my machine. I’m even using a constant defined in the QuickTime headers.

Many hours pass. Heads hit keyboards.

I’ve given up. When I get more experience I plan to post this question to the QuickTime API’s mailing list, but for now I’m going to call it a bug and move on. Of course I only gave up after finding an alternative solution:

+ (void) GetCompressionName:(CodecType) type name:(Str31)aName
{
    aName[0] = 0;

CodecNameSpecListPtr    list;
OSErr err = GetCodecNameList(&list, 1); 

if( err != noErr )
{
    NSLog(@"GetCodecNameList err=%d", err);
    return;
}

int i;
for( i = 0; i < list->count; i++ )
{
    if( list->list[i].cType == type )
    {
        memcpy(aName, list->list[i].typeName, list->list[i].typeName[0]+1);
        return;
    }
}

NSLog("No match found");
return;

} Use this like:

Str31 sname;
[YourOBJ GetCompressionName:kDVCPALCodecType name:sname];

Where kDVCPALCodecType is a Codec Identifier. Also of interest is the fact that the h.264 codec is not listed in that document. It’s identifier is ‘avc1′ and it’s enum name is kH264CodecType. Although not documented, it works fine if passed into the above GetCompressionName, spitting out “h.264″.

Disclaimer: It’s my first day. If someone can explain why GetCompressionName(kH264CodecType, name) is failing I’d love to know. I imagine it’s something I’m missing, but just what, I’m not sure. Like I mentioned earlier, I’ll post this to the QuickTime mailing list later, when I feel more educated. No one wants to get flamed on their first day.

Leave a Reply


© 2006 roobasoft, LLC