Skip to content

Commit

Permalink
Merge branch 'release/4.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos committed Sep 2, 2020
2 parents 42f8148 + 2bf2b94 commit bebe797
Show file tree
Hide file tree
Showing 11 changed files with 197 additions and 83 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github "SRGSSR/ComScore-iOS-watchOS-tvOS" "6.3.1"
github "SRGSSR/srgdataprovider-apple" "8.0.0"
github "SRGSSR/srgidentity-apple" "2.0.3"
github "SRGSSR/srgmediaplayer-apple" "5.0.0"
github "SRGSSR/srgmediaplayer-apple" "5.0.2"
github "SRGSSR/tagcommander-apple" "4.5.4_4.4.1_srg3"
2 changes: 1 addition & 1 deletion Cartfile.resolved.proprietary
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ github "SRGSSR/srgdataprovider-apple" "8.0.0"
github "SRGSSR/srgdiagnostics-apple" "2.0.1"
github "SRGSSR/srgidentity-apple" "2.0.3"
github "SRGSSR/srglogger-apple" "2.0.1"
github "SRGSSR/srgmediaplayer-apple" "5.0.0"
github "SRGSSR/srgmediaplayer-apple" "5.0.2"
github "SRGSSR/srgnetwork-apple" "2.0.2"
github "SRGSSR/tagcommander-apple" "4.5.4_4.4.1_srg3"
2 changes: 1 addition & 1 deletion Cartfile.resolved.public
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ github "SRGSSR/srgdataprovider-apple" "8.0.0"
github "SRGSSR/srgdiagnostics-apple" "2.0.1"
github "SRGSSR/srgidentity-apple" "2.0.3"
github "SRGSSR/srglogger-apple" "2.0.1"
github "SRGSSR/srgmediaplayer-apple" "5.0.0"
github "SRGSSR/srgmediaplayer-apple" "5.0.2"
github "SRGSSR/srgnetwork-apple" "2.0.2"
github "SRGSSR/tagcommander-apple" "4.5.4_4.4.1_srg3"
2 changes: 1 addition & 1 deletion Common.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Version information
MARKETING_VERSION = 4.2.0
MARKETING_VERSION = 4.2.1

// Deployment targets
IPHONEOS_DEPLOYMENT_TARGET = 9.0
Expand Down
66 changes: 33 additions & 33 deletions Framework-MediaPlayer/Sources/SRGComScoreMediaPlayerTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,46 @@ + (void)decreasePlaybackActivityCount
}
}

+ (SCORStreamingAnalytics *)streamingAnalyticsForMediaPlayerController:(SRGMediaPlayerController *)mediaPlayerController
{
SRGAnalyticsStreamLabels *labels = mediaPlayerController.userInfo[SRGAnalyticsMediaPlayerLabelsKey];
NSDictionary<NSString *, NSString *> *labelsDictionary = labels.comScoreLabelsDictionary;
if (labelsDictionary.count == 0) {
return nil;
}

SCORStreamingAnalytics *streamingAnalytics = [[SCORStreamingAnalytics alloc] init];
[streamingAnalytics createPlaybackSession];

[streamingAnalytics setMediaPlayerName:mediaPlayerController.analyticsPlayerName];
[streamingAnalytics setMediaPlayerVersion:mediaPlayerController.analyticsPlayerVersion];

SCORStreamingContentMetadata *streamingMetadata = [SCORStreamingContentMetadata contentMetadataWithBuilderBlock:^(SCORStreamingContentMetadataBuilder *builder) {
NSMutableDictionary<NSString *, NSString *> *customLabels = [labelsDictionary mutableCopy];

if (SRGAnalyticsTracker.sharedTracker.configuration.unitTesting) {
customLabels[@"srg_test_id"] = SRGAnalyticsUnitTestingIdentifier();
}

[builder setCustomLabels:customLabels.copy];
}];
[streamingAnalytics setMetadata:streamingMetadata];

return streamingAnalytics;
}

#pragma mark Object lifecycle

