|
6 | 6 | extern "C" { |
7 | 7 | #include "MP4Movies.h" |
8 | 8 | #include "MP4Atoms.h" |
| 9 | + #include "ISOMovies.h" |
9 | 10 | } |
10 | 11 |
|
11 | 12 | #include <filesystem> |
@@ -81,54 +82,67 @@ static MP4Err findIt35MetadataTrack(MP4Movie moov, |
81 | 82 |
|
82 | 83 | LOG_INFO("Found IT35 track with ID {}", trackID); |
83 | 84 |
|
84 | | - // Get T35MetadataSampleEntry to read description and t35_identifier |
85 | | - MP4T35MetadataSampleEntryPtr it35Entry = (MP4T35MetadataSampleEntryPtr)(*sampleEntryH); |
86 | | - |
87 | | - if (it35Entry && it35Entry->t35_identifier && it35Entry->t35_identifier_size > 0) { |
88 | | - // Convert t35_identifier bytes to hex string |
89 | | - std::string hexStr; |
90 | | - hexStr.reserve(it35Entry->t35_identifier_size * 2); |
91 | | - for (u32 i = 0; i < it35Entry->t35_identifier_size; i++) { |
92 | | - char buf[3]; |
93 | | - snprintf(buf, sizeof(buf), "%02X", it35Entry->t35_identifier[i]); |
94 | | - hexStr += buf; |
95 | | - } |
96 | | - |
97 | | - // Build prefix string: "HEX:Description" |
98 | | - std::string filePrefix = hexStr; |
99 | | - if (it35Entry->description && it35Entry->description[0] != '\0') { |
100 | | - filePrefix += ":"; |
101 | | - filePrefix += it35Entry->description; |
102 | | - LOG_DEBUG("Found T35 identifier: {} with description: '{}'", hexStr, it35Entry->description); |
103 | | - } else { |
104 | | - LOG_DEBUG("Found T35 identifier: {} (no description)", hexStr); |
105 | | - } |
106 | | - |
107 | | - // Parse both prefixes to compare hex part only |
108 | | - T35Prefix requestedPrefix(t35PrefixStr); |
109 | | - T35Prefix filePrefixParsed(filePrefix); |
110 | | - |
111 | | - // Verify hex prefix matches (ignore description) |
112 | | - if (requestedPrefix.hex() != filePrefixParsed.hex()) { |
113 | | - LOG_DEBUG("T35 hex '{}' does not match requested hex '{}'", |
114 | | - filePrefixParsed.hex(), requestedPrefix.hex()); |
115 | | - MP4DisposeHandle(sampleEntryH); |
116 | | - continue; // Try next track |
117 | | - } |
118 | | - LOG_DEBUG("T35 hex matches requested hex"); |
119 | | - |
120 | | - // Warn if descriptions differ (informative only) |
121 | | - if (!requestedPrefix.description().empty() && |
122 | | - !filePrefixParsed.description().empty() && |
123 | | - requestedPrefix.description() != filePrefixParsed.description()) { |
124 | | - LOG_WARN("T.35 description mismatch: requested '{}' but file has '{}'", |
125 | | - requestedPrefix.description(), filePrefixParsed.description()); |
126 | | - } |
127 | | - } else { |
| 85 | + // Read t35_identifier and description from the serialized sample entry handle |
| 86 | + u8 *identifier = nullptr; |
| 87 | + u32 identifierSize = 0; |
| 88 | + char *description = nullptr; |
| 89 | + |
| 90 | + MP4Err readErr = ISOGetT35SampleEntryFields(sampleEntryH, &identifier, &identifierSize, |
| 91 | + &description); |
| 92 | + MP4DisposeHandle(sampleEntryH); |
| 93 | + sampleEntryH = nullptr; |
| 94 | + |
| 95 | + if(readErr || identifier == nullptr || identifierSize == 0) |
| 96 | + { |
128 | 97 | LOG_WARN("Could not read t35_identifier from IT35 sample entry"); |
| 98 | + free(identifier); |
| 99 | + free(description); |
| 100 | + continue; |
129 | 101 | } |
130 | 102 |
|
131 | | - MP4DisposeHandle(sampleEntryH); |
| 103 | + // Convert t35_identifier bytes to hex string |
| 104 | + std::string hexStr; |
| 105 | + hexStr.reserve(identifierSize * 2); |
| 106 | + for(u32 j = 0; j < identifierSize; j++) |
| 107 | + { |
| 108 | + char buf[3]; |
| 109 | + snprintf(buf, sizeof(buf), "%02X", identifier[j]); |
| 110 | + hexStr += buf; |
| 111 | + } |
| 112 | + free(identifier); |
| 113 | + |
| 114 | + // Build prefix string: "HEX:Description" |
| 115 | + std::string filePrefix = hexStr; |
| 116 | + if(description && description[0] != '\0') |
| 117 | + { |
| 118 | + filePrefix += ":"; |
| 119 | + filePrefix += description; |
| 120 | + LOG_DEBUG("Found T35 identifier: {} with description: '{}'", hexStr, description); |
| 121 | + } |
| 122 | + else |
| 123 | + { |
| 124 | + LOG_DEBUG("Found T35 identifier: {} (no description)", hexStr); |
| 125 | + } |
| 126 | + free(description); |
| 127 | + |
| 128 | + // Parse both prefixes to compare hex part only |
| 129 | + T35Prefix requestedPrefix(t35PrefixStr); |
| 130 | + T35Prefix filePrefixParsed(filePrefix); |
| 131 | + |
| 132 | + if(requestedPrefix.hex() != filePrefixParsed.hex()) |
| 133 | + { |
| 134 | + LOG_DEBUG("T35 hex '{}' does not match requested hex '{}'", |
| 135 | + filePrefixParsed.hex(), requestedPrefix.hex()); |
| 136 | + continue; |
| 137 | + } |
| 138 | + LOG_DEBUG("T35 hex matches requested hex"); |
| 139 | + |
| 140 | + if(!requestedPrefix.description().empty() && !filePrefixParsed.description().empty() && |
| 141 | + requestedPrefix.description() != filePrefixParsed.description()) |
| 142 | + { |
| 143 | + LOG_WARN("T.35 description mismatch: requested '{}' but file has '{}'", |
| 144 | + requestedPrefix.description(), filePrefixParsed.description()); |
| 145 | + } |
132 | 146 |
|
133 | 147 | // Check for 'rndr' track reference |
134 | 148 | MP4Track videoTrack = nullptr; |
|
0 commit comments