diff --git a/Headers/Public/Media/VLCMedia.h b/Headers/Public/Media/VLCMedia.h index f59c8c5dd..54f23fcd0 100644 --- a/Headers/Public/Media/VLCMedia.h +++ b/Headers/Public/Media/VLCMedia.h @@ -115,7 +115,8 @@ typedef NS_ENUM(NSInteger, VLCMediaTrackType) { VLCMediaTrackTypeUnknown = -1, VLCMediaTrackTypeAudio = 0, VLCMediaTrackTypeVideo = 1, - VLCMediaTrackTypeText = 2 + VLCMediaTrackTypeText = 2, + VLCMediaTrackTypeData = 3 } NS_SWIFT_NAME(VLCMedia.TrackType); /** @@ -458,6 +459,11 @@ typedef struct VLCMediaStats VLCMediaStats; */ @property(nonatomic, readonly, copy) NSArray *textTracks; +/** + * dataTracks + */ +@property(nonatomic, readonly, copy) NSArray *dataTracks; + @end #pragma mark - VLCMediaTrack diff --git a/Headers/Public/Playback/VLCMediaPlayer.h b/Headers/Public/Playback/VLCMediaPlayer.h index bd50d20e2..5ca1b268e 100644 --- a/Headers/Public/Playback/VLCMediaPlayer.h +++ b/Headers/Public/Playback/VLCMediaPlayer.h @@ -245,6 +245,13 @@ NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state); */ - (void)mediaPlayer:(VLCMediaPlayer *)player didUpdateAribText:(NSString *)text; +/** + * Sent when ARIB BML data is received during playback. + * @param player the player representing the playback + * @param data the raw TS section data + */ +- (void)mediaPlayer:(VLCMediaPlayer *)player didReceiveBMLData:(NSData *)data; + /** * Sent when the frame requested through -gotoNextFrame is about to be displayed. * @param player the player performing the frame step @@ -284,6 +291,12 @@ OBJC_VISIBLE */ @property (nonatomic, copy, nullable) void (^aribTextUpdatedBlock)(NSString *text); +/** + * A block called when ARIB BML data is received during playback. + * The data parameter contains the raw TS section data. + */ +@property (nonatomic, copy, nullable) void (^bmlDataReceivedBlock)(NSData *data); + #if !TARGET_OS_IPHONE /* Initializers */ /** @@ -1040,6 +1053,11 @@ typedef NS_ENUM(unsigned, VLCAudioMixMode) */ @property(nonatomic, readonly, copy) NSArray *textTracks; +/** + * dataTracks + */ +@property(nonatomic, readonly, copy) NSArray *dataTracks; + /** * Select a track of a given type at the given index * \param index position of the track in the list @@ -1068,6 +1086,11 @@ typedef NS_ENUM(unsigned, VLCAudioMixMode) */ - (void)deselectAllTextTracks; +/** + * deselect all data tracks + */ +- (void)deselectAllDataTracks; + @end NS_ASSUME_NONNULL_END diff --git a/Sources/Media/VLCMedia.m b/Sources/Media/VLCMedia.m index 516eec6e7..d3de53643 100644 --- a/Sources/Media/VLCMedia.m +++ b/Sources/Media/VLCMedia.m @@ -470,8 +470,8 @@ - (VLCMediaStats)statistics { NSMutableArray *array = @[].mutableCopy; - // 3 = (libvlc_track_audio = 0 | libvlc_track_video = 1 | libvlc_track_text = 2) - for (libvlc_track_type_t type = 0; type < 3; type++) { + // 4 = (libvlc_track_audio = 0 | libvlc_track_video = 1 | libvlc_track_text = 2 | libvlc_track_data = 3) + for (libvlc_track_type_t type = 0; type < 4; type++) { libvlc_media_tracklist_t *tracklist = libvlc_media_get_tracklist(p_md, type); if (!tracklist) continue; @@ -661,6 +661,13 @@ @implementation VLCMedia (Tracks) return [self _tracksForType: libvlc_track_text]; } +#pragma mark - Data Tracks + +- (NSArray *)dataTracks +{ + return [self _tracksForType: libvlc_track_data]; +} + #pragma mark - Private - (NSArray *)_tracksForType:(const libvlc_track_type_t)type diff --git a/Sources/Playback/VLCMediaPlayer.m b/Sources/Playback/VLCMediaPlayer.m index 9a112c6e6..e7b7d0c7c 100644 --- a/Sources/Playback/VLCMediaPlayer.m +++ b/Sources/Playback/VLCMediaPlayer.m @@ -278,6 +278,8 @@ static VLCMediaTrackType GetMediaTrackType(libvlc_track_type_t trackType) return VLCMediaTrackTypeText; case libvlc_track_video: return VLCMediaTrackTypeVideo; + case libvlc_track_data: + return VLCMediaTrackTypeData; default: return VLCMediaTrackTypeUnknown; } @@ -590,6 +592,22 @@ static void HandleMediaPlayerAribText(const char *text, void *opaque) } } +static void HandleMediaPlayerBMLData(const uint8_t *data, size_t size, void *opaque) +{ + @autoreleasepool { + NSData *nsData = [NSData dataWithBytes:data length:size]; + VLCMediaPlayer *player = (__bridge VLCMediaPlayer *)opaque; + dispatch_async(dispatch_get_main_queue(), ^{ + if (player.bmlDataReceivedBlock) { + player.bmlDataReceivedBlock(nsData); + } + if ([player.delegate respondsToSelector:@selector(mediaPlayer:didReceiveBMLData:)]) { + [player.delegate mediaPlayer:player didReceiveBMLData:nsData]; + } + }); + } +} + static VLCMediaPlayerFrameStepResult GetFrameStepResult(int status) { switch (-status) { @@ -717,6 +735,7 @@ - (instancetype)initWithLibrary:(VLCLibrary *)library &watch_time_cbs, (__bridge void *)_eventsHandler); libvlc_video_set_arib_text_callbacks(_playerInstance, HandleMediaPlayerAribText, (__bridge void *)self); + libvlc_video_set_bml_callbacks(_playerInstance, HandleMediaPlayerBMLData, (__bridge void *)self); } return self; @@ -743,6 +762,7 @@ - (instancetype)initWithLibVLCInstance:(void *)playerInstance andLibrary:(VLCLib &watch_time_cbs, (__bridge void *)_eventsHandler); libvlc_video_set_arib_text_callbacks(_playerInstance, HandleMediaPlayerAribText, (__bridge void *)self); + libvlc_video_set_bml_callbacks(_playerInstance, HandleMediaPlayerBMLData, (__bridge void *)self); } return self; } @@ -797,6 +817,7 @@ - (void)dealloc libvlc_free(_viewpoint); libvlc_video_set_arib_text_callbacks(_playerInstance, NULL, NULL); + libvlc_video_set_bml_callbacks(_playerInstance, NULL, NULL); libvlc_media_player_release(_playerInstance); } @@ -1875,6 +1896,7 @@ - (instancetype)initWithDrawable:(id)aDrawable options:(NSArray *)options &watch_time_cbs, (__bridge void *)_eventsHandler); libvlc_video_set_arib_text_callbacks(_playerInstance, HandleMediaPlayerAribText, (__bridge void *)self); + libvlc_video_set_bml_callbacks(_playerInstance, HandleMediaPlayerBMLData, (__bridge void *)self); [self setDrawable:aDrawable]; } @@ -2009,6 +2031,13 @@ @implementation VLCMediaPlayer (Tracks) return [self _tracksForType: libvlc_track_text]; } +#pragma mark - Data Tracks + +- (NSArray *)dataTracks +{ + return [self _tracksForType: libvlc_track_data]; +} + #pragma mark - Track Selection - (void)selectTrackAtIndex:(NSInteger)index type:(VLCMediaTrackType)type @@ -2068,6 +2097,11 @@ - (void)deselectAllTextTracks libvlc_media_player_unselect_track_type(_playerInstance, libvlc_track_text); } +- (void)deselectAllDataTracks +{ + libvlc_media_player_unselect_track_type(_playerInstance, libvlc_track_data); +} + #pragma mark - Private - (NSArray *)_tracksForType:(const libvlc_track_type_t)type diff --git a/compileAndBuildVLCKit.sh b/compileAndBuildVLCKit.sh index 71befb0b0..90f85ea72 100755 --- a/compileAndBuildVLCKit.sh +++ b/compileAndBuildVLCKit.sh @@ -30,8 +30,8 @@ if [ -z "$MAKEFLAGS" ]; then MAKEFLAGS="-j$(sysctl -n machdep.cpu.core_count || nproc)"; fi -BRANCH="master20260717" -TESTEDHASH="721a8591db3ab8919a65feaa7a9f865ea90a92a2" # libvlc hash that this version of VLCKit is build on +BRANCH="bml2" +TESTEDHASH="b4c6b2317dcdbd48e3264ff5ea1528fd00f4d66a" # libvlc hash that this version of VLCKit is build on usage() {