add mMaskedPath and mMaskedSecondPath and use them when logging so that usernames and passwords are shown in logs. Fixes #3118
parent
ae313fa31b
commit
939e1d83f0
|
@ -131,6 +131,8 @@ FfmpegCamera::FfmpegCamera(
|
||||||
hwaccel_name(p_hwaccel_name),
|
hwaccel_name(p_hwaccel_name),
|
||||||
hwaccel_device(p_hwaccel_device)
|
hwaccel_device(p_hwaccel_device)
|
||||||
{
|
{
|
||||||
|
mMaskedPath = mask_authentication(mPath);
|
||||||
|
mMaskedSecondPath = mask_authentication(mSecondPath);
|
||||||
if ( capture ) {
|
if ( capture ) {
|
||||||
FFMPEGInit();
|
FFMPEGInit();
|
||||||
}
|
}
|
||||||
|
@ -175,12 +177,12 @@ FfmpegCamera::~FfmpegCamera() {
|
||||||
int FfmpegCamera::PrimeCapture() {
|
int FfmpegCamera::PrimeCapture() {
|
||||||
start_read_time = time(nullptr);
|
start_read_time = time(nullptr);
|
||||||
if ( mCanCapture ) {
|
if ( mCanCapture ) {
|
||||||
Debug(1, "Priming capture from %s, Closing", mPath.c_str());
|
Debug(1, "Priming capture from %s, Closing", mMaskedPath.c_str());
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
mVideoStreamId = -1;
|
mVideoStreamId = -1;
|
||||||
mAudioStreamId = -1;
|
mAudioStreamId = -1;
|
||||||
Debug(1, "Priming capture from %s", mPath.c_str());
|
Debug(1, "Priming capture from %s", mMaskedPath.c_str());
|
||||||
|
|
||||||
return OpenFfmpeg();
|
return OpenFfmpeg();
|
||||||
}
|
}
|
||||||
|
@ -304,7 +306,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
||||||
}
|
}
|
||||||
} // end if RTSP
|
} // end if RTSP
|
||||||
|
|
||||||
Debug(1, "Calling avformat_open_input for %s", mPath.c_str());
|
Debug(1, "Calling avformat_open_input for %s", mMaskedPath.c_str());
|
||||||
|
|
||||||
mFormatContext = avformat_alloc_context();
|
mFormatContext = avformat_alloc_context();
|
||||||
// Speed up find_stream_info
|
// Speed up find_stream_info
|
||||||
|
@ -318,7 +320,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
||||||
if ( ret != 0 )
|
if ( ret != 0 )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
Error("Unable to open input %s due to: %s", mPath.c_str(),
|
Error("Unable to open input %s due to: %s", mMaskedPath.c_str(),
|
||||||
av_make_error_string(ret).c_str());
|
av_make_error_string(ret).c_str());
|
||||||
#if !LIBAVFORMAT_VERSION_CHECK(53, 17, 0, 25, 0)
|
#if !LIBAVFORMAT_VERSION_CHECK(53, 17, 0, 25, 0)
|
||||||
av_close_input_file(mFormatContext);
|
av_close_input_file(mFormatContext);
|
||||||
|
@ -346,7 +348,8 @@ int FfmpegCamera::OpenFfmpeg() {
|
||||||
#endif
|
#endif
|
||||||
if ( ret < 0 ) {
|
if ( ret < 0 ) {
|
||||||
Error("Unable to find stream info from %s due to: %s",
|
Error("Unable to find stream info from %s due to: %s",
|
||||||
mPath.c_str(), av_make_error_string(ret).c_str());
|
mMaskedPath.c_str(), av_make_error_string(ret).c_str());
|
||||||
|
avformat_close_input(&mFormatContext);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +379,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
||||||
} // end foreach stream
|
} // end foreach stream
|
||||||
|
|
||||||
if ( mVideoStreamId == -1 ) {
|
if ( mVideoStreamId == -1 ) {
|
||||||
Error("Unable to locate video stream in %s", mPath.c_str());
|
Error("Unable to locate video stream in %s", mMaskedPath.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +411,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
||||||
->codec_id);
|
->codec_id);
|
||||||
if ( !mVideoCodec ) {
|
if ( !mVideoCodec ) {
|
||||||
// Try and get the codec from the codec context
|
// Try and get the codec from the codec context
|
||||||
Error("Can't find codec for video stream from %s", mPath.c_str());
|
Error("Can't find codec for video stream from %s", mMaskedPath.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -512,15 +515,15 @@ int FfmpegCamera::OpenFfmpeg() {
|
||||||
while ( (e = av_dict_get(opts, "", e, AV_DICT_IGNORE_SUFFIX)) != nullptr ) {
|
while ( (e = av_dict_get(opts, "", e, AV_DICT_IGNORE_SUFFIX)) != nullptr ) {
|
||||||
Warning("Option %s not recognized by ffmpeg", e->key);
|
Warning("Option %s not recognized by ffmpeg", e->key);
|
||||||
}
|
}
|
||||||
if ( ret < 0 ) {
|
if (ret < 0) {
|
||||||
Error("Unable to open codec for video stream from %s", mPath.c_str());
|
Error("Unable to open codec for video stream from %s", mMaskedPath.c_str());
|
||||||
av_dict_free(&opts);
|
av_dict_free(&opts);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
zm_dump_codec(mVideoCodecContext);
|
zm_dump_codec(mVideoCodecContext);
|
||||||
|
|
||||||
if (mAudioStreamId == -1 and !monitor->GetSecondPath().empty()) {
|
if (mAudioStreamId == -1 and !monitor->GetSecondPath().empty()) {
|
||||||
Debug(1, "Trying secondary stream at %s", monitor->GetSecondPath().c_str());
|
Debug(1, "Trying secondary stream at %s", mask_authentication(monitor->GetSecondPath()).c_str());
|
||||||
FFmpeg_Input *second_input = new FFmpeg_Input();
|
FFmpeg_Input *second_input = new FFmpeg_Input();
|
||||||
if (second_input->Open(monitor->GetSecondPath().c_str()) > 0) {
|
if (second_input->Open(monitor->GetSecondPath().c_str()) > 0) {
|
||||||
mSecondFormatContext = second_input->get_format_context();
|
mSecondFormatContext = second_input->get_format_context();
|
||||||
|
@ -540,7 +543,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
||||||
mAudioStream->codec->codec_id
|
mAudioStream->codec->codec_id
|
||||||
#endif
|
#endif
|
||||||
)) == nullptr ) {
|
)) == nullptr ) {
|
||||||
Debug(1, "Can't find codec for audio stream from %s", mPath.c_str());
|
Debug(1, "Can't find codec for audio stream from %s", mMaskedPath.c_str());
|
||||||
} else {
|
} else {
|
||||||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||||
mAudioCodecContext = avcodec_alloc_context3(mAudioCodec);
|
mAudioCodecContext = avcodec_alloc_context3(mAudioCodec);
|
||||||
|
@ -560,7 +563,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
||||||
if ( avcodec_open2(mAudioCodecContext, mAudioCodec, nullptr) < 0 )
|
if ( avcodec_open2(mAudioCodecContext, mAudioCodec, nullptr) < 0 )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
Error("Unable to open codec for audio stream from %s", mPath.c_str());
|
Error("Unable to open codec for audio stream from %s", mMaskedPath.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
} // end if opened
|
} // end if opened
|
||||||
} // end if found decoder
|
} // end if found decoder
|
||||||
|
|
|
@ -36,7 +36,9 @@ typedef struct DecodeContext {
|
||||||
class FfmpegCamera : public Camera {
|
class FfmpegCamera : public Camera {
|
||||||
protected:
|
protected:
|
||||||
std::string mPath;
|
std::string mPath;
|
||||||
|
std::string mMaskedPath;
|
||||||
std::string mSecondPath;
|
std::string mSecondPath;
|
||||||
|
std::string mMaskedSecondPath;
|
||||||
std::string mMethod;
|
std::string mMethod;
|
||||||
std::string mOptions;
|
std::string mOptions;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue