-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge PlaybackInfoProvider and PlayerHelper into PlayerAdapter
- Loading branch information
1 parent
96e2ce8
commit c72fe5e
Showing
9 changed files
with
269 additions
and
220 deletions.
There are no files selected for viewing
31 changes: 0 additions & 31 deletions
31
conviva/src/main/java/com/bitmovin/analytics/conviva/BitmovinPlayerHelper.java
This file was deleted.
Oops, something went wrong.
225 changes: 106 additions & 119 deletions
225
conviva/src/main/java/com/bitmovin/analytics/conviva/ConvivaAnalyticsIntegration.java
Large diffs are not rendered by default.
Oops, something went wrong.
109 changes: 109 additions & 0 deletions
109
conviva/src/main/java/com/bitmovin/analytics/conviva/DefaultPlayerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.bitmovin.analytics.conviva; | ||
|
||
import com.bitmovin.analytics.conviva.helper.WithEventEmitter; | ||
import com.bitmovin.player.api.Player; | ||
import com.bitmovin.player.api.media.video.quality.VideoQuality; | ||
import com.conviva.sdk.ConvivaSdkConstants; | ||
|
||
import java.util.HashMap; | ||
|
||
public class DefaultPlayerAdapter implements PlayerAdapter { | ||
private final Player player; | ||
|
||
public DefaultPlayerAdapter(Player player) { | ||
this.player = player; | ||
} | ||
|
||
@Override | ||
public ConvivaSdkConstants.PlayerState getPlayerState() { | ||
ConvivaSdkConstants.PlayerState state; | ||
if (player.isPaused()) { | ||
state = ConvivaSdkConstants.PlayerState.PAUSED; | ||
} else if (player.isStalled()) { | ||
state = ConvivaSdkConstants.PlayerState.BUFFERING; | ||
} else { | ||
state = ConvivaSdkConstants.PlayerState.PLAYING; | ||
} | ||
return state; | ||
} | ||
|
||
@Override | ||
public HashMap<String, Object[]> getPlaybackVideoData() { | ||
HashMap<String, Object[]> videoData = new HashMap<>(); | ||
VideoQuality playbackVideoData = player.getPlaybackVideoData(); | ||
if (playbackVideoData != null) { | ||
videoData.put(ConvivaSdkConstants.PLAYBACK.RESOLUTION, new Object[]{playbackVideoData.getWidth(), playbackVideoData.getHeight()}); | ||
videoData.put(ConvivaSdkConstants.PLAYBACK.BITRATE, new Object[]{playbackVideoData.getBitrate() / 1000}); | ||
final int peakBitrate = playbackVideoData.getPeakBitrate(); | ||
if (peakBitrate != VideoQuality.BITRATE_NO_VALUE) { | ||
videoData.put(ConvivaSdkConstants.PLAYBACK.BITRATE, new Object[]{peakBitrate / 1000}); | ||
} | ||
final int averageBitrate = playbackVideoData.getAverageBitrate(); | ||
if (averageBitrate != VideoQuality.BITRATE_NO_VALUE) { | ||
videoData.put(ConvivaSdkConstants.PLAYBACK.AVG_BITRATE, new Object[]{averageBitrate / 1000}); | ||
} | ||
videoData.put(ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE, new Object[]{Math.round(playbackVideoData.getFrameRate())}); | ||
} | ||
return videoData; | ||
} | ||
|
||
@Override | ||
public String getStreamTitle() { | ||
return player.getSource() == null ? null : player.getSource().getConfig().getTitle(); | ||
} | ||
|
||
@Override | ||
public String getStreamType() { | ||
return player.getSource() == null ? null : player.getSource().getConfig().getType().name(); | ||
} | ||
|
||
@Override | ||
public String getStreamUrl() { | ||
return player.getSource() == null ? null : player.getSource().getConfig().getUrl(); | ||
} | ||
|
||
|
||
@Override | ||
public boolean isAd() { | ||
return player.isAd(); | ||
} | ||
|
||
@Override | ||
public boolean isLive() { | ||
return player.isLive(); | ||
} | ||
|
||
@Override | ||
public boolean isPaused() { | ||
return player.isPaused(); | ||
} | ||
|
||
@Override | ||
public boolean isPlaying() { | ||
return player.isPlaying(); | ||
} | ||
|
||
@Override | ||
public double getDuration() { | ||
return player.getDuration(); | ||
} | ||
|
||
@Override | ||
public long getPlayHeadTimeMillis() { | ||
if (player.isLive()) { | ||
double playerTimeShiftMax = player.getMaxTimeShift(); | ||
double playerTimeShift = player.getTimeShift(); | ||
long playerDurationMs = -(Math.round(playerTimeShiftMax * 1000)); | ||
return playerDurationMs - -(Math.round(playerTimeShift * 1000)); | ||
|
||
} else { | ||
double currentTime = player.getCurrentTime(); | ||
return (long) (currentTime * 1000); | ||
} | ||
} | ||
|
||
@Override | ||
public void withEventEmitter(WithEventEmitter withEventEmitter) { | ||
withEventEmitter.call(player); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
conviva/src/main/java/com/bitmovin/analytics/conviva/PlayerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.bitmovin.analytics.conviva; | ||
|
||
import com.bitmovin.analytics.conviva.helper.WithEventEmitter; | ||
import com.conviva.sdk.ConvivaSdkConstants; | ||
|
||
import java.util.HashMap; | ||
|
||
public interface PlayerAdapter { | ||
ConvivaSdkConstants.PlayerState getPlayerState(); | ||
|
||
HashMap<String, Object[]> getPlaybackVideoData(); | ||
|
||
boolean isAd(); | ||
|
||
String getStreamTitle(); | ||
|
||
String getStreamType(); | ||
|
||
String getStreamUrl(); | ||
|
||
long getPlayHeadTimeMillis(); | ||
|
||
boolean isLive(); | ||
|
||
double getDuration(); | ||
|
||
void withEventEmitter(WithEventEmitter withEventEmitter); | ||
|
||
boolean isPaused(); | ||
|
||
boolean isPlaying(); | ||
} |
8 changes: 8 additions & 0 deletions
8
conviva/src/main/java/com/bitmovin/analytics/conviva/helper/WithEventEmitter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.bitmovin.analytics.conviva.helper; | ||
|
||
import com.bitmovin.player.api.event.Event; | ||
import com.bitmovin.player.api.event.JavaEventEmitter; | ||
|
||
public interface WithEventEmitter { | ||
void call(JavaEventEmitter<Event> player); | ||
} |
47 changes: 0 additions & 47 deletions
47
conviva/src/main/java/com/bitmovin/analytics/conviva/ssai/DefaultPlaybackInfoProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
conviva/src/main/java/com/bitmovin/analytics/conviva/ssai/PlaybackInfoProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters