Skip to content

Commit

Permalink
Cache test in place, failing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomislav Kordic authored and Tomislav Kordic committed Jul 22, 2024
1 parent d92249b commit d5d3edb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void init() {
urlToPlay = "http://localhost:5000/hls/google_glass/playlist.m3u8";
// These video have larger bitrate, make sure we do not cause any
// rebuffering due to low bandwith
bandwidthLimitInBitsPerSecond = 12000000;
bandwidthLimitInBitsPerSecond = 10000000;
enableSmartCache = true;
super.init();
}
Expand All @@ -40,7 +40,7 @@ public void testCachedPlayback() {
fail("Playback did not start in " + waitForPlaybackToStartInMS + " milliseconds !!!");
}
// wait for server to serve first 5 segment.
waitForNSegments(4);
waitForNSegments(8);
// Seek to beginning
boolean serverServingData = httpServer.isServingData();
if (!serverServingData) {
Expand All @@ -55,6 +55,7 @@ public void run() {
}
});
waitForSeekToFinish();
Thread.sleep(1000);
HashMap<String, SegmentStatistics> segmentsAfterSeek = httpServer.getServedSegments();
for (int i = 0; i < 4; i ++) {
Thread.sleep(1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ protected void onCreate(Bundle savedInstanceState) {

playerView = findViewById(R.id.player_view);

initExoPlayer();
playerView.setPlayer(player);

// Do not hide controlls
playerView.setControllerShowTimeoutMs(0);
playerView.setControllerHideOnTouch(false);

// Setup notification and media session.
initAudioSession();
Expand Down Expand Up @@ -133,7 +127,7 @@ protected void onDestroy() {
}
}

public void initExoPlayer() {
public void iniPlayer() {
// Hopfully this will not channge the track selection set programmatically
ExoTrackSelection.Factory trackSelectionFactory = new AdaptiveTrackSelection.Factory(
AdaptiveTrackSelection.DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MS * 10,
Expand All @@ -146,6 +140,7 @@ public void initExoPlayer() {
DefaultTrackSelector.Parameters trackSelectorParameters = builder
.build();

// TODO: if this is used somwhere obtaine it from mux player.
mediaSourceFactory = new MuxMediaSourceFactory(this, new DefaultDataSource.Factory(this));
trackSelector = new DefaultTrackSelector(/* context= */ this, trackSelectionFactory);
trackSelector.setParameters(trackSelectorParameters);
Expand All @@ -157,17 +152,22 @@ public void initExoPlayer() {
player = new MuxPlayer.Builder(this)
.plusExoConfig((ExoPlayer.Builder exoBuilder) -> {
exoBuilder.setRenderersFactory(renderersFactory);
exoBuilder.setMediaSourceFactory(mediaSourceFactory);
// exoBuilder.setMediaSourceFactory(mediaSourceFactory);
exoBuilder.setTrackSelector(trackSelector);
})
.addMonitoringData(initMuxSats())
.addExoPlayerBinding(pBinding)
.addNetwork(mockNetwork)
.enableSmartCache(enableSmartCache)
.enableLogcat(true)
.build();

player.addAnalyticsListener(this);
playerView.setPlayer(player);

// Do not hide controlls
playerView.setControllerShowTimeoutMs(0);
playerView.setControllerHideOnTouch(false);
}

public void initAudioSession() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public void init() {
testActivity.setUrlToPlay(urlToPlay);
testActivity.setPlayWhenReady(playWhenReady);
testActivity.setPlaybackStartPosition(playbackStartPosition);
testActivity.iniPlayer();
testActivity.startPlayback();
pView = testActivity.getPlayerView();
testMediaSource = testActivity.getTestMediaSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class MuxDataSource private constructor(
override fun open(dataSpec: DataSpec): Long {
this.dataSpec = dataSpec;

val readHandle = CacheController.tryRead(dataSpec.uri.toString())
val readHandle = CacheController.tryRead(dataSpec.uri.toString())
val nowUtc = nowUtc()

return if (readHandle == null) {
Expand Down

0 comments on commit d5d3edb

Please sign in to comment.