Skip to content

Commit

Permalink
Merge branch 'release/2.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos committed Apr 13, 2018
2 parents 545af37 + 943ea4a commit 3302f84
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 78 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "SRGSSR/libextobjc" "46f179fbba8dde2a3eb3da284919789b78aac441"
github "SRGSSR/MAKVONotificationCenter" "d5af67218b3b7b49660a43edef5e6eb9c437d670"
github "SRGSSR/srglogger-ios" "1.0.1"
github "SRGSSR/srglogger-ios" "1.0.2"
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "SRGSSR/MAKVONotificationCenter" "d5af67218b3b7b49660a43edef5e6eb9c437d670"
github "SRGSSR/libextobjc" "46f179fbba8dde2a3eb3da284919789b78aac441"
github "SRGSSR/srglogger-ios" "1.0.1"
github "SRGSSR/srglogger-ios" "1.0.2"
2 changes: 1 addition & 1 deletion Demo/Sources/Players/Inline/InlinePlayerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ - (IBAction)prepareToPlay:(id)sender
{
self.mediaPlayerController.view.viewMode = self.media.is360 ? SRGMediaPlayerViewModeMonoscopic : SRGMediaPlayerViewModeFlat;
[self.mediaPlayerController prepareToPlayURL:self.media.URL atTime:kCMTimeZero withSegments:nil userInfo:nil completionHandler:^{
_ready = YES;
self->_ready = YES;
}];
}

Expand Down
5 changes: 5 additions & 0 deletions Framework/Sources/Helpers/SRGPeriodicTimeObserver.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ @implementation SRGPeriodicTimeObserver

#pragma mark Object lifecycle

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"

- (instancetype)init
{
return [self initWithInterval:CMTimeMakeWithSeconds(1., NSEC_PER_SEC) queue:NULL];
}

#pragma clang diagnostic pop

