From 7c88312590eba245abf04aa69d4e8a48e57f9b3c Mon Sep 17 00:00:00 2001 From: Vehovec Date: Thu, 16 May 2024 17:02:29 +0200 Subject: [PATCH 1/5] Add MetadataOverrides.additionalStandardTags --- .../conviva/ContentMetadataBuilder.java | 42 ++++++++++++------- .../analytics/conviva/MetadataOverrides.java | 13 ++++++ 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/conviva/src/main/java/com/bitmovin/analytics/conviva/ContentMetadataBuilder.java b/conviva/src/main/java/com/bitmovin/analytics/conviva/ContentMetadataBuilder.java index ec9d021..e4d4b6c 100644 --- a/conviva/src/main/java/com/bitmovin/analytics/conviva/ContentMetadataBuilder.java +++ b/conviva/src/main/java/com/bitmovin/analytics/conviva/ContentMetadataBuilder.java @@ -1,10 +1,7 @@ package com.bitmovin.analytics.conviva; import android.util.Log; - -import com.conviva.api.ContentMetadata; import com.conviva.sdk.ConvivaSdkConstants; - import org.apache.commons.lang3.ObjectUtils; import java.util.HashMap; @@ -47,7 +44,7 @@ public void setPlaybackStarted(boolean value) { public Map build() { if (!playbackStarted) { - if(!contentInfo.containsKey(ConvivaSdkConstants.ASSET_NAME)) { + if (!contentInfo.containsKey(ConvivaSdkConstants.ASSET_NAME)) { contentInfo.put(ConvivaSdkConstants.ASSET_NAME, getAssetName()); } @@ -60,34 +57,35 @@ public Map build() { contentInfo.put(ConvivaSdkConstants.IS_LIVE, isLive); String applicationName = ObjectUtils.defaultIfNull( - metadataOverrides.getApplicationName(), - metadata.getApplicationName()); + metadataOverrides.getApplicationName(), + metadata.getApplicationName()); contentInfo.put(ConvivaSdkConstants.PLAYER_NAME, applicationName); Integer duration = ObjectUtils.defaultIfNull( - metadataOverrides.getDuration(), - metadata.getDuration()); + metadataOverrides.getDuration(), + metadata.getDuration()); Integer convivaDuration = duration != null ? duration : -1; - if(convivaDuration > 0) { + if (convivaDuration > 0) { contentInfo.put(ConvivaSdkConstants.DURATION, convivaDuration); } contentInfo.putAll(getCustom()); + contentInfo.putAll(getAdditionalStandardTags()); } Integer frameRate = ObjectUtils.defaultIfNull( metadataOverrides.getEncodedFrameRate(), metadata.getEncodedFrameRate()); contentInfo.put(ConvivaSdkConstants.ENCODED_FRAMERATE, frameRate != null ? frameRate : -1); - + String defaultResource = ObjectUtils.defaultIfNull( - metadataOverrides.getDefaultResource(), - metadata.getDefaultResource()); + metadataOverrides.getDefaultResource(), + metadata.getDefaultResource()); contentInfo.put(ConvivaSdkConstants.DEFAULT_RESOURCE, defaultResource); String streamUrl = ObjectUtils.defaultIfNull( - metadataOverrides.getStreamUrl(), - metadata.getStreamUrl()); + metadataOverrides.getStreamUrl(), + metadata.getStreamUrl()); contentInfo.put(ConvivaSdkConstants.STREAM_URL, streamUrl); return contentInfo; @@ -133,6 +131,22 @@ public Map getCustom() { return customs; } + public void setAdditionalStandardTags(Map newValue) { + metadata.setAdditionalStandardTags(newValue); + } + + public Map getAdditionalStandardTags() { + // merge internal and override metadata key-value pairs + // with override values having higher precedence + Map internalStandardTags = metadata.getAdditionalStandardTags(); + Map additionalStandardTags = internalStandardTags != null ? internalStandardTags : new HashMap<>(); + Map additionalStandardTagsOverrides = metadataOverrides.getAdditionalStandardTags(); + if (additionalStandardTagsOverrides != null) { + additionalStandardTags.putAll(additionalStandardTagsOverrides); + } + return additionalStandardTags; + } + public void setDuration(Integer newValue) { metadata.setDuration(newValue); } diff --git a/conviva/src/main/java/com/bitmovin/analytics/conviva/MetadataOverrides.java b/conviva/src/main/java/com/bitmovin/analytics/conviva/MetadataOverrides.java index f439fea..e60cf78 100644 --- a/conviva/src/main/java/com/bitmovin/analytics/conviva/MetadataOverrides.java +++ b/conviva/src/main/java/com/bitmovin/analytics/conviva/MetadataOverrides.java @@ -14,6 +14,7 @@ public class MetadataOverrides { private String applicationName; private Map custom; private Integer duration; + private Map additionalStandardTags; // Dynamic private Integer encodedFrameRate; @@ -68,6 +69,18 @@ public void setDuration(Integer duration) { this.duration = duration; } + public Map getAdditionalStandardTags() { + return additionalStandardTags; + } + + /** + * Standard Conviva tags that aren't covered by the other fields in this class. + * List of tags can be found here: Pre-defined Video and Content Metadata + */ + public void setAdditionalStandardTags(Map additionalStandardTags) { + this.additionalStandardTags = additionalStandardTags; + } + public Integer getEncodedFrameRate() { return encodedFrameRate; } From 250986e4530f6b3e3d88ca4c7f4567fdd1b2f326 Mon Sep 17 00:00:00 2001 From: Vehovec Date: Thu, 16 May 2024 17:25:30 +0200 Subject: [PATCH 2/5] Update README.md --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2110580..27dd9ec 100644 --- a/README.md +++ b/README.md @@ -95,15 +95,20 @@ convivaConfig.setCustomData(customMapOfKeyValuePairs); #### Content Metadata handling -If you want to override some content metadata attributes you can do so by adding the following: +If you want to override some content metadata attributes or track additional custom or standard tags you can do so by adding the following: ```java MetadataOverrides metadata = new MetadataOverrides(); metadata.setApplicationName("Bitmovin Android Conviva integration example app"); metadata.setViewerId("awesomeViewerId"); -Map customInternTags = new HashMap<>(); -customInternTags.put("contentType", "Episode"); -metadata.setCustom(customInternTags); + +Map customTags = new HashMap<>(); +customTags.put("custom_tag", "value"); +metadata.setCustom(customTags); + +Map standardTags = new HashMap<>(); +standardTags.put("c3.cm.contentType", "VOD"); +metadata.setAdditionalStandardTags(standardTags); // … // Initialize ConvivaAnalyticsIntegration From 8ea4ab0161d00d44259279e8b987b429b3778134 Mon Sep 17 00:00:00 2001 From: Vehovec Date: Fri, 17 May 2024 10:43:05 +0200 Subject: [PATCH 3/5] Remove outdated API from readme --- README.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 27dd9ec..adb3e4a 100644 --- a/README.md +++ b/README.md @@ -68,10 +68,8 @@ The following example create a ConvivaAnalyticsIntegration object and attaches a #### Basic Conviva Reporting ```java -// Create your ConvivaConfiguration object -ConvivaConfiguration convivaConfig = new ConvivaConfig( - "ConvivaExample_BitmovinPlayer", - "ViewerId1"); +// Create your ConvivaConfig object +ConvivaConfig convivaConfig = new ConvivaConfig(); // Create ConvivaAnalyticsIntegration convivaAnalyticsIntegration = new ConvivaAnalyticsIntegration(bitmovinPlayer, "YOUR-CUSTOMER-KEY", getApplicationContext(), convivaConfig); @@ -87,9 +85,8 @@ bitmovinPlayer.load(source); #### Optional Configuration Parameters ```java - +convivaConfig.setGatewayUrl("YOUR_DEBUG_GATEWAY_URL"); convivaConfig.setDebugLoggingEnabled(true); -convivaConfig.setCustomData(customMapOfKeyValuePairs); ``` @@ -102,14 +99,14 @@ MetadataOverrides metadata = new MetadataOverrides(); metadata.setApplicationName("Bitmovin Android Conviva integration example app"); metadata.setViewerId("awesomeViewerId"); -Map customTags = new HashMap<>(); -customTags.put("custom_tag", "value"); -metadata.setCustom(customTags); - Map standardTags = new HashMap<>(); standardTags.put("c3.cm.contentType", "VOD"); metadata.setAdditionalStandardTags(standardTags); +Map customTags = new HashMap<>(); +customTags.put("custom_tag", "value"); +metadata.setCustom(customTags); + // … // Initialize ConvivaAnalyticsIntegration // … From 3d078771859f2b17019a5c4f43f1d56d6c80c727 Mon Sep 17 00:00:00 2001 From: Vehovec Date: Fri, 17 May 2024 10:48:38 +0200 Subject: [PATCH 4/5] Update example app to showcase the use of additionalStandardTags --- .../convivaanalyticsexample/MainActivity.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ConvivaExampleApp/src/main/java/com/bitmovin/analytics/convivaanalyticsexample/MainActivity.java b/ConvivaExampleApp/src/main/java/com/bitmovin/analytics/convivaanalyticsexample/MainActivity.java index 79ddf68..28b0616 100644 --- a/ConvivaExampleApp/src/main/java/com/bitmovin/analytics/convivaanalyticsexample/MainActivity.java +++ b/ConvivaExampleApp/src/main/java/com/bitmovin/analytics/convivaanalyticsexample/MainActivity.java @@ -87,18 +87,22 @@ protected void setupBitmovinPlayer() { getApplicationContext(), convivaConfig); - MetadataOverrides metadata = new MetadataOverrides(); metadata.setApplicationName("Bitmovin Android Conviva integration example app"); metadata.setViewerId("awesomeViewerId"); - Map customInternTags = new HashMap<>(); - customInternTags.put("contentType", "Episode"); - metadata.setCustom(customInternTags); + + Map standardTags = new HashMap<>(); + standardTags.put("c3.cm.contentType", "VOD"); + metadata.setAdditionalStandardTags(standardTags); + + Map customTags = new HashMap<>(); + customTags.put("custom_tag", "Episode"); + metadata.setCustom(customTags); + convivaAnalyticsIntegration.updateContentMetadata(metadata); // load source using the created source configuration bitmovinPlayer.load(buildSourceConfiguration()); - } private PlayerConfig buildPlayerConfiguration() { @@ -147,7 +151,7 @@ protected void onPause() { } @Override - protected void onDestroy() { + protected void onDestroy() { bitmovinPlayerView.onDestroy(); convivaAnalyticsIntegration.release(); super.onDestroy(); From 427c50719e01a9264f2669385413b87e1b43b0b4 Mon Sep 17 00:00:00 2001 From: Vehovec Date: Fri, 17 May 2024 10:58:45 +0200 Subject: [PATCH 5/5] Add a changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 131eafe..ea81777 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - New `TimeChanged` callback for reporting Playhead to conviva playback metric. Calculates Live and Vod playback for report. +- New `MetadataOverrides.setAdditionalStandardTags` that allows to set additional standard tags for the session. The List of tags can be found here: [Pre-defined Video and Content Metadata](https://pulse.conviva.com/learning-center/content/sensor_developer_center/sensor_integration/android/android_stream_sensor.htm#PredefinedVideoandContentMetadata) ### Changed - Updated conviva-core to 4.0.35