Detecting protected AAC files in QuickTime

Posted by Dave on April 10th, 2006

Recently, I needed to be able to check if AAC files passed to my application were Protected AACs from the iTunes Music Store or not.

Here’s the C code I used to do this:


extern Boolean FirstSoundTrackIsAProtectedAAC (Movie theMovie)
{

OSStatus osErr;
Track theTrack;
Media theMedia;
Boolean isProtected = false;

// get the first enabled sound track
theTrack = GetMovieIndTrackType(theMovie, 1, AudioMediaCharacteristic, movieTrackCharacteristic | movieTrackEnabledOnly);
if (theTrack != NULL) {

// get the sound track media
theMedia = GetTrackMedia(theTrack);
if (theMedia != NULL) {

SampleDescriptionHandle sourceSoundDescription;

sourceSoundDescription = (SampleDescriptionHandle)NewHandle(0);

// get the description of the sample data
GetMediaSampleDescription(theMedia, 1, sourceSoundDescription);
osErr = GetMoviesError();

// printf("dataFormat is %.4s\n", &(*sourceSoundDescription)->dataFormat);

if ((*sourceSoundDescription)->dataFormat == 'drms') {
isProtected = true;
}

DisposeHandle((Handle)sourceSoundDescription);

}
}

return isProtected;

}

This specifically checks the first soundtrack of a movie. More generally, you might want to check every track for protected content if you are to export any movie given to you.



Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

thank you!

Very helpful indeed. Didn’t need the AAC functionality.
But a working code snippet helps ALLOT!

If the rest of QuickTime would be covered equally well then we might have something. Well, if it would be open source, then that would be great!

Andreas, who is happy that he saved 10 minutes via google and this website and who will look for the paypal button here now …

I’ve just discovered that an alternative approach is described in a technical Q&A document from Apple:

http://developer.apple.com/qa/qa2006/qa1476.html

Hi, I need to do something similar, working with iTunes files on Windows. Any insight to linking the right libraries would be most appreciated.
Thanks