Skip to content

Commit 1ef09ab

Browse files
author
Reis Can
committed
feat: auto frame rate
Change-Id: Id6f6bff58b5cd3eafbb20713bacd62253bf8968f
1 parent ae301bb commit 1ef09ab

File tree

6 files changed

+38
-1
lines changed

6 files changed

+38
-1
lines changed

cobalt/h5vcc/h5vcc_tizen_tube.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,12 @@ std::string H5vccTizenTube::GetArchitecture() const {
9797
return "";
9898
}
9999

100+
void H5vccTizenTube::SetFrameRate(float frame_rate) const {
101+
#if defined(ANDROID)
102+
JniEnvExt* env = JniEnvExt::Get();
103+
env->CallStarboardVoidMethodOrAbort("setFrameRate", "(F)V", frame_rate);
104+
#endif
105+
}
106+
100107
} // namespace h5vcc
101108
} // namespace cobalt

cobalt/h5vcc/h5vcc_tizen_tube.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class H5vccTizenTube : public script::Wrappable {
4949
std::string GetVersion() const;
5050
bool SetUserAgent(const std::string& user_agent) const;
5151
std::string GetArchitecture() const;
52+
void SetFrameRate(float frame_rate) const;
5253

5354
DEFINE_WRAPPABLE_TYPE(H5vccTizenTube);
5455

cobalt/h5vcc/h5vcc_tizen_tube.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ interface H5vccTizenTube {
1717
DOMString GetVersion();
1818
boolean SetUserAgent(DOMString user_agent);
1919
DOMString GetArchitecture();
20+
void SetFrameRate(long frame_rate);
2021
};

starboard/android/apk/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ android {
8080
minSdkVersion MIN_SUPPORTED_SDK_VERSION
8181
targetSdkVersion LATEST_SUPPORTED_SDK_VERSION
8282
compileSdkVersion LATEST_SUPPORTED_SDK_VERSION
83-
versionCode 106
83+
versionCode 107
8484
versionName "${buildId}"
8585
manifestPlaceholders = [
8686
applicationName: "TizenTube",

starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltActivity.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import android.os.Build;
2727
import android.os.Bundle;
2828
import android.util.Pair;
29+
import android.view.Surface;
2930
import android.view.View;
3031
import android.view.ViewGroup.LayoutParams;
3132
import android.view.ViewParent;
@@ -440,4 +441,21 @@ public void run() {
440441

441442
runOnUiThread(runnable);
442443
}
444+
445+
public void setFrameRate(float frameRate) {
446+
if (Build.VERSION.SDK_INT < 30) {
447+
return;
448+
}
449+
450+
Runnable runnable =
451+
new Runnable() {
452+
@Override
453+
public void run() {
454+
Surface videoSurface = VideoSurfaceView.getCurrentSurface();
455+
videoSurface.setFrameRate(frameRate, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT);
456+
}
457+
};
458+
459+
runOnUiThread(runnable);
460+
}
443461
}

starboard/android/apk/app/src/main/java/dev/cobalt/coat/StarboardBridge.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import android.util.Size;
3636
import android.util.SizeF;
3737
import android.view.Display;
38+
import android.view.Surface;
3839
import android.view.InputDevice;
3940
import android.view.accessibility.AccessibilityManager;
4041
import android.view.accessibility.CaptioningManager;
@@ -889,4 +890,13 @@ protected String getBrandAndModel() {
889890
protected String getArchitecture() {
890891
return Build.SUPPORTED_ABIS[0];
891892
}
893+
894+
@SuppressWarnings("unused")
895+
@UsedByNative
896+
protected void setFrameRate(float frameRate) {
897+
Activity activity = activityHolder.get();
898+
if (activity instanceof CobaltActivity) {
899+
((CobaltActivity) activity).setFrameRate(frameRate);
900+
}
901+
}
892902
}

0 commit comments

Comments
 (0)