- MP42Ebml: EBML vint/ID primitives, flat Segment scanner, block track number decoding, and element builders shared by all Matroska writers. - MP42MkvImporter / MP42FileImporter: tagsOnly mode that mirrors the file's own track flags instead of the MP4 conversion heuristics. - MP42MatroskaTagMapping: read/write SimpleTag maps shared by importer and writer, including community names for MP4-only movie fields. - MP42MkvTagWriter: mkvpropedit-style in-place rewrite of Tags, cover art, and per-track name/language/enabled/forced fields with a size+mtime staleness guard; an untouched save is a byte-for-byte no-op. - MP42MkvRemuxer: stream-copy rebuild that drops the blocks of removed tracks (TrackNumbers keep their gaps; block bytes are never rewritten), regenerates SeekHead and Cues, carries metadata edits in the same pass, and writes via temp file + atomic rename. - MP42MkvTagWriter+Internal.h exposes the tag writer's scanning and payload builders so the remuxer reuses them unchanged. Verified with the external matrix harness: 241 assertions green across layout fixtures (ffmpeg/mkvmerge/streamed), removal scenarios, cue parity, and idempotency. Co-Authored-By: Claude Code <noreply@anthropic.com>
70 lines
2.3 KiB
Objective-C
70 lines
2.3 KiB
Objective-C
//
|
|
// MP42FileImporter.h
|
|
// Subler
|
|
//
|
|
// Created by Damiano Galassi on 31/01/10.
|
|
// Copyright 2022 Damiano Galassi All rights reserved.
|
|
//
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import <AudioToolbox/AudioToolbox.h>
|
|
#import <MP42Foundation/MP42Utilities.h>
|
|
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
|
|
|
|
@class MP42SampleBuffer;
|
|
@class MP42AudioTrack;
|
|
@class MP42VideoTrack;
|
|
@class MP42Metadata;
|
|
@class MP42Track;
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
@interface MP42FileImporter : NSObject
|
|
|
|
+ (NSArray<NSString *> *)supportedFileFormats;
|
|
+ (BOOL)canInitWithFileType:(NSString *)fileType;
|
|
|
|
// YES for the extensions handled by the Matroska importer (mkv, mka, mks);
|
|
// used by callers that want to open such files in tags-only mode instead of
|
|
// converting them.
|
|
+ (BOOL)isMatroskaFileType:(NSString *)fileType;
|
|
|
|
+ (NSArray<UTType *> *)supportedContentTypes API_AVAILABLE(macos(11.0));
|
|
+ (BOOL)canInitWithContentType:(UTType *)contentType API_AVAILABLE(macos(11.0));
|
|
|
|
- (nullable instancetype)initWithURL:(NSURL *)fileURL error:(NSError * __autoreleasing *)error;
|
|
|
|
// tagsOnly is YES when the caller opens a Matroska file to edit it in place
|
|
// (tags-only mode): the importer then mirrors the file's own track flags
|
|
// (TrackFlagEnabled) instead of Subler's MP4-oriented "first track of each
|
|
// type enabled" conversion heuristic. Non-Matroska importers ignore it.
|
|
- (nullable instancetype)initWithURL:(NSURL *)fileURL tagsOnly:(BOOL)tagsOnly error:(NSError * __autoreleasing *)error;
|
|
|
|
@property (nonatomic, readonly) NSURL *fileURL;
|
|
@property (nonatomic, readonly) MP42Metadata *metadata;
|
|
@property (nonatomic, readonly) NSArray<MP42Track *> *tracks;
|
|
|
|
#pragma mark - Override
|
|
|
|
- (nullable NSData *)magicCookieForTrack:(MP42Track *)track;
|
|
- (AudioStreamBasicDescription)audioDescriptionForTrack:(MP42AudioTrack *)track;
|
|
|
|
- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track;
|
|
- (BOOL)supportsPreciseTimestamps;
|
|
|
|
- (void)setup;
|
|
- (void)demux;
|
|
- (void)cleanUp:(MP42Track *)track fileHandle:(MP42FileHandle)fileHandle;
|
|
|
|
#pragma mark - Private
|
|
|
|
- (void)enqueue:(MP42SampleBuffer * NS_RELEASES_ARGUMENT)sample MP42_OBJC_DIRECT;
|
|
|
|
@property (nonatomic, readwrite MP42_DIRECT) double progress;
|
|
@property (nonatomic, readonly, getter=isCancelled MP42_DIRECT) BOOL cancelled;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|