- (instancetype)initWithInterval:(CMTime)interval queue:(dispatch_queue_t)queue
{
if (self = [super init]) {
Expand Down
10 changes: 7 additions & 3 deletions SRGMediaPlayer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = SRG;
LastUpgradeCheck = 0910;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "SRG SSR";
TargetAttributes = {
E69A1DA81D61B9380064E6C1 = {
Expand Down Expand Up @@ -1174,12 +1174,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand All @@ -1203,7 +1205,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MARKETING_VERSION = 2.3;
MARKETING_VERSION = 2.3.1;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -1223,12 +1225,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand All @@ -1251,7 +1255,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MARKETING_VERSION = 2.3;
MARKETING_VERSION = 2.3.1;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0910"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,9 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down Expand Up @@ -57,7 +56,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
134 changes: 68 additions & 66 deletions Tests/Sources/PlaybackTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,38 +80,37 @@ - (void)testDeallocationWhileIdle

- (void)testDeallocationWhilePlaying
{
// If the player controller is not retained, its player and all associated resources (including the player layer) must
// be automatically discarded
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-unsafe-retained-assign"
[self mpt_expectationForNotification:SRGMediaPlayerPlaybackStateDidChangeNotification object:self.mediaPlayerController handler:^BOOL(NSNotification * _Nonnull notification) {
return [notification.userInfo[SRGMediaPlayerPlaybackStateKey] integerValue] == SRGMediaPlayerPlaybackStatePlaying;
}];

// If the player controller is not retained, its player and all associated resources (including the player layer) must
// be automatically discarded
__weak SRGMediaPlayerController *weakMediaPlayerController = self.mediaPlayerController;
[self.mediaPlayerController playURL:OnDemandTestURL()];

[self waitForExpectationsWithTimeout:30. handler:nil];

// When no reference retains the player, playback must gracefully stop. Deallocation will occur right afterwards.
[self mpt_expectationForNotification:SRGMediaPlayerPlaybackStateDidChangeNotification object:self.mediaPlayerController handler:^BOOL(NSNotification * _Nonnull notification) {
return [notification.userInfo[SRGMediaPlayerPlaybackStateKey] integerValue] == SRGMediaPlayerPlaybackStateIdle;
}];

// Ensure the player is correctly deallocated
__weak AVPlayer *weakPlayer = self.mediaPlayerController.player;
[self expectationForPredicate:[NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
return weakPlayer == nil;
}] evaluatedWithObject:self /* unused, but a non-nil argument is required */ handler:nil];

// Do not retain the controller anymore, and force an autorelease pool collection. The weak reference must be nilled
// automatically if the controller is correctly deallocated
@autoreleasepool {
[self mpt_expectationForNotification:SRGMediaPlayerPlaybackStateDidChangeNotification object:self.mediaPlayerController handler:^BOOL(NSNotification * _Nonnull notification) {
return [notification.userInfo[SRGMediaPlayerPlaybackStateKey] integerValue] == SRGMediaPlayerPlaybackStatePlaying;
}];

[self.mediaPlayerController playURL:OnDemandTestURL()];

[self waitForExpectationsWithTimeout:30. handler:nil];

// When no reference retains the player, playback must gracefully stop. Deallocation will occur right afterwards.
[self mpt_expectationForNotification:SRGMediaPlayerPlaybackStateDidChangeNotification object:self.mediaPlayerController handler:^BOOL(NSNotification * _Nonnull notification) {
return [notification.userInfo[SRGMediaPlayerPlaybackStateKey] integerValue] == SRGMediaPlayerPlaybackStateIdle;
}];

// Ensure the player is correctly deallocated
[self expectationForPredicate:[NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
return weakPlayer == nil;
}] evaluatedWithObject:self /* unused, but a non-nil argument is required */ handler:nil];

self.mediaPlayerController = nil;

[self waitForExpectationsWithTimeout:30. handler:nil];
}

[self waitForExpectationsWithTimeout:30. handler:nil];

XCTAssertNil(weakMediaPlayerController);
#pragma clang diagnostic pop
}
Expand Down Expand Up @@ -831,6 +830,12 @@ - (void)testOnDemandProperties

- (void)testLiveProperties
{
// FIXME: See https://github.com/SRGSSR/SRGMediaPlayer-iOS/issues/50. Workaround so that the test passes on iOS 11.3.
NSOperatingSystemVersion operatingSystemVersion = [NSProcessInfo processInfo].operatingSystemVersion;
if (operatingSystemVersion.majorVersion == 11 && operatingSystemVersion.minorVersion == 3) {
self.mediaPlayerController.minimumDVRWindowLength = 40.;
}

[self expectationForPredicate:[NSPredicate predicateWithBlock:^BOOL(SRGMediaPlayerController * _Nullable mediaPlayerController, NSDictionary<NSString *,id> * _Nullable bindings) {
return mediaPlayerController.streamType != SRGMediaPlayerStreamTypeUnknown;
}] evaluatedWithObject:self.mediaPlayerController handler:nil];
Expand Down Expand Up @@ -1371,53 +1376,50 @@ - (void)testPauseSeekAndTogglePlayPauseWhileSeeking

- (void)testReset
{
// Wait until playing
[self mpt_expectationForNotification:SRGMediaPlayerPlaybackStateDidChangeNotification object:self.mediaPlayerController handler:^BOOL(NSNotification * _Nonnull notification) {
return [notification.userInfo[SRGMediaPlayerPlaybackStateKey] integerValue] == SRGMediaPlayerPlaybackStatePlaying;
}];

// Pass empty collections as parameters
[self.mediaPlayerController playURL:OnDemandTestURL() atTime:CMTimeMakeWithSeconds(2., NSEC_PER_SEC) withSegments:@[] userInfo:@{}];

[self waitForExpectationsWithTimeout:30. handler:nil];

// Ensure the player is correctly deallocated
__weak AVPlayer *weakPlayer = self.mediaPlayerController.player;
[self expectationForPredicate:[NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
return weakPlayer == nil;
}] evaluatedWithObject:self /* unused, but a non-nil argument is required */ handler:nil];

// Reset the player and check its status
[self mpt_expectationForNotification:SRGMediaPlayerPlaybackStateDidChangeNotification object:self.mediaPlayerController handler:^BOOL(NSNotification * _Nonnull notification) {
XCTAssertEqual([notification.userInfo[SRGMediaPlayerPlaybackStateKey] integerValue], SRGMediaPlayerPlaybackStateIdle);
XCTAssertFalse([notification.userInfo[SRGMediaPlayerSelectedKey] boolValue]);
@autoreleasepool {
// Wait until playing
[self mpt_expectationForNotification:SRGMediaPlayerPlaybackStateDidChangeNotification object:self.mediaPlayerController handler:^BOOL(NSNotification * _Nonnull notification) {
return [notification.userInfo[SRGMediaPlayerPlaybackStateKey] integerValue] == SRGMediaPlayerPlaybackStatePlaying;
}];

XCTAssertNil(self.mediaPlayerController.contentURL);
XCTAssertNil(self.mediaPlayerController.playerItem);
XCTAssertNil(self.mediaPlayerController.segments);
XCTAssertNil(self.mediaPlayerController.userInfo);
// Pass empty collections as parameters
[self.mediaPlayerController playURL:OnDemandTestURL() atTime:CMTimeMakeWithSeconds(2., NSEC_PER_SEC) withSegments:@[] userInfo:@{}];

// Receive previous playback information since it has changed
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousContentURLKey]);
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousPlayerItemKey]);
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousTimeRangeKey]);
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousMediaTypeKey]);
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousStreamTypeKey]);
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousUserInfoKey]);
[self waitForExpectationsWithTimeout:30. handler:nil];

