Skip to content
Draft

bml2 #65

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Headers/Public/Media/VLCMedia.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down Expand Up @@ -458,6 +459,11 @@ typedef struct VLCMediaStats VLCMediaStats;
*/
@property(nonatomic, readonly, copy) NSArray<VLCMediaTrack *> *textTracks;

/**
* dataTracks
*/
@property(nonatomic, readonly, copy) NSArray<VLCMediaTrack *> *dataTracks;

@end

#pragma mark - VLCMediaTrack
Expand Down
23 changes: 23 additions & 0 deletions Headers/Public/Playback/VLCMediaPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
/**
Expand Down Expand Up @@ -1040,6 +1053,11 @@ typedef NS_ENUM(unsigned, VLCAudioMixMode)
*/
@property(nonatomic, readonly, copy) NSArray<VLCMediaPlayerTrack *> *textTracks;

/**
* dataTracks
*/
@property(nonatomic, readonly, copy) NSArray<VLCMediaPlayerTrack *> *dataTracks;

/**
* Select a track of a given type at the given index
* \param index position of the track in the list
Expand Down Expand Up @@ -1068,6 +1086,11 @@ typedef NS_ENUM(unsigned, VLCAudioMixMode)
*/
- (void)deselectAllTextTracks;

/**
* deselect all data tracks
*/
- (void)deselectAllDataTracks;

@end

NS_ASSUME_NONNULL_END
11 changes: 9 additions & 2 deletions Sources/Media/VLCMedia.m
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ - (VLCMediaStats)statistics
{
NSMutableArray<VLCMediaTrack *> *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;

Expand Down Expand Up @@ -661,6 +661,13 @@ @implementation VLCMedia (Tracks)
return [self _tracksForType: libvlc_track_text];
}

#pragma mark - Data Tracks

- (NSArray<VLCMediaTrack *> *)dataTracks
{
return [self _tracksForType: libvlc_track_data];
}

#pragma mark - Private

- (NSArray<VLCMediaTrack *> *)_tracksForType:(const libvlc_track_type_t)type
Expand Down
34 changes: 34 additions & 0 deletions Sources/Playback/VLCMediaPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -2009,6 +2031,13 @@ @implementation VLCMediaPlayer (Tracks)
return [self _tracksForType: libvlc_track_text];
}

#pragma mark - Data Tracks

- (NSArray<VLCMediaPlayerTrack *> *)dataTracks
{
return [self _tracksForType: libvlc_track_data];
}

#pragma mark - Track Selection

- (void)selectTrackAtIndex:(NSInteger)index type:(VLCMediaTrackType)type
Expand Down Expand Up @@ -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<VLCMediaPlayerTrack *> *)_tracksForType:(const libvlc_track_type_t)type
Expand Down
4 changes: 2 additions & 2 deletions compileAndBuildVLCKit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down