- (instancetype)initWithMediaPlayerController:(SRGMediaPlayerController *)mediaPlayerController
{
if (self = [super init]) {
self.mediaPlayerController = mediaPlayerController;
self.streamingAnalytics = [[SCORStreamingAnalytics alloc] init];

BOOL created = [self createPlaybackSession];
if (! created) {
self.streamingAnalytics = [SRGComScoreMediaPlayerTracker streamingAnalyticsForMediaPlayerController:mediaPlayerController];
if (! self.streamingAnalytics) {
return nil;
}

self.mediaPlayerController = mediaPlayerController;

// No need to send explicit 'buffer stop' events. Sending a play or pause at the end of the buffering phase
// (which our player does) suffices to implicitly finish the buffering phase. Buffer events are not required
// to be sent when the player is seeking.
Expand Down Expand Up @@ -119,33 +146,6 @@ - (id)init

#pragma mark Tracking

- (BOOL)createPlaybackSession
{
SRGAnalyticsStreamLabels *labels = self.mediaPlayerController.userInfo[SRGAnalyticsMediaPlayerLabelsKey];
NSDictionary<NSString *, NSString *> *labelsDictionary = labels.comScoreLabelsDictionary;
if (labelsDictionary.count == 0) {
return NO;
}

[self.streamingAnalytics createPlaybackSession];

[self.streamingAnalytics setMediaPlayerName:self.mediaPlayerController.analyticsPlayerName];
[self.streamingAnalytics setMediaPlayerVersion:self.mediaPlayerController.analyticsPlayerVersion];

SCORStreamingContentMetadata *streamingMetadata = [SCORStreamingContentMetadata contentMetadataWithBuilderBlock:^(SCORStreamingContentMetadataBuilder *builder) {
NSMutableDictionary<NSString *, NSString *> *customLabels = [labelsDictionary mutableCopy];

if (SRGAnalyticsTracker.sharedTracker.configuration.unitTesting) {
customLabels[@"srg_test_id"] = SRGAnalyticsUnitTestingIdentifier();
}

[builder setCustomLabels:customLabels.copy];
}];
[self.streamingAnalytics setMetadata:streamingMetadata];

return YES;
}

- (void)recordEventForPlaybackState:(SRGMediaPlayerPlaybackState)playbackState
withStreamType:(SRGMediaPlayerStreamType)streamType
time:(CMTime)time
Expand Down Expand Up @@ -211,7 +211,7 @@ - (void)recordEvent:(ComScoreMediaPlayerTrackerEvent)event

case ComScoreMediaPlayerTrackerEventEnd: {
[streamingAnalytics notifyEnd];
[self createPlaybackSession];
self.streamingAnalytics = [SRGComScoreMediaPlayerTracker streamingAnalyticsForMediaPlayerController:self.mediaPlayerController];
break;
}

Expand Down
2 changes: 1 addition & 1 deletion Framework-MediaPlayer/Sources/SRGMediaPlayerTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ - (void)segmentDidStart:(NSNotification *)notification
SRGMediaPlayerStreamType streamType = mediaPlayerController.streamType;

// Notify full-length end (only if not starting at the given segment, i.e. if the player is not preparing playback)
if (! notification.userInfo[SRGMediaPlayerPreviousSegmentKey]
if (! notification.userInfo[SRGMediaPlayerPreviousSelectedSegmentKey]
&& mediaPlayerController.playbackState != SRGMediaPlayerPlaybackStatePreparing) {
CMTime time = [notification.userInfo[SRGMediaPlayerLastPlaybackTimeKey] CMTimeValue];
NSNumber *timeshift = SRGMediaAnalyticsTimeshiftInMilliseconds(streamType, mediaPlayerController.timeRange, time, mediaPlayerController.liveTolerance);
Expand Down
2 changes: 1 addition & 1 deletion SRGAnalytics.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = SRG;
LastUpgradeCheck = 1150;
LastUpgradeCheck = 1170;
ORGANIZATIONNAME = "SRG SSR";
TargetAttributes = {
08EF593B2221B7B4000E7446 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1150"
LastUpgradeVersion = "1170"
version = "1.3">
<BuildAction
parallelizeBuildables = "NO"
Expand Down
Loading

0 comments on commit bebe797

Please sign in to comment.