TestAssertEqualTimeInSeconds([notification.userInfo[SRGMediaPlayerLastPlaybackTimeKey] CMTimeValue], 2);
// Ensure the player is correctly deallocated
__weak AVPlayer *weakPlayer = self.mediaPlayerController.player;
[self expectationForPredicate:[NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
return weakPlayer == nil;
}] evaluatedWithObject:self /* unused, but a non-nil argument is required */ handler:nil];

// Reset the player and check its status
[self mpt_expectationForNotification:SRGMediaPlayerPlaybackStateDidChangeNotification object:self.mediaPlayerController handler:^BOOL(NSNotification * _Nonnull notification) {
XCTAssertEqual([notification.userInfo[SRGMediaPlayerPlaybackStateKey] integerValue], SRGMediaPlayerPlaybackStateIdle);
XCTAssertFalse([notification.userInfo[SRGMediaPlayerSelectedKey] boolValue]);

XCTAssertNil(self.mediaPlayerController.contentURL);
XCTAssertNil(self.mediaPlayerController.playerItem);
XCTAssertNil(self.mediaPlayerController.segments);
XCTAssertNil(self.mediaPlayerController.userInfo);

// Receive previous playback information since it has changed
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousContentURLKey]);
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousPlayerItemKey]);
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousTimeRangeKey]);
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousMediaTypeKey]);
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousStreamTypeKey]);
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousUserInfoKey]);

TestAssertEqualTimeInSeconds([notification.userInfo[SRGMediaPlayerLastPlaybackTimeKey] CMTimeValue], 2);
return YES;
}];

XCTAssertNotNil(self.mediaPlayerController.contentURL);
XCTAssertNotNil(self.mediaPlayerController.playerItem);
XCTAssertNotNil(self.mediaPlayerController.segments);
XCTAssertNotNil(self.mediaPlayerController.userInfo);

return YES;
}];

XCTAssertNotNil(self.mediaPlayerController.contentURL);
XCTAssertNotNil(self.mediaPlayerController.playerItem);
XCTAssertNotNil(self.mediaPlayerController.segments);
XCTAssertNotNil(self.mediaPlayerController.userInfo);

// Force an autorelease pool collection. The weak reference must be nilled automatically if the controller is correctly
// deallocated
@autoreleasepool {
[self.mediaPlayerController reset];
}

Expand Down
2 changes: 1 addition & 1 deletion docs/Getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ To start playback, bind your media player controller to a `mediaPlayerController
[super viewWillAppear:animated];
if ([self isMovingToParentViewController] || [self isBeingPresented]) {
NSURL *mediaURL = [NSURL URLWithString:@"http://..."]:
NSURL *mediaURL = [NSURL URLWithString:@"http://..."];
[self.mediaPlayerController playURL:mediaURL];
}
}
Expand Down

0 comments on commit 3302f84

Please sign in to comment.