Skip to content

Commit

Permalink
Merge pull request #221 from fgl27/codec
Browse files Browse the repository at this point in the history
Codec
  • Loading branch information
fgl27 authored Aug 7, 2024
2 parents b665d59 + 7df7955 commit 3a37dab
Show file tree
Hide file tree
Showing 29 changed files with 1,065 additions and 378 deletions.
1 change: 1 addition & 0 deletions apk/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/deploymentTargetSelector.xml
.DS_Store
/build
/app/release
Expand Down
18 changes: 0 additions & 18 deletions apk/.idea/deploymentTargetSelector.xml

This file was deleted.

3 changes: 3 additions & 0 deletions apk/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apk/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ dependencies {
implementation project(':media-lib-exoplayer')
implementation project(':media-lib-ui')
implementation project(':media-lib-exoplayer-hls')
//implementation project(':media-lib-decoder-av1')

//Crashlytics
implementation platform('com.google.firebase:firebase-bom:33.1.2')
Expand Down
3 changes: 3 additions & 0 deletions apk/app/src/main/java/com/fgl27/twitch/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public final class Constants {
public static final String CHANNEL_INTENT = "channel_intent";//f update this also update it on the manifest... ChannelsReceiver & PlayerActivity
public static final String CHANNEL_TYPE = "channel_type";

public static final String BLOCKED_CHANNEL = "blocked_channel";
public static final String BLOCKED_GAMES = "blocked_games";

public static final String[][] BASE_HEADERS = {
{"Client-ID", ""},
{"Authorization", "Bearer "}
Expand Down
49 changes: 46 additions & 3 deletions apk/app/src/main/java/com/fgl27/twitch/PlayerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public class PlayerActivity extends Activity {
private long NetCounter = 0L;
private long SpeedCounter = 0L;
private int mLowLatency = 0;
private boolean speedAdjustment = false;
private boolean AlreadyStarted;
private boolean onCreateReady;
private boolean IsStopped;
Expand Down Expand Up @@ -1181,17 +1182,22 @@ private void SwitchPlayer() {
}

public void PlayerObjUpdateTrackSelectorParameters(int ParametersPos, Context context, int width) {

//https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.ParametersBuilder
trackSelectorParameters[ParametersPos] = DefaultTrackSelector.Parameters.getDefaults(context)
.buildUpon()
.setMaxVideoBitrate(PlayerBitrate[ParametersPos])
.setMaxVideoSize(width, PlayerResolution[ParametersPos])
.setAllowVideoNonSeamlessAdaptiveness(true)
.setExceedAudioConstraintsIfNecessary(true)
.setExceedVideoConstraintsIfNecessary(true)
.setAllowVideoMixedMimeTypeAdaptiveness(true)
.setAllowVideoMixedDecoderSupportAdaptiveness(true)
.setViewportSize(//set this to play resolution bigger then current screen resolution
Integer.MAX_VALUE,
Integer.MAX_VALUE,
false)
.setExceedRendererCapabilitiesIfNecessary(true)
.build();

}

public void PlayerObjUpdateTrackSelector(int PlayerObjPos, int ParametersPos) {
Expand Down Expand Up @@ -2259,6 +2265,7 @@ public void setEnabledQualities(int position) {
TrackGroup groupIndex = trackGroupArray.get(0);
int groupIndex_len = groupIndex.length;
boolean add;
String[] BLACKLISTED_QUALITIES_LOWER_UPER = null;

for (int trackIndex = 0; trackIndex < groupIndex_len; trackIndex++) {
format = groupIndex.getFormat(trackIndex);
Expand All @@ -2267,7 +2274,10 @@ public void setEnabledQualities(int position) {
if (format.bitrate <= MaxBitrate && format.height <= MaxResolution) {

for (String value : BLACKLISTED_QUALITIES) {
if (Integer.toString(format.height).startsWith(value)) {
BLACKLISTED_QUALITIES_LOWER_UPER = value.split("-");//'4200-4600', '1700-2200', '1500-1700', '1400-1500', '1000-1100', '900-1000', '700-800', '400-500', '300-400'

if (format.height > Integer.parseInt(BLACKLISTED_QUALITIES_LOWER_UPER[0]) &&
format.height < Integer.parseInt(BLACKLISTED_QUALITIES_LOWER_UPER[1])) {
add = false;
break;
}
Expand Down Expand Up @@ -2715,6 +2725,28 @@ public void setAppToken(String token) {
appPreferences.put(Constants.PREF_CLIENT_TOKEN, token);
}

@JavascriptInterface
public void UpdateBlockedChannels(String channelsJson) {
String savedChannels = Tools.getString(Constants.BLOCKED_CHANNEL, null, appPreferences);

if (!Objects.equals(savedChannels, channelsJson)) {
appPreferences.put(Constants.BLOCKED_CHANNEL, channelsJson);
RefreshChannel(Constants.CHANNEL_TYPE_LIVE, true, mWebViewContext);
}

}

@JavascriptInterface
public void UpdateBlockedGames(String gamesJson) {
String savedGames = Tools.getString(Constants.BLOCKED_GAMES, null, appPreferences);

if (!Objects.equals(savedGames, gamesJson)) {

appPreferences.put(Constants.BLOCKED_GAMES, gamesJson);
RefreshChannel(Constants.CHANNEL_TYPE_GAMES, true, mWebViewContext);
}
}

@JavascriptInterface
public void UpdateUserId(String id, String name, String access_token) {

Expand Down Expand Up @@ -2912,6 +2944,7 @@ public void ReuseFeedPlayer(String uri, String mainPlaylistString, int Type, lon
mWebViewContext,
Type,
mLowLatency,
speedAdjustment,
mainPlaylistString,
userAgent
);
Expand Down Expand Up @@ -2955,6 +2988,7 @@ public void StartAuto(String uri, String mainPlaylistString, int Type, long Resu
mWebViewContext,
Type,
mLowLatency,
speedAdjustment,
mainPlaylistString,
userAgent
);
Expand Down Expand Up @@ -3208,6 +3242,7 @@ public void StartFeedPlayer(String uri, String mainPlaylistString, int position,
mWebViewContext,
isVod ? 2 : 1,
mLowLatency,
speedAdjustment,
mainPlaylistString,
userAgent
);
Expand Down Expand Up @@ -3255,6 +3290,7 @@ public void StartSidePanelPlayer(String uri, String mainPlaylistString) {
mWebViewContext,
1,
mLowLatency,
speedAdjustment,
mainPlaylistString,
userAgent
);
Expand Down Expand Up @@ -3285,6 +3321,7 @@ public void StartScreensPlayer(String uri, String mainPlaylistString, int Resume
mWebViewContext,
Type,
mLowLatency,
speedAdjustment,
mainPlaylistString,
userAgent
);
Expand Down Expand Up @@ -3348,6 +3385,11 @@ public void mSetlatency(int LowLatency) {
mLowLatency = LowLatency;
}

@JavascriptInterface
public void setSpeedAdjustment(boolean pSpeedAdjustment) {
speedAdjustment = pSpeedAdjustment;
}

@JavascriptInterface
public void stopVideo() {
runOnUiThread(PlayerActivity.this::ResetPlayerState);
Expand Down Expand Up @@ -3778,6 +3820,7 @@ public void StartMultiStream(int position, String uri, String mainPlaylistString
mWebViewContext,
1,
mLowLatency,
speedAdjustment,
mainPlaylistString,
userAgent
);
Expand Down
Loading

0 comments on commit 3a37dab

Please sign in to comment.