Skip to content

Commit

Permalink
Merge pull request #56 from bitmovin/PA-2389/placeholder-support-addi…
Browse files Browse the repository at this point in the history
…tional-device-content-tags-in-conviva-integration

Support additional standard device and content tags
  • Loading branch information
zigavehovec authored May 21, 2024
2 parents 6d3b260 + 427c507 commit 7486792
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> customInternTags = new HashMap<>();
customInternTags.put("contentType", "Episode");
metadata.setCustom(customInternTags);

Map<String, Object> standardTags = new HashMap<>();
standardTags.put("c3.cm.contentType", "VOD");
metadata.setAdditionalStandardTags(standardTags);

Map<String, String> 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() {
Expand Down Expand Up @@ -147,7 +151,7 @@ protected void onPause() {
}

@Override
protected void onDestroy() {
protected void onDestroy() {
bitmovinPlayerView.onDestroy();
convivaAnalyticsIntegration.release();
super.onDestroy();
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<String, String> customInternTags = new HashMap<>();
customInternTags.put("contentType", "Episode");
metadata.setCustom(customInternTags);

Map<String, Object> standardTags = new HashMap<>();
standardTags.put("c3.cm.contentType", "VOD");
metadata.setAdditionalStandardTags(standardTags);

Map<String, String> customTags = new HashMap<>();
customTags.put("custom_tag", "value");
metadata.setCustom(customTags);

//
// Initialize ConvivaAnalyticsIntegration
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -47,7 +44,7 @@ public void setPlaybackStarted(boolean value) {
public Map<String, Object> build() {

if (!playbackStarted) {
if(!contentInfo.containsKey(ConvivaSdkConstants.ASSET_NAME)) {
if (!contentInfo.containsKey(ConvivaSdkConstants.ASSET_NAME)) {
contentInfo.put(ConvivaSdkConstants.ASSET_NAME, getAssetName());
}

Expand All @@ -60,34 +57,35 @@ public Map<String, Object> 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;
Expand Down Expand Up @@ -133,6 +131,22 @@ public Map<String, String> getCustom() {
return customs;
}

public void setAdditionalStandardTags(Map<String, Object> newValue) {
metadata.setAdditionalStandardTags(newValue);
}

public Map<String, Object> getAdditionalStandardTags() {
// merge internal and override metadata key-value pairs
// with override values having higher precedence
Map<String, Object> internalStandardTags = metadata.getAdditionalStandardTags();
Map<String, Object> additionalStandardTags = internalStandardTags != null ? internalStandardTags : new HashMap<>();
Map<String, Object> additionalStandardTagsOverrides = metadataOverrides.getAdditionalStandardTags();
if (additionalStandardTagsOverrides != null) {
additionalStandardTags.putAll(additionalStandardTagsOverrides);
}
return additionalStandardTags;
}

public void setDuration(Integer newValue) {
metadata.setDuration(newValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class MetadataOverrides {
private String applicationName;
private Map<String, String> custom;
private Integer duration;
private Map<String, Object> additionalStandardTags;

// Dynamic
private Integer encodedFrameRate;
Expand Down Expand Up @@ -68,6 +69,18 @@ public void setDuration(Integer duration) {
this.duration = duration;
}

public Map<String, Object> getAdditionalStandardTags() {
return additionalStandardTags;
}

/**
* Standard Conviva tags that aren't covered by the other fields in this class.
* List of tags can be found here: <a href="https://pulse.conviva.com/learning-center/content/sensor_developer_center/sensor_integration/android/android_stream_sensor.htm#PredefinedVideoandContentMetadata">Pre-defined Video and Content Metadata</a>
*/
public void setAdditionalStandardTags(Map<String, Object> additionalStandardTags) {
this.additionalStandardTags = additionalStandardTags;
}

public Integer getEncodedFrameRate() {
return encodedFrameRate;
}
Expand Down

0 comments on commit 7486792

Please sign in to comment.