Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alignment main-dxp with legacy/5.X #23

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 15 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
10 changes: 10 additions & 0 deletions ios/RCTVideo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
0177D39827170A7A00F5BE18 /* RCTVideo-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "RCTVideo-Bridging-Header.h"; path = "Video/RCTVideo-Bridging-Header.h"; sourceTree = "<group>"; };
0177D39927170A7A00F5BE18 /* RCTVideo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RCTVideo.swift; path = Video/RCTVideo.swift; sourceTree = "<group>"; };
134814201AA4EA6300B7C361 /* libRCTVideo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTVideo.a; sourceTree = BUILT_PRODUCTS_DIR; };
DCF8FEFD2C1A174E00CCA6B0 /* CurrentVideos.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CurrentVideos.h; path = Video/CurrentVideos.h; sourceTree = "<group>"; };
DCF8FEFE2C1A174E00CCA6B0 /* CurrentVideos.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = CurrentVideos.m; path = Video/CurrentVideos.m; sourceTree = "<group>"; };
DCF8FEFF2C1A18AC00CCA6B0 /* WeakVideoRef.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WeakVideoRef.h; path = Video/WeakVideoRef.h; sourceTree = "<group>"; };
DCF8FF002C1A18AC00CCA6B0 /* WeakVideoRef.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = WeakVideoRef.m; path = Video/WeakVideoRef.m; sourceTree = "<group>"; };
DCF8FF322C1AF64800CCA6B0 /* M3U8Kit */ = {isa = PBXFileReference; lastKnownFileType = folder; name = M3U8Kit; path = Video/M3U8Kit; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -87,10 +92,15 @@
58B511D21A9E6C8500147676 = {
isa = PBXGroup;
children = (
DCF8FF322C1AF64800CCA6B0 /* M3U8Kit */,
01489050272001A100E69940 /* DataStructures */,
01489051272001A100E69940 /* Features */,
0177D39527170A7A00F5BE18 /* RCTSwiftLog */,
0177D39927170A7A00F5BE18 /* RCTVideo.swift */,
DCF8FEFD2C1A174E00CCA6B0 /* CurrentVideos.h */,
DCF8FEFE2C1A174E00CCA6B0 /* CurrentVideos.m */,
DCF8FEFF2C1A18AC00CCA6B0 /* WeakVideoRef.h */,
DCF8FF002C1A18AC00CCA6B0 /* WeakVideoRef.m */,
0177D39727170A7A00F5BE18 /* RCTVideoManager.m */,
0177D39227170A7A00F5BE18 /* RCTVideoManager.swift */,
0177D39427170A7A00F5BE18 /* RCTVideoPlayerViewController.swift */,
Expand Down
19 changes: 19 additions & 0 deletions ios/Video/CurrentVideos.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// CurrentVideos.h
// react-native-video
//
// Created by marcin.dziennik on 9/8/23.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@class RCTVideo;
@interface CurrentVideos : NSObject
+ (instancetype)shared;
- (void)add: (RCTVideo*)video forTag: (NSNumber*)tag;
- (nullable RCTVideo*)videoForTag: (NSNumber*)tag;
@end

NS_ASSUME_NONNULL_END
55 changes: 55 additions & 0 deletions ios/Video/CurrentVideos.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// CurrentVideos.m
// react-native-video
//
// Created by marcin.dziennik on 9/8/23.
//

#import "CurrentVideos.h"
#import "WeakVideoRef.h"

@interface CurrentVideos ()
@property (strong) NSMutableDictionary <NSNumber*, WeakVideoRef*> *videos;
@end

@implementation CurrentVideos

+ (nonnull instancetype)shared {
static CurrentVideos *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[self alloc] init];
});
return instance;
}

- (instancetype)init {
if (self = [super init]) {
_videos = [[NSMutableDictionary alloc] init];
}

return self;
}

- (void)add:(nonnull RCTVideo *)video forTag:(nonnull NSNumber *)tag {
[self cleanup];
WeakVideoRef *ref = [[WeakVideoRef alloc] init];
ref.video = video;
[_videos setObject:ref forKey:tag];
}


- (nullable RCTVideo *)videoForTag:(nonnull NSNumber *)tag {
[self cleanup];
return [[_videos objectForKey:tag] video];
}

- (void)cleanup {
for (NSNumber* key in [_videos allKeys]) {
if (_videos[key].video == nil) {
[_videos removeObjectForKey:key];
}
}
}

@end
38 changes: 37 additions & 1 deletion ios/Video/Features/RCTPlayerOperations.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import AVFoundation
import MediaAccessibility
import MediaPlayer

let RCTVideoUnset = -1

Expand All @@ -9,6 +10,9 @@
* Collection of mutating functions
*/
enum RCTPlayerOperations {

Check failure on line 13 in ios/Video/Features/RCTPlayerOperations.swift

View workflow job for this annotation

GitHub Actions / Swift-Lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
static var remoteCommandHandlerForSpatialAudio: Any?

Check failure on line 15 in ios/Video/Features/RCTPlayerOperations.swift

View workflow job for this annotation

GitHub Actions / Swift-Lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
static func setSideloadedText(player: AVPlayer?, textTracks: [TextTrack], criteria: SelectedTrackCriteria?) {
let type = criteria?.type

Expand Down Expand Up @@ -116,12 +120,20 @@
}
}
} else { // default. invalid type or "system"
#if os(tvOS)
// Do noting. Fix for tvOS native audio menu language selector
#else
await player?.currentItem?.selectMediaOptionAutomatically(in: group)
#endif
return
}

