From 4f927487708abefba6c2d2219c73651dfb722180 Mon Sep 17 00:00:00 2001 From: Gilad Nadav Date: Tue, 4 Apr 2017 10:45:02 +0300 Subject: [PATCH] Fem 1317 - support enrtyId as config and get sessionId from player in KalturaStats KalturaLiveStats Plugnis (#203) * add enrtyId as configuration for KalturaStatsPlugin * support entryId in KlaturaStatsLivePlugin instead of media getId * use real playerSessionId add default value to entryId if not defined in the config stage * add space * remove player null check --- .../kaltura/playkit/plugins/KalturaLiveStatsPlugin.java | 7 ++++--- .../com/kaltura/playkit/plugins/KalturaStatsPlugin.java | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaLiveStatsPlugin.java b/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaLiveStatsPlugin.java index 1d4c9b2b5..b4d9c4488 100644 --- a/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaLiveStatsPlugin.java +++ b/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaLiveStatsPlugin.java @@ -78,7 +78,7 @@ public PKPlugin newInstance() { @Override public void warmUp(Context context) { - + } }; @@ -207,15 +207,16 @@ private void stopLiveEvents() { } private void sendLiveEvent(final long bufferTime) { - String sessionId = pluginConfig.has("sessionId") ? pluginConfig.getAsJsonPrimitive("sessionId").getAsString() : ""; + String sessionId = (player.getSessionId() != null) ? player.getSessionId().toString() : ""; String baseUrl = pluginConfig.has("baseUrl") ? pluginConfig.getAsJsonPrimitive("baseUrl").getAsString() : BASE_URL; int partnerId = pluginConfig.has("partnerId") ? pluginConfig.getAsJsonPrimitive("partnerId").getAsInt() : 0; + String entryId = pluginConfig.has("entryId") ? pluginConfig.getAsJsonPrimitive("entryId").getAsString() : mediaConfig.getMediaEntry().getId(); // Parameters for the request - // String baseUrl, int partnerId, int eventType, int eventIndex, int bufferTime, int bitrate, // String sessionId, String startTime, String entryId, boolean isLive, String referrer RequestBuilder requestBuilder = LiveStatsService.sendLiveStatsEvent(baseUrl, partnerId, isLive ? 1 : 2, eventIdx++, bufferTime, - lastReportedBitrate, sessionId, mediaConfig.getStartPosition(), mediaConfig.getMediaEntry().getId(), isLive, PlayKitManager.CLIENT_TAG, "hls"); + lastReportedBitrate, sessionId, mediaConfig.getStartPosition(), entryId, isLive, PlayKitManager.CLIENT_TAG, "hls"); requestBuilder.completion(new OnRequestCompletion() { @Override diff --git a/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaStatsPlugin.java b/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaStatsPlugin.java index 7f68b6088..fe311d4a3 100644 --- a/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaStatsPlugin.java +++ b/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaStatsPlugin.java @@ -139,7 +139,7 @@ public PKPlugin newInstance() { @Override public void warmUp(Context context) { - + } }; @@ -398,17 +398,19 @@ public void run() { * @param eventType - Enum stating Kaltura state events */ private void sendAnalyticsEvent(final KStatsEvent eventType) { - String sessionId = pluginConfig.has("sessionId") ? pluginConfig.getAsJsonPrimitive("sessionId").getAsString() : ""; + String sessionId = (player.getSessionId() != null) ? player.getSessionId().toString() : ""; int uiconfId = pluginConfig.has("uiconfId") ? pluginConfig.getAsJsonPrimitive("uiconfId").getAsInt() : 0; String baseUrl = pluginConfig.has("baseUrl") ? pluginConfig.getAsJsonPrimitive("baseUrl").getAsString() : BASE_URL; int partnerId = pluginConfig.has("partnerId") ? pluginConfig.getAsJsonPrimitive("partnerId").getAsInt() : 0; + String entryId = pluginConfig.has("entryId") ? pluginConfig.getAsJsonPrimitive("entryId").getAsString() : mediaConfig.getMediaEntry().getId(); + long duration = player.getDuration() == Consts.TIME_UNSET ? -1 : player.getDuration() / 1000; // Parameters for the request - // String baseUrl, int partnerId, int eventType, String clientVer, long duration, // String sessionId, long position, String uiConfId, String entryId, String widgetId, boolean isSeek final RequestBuilder requestBuilder = StatsService.sendStatsEvent(baseUrl, partnerId, eventType.getValue(), PlayKitManager.CLIENT_TAG, duration, - sessionId, player.getCurrentPosition(), uiconfId, mediaConfig.getMediaEntry().getId(), "_" + partnerId, hasSeeked); + sessionId, player.getCurrentPosition(), uiconfId, entryId, "_" + partnerId, hasSeeked); requestBuilder.completion(new OnRequestCompletion() { @Override