OlivierGrenoble / mp4v2

Automatically exported from code.google.com/p/mp4v2
Other
0 stars 0 forks source link

Assign reverse DNS with tags API #116

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
It looks like if I'm using the (newer?) tags API, then I'm not able to set 
reverse DNS atoms.  If I use the older API, then I can.  This leaves me in a 
situation where I open the file with the tags and do all my stuff, then close 
the file, then re-open in the old API to set the reverse DNS tags....that means 
writing the file twice.  Not a good thing on a 2 gig HD movie.

Am I missing something simple?  Specifically I want to write 
com.apple.iTunes;iTunEXTC and comp.apple.iTunes.iTunMOV tags.

Original issue reported on code.google.com by Scott.Gr...@gmail.com on 19 Aug 2011 at 9:40

GoogleCodeExporter commented 8 years ago
What's the old code you use to write reverse DNS atoms?  (if you could 
copy/paste here, I might be able to figure it out)

Original comment by kid...@gmail.com on 23 Aug 2011 at 4:34

GoogleCodeExporter commented 8 years ago
        file = MP4Modify([self.pathname UTF8String], 0);

        @try {
            if (self.selectedRating) {
                MP4ItmfItem *item = MP4ItmfItemAlloc("----", 1);
                item->mean = strdup("com.apple.iTunes");
                item->name = strdup("iTunEXTC");

                // If it's already there, remove it
                MP4ItmfRemoveItem(file, item);

                MP4ItmfData * data = &item->dataList.elements[0];
                data->typeCode = MP4_ITMF_BT_UTF8;
                data->valueSize = (uint32_t) [self.selectedRating length];
                data->value = (uint8_t *) malloc(data->valueSize);
                memcpy(data->value, [self.selectedRating UTF8String], data->valueSize);

                MP4ItmfAddItem(file, item);
                MP4ItmfItemFree(item);
            }

            if ([dict count] > 0) {
                NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]];
                [dict writeToFile:path atomically:YES];
                NSString *xml = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL];
                [[NSFileManager defaultManager] removeItemAtPath:path error:NULL];

                MP4ItmfItem *item = MP4ItmfItemAlloc("----", 1);
                item->mean = strdup("com.apple.iTunes");
                item->name = strdup("iTunMOVI");

                // If it's already there, remove it
                MP4ItmfRemoveItem(file, item);

                MP4ItmfData * data = &item->dataList.elements[0];
                data->typeCode = MP4_ITMF_BT_UTF8;
                data->valueSize = (uint32_t) [xml length];
                data->value = (uint8_t *) malloc(data->valueSize);
                memcpy(data->value, [xml UTF8String], data->valueSize);

                MP4ItmfAddItem(file, item);
                MP4ItmfItemFree(item);
            }

        } @finally {
            MP4Close(file, 0);
        }

Original comment by Scott.Gr...@gmail.com on 23 Aug 2011 at 5:30

GoogleCodeExporter commented 8 years ago
That isn't the old api, it's just a lower level api.

Original comment by damiog on 27 Aug 2011 at 6:21

GoogleCodeExporter commented 8 years ago
Right, but it's different, which means I have to be sure I've saved and closed 
the file with the 'higher' level api, and then do this, and then make sure this 
one is saved and closed if I'm going to do anything else with the higher level 
one.  

If you'll pull this functionality into the higher level, then I don't run the 
risk of corrupting my file by forgetting to save/close something.

Original comment by Scott.Gr...@gmail.com on 27 Aug 2011 at 8:28

GoogleCodeExporter commented 8 years ago
No you don't need to close the file and reopen it. Just make sure to use first 
one and then the other.

Original comment by damiog on 28 Aug 2011 at 8:30

GoogleCodeExporter commented 8 years ago
The 'make sure' part is the problem.  If tags are getting set in different 
places, I don't really *know* that I'm just doing one type at a time.  If the 
higher level API provided a method for this, then we wouldn't have to worry 
about it.

Original comment by Scott.Gr...@gmail.com on 29 Aug 2011 at 7:38