Skip to content

Commit

Permalink
perf(rtsp-output): Simplified the way audio tracks configurations are…
Browse files Browse the repository at this point in the history
… stored in configuration files.
  • Loading branch information
iamscottxu committed Dec 22, 2023
1 parent 399dcd5 commit cb260f6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
6 changes: 1 addition & 5 deletions rtsp_output_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,7 @@ void RtspOutputHelper::CreateAudioEncoder()
}
auto trackIndex = 0;
for (auto idx = 0; idx < OBS_OUTPUT_MULTI_TRACK; idx++) {
if (!config_get_bool(config, CONFIG_SECTIION,
string("AudioTrack")
.append(to_string(idx + 1))
.c_str()))
continue;
if ((tracks & (1 << idx)) == 0) continue;
auto audioEncoder = obs_audio_encoder_create(
obs_encoder_get_id(encoder),
string("rtsp_output_audio_track")
Expand Down
23 changes: 22 additions & 1 deletion ui/rtsp_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ void RtspProperties::LoadConfig(config_t *config) const
{
ui->checkBoxAuto->setChecked(
config_get_bool(config, CONFIG_SECTIION, "AutoStart"));
/*
ui->checkBoxAudioTrack1->setChecked(
config_get_bool(config, CONFIG_SECTIION, "AudioTrack1"));
ui->checkBoxAudioTrack2->setChecked(
Expand All @@ -305,15 +306,26 @@ void RtspProperties::LoadConfig(config_t *config) const
config_get_bool(config, CONFIG_SECTIION, "AudioTrack5"));
ui->checkBoxAudioTrack6->setChecked(
config_get_bool(config, CONFIG_SECTIION, "AudioTrack6"));
*/
{
auto tracks =
config_get_uint(config, CONFIG_SECTIION, "AudioTracks");
ui->checkBoxAudioTrack1->setChecked(tracks & (1 << 0));
ui->checkBoxAudioTrack2->setChecked(tracks & (1 << 1));
ui->checkBoxAudioTrack3->setChecked(tracks & (1 << 2));
ui->checkBoxAudioTrack4->setChecked(tracks & (1 << 3));
ui->checkBoxAudioTrack5->setChecked(tracks & (1 << 4));
ui->checkBoxAudioTrack6->setChecked(tracks & (1 << 5));
}
}

void RtspProperties::SaveConfig(config_t *config) const
{
if (!config)
return;

config_set_bool(config, CONFIG_SECTIION, "AutoStart",
ui->checkBoxAuto->isChecked());
/*
config_set_bool(config, CONFIG_SECTIION, "AudioTrack1",
ui->checkBoxAudioTrack1->isChecked());
config_set_bool(config, CONFIG_SECTIION, "AudioTrack2",
Expand All @@ -326,5 +338,14 @@ void RtspProperties::SaveConfig(config_t *config) const
ui->checkBoxAudioTrack5->isChecked());
config_set_bool(config, CONFIG_SECTIION, "AudioTrack6",
ui->checkBoxAudioTrack6->isChecked());
*/
uint64_t tracks = 0;
tracks |= ui->checkBoxAudioTrack1->isChecked() ? (1 << 0) : 0;
tracks |= ui->checkBoxAudioTrack2->isChecked() ? (1 << 1) : 0;
tracks |= ui->checkBoxAudioTrack3->isChecked() ? (1 << 2) : 0;
tracks |= ui->checkBoxAudioTrack4->isChecked() ? (1 << 3) : 0;
tracks |= ui->checkBoxAudioTrack5->isChecked() ? (1 << 4) : 0;
tracks |= ui->checkBoxAudioTrack6->isChecked() ? (1 << 5) : 0;
config_set_uint(config, CONFIG_SECTIION, "AudioTracks", tracks);
config_save(config);
}

0 comments on commit cb260f6

Please sign in to comment.