h265 support

This commit is contained in:
JerryXiao 2023-08-22 17:24:26 +08:00
parent 46b344eee2
commit 5019f00617
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5
5 changed files with 18 additions and 5 deletions

View file

@ -38,5 +38,5 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.github.pedroSG94.rtmp-rtsp-stream-client-java:rtplibrary:2.2.6'
implementation 'com.github.pedroSG94.rtmp-rtsp-stream-client-java:rtplibrary:a813c206292cea0767d9cb091f14c87ca9afdc9e'
}

View file

@ -190,8 +190,13 @@ public class ScreenCapService extends Service {
if (screenCapDisplay instanceof RtmpDisplay d) {
d.setWriteChunkSize(prefs.getInt("write_chunk_size_int", 1024));
}
if (screenCapDisplay instanceof RtmpDisplay d) {
d.setVideoCodec(prefs.getBoolean("enable_h265", false) ? com.pedro.rtmp.rtmp.VideoCodec.H265 : com.pedro.rtmp.rtmp.VideoCodec.H264);
}
else if (screenCapDisplay instanceof RtspDisplay d) {
d.setVideoCodec(prefs.getBoolean("enable_h265", false) ? com.pedro.rtsp.rtsp.VideoCodec.H265 : com.pedro.rtsp.rtsp.VideoCodec.H264);
}
screenCapDisplay.setReTries(prefs.getInt("retries_int", 0));
screenCapDisplay.resizeCache(prefs.getInt("cache_size_int", 120));
screenCapDisplay.setLogs(prefs.getBoolean("enable_lib_logs", true));
if (prefs.getBoolean("use_gl", true) && prefs.getBoolean("use_force_render", true)) {
screenCapDisplay.getGlInterface().setForceRender(true);
@ -215,7 +220,7 @@ public class ScreenCapService extends Service {
}
Log.d(TAG, String.format("capture width %d height %d", video_width, video_height));
if (this.screenCapDisplay.prepareInternalAudio(Integer.parseInt(prefs.getString("audio_bitrate", "131072")), 48000, prefs.getBoolean("stereo_audio", true), false, false) &&
this.screenCapDisplay.prepareVideo(video_width, video_height, Integer.parseInt(prefs.getString("fps", "30")), Integer.parseInt(prefs.getString("video_bitrate", "10485760")), 0, 320, -1, -1, 2)) {
this.screenCapDisplay.prepareVideo(video_width, video_height, Integer.parseInt(prefs.getString("fps", "30")), Integer.parseInt(prefs.getString("video_bitrate", "10485760")), 0, 320)) {
this.screenCapDisplay.startStream(server);
}
else {

View file

@ -16,7 +16,6 @@
<string name="network_header">网络设置</string>
<string name="video_bitrate_title">视频比特率</string>
<string name="audio_bitrate_title">音频比特率</string>
<string name="hint_rtmp">rtmp://</string>
<string name="start_button">开始</string>
<string name="stop_button">停止</string>
<string name="settings_button">设置</string>
@ -37,4 +36,6 @@
<string name="button_ok"></string>
<string name="misc_header">杂项</string>
<string name="enable_lib_logs_title">开启库日志</string>
<string name="enable_h265_title">开启 H.265</string>
<string name="h265_warning">并非所有服务器均支持 h265 推流</string>
</resources>

View file

@ -17,7 +17,6 @@
<string name="video_bitrate_title">Video Bitrate (bps)</string>
<string name="audio_bitrate_title">Audio Bitrate</string>
<string name="hint_rtmp">rtmp://</string>
<string name="start_button">Start</string>
<string name="stop_button">Stop</string>
<string name="settings_button">Settings</string>
@ -41,4 +40,6 @@
<string name="button_ok">OK</string>
<string name="misc_header">Misc</string>
<string name="enable_lib_logs_title">Enable library logs</string>
<string name="enable_h265_title">Enable H.265</string>
<string name="h265_warning">Only a few servers support h265 rtmp streaming</string>
</resources>

View file

@ -32,6 +32,12 @@
app:title="@string/fps_title"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat
app:key="enable_h265"
app:title="@string/enable_h265_title"
app:summaryOn="@string/h265_warning"
app:defaultValue="false" />
<SwitchPreferenceCompat
app:key="stereo_audio"
app:title="@string/stereo_audio_title"