From 45552f45c0bca08c01ca4345219520d819093a68 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Thu, 9 Dec 2021 12:03:28 +0100 Subject: [PATCH] Make MP4GetTrackMediaDataName aware of multiple sample descriptions. Only the first one is ready at the moment. --- MP42/MP42AudioTrack.m | 2 +- MP42/MP42Mp4Importer.m | 2 +- MP42/MP42PrivateUtilities.h | 2 +- MP42/MP42PrivateUtilities.m | 4 ++-- MP42/MP42Track.m | 2 +- MP42/MP42VideoTrack.m | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MP42/MP42AudioTrack.m b/MP42/MP42AudioTrack.m index 8bd67a6..ce2419d 100644 --- a/MP42/MP42AudioTrack.m +++ b/MP42/MP42AudioTrack.m @@ -24,7 +24,7 @@ MP42_OBJC_DIRECT_MEMBERS if (self) { MP4GetTrackFloatProperty(fileHandle, self.trackId, "tkhd.volume", &_volume); - const char *dataName = MP4GetTrackMediaDataName(fileHandle, self.trackId); + const char *dataName = MP4GetTrackMediaDataName(fileHandle, self.trackId, 0); _extensionType = kMP42AudioEmbeddedExtension_None; if (dataName && !strcmp(dataName, "mp4a")) { diff --git a/MP42/MP42Mp4Importer.m b/MP42/MP42Mp4Importer.m index 9fceab1..e806122 100644 --- a/MP42/MP42Mp4Importer.m +++ b/MP42/MP42Mp4Importer.m @@ -62,7 +62,7 @@ typedef struct MP4DemuxHelper { MP4TrackId srcTrackId = track.sourceId; const char *trackType = MP4GetTrackType(_fileHandle, srcTrackId); - const char *media_data_name = MP4GetTrackMediaDataName(_fileHandle, srcTrackId); + const char *media_data_name = MP4GetTrackMediaDataName(_fileHandle, srcTrackId, 0); if (!trackType) { return nil; diff --git a/MP42/MP42PrivateUtilities.h b/MP42/MP42PrivateUtilities.h index 77060c5..88ea377 100644 --- a/MP42/MP42PrivateUtilities.h +++ b/MP42/MP42PrivateUtilities.h @@ -47,7 +47,7 @@ uint16_t getFixedVideoWidth(MP4FileHandle fileHandle, MP4TrackId videoTrack); NSString * getTrackName(MP4FileHandle fileHandle, MP4TrackId videoTrack); FourCharCode getTrackMediaType(MP4FileHandle fileHandle, MP4TrackId Id); -FourCharCode getTrackMediaSubType(MP4FileHandle fileHandle, MP4TrackId Id); +FourCharCode getTrackMediaSubType(MP4FileHandle fileHandle, MP4TrackId Id, uint32_t index); NSString * getTrackLanguage(MP4FileHandle fileHandle, MP4TrackId Id); NSString * getFilenameLanguage(CFStringRef filename); diff --git a/MP42/MP42PrivateUtilities.m b/MP42/MP42PrivateUtilities.m index 3a868cb..61a80dc 100644 --- a/MP42/MP42PrivateUtilities.m +++ b/MP42/MP42PrivateUtilities.m @@ -214,10 +214,10 @@ FourCharCode getTrackMediaType(MP4FileHandle fileHandle, MP4TrackId Id) return kMP42MediaType_Unknown; } -FourCharCode getTrackMediaSubType(MP4FileHandle fileHandle, MP4TrackId Id) +FourCharCode getTrackMediaSubType(MP4FileHandle fileHandle, MP4TrackId Id, uint32_t index) { const char *type = MP4GetTrackType(fileHandle, Id); - const char *dataName = MP4GetTrackMediaDataName(fileHandle, Id); + const char *dataName = MP4GetTrackMediaDataName(fileHandle, Id, index); if (dataName && strlen(dataName) == 4) { if (!strcmp(dataName, "avc1")) { return kMP42VideoCodecType_H264; diff --git a/MP42/MP42Track.m b/MP42/MP42Track.m index b4b5055..c9a5920 100644 --- a/MP42/MP42Track.m +++ b/MP42/MP42Track.m @@ -74,7 +74,7 @@ typedef struct muxer_helper { _updatedProperty = [[NSMutableDictionary alloc] init]; if (fileHandle) { - _format = getTrackMediaSubType(fileHandle, _trackId); + _format = getTrackMediaSubType(fileHandle, _trackId, 0); _mediaType = getTrackMediaType(fileHandle, _trackId); NSString *trackName = getTrackName(fileHandle, _trackId); diff --git a/MP42/MP42VideoTrack.m b/MP42/MP42VideoTrack.m index 8700d0a..4ce5838 100644 --- a/MP42/MP42VideoTrack.m +++ b/MP42/MP42VideoTrack.m @@ -30,7 +30,7 @@ MP42_OBJC_DIRECT_MEMBERS MP4GetTrackFloatProperty(fileHandle, self.trackId, "tkhd.height", &_trackHeight); _transform = CGAffineTransformIdentity; - + uint8_t *val; uint8_t nval[36]; uint32_t *ptr32 = (uint32_t*) nval;