Sunday, August 21, 2005

You are currently browsing the daily archive for Sunday, August 21, 2005.

On Report-an-Apple-Bug Fridays

Brent Simmons writes on inessential about Report-an-Apple-Bug Friday:

If you reported a bug to Apple today—it being Report-an-Apple-Bug Friday—please leave a comment and say what your bug id is. (Oh, and why not say what the bug is too. But we gotta have an id—a bug id is a badge of honor.)

I think weekly bug reports are a pretty good idea and so I will try to follow this new tradition among Mac developers as dutifully as I can. My first one will probably be about either a limitation or a bug in QTKit related to movie creation.

The problem has to do with opening embedded QuickTime movies – that is, opening movies that are somewhere inside another file. This is supported by QuickTime through various means:

  • You can either open the movie using an existing fork, or
  • you can open the movie using a file reference of some sort

In both cases, you specify the offset of the QuickTime movie when the movie is created, which in our case we assume is a known correct value. The best way to open a movie in such a way with QuickTime 7 is by using the new NewMovieFromProperties function. The following code demonstrate how this can be done. It’s an excerpt from MHKKit, a framework project I will soon introduce in more details.

// setup the movie properties
Boolean active = TRUE;
QTVisualContextRef visualContext = NULL;
QTNewMoviePropertyElement newMovieProperties[] = {
{kQTPropertyClass_DataLocation, kQTDataLocationPropertyID_DataFork, sizeof(forkRef), &forkRef, 0},
{kQTPropertyClass_MovieResourceLocator, kQTMovieResourceLocatorPropertyID_FileOffset, sizeof(qt_offset), &qt_offset, 0},
{kQTPropertyClass_Context, kQTContextPropertyID_VisualContext, sizeof(visualContext), &visualContext, 0},
{kQTPropertyClass_NewMovieProperty, kQTNewMoviePropertyID_Active, sizeof(active), &active, 0}
};

// make the movie
Movie aMovie = NULL;
err = NewMovieFromProperties(sizeof(newMovieProperties) / sizeof(newMovieProperties[0]), newMovieProperties, 0, NULL, &aMovie);

In this particular case, I use an existing fork to open the movie, but using a URL or FSRef to the file from which that fork was opened shouldn’t make any difference in theory. That is unfortunately where QTMovie seems to be broken. Attempting to create an instance of that class with - initWithAttributes:error: and the QTMovieFileOffsetAttribute attribute fails, even if the specified file and offset are the same.

I haven’t done any digging in order to figure out exactly what is broken, but I intent to before posting my bug report. Remember kids: detailed bug reports make QA people happy and bug squishing a joy.