Skip to content
Open
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
61 changes: 61 additions & 0 deletions ios/Video/RCTVideo.m
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ - (void)sendProgressUpdate
@"currentPlaybackTime": [NSNumber numberWithLongLong:[@(floor([currentPlaybackTime timeIntervalSince1970] * 1000)) longLongValue]],
@"target": self.reactTag,
@"seekableDuration": [self calculateSeekableDuration],
@"playerAccessLogs": [self getPlayerAccessLogs],
@"codecs": [self getEnabledTrackCodecs],
});
}
}
Expand Down Expand Up @@ -1369,6 +1371,65 @@ - (NSArray *)getTextTrackInfo
return textTracks;
}

- (NSArray *)getPlayerAccessLogs
{
AVPlayerItem *video = [_player currentItem];
NSMutableArray *playerAccessLogs = [[NSMutableArray alloc] init];

for (AVPlayerItemAccessLogEvent *event in [[video accessLog] events] ) {
NSDictionary *accessLog = @{
@"uri": [event URI],
@"segmentsDownloadedDuration": @([event segmentsDownloadedDuration]),
@"durationWatched": @([event durationWatched])
};
[playerAccessLogs addObject:accessLog];
}
return playerAccessLogs;
}

- (NSString *)mediaFormatWithFormatDescriptions:(NSArray *)formatDescriptions {
NSMutableString *format = [[NSMutableString alloc] init];
for (int i = 0; i < formatDescriptions.count; i++) {
CMFormatDescriptionRef desc =
(__bridge CMFormatDescriptionRef)formatDescriptions[i];
NSString *type = FourCCString(CMFormatDescriptionGetMediaType(desc));
NSString *subType = FourCCString(CMFormatDescriptionGetMediaSubType(desc));
[format appendFormat:@"%@/%@", type, subType];
if (i < formatDescriptions.count - 1) {
[format appendString:@","];
}
}
return format;
}

static NSString * FourCCString(FourCharCode code) {
NSString *result = [NSString stringWithFormat:@"%c%c%c%c",
(code >> 24) & 0xff,
(code >> 16) & 0xff,
(code >> 8) & 0xff,
code & 0xff];
NSCharacterSet *characterSet = [NSCharacterSet whitespaceCharacterSet];
return [result stringByTrimmingCharactersInSet:characterSet];
}

- (NSArray *)getEnabledTrackCodecs
{
AVPlayerItem *video = [_player currentItem];
NSMutableArray *codecs = [[NSMutableArray alloc] init];

for (AVPlayerItemTrack *track in video.tracks ) {
if(track.enabled){
NSArray *formatDescriptions = track.assetTrack.formatDescriptions;
NSString *formats = [self mediaFormatWithFormatDescriptions:formatDescriptions];
[codecs addObject:formats];
}
}

return codecs;
}



- (BOOL)getFullscreen
{
return _fullscreenPlayerPresented;
Expand Down