Skip to content

Commit

Permalink
New stream preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
omouren committed Jun 2, 2021
1 parent 75fa77f commit ea0656e
Show file tree
Hide file tree
Showing 18 changed files with 427 additions and 148 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</activity>

<service
android:name=".StreamingService"
android:name=".streaming.StreamingService"
android:foregroundServiceType="mediaProjection" />

<meta-data
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/fpvout/digiview/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import androidx.core.content.res.ResourcesCompat;
import androidx.preference.PreferenceManager;

import com.fpvout.digiview.streaming.StreamingService;
import com.google.android.material.floatingactionbutton.FloatingActionButton;

import net.ossrs.rtmp.ConnectCheckerRtmp;
Expand Down Expand Up @@ -187,7 +188,7 @@ protected void onCreate(Bundle savedInstanceState) {
liveButton = findViewById(R.id.liveButton);
liveButton.setOnClickListener(v -> {
if (!StreamingService.isStreaming()) {
if (sharedPreferences.getString("RtmpUrl", "").isEmpty() || sharedPreferences.getString("RtmpKey", "").isEmpty()) {
if (sharedPreferences.getString("StreamRtmpUrl", "").isEmpty() || sharedPreferences.getString("StreamRtmpKey", "").isEmpty()) {
Toast.makeText(this, getString(R.string.rtmp_settings_empty), Toast.LENGTH_LONG).show();
Intent intent = new Intent(v.getContext(), SettingsActivity.class);
v.getContext().startActivity(intent);
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/java/com/fpvout/digiview/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import androidx.preference.ListPreference;
import androidx.preference.PreferenceFragmentCompat;

import com.fpvout.digiview.streaming.StreamAudioSource;

import java.util.ArrayList;
import java.util.Arrays;

Expand Down Expand Up @@ -48,13 +50,16 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.root_preferences, rootKey);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ListPreference audioSourcePreference = findPreference("AudioSource");
ListPreference audioSourcePreference = findPreference("StreamAudioSource");

ArrayList<CharSequence> entries = new ArrayList<>(Arrays.asList(audioSourcePreference.getEntries()));
ArrayList<CharSequence> entryValues = new ArrayList<>(Arrays.asList(audioSourcePreference.getEntryValues()));

entries.add(getString(R.string.audio_source_internal));
entryValues.add("internal");
entries.add(getString(R.string.stream_audio_source_performance));
entryValues.add(StreamAudioSource.PERFORMANCE);

entries.add(getString(R.string.stream_audio_source_internal));
entryValues.add(StreamAudioSource.INTERNAL);

audioSourcePreference.setEntries(entries.toArray(new CharSequence[0]));
audioSourcePreference.setEntryValues(entryValues.toArray(new CharSequence[0]));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.fpvout.digiview.streaming;

public class StreamAudioBitrate {
public static final String DEFAULT = "128";

public static int getBitrate(String value) {
return Integer.parseInt(value) * 1024;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.fpvout.digiview.streaming;

public class StreamAudioSampleRate {
public static final String DEFAULT = "44100hz";

public static int getSampleRate(String value) {
switch (value) {
case "8khz":
return 8000;
case "11025hz":
return 11025;
case "16khz":
return 16000;
case "22050hz":
return 22050;
case "32000hz":
return 32000;
case DEFAULT:
return 44100;
case "48khz":
return 48000;
case "96khz":
return 96000;
}

return -1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.fpvout.digiview.streaming;

import android.media.MediaRecorder;

public class StreamAudioSource {
public static final String DEFAULT = "default";
public static final String INTERNAL = "internal";
public static final String PERFORMANCE = "performance";

public static int getAudioSource(String value) {
switch (value) {
case DEFAULT:
return MediaRecorder.AudioSource.DEFAULT;
case "mic":
return MediaRecorder.AudioSource.MIC;
case "cam":
return MediaRecorder.AudioSource.CAMCORDER;
case "communication":
return MediaRecorder.AudioSource.VOICE_COMMUNICATION;
case PERFORMANCE:
return MediaRecorder.AudioSource.VOICE_PERFORMANCE;
}

return -1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.fpvout.digiview.streaming;

public class StreamBitrate {
public static final String DEFAULT = "2500";

public static int getBitrate(String value) {
return Integer.parseInt(value) * 1024;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.fpvout.digiview.streaming;

public class StreamFramerate {
public static final String DEFAULT = "60";

public static int getFramerate(String value) {
return Integer.parseInt(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.fpvout.digiview.streaming;

public class StreamResolution {
public static final String DEFAULT = "720p";
private final int width;
private final int height;

private StreamResolution(int width, int height) {
this.width = width;
this.height = height;
}

public static StreamResolution getResolution(String value) {
switch (value) {
case "240p":
return new StreamResolution(426, 240);
case "360p":
return new StreamResolution(640, 360);
case "480p":
return new StreamResolution(854, 480);
case DEFAULT:
return new StreamResolution(1280, 720);
case "1080p":
return new StreamResolution(1920, 1080);
}

return null;
}

public int getWidth() {
return width;
}

public int getHeight() {
return height;
}
}
36 changes: 20 additions & 16 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,27 @@
<string name="open_source_license">Open-Source Lizenz</string>
<string name="open_source_license_summary">MIT Lizenz</string>
<string name="streaming">Streaming</string>
<string name="rtmp_url">RTMP Url</string>
<string name="rtmp_key">RTMP Key</string>
<string name="rtmp_username">RTMP Username</string>
<string name="rtmp_password">RTMP Password</string>
<string name="record_audio">Record audio</string>
<string name="audio_source">Audio source</string>
<string name="audio_source_default">Default</string>
<string name="audio_source_mic">Mic</string>
<string name="audio_source_cam">Camera</string>
<string name="audio_source_communication">Communication</string>
<string name="audio_source_performance">Performance</string>
<string name="audio_source_internal">Internal audio</string>
<string name="output_width">Output Width</string>
<string name="output_height">Output Height</string>
<string name="output_framerate">Output Framerate</string>
<string name="output_bitrate">Output Bitrate</string>
<string name="stream_rtmp_url">RTMP Url</string>
<string name="stream_rtmp_key">RTMP Key</string>
<string name="stream_rtmp_username">RTMP Username</string>
<string name="stream_rtmp_password">RTMP Password</string>
<string name="stream_record_audio">Record audio</string>
<string name="stream_audio_source">Audio source</string>
<string name="stream_audio_source_default">Default</string>
<string name="stream_audio_source_mic">Mic</string>
<string name="stream_audio_source_cam">Camera</string>
<string name="stream_audio_source_communication">Communication</string>
<string name="stream_audio_source_performance">Performance</string>
<string name="stream_audio_source_internal">Internal audio</string>
<string name="stream_resolution">Output Resolution</string>
<string name="stream_framerate">Output Framerate</string>
<string name="stream_max_bitrate">Output Max Bitrate</string>
<string name="rtmp_connection_failed">Failed to connect to RTMP server</string>
<string name="rtmp_auth_error">RTMP authentication failed</string>
<string name="rtmp_settings_empty">Please, check your streaming RTMP URL and Key</string>
<string name="stream_record_audio_summary">Audio recording can be muted during live</string>
<string name="stream_audio_stereo">Stereo audio</string>
<string name="stream_audio_stereo_summary">Only if your device or the audio source supports it</string>
<string name="stream_audio_sample_rate">Audio sample rate</string>
<string name="stream_audio_bitrate">Audio bitrate</string>
</resources>
36 changes: 20 additions & 16 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,27 @@
<string name="open_source_license">Licencia Open-Source</string>
<string name="open_source_license_summary">Licencia MIT</string>
<string name="streaming">Streaming</string>
<string name="rtmp_url">RTMP Url</string>
<string name="rtmp_key">RTMP Key</string>
<string name="rtmp_username">RTMP Username</string>
<string name="rtmp_password">RTMP Password</string>
<string name="record_audio">Record audio</string>
<string name="audio_source">Audio source</string>
<string name="audio_source_default">Default</string>
<string name="audio_source_mic">Mic</string>
<string name="audio_source_cam">Camera</string>
<string name="audio_source_communication">Communication</string>
<string name="audio_source_performance">Performance</string>
<string name="audio_source_internal">Internal audio</string>
<string name="output_width">Output Width</string>
<string name="output_height">Output Height</string>
<string name="output_framerate">Output Framerate</string>
<string name="output_bitrate">Output Bitrate</string>
<string name="stream_rtmp_url">RTMP Url</string>
<string name="stream_rtmp_key">RTMP Key</string>
<string name="stream_rtmp_username">RTMP Username</string>
<string name="stream_rtmp_password">RTMP Password</string>
<string name="stream_record_audio">Record audio</string>
<string name="stream_audio_source">Audio source</string>
<string name="stream_audio_source_default">Default</string>
<string name="stream_audio_source_mic">Mic</string>
<string name="stream_audio_source_cam">Camera</string>
<string name="stream_audio_source_communication">Communication</string>
<string name="stream_audio_source_performance">Performance</string>
<string name="stream_audio_source_internal">Internal audio</string>
<string name="stream_resolution">Output Resolution</string>
<string name="stream_framerate">Output Framerate</string>
<string name="stream_max_bitrate">Output Max Bitrate</string>
<string name="rtmp_connection_failed">Failed to connect to RTMP server</string>
<string name="rtmp_auth_error">RTMP authentication failed</string>
<string name="rtmp_settings_empty">Please, check your streaming RTMP URL and Key</string>
<string name="stream_record_audio_summary">Audio recording can be muted during live</string>
<string name="stream_audio_stereo">Stereo audio</string>
<string name="stream_audio_stereo_summary">Only if your device or the audio source supports it</string>
<string name="stream_audio_sample_rate">Audio sample rate</string>
<string name="stream_audio_bitrate">Audio bitrate</string>
</resources>
36 changes: 20 additions & 16 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,27 @@
<string name="open_source_license">License Open-Source</string>
<string name="open_source_license_summary">License MIT</string>
<string name="streaming">Streaming</string>
<string name="rtmp_url">RTMP Url</string>
<string name="rtmp_key">RTMP Key</string>
<string name="rtmp_username">RTMP Username</string>
<string name="rtmp_password">RTMP Password</string>
<string name="record_audio">Enregistrer le son</string>
<string name="audio_source">Source audio</string>
<string name="audio_source_default">Par défaut</string>
<string name="audio_source_mic">Mic</string>
<string name="audio_source_cam">Camera</string>
<string name="audio_source_communication">Communication</string>
<string name="audio_source_performance">Performance</string>
<string name="audio_source_internal">Audio interne</string>
<string name="output_width">Output Width</string>
<string name="output_height">Output Height</string>
<string name="output_framerate">Output Framerate</string>
<string name="output_bitrate">Output Bitrate</string>
<string name="stream_rtmp_url">RTMP Url</string>
<string name="stream_rtmp_key">RTMP Key</string>
<string name="stream_rtmp_username">RTMP Username</string>
<string name="stream_rtmp_password">RTMP Password</string>
<string name="stream_record_audio">Enregistrer le son</string>
<string name="stream_audio_source">Source audio</string>
<string name="stream_audio_source_default">Par défaut</string>
<string name="stream_audio_source_mic">Mic</string>
<string name="stream_audio_source_cam">Camera</string>
<string name="stream_audio_source_communication">Communication</string>
<string name="stream_audio_source_performance">Performance</string>
<string name="stream_audio_source_internal">Audio interne</string>
<string name="stream_resolution">Output Resolution</string>
<string name="stream_framerate">Output Framerate</string>
<string name="stream_max_bitrate">Output Max Bitrate</string>
<string name="rtmp_connection_failed">Failed to connect to RTMP server</string>
<string name="rtmp_auth_error">RTMP authentication failed</string>
<string name="rtmp_settings_empty">Please, check your streaming RTMP URL and Key</string>
<string name="stream_record_audio_summary">Audio recording can be muted during live</string>
<string name="stream_audio_stereo">Stereo audio</string>
<string name="stream_audio_stereo_summary">Only if your device or the audio source supports it</string>
<string name="stream_audio_sample_rate">Audio sample rate</string>
<string name="stream_audio_bitrate">Audio bitrate</string>
</resources>
36 changes: 20 additions & 16 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,28 @@
<string name="open_source_license">Licença Open-Source</string>
<string name="open_source_license_summary">Licença MIT</string>
<string name="streaming">Streaming</string>
<string name="rtmp_url">RTMP Url</string>
<string name="rtmp_key">RTMP Key</string>
<string name="rtmp_username">RTMP Username</string>
<string name="rtmp_password">RTMP Password</string>
<string name="record_audio">Record audio</string>
<string name="audio_source">Audio source</string>
<string name="audio_source_default">Default</string>
<string name="audio_source_mic">Mic</string>
<string name="audio_source_cam">Camera</string>
<string name="audio_source_communication">Communication</string>
<string name="audio_source_performance">Performance</string>
<string name="audio_source_internal">Internal audio</string>
<string name="output_width">Output Width</string>
<string name="output_height">Output Height</string>
<string name="output_framerate">Output Framerate</string>
<string name="output_bitrate">Output Bitrate</string>
<string name="stream_rtmp_url">RTMP Url</string>
<string name="stream_rtmp_key">RTMP Key</string>
<string name="stream_rtmp_username">RTMP Username</string>
<string name="stream_rtmp_password">RTMP Password</string>
<string name="stream_record_audio">Record audio</string>
<string name="stream_audio_source">Audio source</string>
<string name="stream_audio_source_default">Default</string>
<string name="stream_audio_source_mic">Mic</string>
<string name="stream_audio_source_cam">Camera</string>
<string name="stream_audio_source_communication">Communication</string>
<string name="stream_audio_source_performance">Performance</string>
<string name="stream_audio_source_internal">Internal audio</string>
<string name="stream_resolution">Output Resolution</string>
<string name="stream_framerate">Output Framerate</string>
<string name="stream_max_bitrate">Output Max Bitrate</string>
<string name="rtmp_connection_failed">Failed to connect to RTMP server</string>
<string name="rtmp_auth_error">RTMP authentication failed</string>
<string name="rtmp_settings_empty">Please, check your streaming RTMP URL and Key</string>
<string name="stream_record_audio_summary">Audio recording can be muted during live</string>
<string name="stream_audio_stereo">Stereo audio</string>
<string name="stream_audio_stereo_summary">Only if your device or the audio source supports it</string>
<string name="stream_audio_sample_rate">Audio sample rate</string>
<string name="stream_audio_bitrate">Audio bitrate</string>

</resources>
Loading

0 comments on commit ea0656e

Please sign in to comment.