From 4a86f9831b92f8eed81fd48a10cb17e60bbfc798 Mon Sep 17 00:00:00 2001 From: GouravSna <38206744+GouravSna@users.noreply.github.com> Date: Thu, 18 Jul 2019 13:10:10 +0530 Subject: [PATCH] FEM-2585 Add support in Youbora to send Youbora Options as Bundle (#29) * - Youbora update to v6.5.1 * - Household Id changes * Youbora upgrade to v6.5.1 * - upgrade version: 6.4.7 --- youboraplugin/build.gradle | 2 +- .../youbora/PKYouboraPlayerAdapter.java | 10 +- .../plugins/youbora/YouboraPlugin.java | 36 ++++-- .../youbora/pluginconfig/YouboraConfig.java | 122 ++++++++++-------- 4 files changed, 98 insertions(+), 72 deletions(-) diff --git a/youboraplugin/build.gradle b/youboraplugin/build.gradle index e76f8cb..6033cb4 100644 --- a/youboraplugin/build.gradle +++ b/youboraplugin/build.gradle @@ -31,7 +31,7 @@ dependencies { implementation 'com.kaltura:playkit-android:dev-SNAPSHOT' //implementation project(":playkit") - api 'com.npaw.youbora:youboralib:6.3.5' + api 'com.npaw.youbora:youboralib:6.4.7' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.1.1' diff --git a/youboraplugin/src/main/java/com/kaltura/playkit/plugins/youbora/PKYouboraPlayerAdapter.java b/youboraplugin/src/main/java/com/kaltura/playkit/plugins/youbora/PKYouboraPlayerAdapter.java index 5c2f96d..3e7495e 100644 --- a/youboraplugin/src/main/java/com/kaltura/playkit/plugins/youbora/PKYouboraPlayerAdapter.java +++ b/youboraplugin/src/main/java/com/kaltura/playkit/plugins/youbora/PKYouboraPlayerAdapter.java @@ -29,7 +29,6 @@ import com.kaltura.playkit.ads.PKAdPluginType; import com.kaltura.playkit.plugins.ads.AdCuePoints; import com.kaltura.playkit.plugins.ads.AdEvent; -import com.kaltura.playkit.plugins.youbora.pluginconfig.YouboraConfig; import com.kaltura.playkit.utils.Consts; import com.npaw.youbora.lib6.YouboraUtil; import com.npaw.youbora.lib6.adapter.PlayerAdapter; @@ -66,13 +65,13 @@ class PKYouboraPlayerAdapter extends PlayerAdapter { private boolean isAdPlaying; private AdCuePoints adCuePoints; - PKYouboraPlayerAdapter(Player player, MessageBus messageBus, PKMediaConfig mediaConfig, YouboraConfig pluginConfig) { + PKYouboraPlayerAdapter(Player player, MessageBus messageBus, PKMediaConfig mediaConfig, String houseHoldId) { super(player); log.d("Start PKYouboraPlayerAdapter"); this.messageBus = messageBus; this.mediaConfig = mediaConfig; updateDurationFromMediaConfig(mediaConfig); - this.houseHoldId = pluginConfig.getHouseHoldId(); + this.houseHoldId = houseHoldId; registerListeners(); } @@ -361,6 +360,7 @@ public String getPlayerName() { @Override public String getHouseholdId() { + log.d("Household Id: " + houseHoldId); return houseHoldId; } @@ -478,8 +478,8 @@ public void setMediaConfig(PKMediaConfig mediaConfig) { } - public void setPluginConfig(YouboraConfig pluginConfig) { - this.houseHoldId = pluginConfig.getHouseHoldId(); + public void setHouseHoldId(String houseHoldId) { + this.houseHoldId = houseHoldId; } public void setLastReportedResource(String lastReportedResource) { diff --git a/youboraplugin/src/main/java/com/kaltura/playkit/plugins/youbora/YouboraPlugin.java b/youboraplugin/src/main/java/com/kaltura/playkit/plugins/youbora/YouboraPlugin.java index 1eac8e7..2f375f1 100644 --- a/youboraplugin/src/main/java/com/kaltura/playkit/plugins/youbora/YouboraPlugin.java +++ b/youboraplugin/src/main/java/com/kaltura/playkit/plugins/youbora/YouboraPlugin.java @@ -1,6 +1,7 @@ package com.kaltura.playkit.plugins.youbora; import android.content.Context; +import android.os.Bundle; import com.google.gson.Gson; import com.google.gson.JsonObject; @@ -12,6 +13,9 @@ import com.kaltura.playkit.PlayerEvent; import com.kaltura.playkit.plugin.youbora.BuildConfig; import com.kaltura.playkit.plugins.youbora.pluginconfig.YouboraConfig; +import com.npaw.youbora.lib6.plugin.Options; + +import static com.kaltura.playkit.plugins.youbora.pluginconfig.YouboraConfig.KEY_HOUSEHOLD_ID; /** * Created by zivilan on 02/11/2016. @@ -24,10 +28,11 @@ public class YouboraPlugin extends PKPlugin { private static PKYouboraAdsAdapter adsManager; private PKMediaConfig mediaConfig; - private YouboraConfig pluginConfig; + private Options pluginConfig; private NPAWPlugin npawPlugin; private Player player; private MessageBus messageBus; + private static String houseHoldId; private boolean isMonitoring = false; private boolean isAdsMonitoring = false; @@ -62,7 +67,7 @@ protected void onLoad(final Player player, Object config, final MessageBus messa this.pluginConfig = parseConfig(config); //YouboraLog.setDebugLevel(YouboraLog.Level.VERBOSE); - npawPlugin = new NPAWPlugin(pluginConfig.getYouboraOptions()); + npawPlugin = new NPAWPlugin(pluginConfig); loadPlugin(); } @@ -79,7 +84,7 @@ private void loadPlugin() { }); messageBus.addListener(this, PlayerEvent.durationChanged, event -> { - log.d("YouboraPlugin DURATION_CHANGE"); + log.d("YouboraPlugin DURATION_CHANGE"); }); messageBus.addListener(this, PlayerEvent.stopped, event -> { @@ -97,16 +102,16 @@ protected void onUpdateMedia(PKMediaConfig mediaConfig) { if (!isMonitoring) { isMonitoring = true; if (pluginManager == null) { - pluginManager = new PKYouboraPlayerAdapter(player, messageBus, mediaConfig, pluginConfig); + pluginManager = new PKYouboraPlayerAdapter(player, messageBus, mediaConfig, houseHoldId); } else { pluginManager.resetPlaybackValues(); pluginManager.registerListeners(); } pluginManager.setMediaConfig(mediaConfig); - pluginManager.setPluginConfig(pluginConfig); + pluginManager.setHouseHoldId(houseHoldId); } - npawPlugin.setOptions(pluginConfig.getYouboraOptions()); + npawPlugin.setOptions(pluginConfig); npawPlugin.setAdapter(pluginManager); if (!isAdsMonitoring) { @@ -127,10 +132,11 @@ protected void onUpdateConfig(Object config) { if (config == null) { return; } + this.pluginConfig = parseConfig(config); // Refresh options with updated media if (npawPlugin != null && pluginConfig != null) { - npawPlugin.setOptions(pluginConfig.getYouboraOptions()); + npawPlugin.setOptions(pluginConfig); } if (pluginManager == null) { @@ -200,13 +206,19 @@ private void stopMonitoring() { } } - private static YouboraConfig parseConfig(Object config) { + private static Options parseConfig(Object config) { if (config instanceof YouboraConfig) { - return ((YouboraConfig) config); - + houseHoldId = ((YouboraConfig) config).getHouseHoldId(); + return ((YouboraConfig) config).getYouboraOptions(); } else if (config instanceof JsonObject) { - return new Gson().fromJson(((JsonObject) config), YouboraConfig.class); + YouboraConfig youboraConfig = new Gson().fromJson(((JsonObject) config), YouboraConfig.class); + houseHoldId = youboraConfig.getHouseHoldId(); + return youboraConfig.getYouboraOptions(); + } else if (config instanceof Bundle) { + Options options = new Options((Bundle) config); + houseHoldId = ((Bundle) config).getString(KEY_HOUSEHOLD_ID); + return options; } return null; } -} \ No newline at end of file +} diff --git a/youboraplugin/src/main/java/com/kaltura/playkit/plugins/youbora/pluginconfig/YouboraConfig.java b/youboraplugin/src/main/java/com/kaltura/playkit/plugins/youbora/pluginconfig/YouboraConfig.java index a17e567..1af1ce5 100644 --- a/youboraplugin/src/main/java/com/kaltura/playkit/plugins/youbora/pluginconfig/YouboraConfig.java +++ b/youboraplugin/src/main/java/com/kaltura/playkit/plugins/youbora/pluginconfig/YouboraConfig.java @@ -11,6 +11,24 @@ public class YouboraConfig { + // Kaltura Youbora Keys for Bundle + + public static final String KEY_HOUSEHOLD_ID = "houseHoldId"; + + public static final String KEY_CONTENT_METADATA_YEAR = "year"; + + public static final String KEY_CONTENT_METADATA_CAST = "cast"; + + public static final String KEY_CONTENT_METADATA_DIRECTOR = "director"; + + public static final String KEY_CONTENT_METADATA_OWNER = "owner"; + + public static final String KEY_CONTENT_METADATA_PARENTAL = "parental"; + + public static final String KEY_CONTENT_METADATA_RATING = "rating"; + + public static final String KEY_CONTENT_METADATA_QUALITY = "quality"; + private String accountCode; private String username; @@ -19,7 +37,7 @@ public class YouboraConfig { private String houseHoldId; // which device is used to play - private boolean obfuscateIP; // ip in dahsbord will be encrytpted + private boolean obfuscateIP; // ip in dashboard will be encrypted private boolean httpSecure = true; // youbora events will be sent via https @@ -124,97 +142,93 @@ public void setExtraParams(ExtraParams extraParams) { public Options getYouboraOptions() { - Options youboraLocalConfig = new Options(); + Options youboraOptions = new Options(); + + youboraOptions.setAccountCode(accountCode); + youboraOptions.setUsername(username); + youboraOptions.setUserType(userType); + youboraOptions.setNetworkObfuscateIp(obfuscateIP); + youboraOptions.setHttpSecure(httpSecure); - youboraLocalConfig.setAccountCode(accountCode); - youboraLocalConfig.setUsername(username); - youboraLocalConfig.setUserType(userType); - youboraLocalConfig.setNetworkObfuscateIp(obfuscateIP); - youboraLocalConfig.setHttpSecure(httpSecure); + youboraOptions.setParseHls(false); + youboraOptions.setParseCdnNode(false); - youboraLocalConfig.setParseHls(false); - youboraLocalConfig.setParseCdnNode(false); + youboraOptions.setDeviceCode(null); //TODO // List of device codes http://mapi.youbora.com:8081/devices + youboraOptions.setContentCdn(null); - youboraLocalConfig.setDeviceCode(null); //TODO // List of device codes http://mapi.youbora.com:8081/devices - youboraLocalConfig.setContentCdn(null); if (device != null) { if (device.getDeviceCode() != null) { //Generic Data by code see in Device class what Codes are available - youboraLocalConfig.setDeviceCode(device.getDeviceCode()); + youboraOptions.setDeviceCode(device.getDeviceCode()); } // Specific Data if (device.getModel() != null) { - youboraLocalConfig.setDeviceModel(device.getModel()); + youboraOptions.setDeviceModel(device.getModel()); } if (device.getBrand() != null) { - youboraLocalConfig.setDeviceBrand(device.getBrand()); + youboraOptions.setDeviceBrand(device.getBrand()); } if (device.getType() != null) { - youboraLocalConfig.setDeviceType(device.getType()); + youboraOptions.setDeviceType(device.getType()); } if (device.getOsName() != null) { - youboraLocalConfig.setDeviceOsName(device.getOsName()); + youboraOptions.setDeviceOsName(device.getOsName()); } if (device.getOsVersion() != null) { - youboraLocalConfig.setDeviceOsVersion(device.getOsVersion()); + youboraOptions.setDeviceOsVersion(device.getOsVersion()); } } if (media != null) { - youboraLocalConfig.setContentIsLive(media.getIsLive()); - youboraLocalConfig.setContentIsLiveNoSeek((media.getIsDVR() != null) ? !media.getIsDVR() : null); - youboraLocalConfig.setContentDuration(media.getDuration()); - youboraLocalConfig.setContentTitle(media.getTitle()); - youboraLocalConfig.setContentTitle2(media.getTitle2()); - youboraLocalConfig.setContentTransactionCode(media.getTransactionCode()); + youboraOptions.setContentIsLive(media.getIsLive()); + youboraOptions.setContentIsLiveNoSeek((media.getIsDVR() != null) ? !media.getIsDVR() : null); + youboraOptions.setContentDuration(media.getDuration()); + youboraOptions.setContentTitle(media.getTitle()); + youboraOptions.setProgram(media.getTitle2()); + youboraOptions.setContentTransactionCode(media.getTransactionCode()); } - - youboraLocalConfig.setAdResource(null); + youboraOptions.setAdResource(null); if (ads != null) { - youboraLocalConfig.setAdCampaign(ads.getCampaign()); + youboraOptions.setAdCampaign(ads.getCampaign()); } - youboraLocalConfig.setAdTitle(""); - - - - youboraLocalConfig.setContentMetadata(getPropertiesBundle()); + youboraOptions.setAdTitle(""); + youboraOptions.setContentMetadata(getPropertiesBundle()); if (ads != null && ads.getExtraParams() != null) { - youboraLocalConfig.setAdExtraparam1(ads.getExtraParams().getParam1()); - youboraLocalConfig.setAdExtraparam2(ads.getExtraParams().getParam2()); - youboraLocalConfig.setAdExtraparam3(ads.getExtraParams().getParam3()); - youboraLocalConfig.setAdExtraparam4(ads.getExtraParams().getParam4()); - youboraLocalConfig.setAdExtraparam5(ads.getExtraParams().getParam5()); - youboraLocalConfig.setAdExtraparam6(ads.getExtraParams().getParam6()); - youboraLocalConfig.setAdExtraparam7(ads.getExtraParams().getParam7()); - youboraLocalConfig.setAdExtraparam8(ads.getExtraParams().getParam8()); - youboraLocalConfig.setAdExtraparam9(ads.getExtraParams().getParam9()); - youboraLocalConfig.setAdExtraparam10(ads.getExtraParams().getParam10()); + youboraOptions.setAdCustomDimension1(ads.getExtraParams().getParam1()); + youboraOptions.setAdCustomDimension2(ads.getExtraParams().getParam2()); + youboraOptions.setAdCustomDimension3(ads.getExtraParams().getParam3()); + youboraOptions.setAdCustomDimension4(ads.getExtraParams().getParam4()); + youboraOptions.setAdCustomDimension5(ads.getExtraParams().getParam5()); + youboraOptions.setAdCustomDimension6(ads.getExtraParams().getParam6()); + youboraOptions.setAdCustomDimension7(ads.getExtraParams().getParam7()); + youboraOptions.setAdCustomDimension8(ads.getExtraParams().getParam8()); + youboraOptions.setAdCustomDimension9(ads.getExtraParams().getParam9()); + youboraOptions.setAdCustomDimension10(ads.getExtraParams().getParam10()); } if (extraParams != null) { - youboraLocalConfig.setExtraparam1(extraParams.getParam1()); - youboraLocalConfig.setExtraparam2(extraParams.getParam2()); - youboraLocalConfig.setExtraparam3(extraParams.getParam3()); - youboraLocalConfig.setExtraparam4(extraParams.getParam4()); - youboraLocalConfig.setExtraparam5(extraParams.getParam5()); - youboraLocalConfig.setExtraparam6(extraParams.getParam6()); - youboraLocalConfig.setExtraparam7(extraParams.getParam7()); - youboraLocalConfig.setExtraparam8(extraParams.getParam8()); - youboraLocalConfig.setExtraparam9(extraParams.getParam9()); - youboraLocalConfig.setExtraparam10(extraParams.getParam10()); - } - return youboraLocalConfig; + youboraOptions.setContentCustomDimension1(extraParams.getParam1()); + youboraOptions.setContentCustomDimension2(extraParams.getParam2()); + youboraOptions.setContentCustomDimension3(extraParams.getParam3()); + youboraOptions.setContentCustomDimension4(extraParams.getParam4()); + youboraOptions.setContentCustomDimension5(extraParams.getParam5()); + youboraOptions.setContentCustomDimension6(extraParams.getParam6()); + youboraOptions.setContentCustomDimension7(extraParams.getParam7()); + youboraOptions.setContentCustomDimension8(extraParams.getParam8()); + youboraOptions.setContentCustomDimension9(extraParams.getParam9()); + youboraOptions.setContentCustomDimension10(extraParams.getParam10()); + } + return youboraOptions; } - private Bundle getPropertiesBundle() { if (getProperties() == null) { return new Bundle();