// If a match isn't found, option will be nil and text tracks will be disabled
#if os(tvOS)
// Do noting. Fix for tvOS native audio menu language selector
#else
// If a match isn't found, option will be nil and text tracks will be disabled
await player?.currentItem?.select(mediaOption, in: group)
#endif
}

static func seek(player: AVPlayer, playerItem: AVPlayerItem, paused: Bool, seekTime: Float, seekTolerance: Float, completion: @escaping (Bool) -> Void) {
Expand Down Expand Up @@ -196,4 +208,28 @@
}
}
}

Check failure on line 211 in ios/Video/Features/RCTPlayerOperations.swift

View workflow job for this annotation

GitHub Actions / Swift-Lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
// MARK: - Spatial Audio / Dolby Atmos Workaround

/* These functions are a temporarily workaround to enable the rendering of Dolby Atmos on
* iOS 15 and above.
*/

Check failure on line 217 in ios/Video/Features/RCTPlayerOperations.swift

View workflow job for this annotation

GitHub Actions / Swift-Lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
static func addSpatialAudioRemoteCommandHandler() {
let command = MPRemoteCommandCenter.shared().playCommand

Check failure on line 220 in ios/Video/Features/RCTPlayerOperations.swift

View workflow job for this annotation

GitHub Actions / Swift-Lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
remoteCommandHandlerForSpatialAudio = command.addTarget(handler: { event in

Check failure on line 221 in ios/Video/Features/RCTPlayerOperations.swift

View workflow job for this annotation

GitHub Actions / Swift-Lint

Unused Closure Parameter Violation: Unused parameter in a closure should be replaced with _ (unused_closure_parameter)
MPRemoteCommandHandlerStatus.success
})
}

Check failure on line 225 in ios/Video/Features/RCTPlayerOperations.swift

View workflow job for this annotation

GitHub Actions / Swift-Lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
static func removeSpatialAudioRemoteCommandHandler() {

Check failure on line 227 in ios/Video/Features/RCTPlayerOperations.swift

View workflow job for this annotation

GitHub Actions / Swift-Lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
let command = MPRemoteCommandCenter.shared().playCommand

Check failure on line 229 in ios/Video/Features/RCTPlayerOperations.swift

View workflow job for this annotation

GitHub Actions / Swift-Lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
if let remoteCommand = RCTPlayerOperations.remoteCommandHandlerForSpatialAudio {
command.removeTarget(remoteCommand)
RCTPlayerOperations.remoteCommandHandlerForSpatialAudio = nil
}
}
}
22 changes: 22 additions & 0 deletions ios/Video/M3U8Kit/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Sun Jin <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

44 changes: 44 additions & 0 deletions ios/Video/M3U8Kit/Source/M3U8ExtXByteRange.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// M3U8ExtXByteRange.h
// M3U8Kit
//
// Created by Frank on 2020/10/1.
// Copyright © 2020 M3U8Kit. All rights reserved.
//
//The MIT License (MIT)
//
//Copyright (c) 2015 Sun Jin <[email protected]>
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in all
//copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//SOFTWARE.

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface M3U8ExtXByteRange : NSObject

- (instancetype)initWithAtString:(NSString *)atString;
- (instancetype)initWithLength:(NSInteger)length offset:(NSInteger)offset;

@property (nonatomic, assign, readonly) NSInteger length;
@property (nonatomic, assign, readonly) NSInteger offset;

@end

NS_ASSUME_NONNULL_END
54 changes: 54 additions & 0 deletions ios/Video/M3U8Kit/Source/M3U8ExtXByteRange.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// M3U8ExtXByteRange.m
// M3U8Kit
//
// Created by Frank on 2020/10/1.
// Copyright © 2020 M3U8Kit. All rights reserved.
//
//The MIT License (MIT)
//
//Copyright (c) 2015 Sun Jin <[email protected]>
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in all
//copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//SOFTWARE.

#import "M3U8ExtXByteRange.h"

@implementation M3U8ExtXByteRange

- (instancetype)initWithAtString:(NSString *)atString {
NSArray<NSString *> *params = [atString componentsSeparatedByString:@"@"];
NSInteger length = params.firstObject.integerValue;
NSInteger offset = 0;
if (params.count > 1) {
offset = MAX(0, params[1].integerValue);
}

return [self initWithLength:length offset:offset];
}

- (instancetype)initWithLength:(NSInteger)length offset:(NSInteger)offset {
self = [super init];
if (self) {
_length = length;
_offset = offset;
}
return self;
}

@end
40 changes: 40 additions & 0 deletions ios/Video/M3U8Kit/Source/M3U8ExtXKey.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// M3U8ExtXKey.h
// M3U8Kit
//
// Created by Pierre Perrin on 01/02/2019.
// Copyright © 2019 M3U8Kit. All rights reserved.
//
//The MIT License (MIT)
//
//Copyright (c) 2015 Sun Jin <[email protected]>
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in all
//copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//SOFTWARE.

#import <Foundation/Foundation.h>
@interface M3U8ExtXKey : NSObject

- (instancetype)initWithDictionary:(NSDictionary *)dictionary;

- (NSString *)method;
- (NSString *)url;
- (NSString *)keyFormat;
- (NSString *)iV;

@end
Loading
Loading