Isaac Connor
0a1bd3537d
ready_count is now max(warmup_count,pre_event_count). This should ensure that we have enough packets in the packet queue when creating an event.
2021-02-10 13:54:20 -05:00
Isaac Connor
991e8dc860
Include mysqld_error.h so we can test for specific errors
2021-02-10 13:54:20 -05:00
Isaac Connor
64cfac9255
Only loop on SQL insert for wait timeout error, not others
2021-02-10 13:54:20 -05:00
Peter Keresztes Schmidt
2f5dff7244
Monitor: Don't push packets into the packet queue when in Monitor mode
...
There is no consumer for the packets in this mode, so don't queue them up. This saves quite a bit of RAM for mode of operation.
2021-02-10 16:13:47 +01:00
Peter Keresztes Schmidt
687ba03eb4
Drop relicts of zma
2021-02-10 13:26:25 +01:00
Isaac Connor
8f783c0ec4
Must also include cstdarg for va_start etc al
2021-02-09 23:32:27 -05:00
Isaac Connor
9879a40c4b
Must include cstring
2021-02-09 23:32:27 -05:00
Isaac Connor
b18522b6c0
Merge branch 'master' of github.com:ZoneMinder/zoneminder
2021-02-09 20:29:45 -05:00
Isaac Connor
fab7efa003
Fix PrimeCapture on local cams. We need to be able to call it for each monitor
2021-02-09 20:29:37 -05:00
Isaac Connor
dcf1ff3133
Merge pull request #3152 from Carbenium/ffmpeg-warnings
...
Fix some ffmpeg deprecation warnings
2021-02-09 20:15:41 -05:00
Peter Keresztes Schmidt
a66a9a6f10
Rtsp: Use AvStream.codecpar if available
...
.codec has been deprecated in libavf 57.33.100
2021-02-10 00:21:23 +01:00
Peter Keresztes Schmidt
e18f9e1f03
FFmpeg: Drop function which is not needed with supported ffmpeg versions
...
avformat_alloc_output_context2 was introduced in libavformat 53.2 (2011). Drop our own implementation which was used if the library version wasn't available. It isn't used anymore an causes compile warnings.
2021-02-10 00:21:23 +01:00
Peter Keresztes Schmidt
d0b80d63c3
FFmpeg: Fix a version check to avoid deprecation warnings on newer systems
2021-02-10 00:20:34 +01:00
Peter Keresztes Schmidt
0380bee130
AnalysisThread: Make the class un-movable
...
We depend on an unchanged value of "this" after the creation of the thread otherwise undefined values would be accessed within the std::thread.
2021-02-09 23:54:50 +01:00
Peter Keresztes Schmidt
8fa1249b33
Utils: Add some helper to create unique_ptrs
...
They follow the C++14 API and can be removed once the language level is increased.
2021-02-09 23:52:13 +01:00
Isaac Connor
67cd038a4f
Include pre-alarm frames in db
2021-02-09 15:33:09 -05:00
Isaac Connor
727594e3af
Fix rotated images by allocating image with camera dimensions
2021-02-09 14:53:14 -05:00
Isaac Connor
13d72bdec6
Merge branch 'master' of github.com:ZoneMinder/zoneminder
2021-02-09 14:24:20 -05:00
Isaac Connor
1780cfbff1
Add frames_duration
2021-02-09 14:23:34 -05:00
Isaac Connor
9b3d423f3d
Separate duration==endtime-starttime from Frames Duration
2021-02-09 14:22:23 -05:00
Isaac Connor
a5519075f5
Also save ALERT frames to db
2021-02-09 14:22:02 -05:00
Isaac Isaac
c233bf3463
spacing and a fix for duplicated for loop setting up rtsp server
2021-02-09 13:18:34 -05:00
Isaac Isaac
032420beb2
Don't need to init mVideoStream etc as they are done in Camera(). Set stream_index in packet.
2021-02-09 13:16:19 -05:00
Isaac Connor
05b5927f01
Don't queue audio packets if we aren't saving audio
2021-02-09 11:54:38 -05:00
Isaac Connor
1bce4f6bfa
When flushing queues, will return 0 when done. Handle it. Also set next dts from pkt, not opkt
2021-02-09 11:30:42 -05:00
Isaac Connor
e3eebeb9dd
Must return ret to handle case where ret=0.
2021-02-09 11:30:06 -05:00
Isaac Connor
aab3aed791
Merge pull request #3145 from Carbenium/analysis-thread
...
AnalysisThread: Move it over to std::thread
2021-02-09 09:26:47 -05:00
Peter Keresztes Schmidt
23a4b5087c
RTSPServerThread: Fix a crash during construction
...
It's a bad idea to use a shared_ptr instance from which the data just got moved away. Rename the instance variable to distinguish them.
2021-02-09 14:50:07 +01:00
Peter Keresztes Schmidt
4056782954
Comms: Move all classes to ZM:: namespace
...
The Socket class collides with a class named the same way from liblive555. This confuses the linker and links the wrong object leading to a crash when connecting to the RTSP server.
2021-02-09 14:45:33 +01:00
Peter Keresztes Schmidt
888ddc5d63
AnalysisThread: Sprinkle some more std::chrono
2021-02-09 12:26:53 +01:00
Peter Keresztes Schmidt
3ba8ff604f
AnalysisThread: Use std::this_thread::sleep_for instead of usleep
2021-02-09 12:26:53 +01:00
Peter Keresztes Schmidt
4cd70fec1a
Utils: Add some typedefs for std::chrono durations
2021-02-09 12:26:53 +01:00
Peter Keresztes Schmidt
b22dbd4788
AnalysisThread: Move it over to std::thread
2021-02-09 12:26:53 +01:00
Peter Keresztes Schmidt
00104b020c
Build: Link our libs and executable targets against zm-core-interface
2021-02-08 23:08:22 +01:00
Isaac Connor
4d0800151a
Merge pull request #3143 from Carbenium/close-event-crash
...
Monitor: Don't segfault in closeEvent if mmap is already unmapped
2021-02-08 15:32:38 -05:00
Peter Keresztes Schmidt
6fd6654488
Monitor: Don't segfault in closeEvent if mmap is already unmapped
2021-02-08 19:47:40 +01:00
Peter Keresztes Schmidt
7e7b1a0b1f
Logger: Try harder to obtain the DB lock
...
Since we are now multi-threaded it can happen quite easily that a log message should be written to the DB on one thread while the other thread executes another query. Don't bail out immediately in the logging code, instead try to obtain the lock within 1s.
2021-02-08 19:07:01 +01:00
Peter Keresztes Schmidt
70fbc25dbd
Mutex: Change method signatures so they resemble std::unique_lock a bit more
...
try_lock_for should specify in their return value whether obtaining the lock succeeded.
2021-02-08 18:59:25 +01:00
Isaac Connor
05a115e315
Merge pull request #3141 from Carbenium/recursive-mutex
...
RecursiveMutex: Use the pthread_mutex_t of the base class
2021-02-08 11:49:35 -05:00
Peter Keresztes Schmidt
40ddca14c6
RecursiveMutex: Use the pthread_mutex_t of the base class
...
Not doing so initializes a pthread_mutex_t with PTHREAD_MUTEX_RECURSIVE in the derived class but the lock/unlock
methods still use the pthread_mutex_t instance of the base class, which is not a recursive mutex.
2021-02-08 17:33:06 +01:00
Isaac Connor
583779438b
Don't unlock db_mutex if we don't get the lock in the first place
2021-02-08 11:09:44 -05:00
Isaac Connor
192aae8e30
small space and code doc
2021-02-08 09:04:06 -05:00
Isaac Connor
01e69569eb
Placement of -- matters.
2021-02-08 09:04:06 -05:00
Isaac Connor
b75d2f6164
Don't need to set ctx to null. fre_context does it for us
2021-02-08 09:04:06 -05:00
Isaac Connor
061140958c
Only update videodata if shared_data is active
2021-02-08 09:04:06 -05:00
Isaac Connor
57f599237c
Merge pull request #3136 from Carbenium/db-connect
...
DB: Make connection initialization more predictable and finalize mysql library correctly
2021-02-08 08:43:33 -05:00
Peter Keresztes Schmidt
3376b44290
Monitor: Fix a segfault when loading local cameras
2021-02-08 12:25:18 +01:00
Peter Keresztes Schmidt
f43507dce0
Use the power of smart pointers to manage Monitor instances
2021-02-07 21:20:45 +01:00
Peter Keresztes Schmidt
a3dc48b55d
Define printf format specifier for size_t types (SZFMTD)
2021-02-07 20:39:48 +01:00
Peter Keresztes Schmidt
cbb37337cb
DB: Improve resource cleanup on connection failure
2021-02-07 20:16:16 +01:00
Isaac Connor
e5f39e78c6
Merge pull request #3133 from Carbenium/dump-packet
...
ffmpeg: exit dumpPacket early if debug logging is not enabled
2021-02-07 10:40:58 -05:00
Peter Keresztes Schmidt
cc6ea04afe
Reformat touched code
2021-02-07 13:55:08 +01:00
Peter Keresztes Schmidt
3690da90ec
DB: Call mysql_library_end when closing the connection
...
With the previous commit double initialization of the mysql library is avoided which could have led to the segfaults.
2021-02-07 13:46:33 +01:00
Peter Keresztes Schmidt
aec4dbc6ff
DB: Make connection initialization more predictable and avoid double-initialization
...
Remove calls to zmDBConnect from various places to avoid possible side-effects/double initialization.
The function should be called once from the main thread of the daemon.
Also split config loading into 2 steps: static and DB config loading. Load the static config before zmDBConnect is called so it has a chance to succeed.
2021-02-07 13:44:41 +01:00
Peter Keresztes Schmidt
938676b129
ffmpeg: exit dumpPacket early if debug logging is not enabled
2021-02-07 11:58:17 +01:00
Isaac Connor
ace93e2422
fix event start packets getting deleted while writing because we don't have a lock on them.
2021-02-06 20:11:38 -05:00
Isaac Connor
010674b3dd
Fix use of local mem in return value reported by cppcheck
2021-02-06 20:11:38 -05:00
Isaac Connor
c28e1b09e5
Fix compile when using sysv shm
2021-02-06 20:11:38 -05:00
Isaac Connor
ab2e468322
Fix resource leak on failure to load font
2021-02-06 20:11:38 -05:00
Isaac Connor
87c3a862e2
remove our copies of min() and max(). Use std::min() and std::max()
2021-02-06 16:02:09 -05:00
Isaac Connor
0b138ee687
Merge pull request #3134 from Carbenium/sort
...
Image: Replace qsort with std::sort
2021-02-06 13:14:58 -05:00
Peter Keresztes Schmidt
9dc3f15eac
Image: Replace qsort with std::sort
...
std::sort has stricter complexity requirements than qsort and can be better optimized
by the compiler due to templating.
2021-02-06 15:41:56 +01:00
Isaac Connor
7f99635763
Fix xenial builds. Fixes #3130
2021-02-05 12:30:51 -05:00
Isaac Connor
885efc27ee
adjust pts/dts on flushed video packets. Improve code comments and debugging
2021-02-04 21:38:37 -05:00
Isaac Connor
2cdf017767
Fixi endlessly writing null frames to video on close when encoding audio to aac
2021-02-04 20:40:11 -05:00
Isaac Connor
9df4487eb7
Remove code to update the frames to match videostore. they are always in sync now
2021-02-04 20:39:48 -05:00
Isaac Connor
8f9637f21a
Merge pull request #3129 from Carbenium/cmake-reformat
...
Build: Reindent the CMakeLists
2021-02-04 17:20:34 -05:00
Isaac Connor
5ce9203d2c
add include <cstring>
2021-02-04 17:07:25 -05:00
Peter Keresztes Schmidt
6c9983155c
Build: Reindent the CMakeLists
...
Indent with 2 spaces
Also remove expressions form closing tags. They have been made optional a while ago since they make reading rather more difficult.
2021-02-04 22:00:56 +01:00
Isaac Connor
2ee097c5f2
Merge pull request #3128 from Carbenium/int-type-macros
...
Consolidate __STDC_FORMAT_MACROS and __STDC_CONSTANT_MACROS definition
2021-02-04 14:44:51 -05:00
Isaac Connor
da4b1fe3bc
Use global FFMPEGInit(). Removed compiler warning
2021-02-04 14:07:37 -05:00
Peter Keresztes Schmidt
dd527f0888
Consolidate __STDC_FORMAT_MACROS and __STDC_CONSTANT_MACROS definition
...
Move the definitions to zm_define.h and include the header at the appropriate locations.
These macros have not been adopted by the C++11 standard.
However glibc 2.17 (CentOS 7) still depends on them to provide the macros which are guarded by these defines.
2021-02-04 19:58:29 +01:00
Isaac Connor
c57c50fd4a
Merge pull request #3123 from Carbenium/catch2
...
[RFC] Add Catch2 as C++ test framework and some exemplary tests
2021-02-04 12:57:04 -05:00
Peter Keresztes Schmidt
bef4e4032f
Add Catch2 as C++ test framework
...
Use -DCMAKE_BUILD_TEST_SUITE=1 during CMake invocation to activate building the tests.
The 'tests' target builds the unit tests which can then be executed using the 'test' target.
We depend on the Catch2 version of the system.
Since development normally takes place on current OSs, this shouldn't pose a problem.
2021-02-04 18:53:54 +01:00
Isaac Connor
513739aeb5
Merge pull request #3127 from Carbenium/header-cleanup
...
Cleanup and reorganize includes
2021-02-04 12:52:04 -05:00
Isaac Connor
bf8b3fee2a
Merge pull request #3126 from Carbenium/cmake-man-pages
...
Build: Make building man pages optional (enabled by default)
2021-02-04 12:05:22 -05:00
Peter Keresztes Schmidt
eef0da8f19
Remove references to <csignal> from AnalysisThread
...
The removed block_set member was unused.
2021-02-04 18:02:08 +01:00
Peter Keresztes Schmidt
22372b5117
Replace #pragama once with include guards to be consistent
2021-02-04 18:02:08 +01:00
Peter Keresztes Schmidt
8869bfd903
Gut out zm.h since it is used only to store the self variable
2021-02-04 18:02:08 +01:00
Peter Keresztes Schmidt
0dbc39ee25
Cleanup and reorganize includes
...
With this commit a unified structure for includes is introduced.
The general rules:
* Only include what you need
* Include wherever possible in the cpp and forward-declare in the header
The includes are sorted in a local to global fashion. This means for the include order:
0. If cpp file: The corresponding h file and an empty line
1. Includes from the project sorted alphabetically
2. System/library includes sorted alphabetically
3. Conditional includes
2021-02-04 18:02:01 +01:00
Isaac Connor
046e352304
improvements to fps reporting. In analysis, we report based on image packets processed, but the fps value is calculated based on the count of images we did motion detection on. We no longer count audio packets in capture fps reporting.
2021-02-04 11:50:01 -05:00
Isaac Connor
ad9fd05955
When allocating mVideoStream, set mVideoStreamId as well
2021-02-04 10:28:17 -05:00
Isaac Connor
ac42aa2488
Setup mVideoStream and mVideoStreamId and set it in packet.
2021-02-04 10:27:56 -05:00
Peter Keresztes Schmidt
5a57efdfe2
Replace deprecated C header includes with the C++ ones.
2021-02-04 05:39:03 +01:00
Isaac Connor
c61e6a8c56
If there is an open event in disconnect close it. The idea is that by the time we get to the destructor we should be all shut down
2021-02-03 17:04:40 -05:00
Isaac Connor
6ac5472606
Add disconnecting to zmc to free up resources.
2021-02-03 16:58:03 -05:00
Isaac Connor
cb60b6c141
Fix bulk frame code and move it to event. Revert base score to 0. Fix cause of continuous events. Move GetState to .h
2021-02-03 16:57:44 -05:00
Isaac Connor
35470951ad
Move the bulk frame logic from monitor to event. Fix up the logic of when to store a db frame. Fix altering max_score too early
2021-02-03 16:56:34 -05:00
Peter Keresztes Schmidt
4db0dea1f2
Build: Make building man pages optional (enabled by default)
...
Add a new CMake option (-DBUILD_MAN) which can be used
to deactivate the man page build steps.
This is especially useful in a development situation where "make all"
is needlessly slowed down by these build steps.
2021-02-03 21:22:28 +01:00
Isaac Connor
be1db1ff20
Score should be a signed int
2021-02-03 09:08:06 -05:00
Isaac Connor
f868d92269
Fix colour shift in Crop function due to not multiplying x position by colours
2021-02-02 23:19:53 -05:00
Isaac Connor
49e9bf86fa
Code style
2021-02-02 23:19:53 -05:00
Isaac Connor
09d8dbb460
spacing
2021-02-02 23:19:53 -05:00
Isaac Connor
0958768ce5
Fix no bulk frames by setting score to -1 which means BULK. It will get changed to 0 or more by later code. Fixes #3121
2021-02-02 23:19:53 -05:00
Isaac Connor
7e469a28fa
remove redundant code, code style and remove some unnecessary multiplies
2021-02-02 23:19:53 -05:00
Isaac Connor
38368a8b9d
remove deprecated video_buffer_duration stuff. Fix loading monitor column order
2021-02-02 23:19:53 -05:00
Isaac Connor
e09c80e385
Have to close camera AFTER threads have stopped
2021-02-02 23:19:52 -05:00
Isaac Connor
61c3c0d565
Should increment_it after releasing the packet to prevent deadlock
2021-02-02 23:19:52 -05:00
Isaac Connor
8de260472d
improve the logic of clearing packets from queue. make get_event_start_it return a pointer to an it tracked by the packetqueue.
2021-02-02 23:19:52 -05:00
Isaac Connor
cb0008fb8c
Add rtsp_server and accessor
2021-02-02 23:19:52 -05:00
Isaac Connor
afa5e27d56
load RTSPServer column as well. start_it needs to be tracked by packetqueue. We no longer close the camera in Monitor::Close because we need to clear the packetqueue, then wait for threads to finish, THEN close camera. So that logic needs to move to zmc
2021-02-02 23:19:52 -05:00
Peter Keresztes Schmidt
0c5c720e4b
Remove includes of <stdint.h>
...
Instead of including the deprecated header <stdint.h>, zm_define.h should be used.
2021-02-02 21:37:26 +01:00
Peter Keresztes Schmidt
e09fa1bebf
Remove includes of <cinttypes>
...
Instead of including <cinttypes> directly, zm_define.h should be used
to get the typedef'ed types as well.
2021-02-02 21:37:26 +01:00
Peter Keresztes Schmidt
0f5df0c739
zm: Typedef C++11 int types to make them easier to use
...
In order to clearly state the intended length of an integer variable
all usages of other integer types (short int, int, long int, ...)
should be converted.
2021-02-02 21:37:26 +01:00
Isaac Connor
b71aa4bd97
Fix never allowing the queue to fill when pre_event_count=0
2021-02-01 16:01:30 -05:00
Isaac Connor
a5417cfe6c
NULL=>nullptr. Update analysis_fps earlier on startup
2021-02-01 16:01:09 -05:00
Isaac Connor
aa53260a32
Free packet counts and iterators in destructor. Fix mem leak in queuePacket. Introduce free_it method to release iterators
2021-02-01 10:25:48 -05:00
Isaac Connor
0676c7cfb4
Use packetqueue::free_it to release iterators
2021-02-01 10:24:58 -05:00
Isaac Connor
08a498ef6a
Convert packetqueue from a pointer to a packetqueue to a member packetqueue that is always available.
2021-01-31 21:31:33 -05:00
Isaac Connor
a0722b3782
stop thread
2021-01-31 21:31:33 -05:00
Isaac Connor
fdadacac6c
set packet.size and data because av_init_packet don't do that
2021-01-31 21:31:33 -05:00
Isaac Connor
dd57d05f40
Convert packetqueue from a pointer to a packetqueue to a member packetqueue that is always available. Add methods to set packetqueue parameters. Emptying the queue is now in packetqueue::clear()
2021-01-31 21:31:33 -05:00
Isaac Connor
49cf55c22c
Put close back before joins
2021-01-31 12:39:06 -05:00
Isaac Connor
e08060af3f
Free linked monitors
2021-01-31 11:57:43 -05:00
Isaac Connor
4bcefe0562
Add a 10 second wait to force alarm on. If the monitor doesn't notice it is likely not running, leaving an mmap behind
2021-01-31 11:44:58 -05:00
Isaac Connor
14c06cd2d4
Close monitor after terminating threads instead of before
2021-01-31 11:44:25 -05:00
Isaac Connor
e237719d6a
Delete frame queue on stop
2021-01-31 11:43:16 -05:00
Isaac Connor
b83becd856
spacing
2021-01-31 11:43:03 -05:00
Isaac Connor
0fb7cb935f
Fix skipping over the head packet when deleting packets.
2021-01-31 11:42:51 -05:00
Isaac Connor
e084780123
Remove no longer used pre_event buffer and event_delete_thread
2021-01-31 10:09:03 -05:00
Isaac Connor
00114d32bc
Minor code improvements ostly just being more specific about parenthesis
2021-01-30 20:35:10 -05:00
Isaac Connor
b47d2428da
Minor code, debugging improvements
2021-01-30 20:34:39 -05:00
Isaac Connor
5fc52ae6df
Handle iterator pointing to end
2021-01-30 20:34:09 -05:00
Isaac Connor
9ef9fe81fa
Don't log error when flushing queues
2021-01-30 14:05:19 -05:00
Isaac Connor
b93aab6a11
turn off hwtransfer direct to image. Too compliated for now with not enough benefit
2021-01-30 12:34:29 -05:00
Isaac Connor
ac88567ee2
fix
2021-01-29 17:32:22 -05:00
Isaac Connor
5581cdafb6
must increment iterators in the packetqueue lock
2021-01-29 17:30:39 -05:00
Isaac Connor
95d2b1518e
Don't treat send_frame null as errors. We are ni flushing mode
2021-01-29 17:07:58 -05:00
Isaac Connor
dbad734414
Just include zm_ffmpeg.h
2021-01-29 15:49:53 -05:00
Isaac Connor
b812e0d484
It is necessary to prefer the image in the packet to in_frame as it has been timestamped etc
2021-01-29 15:37:51 -05:00
Isaac Connor
292e1b4c9e
Set stream time_base to Q. Set PTS/DTS of packets to current time
2021-01-29 15:37:23 -05:00
Isaac Connor
fea2ea37e5
Cleanup unused first/start/last pts/dts
2021-01-29 14:04:50 -05:00
Isaac Connor
a7d05613b5
When using remote RTSP need to set videoStream parameters
2021-01-29 14:04:21 -05:00
Isaac Connor
5f7f066a4f
Better to alloc context with codec
2021-01-29 14:03:48 -05:00
Isaac Connor
63a6bdaac1
spacing
2021-01-29 09:53:48 -05:00
Isaac Connor
5a21ebe3ef
allow audio streams
2021-01-28 10:49:46 -05:00
Isaac Connor
8199116c15
Make error message more clear
2021-01-28 10:46:08 -05:00
Isaac Connor
ab65a65dfb
use camel case on video_stream and audio_stream
2021-01-28 10:45:53 -05:00
Isaac Connor
335c1b1404
populate mVideoStream and mAudioStream so we don't allocate new ones later
2021-01-28 10:45:39 -05:00
Isaac Connor
28d27cc30a
use camel case on video_stream and audio_stream
2021-01-28 10:45:19 -05:00
Isaac Connor
4bd813d980
Don't try to transfer image when there is no image available
2021-01-28 10:22:14 -05:00
Isaac Connor
f32e546b94
Remove unused members
2021-01-28 10:18:22 -05:00
Isaac Connor
acf909d4f3
Move setting codec parameters below the copy in case they get overwritten
2021-01-28 10:17:23 -05:00
Isaac Connor
2baa22dc85
Fix case when hwaccel not compiled in
2021-01-28 10:16:58 -05:00
Isaac Connor
7ff38a3a5c
Remove unused code from FFmpegCamera
2021-01-28 10:11:26 -05:00
Isaac Connor
d16a7b98eb
fix send_packet_receive_frame. Can't just resend the same packet until we get a frame!
2021-01-28 10:04:02 -05:00
Isaac Connor
1212830354
fix AVOCDEC version check
2021-01-28 09:08:51 -05:00
Isaac Connor
d64745a5da
Add debug in zm_send_packet_receive_frame
2021-01-28 09:08:33 -05:00
Isaac Connor
7923e0c279
fix min_section_length not being honoured
2021-01-27 18:13:16 -05:00
Isaac Connor
c4b80e61bc
code comments
2021-01-27 16:14:17 -05:00