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 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(); diff --git a/README.md b/README.md index 2110580..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,23 +85,27 @@ bitmovinPlayer.load(source); #### Optional Configuration Parameters ```java - +convivaConfig.setGatewayUrl("YOUR_DEBUG_GATEWAY_URL"); convivaConfig.setDebugLoggingEnabled(true); -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 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 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; }