Skip to content

Commit

Permalink
Fem 1317 - support enrtyId as config and get sessionId from player in…
Browse files Browse the repository at this point in the history
… KalturaStats KalturaLiveStats Plugnis (kaltura#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
  • Loading branch information
giladna authored Apr 4, 2017
1 parent a7d2f04 commit 4f92748
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public PKPlugin newInstance() {

@Override
public void warmUp(Context context) {

}
};

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public PKPlugin newInstance() {

@Override
public void warmUp(Context context) {

}
};

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4f92748

Please sign in to comment.