Skip to content

Commit

Permalink
FEC-12389 - upgrade bp ver 04.01.02.12bb25b (#25)
Browse files Browse the repository at this point in the history
* upgrade bp ver 04.01.02.12bb25b
add missing plugin configs

adParameters;
customParameters;
options( stringOptions, integerOptions, booleanOptions)
  • Loading branch information
giladna authored Jul 25, 2022
1 parent fcf8326 commit f38eda0
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 7 deletions.
2 changes: 1 addition & 1 deletion broadpeakplugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {
// TODO: when tvplayer is released, replace this.
api 'com.kaltura:kaltura-player-android:develop-SNAPSHOT'
//api project(":tvplayer")
api 'tv.broadpeak.smartlib:smartlib-kaltura:04.00.01.50f043'
api 'tv.broadpeak.smartlib:smartlib-kaltura:04.01.02.12bb25b'
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.kaltura.playkit.plugins.broadpeak;

import java.util.Map;

/**
* Created by alex_lytvynenko on 04.11.2020.
*/
Expand All @@ -9,6 +11,15 @@ public class BroadpeakConfig {
private String nanoCDNHost;
private String broadpeakDomainNames;
private String uuid;
private String deviceType;
private String userAgent;
private Integer nanoCDNResolvingRetryDelay; // In miliseconds
private Boolean nanoCDNHttpsEnabled;

private String adCustomReference;
private Map<String, String> adParameters;
private Map<String, String> customParameters;
private Map<Integer, Object> options;

public String getAnalyticsAddress() {
return analyticsAddress;
Expand Down Expand Up @@ -46,6 +57,83 @@ public BroadpeakConfig setUUID(String uuid) {
return this;
}

public String getDeviceType() {
return deviceType;
}

public BroadpeakConfig setDeviceType(String deviceType) {
this.deviceType = deviceType;
return this;
}

public String getUserAgent() {
return userAgent;
}

public BroadpeakConfig setUserAgent(String userAgent) {
this.userAgent = userAgent;
return this;
}

public Integer getNanoCDNResolvingRetryDelay() {
return nanoCDNResolvingRetryDelay;
}

/**
* Set the delay to resolve the nanoCDN. Default is 60000ms.
* Set the value in milliseconds, the minimum value is 1000.
* Set -1 to disable the retry mechanism
*/
public BroadpeakConfig setNanoCDNResolvingRetryDelay(Integer nanoCDNResolvingRetryDelay) {
this.nanoCDNResolvingRetryDelay = nanoCDNResolvingRetryDelay;
return this;
}

public Boolean getNanoCDNHttpsEnabled() {
return nanoCDNHttpsEnabled;
}

public BroadpeakConfig setNanoCDNHttpsEnabled(Boolean nanoCDNHttpsEnabled) {
this.nanoCDNHttpsEnabled = nanoCDNHttpsEnabled;
return this;
}

public String getAdCustomReference() {
return adCustomReference;
}

public BroadpeakConfig setAdCustomReference(String adCustomReference) {
this.adCustomReference = adCustomReference;
return this;
}

public Map<String, String> getAdParameters() {
return adParameters;
}

public BroadpeakConfig setAdParameters(Map<String, String> adParameters) {
this.adParameters = adParameters;
return this;
}

public Map<String, String> getCustomParameters() {
return customParameters;
}

public BroadpeakConfig setCustomParameters(Map<String, String> customParameters) {
this.customParameters = customParameters;
return this;
}

public Map<Integer, Object> getOptions() {
return options;
}

public BroadpeakConfig setOptions(Map<Integer, Object> options) {
this.options = options;
return this;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -59,15 +147,40 @@ public boolean equals(Object o) {
return false;
if (getBroadpeakDomainNames() != null ? !getBroadpeakDomainNames().equals(that.getBroadpeakDomainNames()) : that.getBroadpeakDomainNames() != null)
return false;
return getUUID() != null ? getUUID().equals(that.getUUID()) : that.getUUID() == null;
if (getUUID() != null ? !getUUID().equals(that.getUUID()) : that.getUUID() != null)
return false;
if (getDeviceType() != null ? !getDeviceType().equals(that.getDeviceType()) : that.getDeviceType() != null)
return false;
if (getUserAgent() != null ? !getUserAgent().equals(that.getUserAgent()) : that.getUserAgent() != null)
return false;
if (getNanoCDNResolvingRetryDelay() != null ? !getNanoCDNResolvingRetryDelay().equals(that.getNanoCDNResolvingRetryDelay()) : that.getNanoCDNResolvingRetryDelay() != null)
return false;
if (getNanoCDNHttpsEnabled() != null ? !getNanoCDNHttpsEnabled().equals(that.getNanoCDNHttpsEnabled()) : that.getNanoCDNHttpsEnabled() != null)
return false;
if (getAdCustomReference() != null ? !getAdCustomReference().equals(that.getAdCustomReference()) : that.getAdCustomReference() != null)
return false;
if (getAdParameters() != null ? !getAdParameters().equals(that.getAdParameters()) : that.getAdParameters() != null)
return false;
if (getCustomParameters() != null ? !getCustomParameters().equals(that.getCustomParameters()) : that.getCustomParameters() != null)
return false;
return getOptions() != null ? getOptions().equals(that.getOptions()) : that.getOptions() == null;
}

@Override
public int hashCode() {
int result = getAnalyticsAddress() != null ? getAnalyticsAddress().hashCode() : 0;
result = 31 * result + (getNanoCDNHost() != null ? getNanoCDNHost().hashCode() : 0);
result = 31 * result + (getBroadpeakDomainNames() != null ? getBroadpeakDomainNames().hashCode() : 0);
result = 31 * result + (getUUID() != null ? getUUID().hashCode() : 0);
result = 31 * result + (getUUID() != null ? getUUID() .hashCode() : 0);
result = 31 * result + (getDeviceType() != null ? getDeviceType().hashCode() : 0);
result = 31 * result + (getUserAgent() != null ? getUserAgent().hashCode() : 0);
result = 31 * result + (getNanoCDNResolvingRetryDelay() != null ? getNanoCDNResolvingRetryDelay().hashCode() : 0);
result = 31 * result + (getNanoCDNHttpsEnabled() != null ? getNanoCDNHttpsEnabled().hashCode() : 0);
result = 31 * result + (getAdCustomReference() != null ? getAdCustomReference().hashCode() : 0);
result = 31 * result + (getAdParameters() != null ? getAdParameters().hashCode() : 0);
result = 31 * result + (getCustomParameters() != null ? getCustomParameters().hashCode() : 0);
result = 31 * result + (getOptions() != null ? getOptions().hashCode() : 0);
return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import com.kaltura.playkit.PlayerEvent;
import com.kaltura.tvplayer.PKMediaEntryInterceptor;

import java.util.Map;

import tv.broadpeak.smartlib.SmartLib;
import tv.broadpeak.smartlib.session.streaming.StreamingSession;
import tv.broadpeak.smartlib.session.streaming.StreamingSessionResult;
Expand Down Expand Up @@ -73,10 +75,8 @@ protected void onLoad(final Player player, Object config, final MessageBus messa
bpConfig.getNanoCDNHost(),
bpConfig.getBroadpeakDomainNames());

if (!TextUtils.isEmpty(bpConfig.getUUID())) {
SmartLib.getInstance().setUUID(bpConfig.getUUID());
}

addGeneralConfig(bpConfig);

this.player = player;
this.messageBus = messageBus;
this.context = context;
Expand All @@ -90,6 +90,28 @@ protected void onLoad(final Player player, Object config, final MessageBus messa
});
}

private void addGeneralConfig(BroadpeakConfig bpConfig) {
if (!TextUtils.isEmpty(bpConfig.getUUID())) {
SmartLib.getInstance().setUUID(bpConfig.getUUID());
}

if (!TextUtils.isEmpty(bpConfig.getDeviceType())) {
SmartLib.getInstance().setDeviceType(bpConfig.getDeviceType());
}

if (!TextUtils.isEmpty(bpConfig.getUserAgent())) {
SmartLib.getInstance().setUserAgent(bpConfig.getUserAgent());
}

if (bpConfig.getNanoCDNResolvingRetryDelay() != null) {
SmartLib.getInstance().setNanoCDNResolvingRetryDelay(bpConfig.getNanoCDNResolvingRetryDelay());
}

if (bpConfig.getNanoCDNHttpsEnabled() != null) {
SmartLib.getInstance().setNanoCDNHttpsEnabled(bpConfig.getNanoCDNHttpsEnabled());
}
}

@Override
protected void onUpdateMedia(PKMediaConfig mediaConfig) {
log.d("Start onUpdateMedia");
Expand Down Expand Up @@ -126,6 +148,8 @@ private void restartSmartLib(BroadpeakConfig bpConfig) {
bpConfig.getAnalyticsAddress(),
bpConfig.getNanoCDNHost(),
bpConfig.getBroadpeakDomainNames());

addGeneralConfig(bpConfig);
}
}

Expand Down Expand Up @@ -180,7 +204,10 @@ public void apply(PKMediaEntry mediaEntry, PKMediaEntryInterceptor.Listener list
sendBroadpeakErrorEvent(errorCode, errorMessage);
return;
}

addSessionConfig();
session.attachPlayer(player, messageBus);

StreamingSessionResult result = session.getURL(source.getUrl());
if (result != null && !result.isError()) {
sendSourceUrlSwitchedEvent(source, result);
Expand Down Expand Up @@ -208,6 +235,42 @@ public void apply(PKMediaEntry mediaEntry, PKMediaEntryInterceptor.Listener list
listener.onComplete();
}

private void addSessionConfig() {
if (!TextUtils.isEmpty(config.getAdCustomReference())) {
session.setAdCustomReference(config.getAdCustomReference());
}

if (config.getAdParameters() != null) {
for (Map.Entry<String, String> entry : config.getAdParameters().entrySet()) {
if (entry != null && entry.getKey() != null) {
session.setAdParameter(entry.getKey(), entry.getValue());
}
}
}

if (config.getCustomParameters() != null) {
for (Map.Entry<String, String> entry : config.getCustomParameters().entrySet()) {
if (entry != null && entry.getKey() != null) {
session.setCustomParameter(entry.getKey(), entry.getValue());
}
}
}

if (config.getOptions() != null) {
for (Map.Entry<Integer, Object> entry : config.getOptions().entrySet()) {
if (entry != null && entry.getKey() != null) {
if (entry.getValue() instanceof Integer) {
session.setOption(entry.getKey(), (int) entry.getValue());
} else if (entry.getValue() instanceof Boolean) {
session.setOption(entry.getKey(), (boolean) entry.getValue());
} else if (entry.getValue() instanceof String) {
session.setOption(entry.getKey(), entry.getValue().toString());
}
}
}
}
}

private void sendSourceUrlSwitchedEvent(PKMediaSource source, StreamingSessionResult result) {
String originalUrl = source.getUrl();
String updatedUrl = result.getURL();
Expand Down

0 comments on commit f38eda0

Please sign in to comment.