Skip to content

Commit

Permalink
Merge pull request #60 from Lu-Fi/master
Browse files Browse the repository at this point in the history
allow to name subchannel and disable audio gain
  • Loading branch information
themactep authored Dec 7, 2024
2 parents 0e88d56 + 8ceba30 commit e99ef07
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
6 changes: 4 additions & 2 deletions prudynt.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ stream0: {
# enabled: true; # Enable or disable Stream0.
# audio_enabled: true; # Enable audio on the stream.
# rtsp_endpoint: "ch0"; # Endpoint name for the RTSP url stream.
# rtsp_info: "stream0"; # Endpoint info for the RTSP url stream.
# format: "H264"; # Video format for the stream (H264 or H265).
# bitrate: 3000; # Bitrate for the stream (in kbps).
# mode: "SMART"; # Rate control mode: ("CBR", "VBR", "FIXQP", ("SMART" on T1x, T2x, T30), ("CAPPED_VBR", "CAPPED_QUALITY" on T31))
Expand Down Expand Up @@ -133,6 +134,7 @@ stream1: {
# enabled: true; # Enable or disable Stream1.
# audio_enabled: true; # Enable audio on the stream.
# rtsp_endpoint: "ch1"; # Endpoint name for the RTSP url stream.
# rtsp_info: "stream1"; # Endpoint info for the RTSP url stream.
# format: "H264"; # Video format for the stream (H264 or H265).
# bitrate: 1000; # Bitrate for the stream (in kbps).
# mode: "SMART"; # Rate control mode: ("CBR", "VBR", "FIXQP", ("SMART" on T1x, T2x, T30), ("CAPPED_VBR", "CAPPED_QUALITY" on T31))
Expand Down Expand Up @@ -215,8 +217,8 @@ audio: {
# input_high_pass_filter: false; # Enable or disable high pass filter for audio input.
# input_agc_enabled: false; # Enable or disable AGC for audio input.
# input_vol: 80; # Input volume for audio (-30 to 120).
# input_gain: 25; # Input gain for audio (0 to 31).
# input_alc_gain: 0; # ALC gain for audio input (0 to 7).
# input_gain: 25; # Input gain for audio (-1 to 31), -1 will disable this setting.
# input_alc_gain: 0; # ALC gain for audio input (-1 to 7), -1 will disable this setting.
# input_agc_target_level_dbfs: 10; # AGC target level in dBFS for audio input (0 to 31).
# input_agc_compression_gain_db: 0; # AGC compression gain in dB for audio input (0 to 90).
# input_noise_suppression: 0; # Noise suppression for audio input (0 to 3).
Expand Down
10 changes: 5 additions & 5 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ std::vector<ConfigItem<const char *>> CFG::getCharItems()
return a.count(std::string(v)) == 1;
}},
{"stream0.rtsp_endpoint", stream0.rtsp_endpoint, "ch0", validateCharNotEmpty},
{"stream1.rtsp_endpoint", stream1.rtsp_endpoint, "ch1", validateCharNotEmpty},
{"stream0.rtsp_info", stream0.rtsp_info, "stream0", validateCharNotEmpty},
{"stream1.format", stream1.format, "H264", [](const char *v) { return strcmp(v, "H264") == 0 || strcmp(v, "H265") == 0; }},
{"stream1.osd.font_path", stream1.osd.font_path, "/usr/share/fonts/NotoSansDisplay-Condensed2.ttf", validateCharNotEmpty},
{"stream1.osd.logo_path", stream1.osd.logo_path, "/usr/share/images/thingino_logo_1.bgra", validateCharNotEmpty},
Expand All @@ -163,6 +163,8 @@ std::vector<ConfigItem<const char *>> CFG::getCharItems()
std::set<std::string> a = {"CBR", "VBR", "SMART", "FIXQP", "CAPPED_VBR", "CAPPED_QUALITY"};
return a.count(std::string(v)) == 1;
}},
{"stream1.rtsp_endpoint", stream1.rtsp_endpoint, "ch1", validateCharNotEmpty},
{"stream1.rtsp_info", stream1.rtsp_info, "stream1", validateCharNotEmpty},
{"stream2.jpeg_path", stream2.jpeg_path, "/tmp/snapshot.jpg", validateCharNotEmpty},
{"websocket.name", websocket.name, "wss prudynt", validateCharNotEmpty},
{"websocket.usertoken", websocket.usertoken, "", [](const char *v) {
Expand All @@ -181,9 +183,9 @@ std::vector<ConfigItem<int>> CFG::getIntItems()
return a.count(v) == 1;
}},
{"audio.input_vol", audio.input_vol, 80, [](const int &v) { return v >= -30 && v <= 120; }},
{"audio.input_gain", audio.input_gain, 25, [](const int &v) { return v >= 0 && v <= 31; }},
{"audio.input_gain", audio.input_gain, 25, [](const int &v) { return v >= -1 && v <= 31; }},
#if defined(LIB_AUDIO_PROCESSING)
{"audio.input_alc_gain", audio.input_alc_gain, 0, [](const int &v) { return v >= 0 && v <= 7; }},
{"audio.input_alc_gain", audio.input_alc_gain, 0, [](const int &v) { return v >= -1 && v <= 7; }},
{"audio.input_agc_target_level_dbfs", audio.input_agc_target_level_dbfs, 10, [](const int &v) { return v >= 0 && v <= 31; }},
{"audio.input_agc_compression_gain_db", audio.input_agc_compression_gain_db, 0, [](const int &v) { return v >= 0 && v <= 90; }},
{"audio.input_noise_suppression", audio.input_noise_suppression, 0, [](const int &v) { return v >= 0 && v <= 3; }},
Expand Down Expand Up @@ -514,8 +516,6 @@ void handleConfigItem(Config &lc, ConfigItem<T> &item)
template <typename T>
void handleConfigItem2(Config &lc, ConfigItem<T> &item)
{
T configValue{0};

std::string path(item.path);
size_t pos = path.find_last_of('.');
std::string sect = path.substr(0, pos);
Expand Down
1 change: 1 addition & 0 deletions src/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ struct _stream {
bool allow_shared;
const char *mode;
const char *rtsp_endpoint;
const char *rtsp_info;
const char *format{"JPEG"};
/* JPEG stream*/
int jpeg_quality;
Expand Down
14 changes: 10 additions & 4 deletions src/IMPAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,11 @@ int IMPAudio::init()
ret = IMP_AI_GetVol(devId, inChn, &vol);
LOG_DEBUG_OR_ERROR(ret, "IMP_AI_GetVol(" << devId << ", " << inChn << ", &vol)");

ret = IMP_AI_SetGain(devId, inChn, cfg->audio.input_gain);
LOG_DEBUG_OR_ERROR(ret, "IMP_AI_SetGain(" << devId << ", " << inChn << ", " << cfg->audio.input_gain << ")");
if(cfg->audio.input_gain >= 0)
{
ret = IMP_AI_SetGain(devId, inChn, cfg->audio.input_gain);
LOG_DEBUG_OR_ERROR(ret, "IMP_AI_SetGain(" << devId << ", " << inChn << ", " << cfg->audio.input_gain << ")");
}

int gain;
ret = IMP_AI_GetGain(devId, inChn, &gain);
Expand Down Expand Up @@ -210,8 +213,11 @@ int IMPAudio::init()
}
#endif
#if defined(PLATFORM_T21) || (defined(PLATFORM_T31))
ret = IMP_AI_SetAlcGain(devId, inChn, cfg->audio.input_alc_gain);
LOG_DEBUG_OR_ERROR(ret, "IMP_AI_SetAlcGain(" << devId << ", " << inChn << ", " << cfg->audio.input_alc_gain << ")");
if(cfg->audio.input_alc_gain > 0)
{
ret = IMP_AI_SetAlcGain(devId, inChn, cfg->audio.input_alc_gain);
LOG_DEBUG_OR_ERROR(ret, "IMP_AI_SetAlcGain(" << devId << ", " << inChn << ", " << cfg->audio.input_alc_gain << ")");
}
#endif
#endif //LIB_AUDIO_PROCESSING
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/RTSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void RTSP::addSubsession(int chnNr, _stream &stream)
LOG_DEBUG("Got necessary NAL Units.");

ServerMediaSession *sms = ServerMediaSession::createNew(
*env, stream.rtsp_endpoint, "Sub", cfg->rtsp.name);
*env, stream.rtsp_endpoint, stream.rtsp_info, cfg->rtsp.name);
IMPServerMediaSubsession *sub = IMPServerMediaSubsession::createNew(
*env, (is_h265 ? vps : nullptr), sps, pps, chnNr // Conditional VPS
);
Expand Down
7 changes: 7 additions & 0 deletions src/WS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ enum
PNT_STREAM_AUDIO_ENABLED,
PNT_STREAM_SCALE_ENABLED,
PNT_STREAM_RTSP_ENDPOINT,
PNT_STREAM_RTSP_INFO,
PNT_STREAM_FORMAT,
PNT_STREAM_MODE,
PNT_STREAM_GOP,
Expand All @@ -271,6 +272,7 @@ static const char *const stream_keys[] = {
"audio_enabled",
"scale_enabled",
"rtsp_endpoint",
"rtsp_info",
"format",
"mode",
"gop",
Expand Down Expand Up @@ -1277,6 +1279,11 @@ signed char WS::stream_callback(struct lejp_ctx *ctx, char reason)
cfg->set<const char *>(u_ctx->path, strdup(ctx->buf));
add_json_str(u_ctx->message, cfg->get<const char *>(u_ctx->path));
break;
case PNT_STREAM_RTSP_INFO:
if (reason == LEJPCB_VAL_STR_END)
cfg->set<const char *>(u_ctx->path, strdup(ctx->buf));
add_json_str(u_ctx->message, cfg->get<const char *>(u_ctx->path));
break;
case PNT_STREAM_SCALE_ENABLED:
if (reason == LEJPCB_VAL_TRUE)
{
Expand Down

0 comments on commit e99ef07

Please sign in to comment.