Merge sync fixes from storageareas
This commit is contained in:
parent
3bae7a5432
commit
470da03322
|
@ -66,14 +66,14 @@ std::pair <std::string, unsigned int> verifyToken(std::string jwt_token_str, std
|
|||
|
||||
bool verifyPassword(const char *username, const char *input_password, const char *db_password_hash) {
|
||||
bool password_correct = false;
|
||||
if (strlen(db_password_hash ) < 4) {
|
||||
if ( strlen(db_password_hash) < 4 ) {
|
||||
// actually, shoud be more, but this is min. for next code
|
||||
Error ("DB Password is too short or invalid to check");
|
||||
Error("DB Password is too short or invalid to check");
|
||||
return false;
|
||||
}
|
||||
if (db_password_hash[0] == '*') {
|
||||
if ( db_password_hash[0] == '*' ) {
|
||||
// MYSQL PASSWORD
|
||||
Debug (1,"%s is using an MD5 encoded password", username);
|
||||
Debug(1, "%s is using an MD5 encoded password", username);
|
||||
|
||||
SHA_CTX ctx1, ctx2;
|
||||
unsigned char digest_interim[SHA_DIGEST_LENGTH];
|
||||
|
@ -90,28 +90,30 @@ bool verifyPassword(const char *username, const char *input_password, const char
|
|||
SHA1_Final (digest_final, &ctx2);
|
||||
|
||||
char final_hash[SHA_DIGEST_LENGTH * 2 +2];
|
||||
final_hash[0]='*';
|
||||
final_hash[0] = '*';
|
||||
//convert to hex
|
||||
for(int i = 0; i < SHA_DIGEST_LENGTH; i++)
|
||||
sprintf(&final_hash[i*2]+1, "%02X", (unsigned int)digest_final[i]);
|
||||
final_hash[SHA_DIGEST_LENGTH *2 + 1]=0;
|
||||
for ( int i = 0; i < SHA_DIGEST_LENGTH; i++ )
|
||||
sprintf(&final_hash[i*2]+1, "%02X", (unsigned int)digest_final[i]);
|
||||
final_hash[SHA_DIGEST_LENGTH *2 + 1] = 0;
|
||||
|
||||
Debug (1,"Computed password_hash:%s, stored password_hash:%s", final_hash, db_password_hash);
|
||||
Debug (5, "Computed password_hash:%s, stored password_hash:%s", final_hash, db_password_hash);
|
||||
Debug(1, "Computed password_hash:%s, stored password_hash:%s", final_hash, db_password_hash);
|
||||
password_correct = (strcmp(db_password_hash, final_hash)==0);
|
||||
}
|
||||
else if ((db_password_hash[0] == '$') && (db_password_hash[1]== '2')
|
||||
&&(db_password_hash[3] == '$')) {
|
||||
} else if (
|
||||
(db_password_hash[0] == '$')
|
||||
&&
|
||||
(db_password_hash[1]== '2')
|
||||
&&
|
||||
(db_password_hash[3] == '$')
|
||||
) {
|
||||
// BCRYPT
|
||||
Debug (1,"%s is using a bcrypt encoded password", username);
|
||||
Debug(1, "%s is using a bcrypt encoded password", username);
|
||||
BCrypt bcrypt;
|
||||
std::string input_hash = bcrypt.generateHash(std::string(input_password));
|
||||
password_correct = bcrypt.validatePassword(std::string(input_password), std::string(db_password_hash));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// plain
|
||||
Warning ("%s is using a plain text password, please do not use plain text", username);
|
||||
Warning("%s is using a plain text password, please do not use plain text", username);
|
||||
password_correct = (strcmp(input_password, db_password_hash) == 0);
|
||||
}
|
||||
return password_correct;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -458,9 +458,9 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
}
|
||||
} // end foreach stream
|
||||
if ( mVideoStreamId == -1 )
|
||||
Fatal( "Unable to locate video stream in %s", mPath.c_str() );
|
||||
Fatal("Unable to locate video stream in %s", mPath.c_str());
|
||||
if ( mAudioStreamId == -1 )
|
||||
Debug( 3, "Unable to locate audio stream in %s", mPath.c_str() );
|
||||
Debug(3, "Unable to locate audio stream in %s", mPath.c_str());
|
||||
|
||||
Debug(3, "Found video stream at index %d", mVideoStreamId);
|
||||
Debug(3, "Found audio stream at index %d", mAudioStreamId);
|
||||
|
@ -758,6 +758,11 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event
|
|||
int keyframe = packet.flags & AV_PKT_FLAG_KEY;
|
||||
bytes += packet.size;
|
||||
dumpPacket(mFormatContext->streams[packet.stream_index], &packet, "Captured Packet");
|
||||
if ( packet.dts == AV_NOPTS_VALUE ) {
|
||||
packet.dts = packet.pts;
|
||||
//} else if ( packet.pts == AV_NOPTS_VALUE ) {
|
||||
//packet.pts = packet.dts;
|
||||
}
|
||||
|
||||
// Video recording
|
||||
if ( recording.tv_sec ) {
|
||||
|
@ -802,6 +807,7 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event
|
|||
if ( last_event_id and !videoStore ) {
|
||||
//Instantiate the video storage module
|
||||
|
||||
packetqueue->dumpQueue();
|
||||
if ( record_audio ) {
|
||||
if ( mAudioStreamId == -1 ) {
|
||||
Debug(3, "Record Audio on but no audio stream found");
|
||||
|
@ -967,7 +973,8 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event
|
|||
ret = avcodec_receive_frame(mVideoCodecContext, mRawFrame);
|
||||
if ( ret < 0 ) {
|
||||
av_strerror(ret, errbuf, AV_ERROR_MAX_STRING_SIZE);
|
||||
Warning("Unable to receive frame %d: %s, continuing", frameCount, errbuf);
|
||||
Warning("Unable to receive frame %d: %s, continuing. error count is %s",
|
||||
frameCount, errbuf, error_count);
|
||||
error_count += 1;
|
||||
if ( error_count > 100 ) {
|
||||
Error("Error count over 100, going to close and re-open stream");
|
||||
|
|
|
@ -63,7 +63,7 @@ bool zm_packetqueue::queuePacket(ZMPacket* zm_packet) {
|
|||
&&
|
||||
( av_packet->dts <= zm_packet->packet.dts)
|
||||
) {
|
||||
Debug(2, "break packet with stream index (%d) with dts %" PRId64,
|
||||
Debug(2, "break packet with stream index (%d) with dts %" PRId64,
|
||||
(*it)->packet.stream_index, (*it)->packet.dts);
|
||||
break;
|
||||
}
|
||||
|
@ -273,3 +273,12 @@ void zm_packetqueue::clear_unwanted_packets( timeval *recording_started, int mVi
|
|||
deleted_frames, pktQueue.size(), av_packet->stream_index, ( av_packet->flags & AV_PKT_FLAG_KEY ), distance( it, pktQueue.rend() ), pktQueue.size() );
|
||||
}
|
||||
} // end void zm_packetqueue::clear_unwanted_packets( timeval *recording_started, int mVideoStreamId )
|
||||
|
||||
void zm_packetqueue::dumpQueue() {
|
||||
std::list<ZMPacket *>::reverse_iterator it;
|
||||
for ( it = pktQueue.rbegin(); it != pktQueue.rend(); ++ it ) {
|
||||
ZMPacket *zm_packet = *it;
|
||||
AVPacket *av_packet = &(zm_packet->packet);
|
||||
dumpPacket(av_packet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
bool popAudioPacket(ZMPacket* packet);
|
||||
unsigned int clearQueue(unsigned int video_frames_to_keep, int stream_id);
|
||||
void clearQueue();
|
||||
void dumpQueue();
|
||||
unsigned int size();
|
||||
void clear_unwanted_packets(timeval *recording, int mVideoStreamId);
|
||||
int packet_count(int stream_id);
|
||||
|
|
|
@ -285,8 +285,8 @@ VideoStore::VideoStore(
|
|||
video_last_pts = 0;
|
||||
video_last_dts = 0;
|
||||
|
||||
audio_first_pts = 0;
|
||||
audio_first_dts = 0;
|
||||
video_first_pts = 0;
|
||||
video_first_dts = 0;
|
||||
audio_next_pts = 0;
|
||||
audio_next_dts = 0;
|
||||
|
||||
|
@ -371,6 +371,8 @@ VideoStore::VideoStore(
|
|||
audio_out_ctx->codec_tag = 0;
|
||||
#endif
|
||||
|
||||
audio_out_ctx->frame_size = audio_in_ctx->frame_size;
|
||||
|
||||
if ( audio_out_ctx->channels > 1 ) {
|
||||
Warning("Audio isn't mono, changing it.");
|
||||
audio_out_ctx->channels = 1;
|
||||
|
@ -938,7 +940,7 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) {
|
|||
Debug(3, "opkt.dts = %" PRId64 " from ipkt->dts(%" PRId64 ") - first_pts(%" PRId64 ")",
|
||||
opkt.dts, ipkt->dts, video_first_dts);
|
||||
}
|
||||
if ( opkt.dts > opkt.pts ) {
|
||||
if ( (opkt.pts != AV_NOPTS_VALUE) && (opkt.dts > opkt.pts) ) {
|
||||
Debug(1,
|
||||
"opkt.dts(%" PRId64 ") must be <= opkt.pts(%" PRId64 "). Decompression must happen "
|
||||
"before presentation.",
|
||||
|
@ -1017,12 +1019,12 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) {
|
|||
zm_dump_frame(out_frame, "Out frame after resample");
|
||||
// out_frame pts is in the input pkt pts... needs to be adjusted before sending to the encoder
|
||||
if ( out_frame->pts != AV_NOPTS_VALUE ) {
|
||||
if ( !audio_first_pts ) {
|
||||
audio_first_pts = out_frame->pts;
|
||||
Debug(1, "No audio_first_pts setting to %" PRId64, audio_first_pts);
|
||||
if ( !video_first_pts ) {
|
||||
video_first_pts = out_frame->pts;
|
||||
Debug(1, "No video_first_pts setting to %" PRId64, video_first_pts);
|
||||
out_frame->pts = 0;
|
||||
} else {
|
||||
out_frame->pts = out_frame->pts - audio_first_pts;
|
||||
out_frame->pts = out_frame->pts - video_first_pts;
|
||||
zm_dump_frame(out_frame, "Out frame after pts adjustment");
|
||||
}
|
||||
//
|
||||
|
@ -1097,18 +1099,18 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) {
|
|||
}
|
||||
// Scale the PTS of the outgoing packet to be the correct time base
|
||||
if ( ipkt->pts != AV_NOPTS_VALUE ) {
|
||||
if ( !audio_first_pts ) {
|
||||
if ( !video_first_pts ) {
|
||||
opkt.pts = 0;
|
||||
audio_first_pts = ipkt->pts;
|
||||
Debug(1, "No audio_first_pts");
|
||||
video_first_pts = ipkt->pts;
|
||||
Debug(1, "No video_first_pts");
|
||||
} else {
|
||||
opkt.pts = av_rescale_q(
|
||||
ipkt->pts - audio_first_pts,
|
||||
ipkt->pts - video_first_pts,
|
||||
AV_TIME_BASE_Q,
|
||||
//audio_in_stream->time_base,
|
||||
audio_out_stream->time_base);
|
||||
Debug(2, "audio opkt.pts = %" PRId64 " from ipkt->pts(%" PRId64 ") - first_pts(%" PRId64 ")",
|
||||
opkt.pts, ipkt->pts, audio_first_pts);
|
||||
opkt.pts, ipkt->pts, video_first_pts);
|
||||
}
|
||||
} else {
|
||||
Debug(2, "opkt.pts = undef");
|
||||
|
@ -1126,17 +1128,17 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) {
|
|||
opkt.dts = audio_next_dts + av_rescale_q( audio_in_stream->cur_dts - audio_last_dts, AV_TIME_BASE_Q, audio_out_stream->time_base);
|
||||
}
|
||||
#endif
|
||||
if ( !audio_first_dts ) {
|
||||
if ( !video_first_dts ) {
|
||||
opkt.dts = 0;
|
||||
audio_first_dts = ipkt->dts;
|
||||
video_first_dts = ipkt->dts;
|
||||
} else {
|
||||
opkt.dts = av_rescale_q(
|
||||
ipkt->dts - audio_first_dts,
|
||||
ipkt->dts - video_first_dts,
|
||||
AV_TIME_BASE_Q,
|
||||
//audio_in_stream->time_base,
|
||||
audio_out_stream->time_base);
|
||||
Debug(2, "opkt.dts = %" PRId64 " from ipkt.dts(%" PRId64 ") - first_dts(%" PRId64 ")",
|
||||
opkt.dts, ipkt->dts, audio_first_dts);
|
||||
opkt.dts, ipkt->dts, video_first_dts);
|
||||
}
|
||||
audio_last_dts = ipkt->dts;
|
||||
} else {
|
||||
|
@ -1200,12 +1202,12 @@ int VideoStore::resample_audio() {
|
|||
#if 0
|
||||
// out_frame pts is in the input pkt pts... needs to be adjusted before sending to the encoder
|
||||
if ( out_frame->pts != AV_NOPTS_VALUE ) {
|
||||
if ( !audio_first_pts ) {
|
||||
audio_first_pts = out_frame->pts;
|
||||
Debug(1, "No audio_first_pts setting to %" PRId64, audio_first_pts);
|
||||
if ( !video_first_pts ) {
|
||||
video_first_pts = out_frame->pts;
|
||||
Debug(1, "No video_first_pts setting to %" PRId64, video_first_pts);
|
||||
out_frame->pts = 0;
|
||||
} else {
|
||||
out_frame->pts = out_frame->pts - audio_first_pts;
|
||||
out_frame->pts = out_frame->pts - video_first_pts;
|
||||
}
|
||||
//
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue