More cosmetics changes.

This commit is contained in:
Damiano Galassi committed 2014-03-27 10:47:47 +01:00
1 parent ba273bc261
commit d1fbdb19d5
1 file changed
+16 -15
+16 -15
View File
@@ -315,6 +315,10 @@
return self; return self;
} }
/**
* Converts the AVAsset metadata to the MP42File format
*/
- (void)convertMetadata { - (void)convertMetadata {
NSArray *items = nil; NSArray *items = nil;
NSDictionary *commonItemsDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Name", AVMetadataCommonKeyTitle, NSDictionary *commonItemsDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Name", AVMetadataCommonKeyTitle,
@@ -544,9 +548,12 @@
} }
- (NSSize)sizeForTrack:(MP42Track *)track { - (NSSize)sizeForTrack:(MP42Track *)track {
if ([track isKindOfClass:[MP42VideoTrack class]]) {
MP42VideoTrack *currentTrack = (MP42VideoTrack *)track; MP42VideoTrack *currentTrack = (MP42VideoTrack *)track;
return NSMakeSize(currentTrack.width, currentTrack.height);
return NSMakeSize([currentTrack width], [currentTrack height]); } else {
return NSMakeSize(0, 0);
}
} }
- (NSData *)magicCookieForTrack:(MP42Track *)track { - (NSData *)magicCookieForTrack:(MP42Track *)track {
@@ -676,9 +683,8 @@
time.value -= helper->edits[helper->editsCount].start.value; time.value -= helper->edits[helper->editsCount].start.value;
helper->edits[helper->editsCount].duration = time; helper->edits[helper->editsCount].duration = time;
if (type) { if (type)
helper->edits[helper->editsCount].start.value = -1; helper->edits[helper->editsCount].start.value = -1;
}
helper->editsCount++; helper->editsCount++;
helper->editOpen = NO; helper->editOpen = NO;
@@ -702,7 +708,8 @@
success = (assetReader != nil); success = (assetReader != nil);
if (success) { if (success) {
for (MP42Track *track in _inputTracks) { for (MP42Track *track in _inputTracks) {
AVAssetReaderOutput *assetReaderOutput = [AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:[_localAsset trackWithTrackID:track.sourceId] outputSettings:nil]; AVAssetReaderOutput *assetReaderOutput = [AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:[_localAsset trackWithTrackID:track.sourceId]
outputSettings:nil];
if (![assetReader canAddOutput: assetReaderOutput]) if (![assetReader canAddOutput: assetReaderOutput])
NSLog(@"Unable to add the output to assetReader!"); NSLog(@"Unable to add the output to assetReader!");
@@ -843,9 +850,6 @@
CMBlockBufferRef buffer = CMSampleBufferGetDataBuffer(sampleBuffer); CMBlockBufferRef buffer = CMSampleBufferGetDataBuffer(sampleBuffer);
size_t bufferSize = CMBlockBufferGetDataLength(buffer); size_t bufferSize = CMBlockBufferGetDataLength(buffer);
#ifdef SB_AVF_DEBUG
#endif
// Check if we have to trim the start or end of a sample // Check if we have to trim the start or end of a sample
// If so it means we need to start/end an edit // If so it means we need to start/end an edit
CFTypeRef trimStart = CMGetAttachment(sampleBuffer, kCMSampleBufferAttachmentKey_TrimDurationAtStart, kCMAttachmentMode_ShouldNotPropagate); CFTypeRef trimStart = CMGetAttachment(sampleBuffer, kCMSampleBufferAttachmentKey_TrimDurationAtStart, kCMAttachmentMode_ShouldNotPropagate);
@@ -987,10 +991,10 @@
MP4Duration trackDuration = 0; MP4Duration trackDuration = 0;
MP42Track *inputTrack = [self inputTrackWithTrackID:track.sourceId]; MP42Track *inputTrack = [self inputTrackWithTrackID:track.sourceId];
AVFDemuxHelper *demuxHelper = inputTrack.muxer_helper->demuxer_context; AVFDemuxHelper *helper = inputTrack.muxer_helper->demuxer_context;
for (int i = 0; i < demuxHelper->editsCount; i++) { for (int i = 0; i < helper->editsCount; i++) {
CMTimeRange timeRange = demuxHelper->edits[i]; CMTimeRange timeRange = helper->edits[i];
CMTime duration = CMTimeConvertScale(timeRange.duration, timescale, kCMTimeRoundingMethod_Default); CMTime duration = CMTimeConvertScale(timeRange.duration, timescale, kCMTimeRoundingMethod_Default);
trackDuration += duration.value; trackDuration += duration.value;
@@ -998,15 +1002,12 @@
MP4AddTrackEdit(fileHandle, track.Id, MP4_INVALID_EDIT_ID, timeRange.start.value, MP4AddTrackEdit(fileHandle, track.Id, MP4_INVALID_EDIT_ID, timeRange.start.value,
duration.value, 0); duration.value, 0);
#ifdef SB_AVF_DEBUG
NSLog(@"Edit start: %lld, duration: %lld", timeRange.start.value, duration.value);
#endif
} }
if (trackDuration) if (trackDuration)
MP4SetTrackIntegerProperty(fileHandle, track.Id, "tkhd.duration", trackDuration); MP4SetTrackIntegerProperty(fileHandle, track.Id, "tkhd.duration", trackDuration);
free(demuxHelper->edits); free(helper->edits);
} }
return YES; return YES;