Skip to content

Commit

Permalink
fix(demos): camera: fix default parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Dec 17, 2024
1 parent 0797c29 commit 19b472f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
else -> supportedVideoEncoder.first()
}

videoEncoderListPreference.setDefaultValue(defaultVideoEncoder)
videoEncoderListPreference.entryValues = supportedVideoEncoder.toTypedArray()
videoEncoderListPreference.entries =
supportedVideoEncoder.map { supportedVideoEncoderName[it] }.toTypedArray()
Expand Down Expand Up @@ -234,7 +233,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
videoFpsListPreference.entries = this
videoFpsListPreference.entryValues = this
}
videoFpsListPreference.setDefaultValue(ApplicationConstants.Video.defaultFps.toString())
videoFpsListPreference.setOnPreferenceChangeListener { _, newValue ->
val fps = (newValue as String).toInt()
val unsupportedCameras = requireContext().cameras.filter {
Expand Down Expand Up @@ -312,7 +310,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
} else {
supportedAudioEncoder.first()
}
audioEncoderListPreference.setDefaultValue(defaultAudioEncoder)
audioEncoderListPreference.entryValues = supportedAudioEncoder.toTypedArray()
audioEncoderListPreference.entries =
supportedAudioEncoder.map { supportedAudioEncoderName[it] }.toTypedArray()
Expand Down Expand Up @@ -353,7 +350,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
this.map { "${it.toString().toInt() / 1000} Kbps" }.toTypedArray()
audioBitrateListPreference.entryValues = this
}
audioBitrateListPreference.setDefaultValue(ApplicationConstants.Audio.defaultBitrateInBps.toString())
if (audioBitrateListPreference.entry == null) {
audioBitrateListPreference.value = "128000"
}
Expand All @@ -364,7 +360,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
sampleRates.map { "${"%.1f".format(it.toString().toFloat() / 1000)} kHz" }
.toTypedArray()
audioSampleRateListPreference.entryValues = sampleRates.map { "$it" }.toTypedArray()
audioSampleRateListPreference.setDefaultValue(ApplicationConstants.Audio.defaultSampleRate.toString())
if (audioSampleRateListPreference.entry == null) {
audioSampleRateListPreference.value = when {
sampleRates.contains(44100) -> "44100"
Expand All @@ -383,7 +378,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
audioByteFormatListPreference.entries =
byteFormats.map { supportedByteFormatName[it] }.toTypedArray()
audioByteFormatListPreference.entryValues = byteFormats.map { "$it" }.toTypedArray()
audioByteFormatListPreference.setDefaultValue(ApplicationConstants.Audio.defaultByteFormat)
if (audioByteFormatListPreference.entry == null) {
audioByteFormatListPreference.value = "${AudioFormat.ENCODING_PCM_16BIT}"
}
Expand Down Expand Up @@ -412,7 +406,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
private fun loadEndpoint() {
// Inflates endpoint
val supportedEndpoint = EndpointType.entries.map { "${it.id}" }.toTypedArray()
endpointTypePreference.setDefaultValue(EndpointType.SRT.id)
endpointTypePreference.entryValues = supportedEndpoint
endpointTypePreference.entries =
supportedEndpoint.map { getString(it.toInt()) }
Expand Down
7 changes: 7 additions & 0 deletions demos/camera/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@

<string name="video_encoder">Encoder</string>
<string name="video_encoder_key">video_encoder_key</string>
<string name="default_video_encoder">video/avc</string>

<string name="video_resolution">Resolution</string>
<string name="video_resolution_key">video_resolution_key</string>
<string name="default_video_resolution">1280x720</string>

<string name="video_fps">Frames per second</string>
<string name="video_fps_key">video_fps_key</string>
Expand All @@ -66,6 +68,7 @@

<string name="audio_encoder">Encoder</string>
<string name="audio_encoder_key">audio_encoder_key</string>
<string name="default_audio_encoder">audio/mp4a-latm</string>

<string name="audio_number_of_channels">Number of channels</string>
<string name="audio_channel_config_key">audio_channel_config_key</string>
Expand Down Expand Up @@ -106,10 +109,13 @@
<string name="default_srt_server_url">192.168.1.11</string>
<string name="server_port">Port</string>
<string name="srt_server_port_key">srt_server_port_key</string>
<string name="default_srt_server_port">9998</string>
<string name="srt_server_stream_id_key">server_stream_id_key</string>
<string name="srt_server_stream_id">Stream ID</string>
<string name="default_srt_server_stream_id" />
<string name="srt_server_passphrase_key">srt_server_passphrase_key</string>
<string name="srt_server_passphrase">Passphrase</string>
<string name="default_srt_server_stream_passphrase" />
<string name="default_srt_server_passphrase">""</string>
<string name="srt_server_enable_bitrate_regulation_key">srt_server_enable_bitrate_regulation_key</string>
<string name="srt_server_enable_bitrate_regulation">Enable bitrate regulation</string>
Expand All @@ -128,6 +134,7 @@
<string name="file">File</string>
<string name="file_name_key">file_name_key</string>
<string name="file_name">File name</string>
<string name="default_file_name">StreamPackFile</string>

<!-- Video and audio encoders -->
<string name="video_encoder_h264">AVC/H.264</string>
Expand Down
16 changes: 14 additions & 2 deletions demos/camera/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@
app:title="@string/settings">

<ListPreference
app:defaultValue="@string/default_video_encoder"
app:key="@string/video_encoder_key"
app:title="@string/video_encoder"
app:useSimpleSummaryProvider="true" />

<ListPreference
app:defaultValue="@string/default_video_resolution"
app:key="@string/video_resolution_key"
app:title="@string/video_resolution"
app:useSimpleSummaryProvider="true" />

<ListPreference
app:defaultValue="@string/default_fps"
app:entries="@array/FpsEntries"
app:entryValues="@array/FpsEntries"
app:key="@string/video_fps_key"
Expand All @@ -30,6 +33,7 @@

<SeekBarPreference
android:max="10000"
app:defaultValue="@string/default_video_bitrate"
app:key="@string/video_bitrate_key"
app:min="500"
app:showSeekBarValue="true"
Expand Down Expand Up @@ -61,34 +65,40 @@
app:title="@string/settings">

<ListPreference
app:defaultValue="@string/default_audio_encoder"
app:key="@string/audio_encoder_key"
app:title="@string/audio_encoder"
app:useSimpleSummaryProvider="true" />

<ListPreference
app:defaultValue="12"
app:entries="@array/AudioChannelConfigEntries"
app:entryValues="@array/AudioChannelConfigEntryValues"
app:key="@string/audio_channel_config_key"
app:title="@string/audio_number_of_channels"
app:useSimpleSummaryProvider="true" />

<ListPreference
app:defaultValue="128000"
app:entryValues="@array/AudioBitrateEntryValues"
app:key="@string/audio_bitrate_key"
app:title="@string/audio_bitrate"
app:useSimpleSummaryProvider="true" />

<ListPreference
app:defaultValue="44100"
app:key="@string/audio_sample_rate_key"
app:title="@string/audio_sample_rate"
app:useSimpleSummaryProvider="true" />

<ListPreference
app:defaultValue="2"
app:key="@string/audio_byte_format_key"
app:title="@string/audio_byte_format"
app:useSimpleSummaryProvider="true" />

<ListPreference
app:defaultValue="2"
app:key="@string/audio_profile_key"
app:title="@string/audio_profile"
app:useSimpleSummaryProvider="true" />
Expand All @@ -99,6 +109,7 @@

<PreferenceCategory app:title="@string/endpoint">
<ListPreference
app:defaultValue="2"
app:key="@string/endpoint_type_key"
app:title="@string/endpoint_type"
app:useSimpleSummaryProvider="true" />
Expand All @@ -114,12 +125,13 @@
app:useSimpleSummaryProvider="true" />

<EditTextPreference
app:defaultValue="9998"
app:defaultValue="@string/default_srt_server_port"
app:key="@string/srt_server_port_key"
app:title="@string/server_port"
app:useSimpleSummaryProvider="true" />

<EditTextPreference
app:defaultValue="@string/default_srt_server_stream_id"
app:key="@string/srt_server_stream_id_key"
app:title="@string/srt_server_stream_id"
app:useSimpleSummaryProvider="true" />
Expand Down Expand Up @@ -172,7 +184,7 @@
app:title="@string/file">

<EditTextPreference
app:defaultValue="StreamPackTest"
app:defaultValue="@string/default_file_name"
app:key="@string/file_name_key"
app:title="@string/file_name"
app:useSimpleSummaryProvider="true" />
Expand Down

0 comments on commit 19b472f

Please sign in to comment.