diff --git a/prudynt.cfg.example b/prudynt.cfg.example index 837453b..24f1d03 100644 --- a/prudynt.cfg.example +++ b/prudynt.cfg.example @@ -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)) @@ -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)) @@ -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). diff --git a/src/Config.cpp b/src/Config.cpp index f5816df..ca76c6f 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -152,7 +152,7 @@ std::vector> 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}, @@ -163,6 +163,8 @@ std::vector> CFG::getCharItems() std::set 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) { @@ -181,9 +183,9 @@ std::vector> 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; }}, @@ -514,8 +516,6 @@ void handleConfigItem(Config &lc, ConfigItem &item) template void handleConfigItem2(Config &lc, ConfigItem &item) { - T configValue{0}; - std::string path(item.path); size_t pos = path.find_last_of('.'); std::string sect = path.substr(0, pos); diff --git a/src/Config.hpp b/src/Config.hpp index 8218d4d..a8c0213 100644 --- a/src/Config.hpp +++ b/src/Config.hpp @@ -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; diff --git a/src/IMPAudio.cpp b/src/IMPAudio.cpp index 0d2e55b..008e4bb 100644 --- a/src/IMPAudio.cpp +++ b/src/IMPAudio.cpp @@ -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); @@ -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; diff --git a/src/RTSP.cpp b/src/RTSP.cpp index 61e30b5..dfb4b75 100644 --- a/src/RTSP.cpp +++ b/src/RTSP.cpp @@ -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 ); diff --git a/src/WS.cpp b/src/WS.cpp index fa2fbc1..927c21c 100644 --- a/src/WS.cpp +++ b/src/WS.cpp @@ -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, @@ -271,6 +272,7 @@ static const char *const stream_keys[] = { "audio_enabled", "scale_enabled", "rtsp_endpoint", + "rtsp_info", "format", "mode", "gop", @@ -1277,6 +1279,11 @@ signed char WS::stream_callback(struct lejp_ctx *ctx, char reason) cfg->set(u_ctx->path, strdup(ctx->buf)); add_json_str(u_ctx->message, cfg->get(u_ctx->path)); break; + case PNT_STREAM_RTSP_INFO: + if (reason == LEJPCB_VAL_STR_END) + cfg->set(u_ctx->path, strdup(ctx->buf)); + add_json_str(u_ctx->message, cfg->get(u_ctx->path)); + break; case PNT_STREAM_SCALE_ENABLED: if (reason == LEJPCB_VAL_TRUE) {