Commit Graph

4222 Commits

Author SHA1 Message Date
Isaac Connor c5ee837b9b Add getFrequency and getChannels 2021-03-01 16:49:27 -05:00
Isaac Connor cc80ae37fb Add a generic fif_audio_source class 2021-03-01 16:49:27 -05:00
Isaac Connor b4fc782778 fifo.h got split into zm_fifo and zm_stream so update the code in zms 2021-03-01 16:49:27 -05:00
Isaac Connor 8c2e6589ac fifo.h got split into zm_fifo and zm_fifo_debug so update the code in zm_zone 2021-03-01 16:49:27 -05:00
Isaac Connor 8af7e40ea1 Use fifo version of code 2021-03-01 16:49:27 -05:00
Isaac Connor bfc12384f6 Increase debug level of auxline reporting 2021-03-01 16:49:27 -05:00
Isaac Connor 6d938817b1 Rework to use a fifo source instead of Device. We no longer pass the monitor in and only open 1 port. Add addFifo function and addSession function 2021-03-01 16:49:27 -05:00
Isaac Connor db13b4c3b6 Document possible parameters, don't add a newline to auxline 2021-03-01 16:49:27 -05:00
Isaac Connor 19d9812a3f Add a debug function to print out the start of the nal 2021-03-01 16:49:27 -05:00
Isaac Connor 53851b67c7 use a Buffer to implement the simple ZM header protocol for passing packet data from ZM to RTSP Server 2021-03-01 16:49:27 -05:00
Isaac Connor c716e8c149 Add logging of audio auxLine. Default to 8000Hz 2021-03-01 16:49:27 -05:00
Isaac Connor 7ba6e45505 Rough in rtsp_server concept. Wait for fifo's to exist before connecting. Check for monitor disconnection. WIP 2021-03-01 16:49:27 -05:00
Isaac Connor 449b547f2b Use buffer.head() instead of casting 2021-03-01 16:49:27 -05:00
Isaac Connor 05e7d76ccd Add pts which will be scaled to AV_TIME_BASE_Q 2021-03-01 16:49:27 -05:00
Isaac Connor 6e73c08a21 add fifo's for video and audio. Write the packet data to them. Update FifoStream->Fifo 2021-03-01 16:49:26 -05:00
Isaac Connor a81e3d6e19 Set zm_packet.pts scaled to AV_TIME_BASE_Q. 2021-03-01 16:47:18 -05:00
Isaac Connor c554a22374 use .head() instead of casting the buffer 2021-03-01 16:47:18 -05:00
Isaac Connor 1d73087e5b Split zm_fifo up into zm_fifo, zm_fifo_debug and zm_fifo_stream. Implement a Fifo class to keep the filehandle open. 2021-03-01 16:47:18 -05:00
Isaac Connor 3ad76f18ec code style updates 2021-03-01 16:47:18 -05:00
Isaac Connor 2d0a8549af Fix cmake to only build zm_rtsp_server if it is turned on 2021-03-01 16:47:17 -05:00
Isaac Connor cafdd02307 Remote rtsp server code. It got moved to zm_rtsp_server.cpp 2021-03-01 16:46:48 -05:00
Isaac Connor 6c6d6c51b0 Add RTSPSTreamName loading and write packet data to the video and audio fifos 2021-03-01 16:46:48 -05:00
Isaac Connor 3e9a2f2651 It is actually importatnt that smInstance get cleared. The subsequent new Logger will check for it. 2021-03-01 16:46:48 -05:00
Isaac Connor 57585e4986 Not sure why raw_fd should be static... 2021-03-01 16:46:48 -05:00
Isaac Connor 78062a03ef Add writePacket and write static function to write h264 packet stream and audio stream to a fifo for the zm_rtsp_server to read from 2021-03-01 16:46:48 -05:00
Isaac Connor d2e1c23140 Add zm_rtsp_server build target and source files 2021-03-01 16:46:48 -05:00
Isaac Connor fdf1fbd497 Add a fifo version of the rtsp server 2021-03-01 16:46:48 -05:00
Isaac Connor 430f839954 add video_fifo filename strings to shmem. 2021-03-01 16:46:48 -05:00
Isaac Connor 33dbcc449a
Merge pull request #3181 from Carbenium/rgb-const
rgb: Convert some constant defines to constexpr
2021-03-01 09:40:39 -05:00
Isaac Connor 71d864d77b
Merge pull request #3182 from Carbenium/monitor-includes
monitor: Move system includes back to their original location
2021-03-01 09:40:08 -05:00
Peter Keresztes Schmidt 3b3ecb89b2 monitor: Move system includes back to their original location
41dc0212e0 moved the system includes to work around some compilation problems.
The underlying cause has been fixed in cf9406a1e8.
Thus we can move the includes back so the follow the project-wide order.
2021-03-01 00:45:57 +01:00
Peter Keresztes Schmidt 76e6c468e8 rgb: Convert some constant defines to constexpr
Using defines interferes with fmt.
Also rename them according to the Google styleguide.
2021-03-01 00:38:21 +01:00
Admin 741e67e8cd
ALERT also mean warming up with alarm_frame_count value before returning to ALARM.... 2021-02-28 22:42:29 +01:00
Peter Keresztes Schmidt c33b5a4393 Move in-tree dependencies to their own folder
src/ should only contain our code. Move the in-tree dependencies to dep/
This allows us (if necessary) to e.g. exclude that part of the tree from being analyzed by
various tools or mark it as external code in IDEs.
2021-02-28 02:12:07 +01:00
Peter Keresztes Schmidt 866bcc9518 build: Cleanup CMakeLists.txt of libbcrypt
Remove unnecessary cruft and make sure it uses our compile options as dictated by zm-dependency-interface.
An additional step towards a warning-free compile.

Define __SKIP_GNU on BSD since they have their own bcrypt implementation.
2021-02-28 02:12:07 +01:00
Peter Keresztes Schmidt 6b7b23970b build: Add a CMakeLists.txt for jwt-cpp
This allows us to use a cmake link target to import the library.
2021-02-27 18:18:35 +01:00
Peter Keresztes Schmidt 6a47780f60 Fix a warning reported by -Wextra
/home/peterke/DEV/zoneminder/src/zm_monitor.h: In member function ‘Monitor::TriggerState Monitor::GetTriggerState() const’:
/home/peterke/DEV/zoneminder/src/zm_monitor.h:499:76: warning: enumerated and non-enumerated type in conditional expression [-Wextra]
  499 |   TriggerState GetTriggerState() const { return (TriggerState)(trigger_data?trigger_data->trigger_state:TRIGGER_CANCEL); }
      |                                                                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-02-27 01:27:58 +01:00
Peter Keresztes Schmidt 814953b331 Fix warnings reported by -Wimplicit-fallthrough
Note: Once C++17 is supported switch to the standard conform [[fallthrough]] attribute.
For the time being [[gnu::fallthrough]] can be used since it is supported by GCC and Clang [1].

[1] https://clang.llvm.org/docs/AttributeReference.html#fallthrough
2021-02-27 00:29:35 +01:00
Peter Keresztes Schmidt 403061a39c Fix warnings reported by -Wmissing-field-initializers 2021-02-26 22:46:09 +01:00
Peter Keresztes Schmidt dffb2d2c87 Fix warnings reported by -Wignored-qualifiers 2021-02-26 19:31:32 +01:00
Isaac Connor b8fcd7c85f
Merge pull request #3172 from Carbenium/db-queue-move
db: Make sure to bind only rvalues when pushing to zmDbQueue
2021-02-25 17:19:11 -05:00
Peter Keresztes Schmidt 3dd52a92eb db: Make sure to bind only rvalues when pushing to zmDbQueue
With this we can ensure that no copy-construction of the SQL string takes place.
Regarding calling semantics: The pushed SQL string will be moved and cannot be reused.
2021-02-25 23:08:43 +01:00
Isaac Connor 3ce4b3e657 Keep capture_delay in useconds instead of msecs. Fix fps by adding back in the previous sleep_time. Fix crash due to capture_image not being asigned for local cameras 2021-02-25 16:58:54 -05:00
Isaac Connor 224fcd2cd3 Merge branch 'master' of github.com:ZoneMinder/zoneminder 2021-02-25 14:58:45 -05:00
Isaac Connor 8aeb4ab758 Switch db_mutex to a std::mutex. Use modern locking with it. Use zmDbDo or dbQueue.push where appropriate. code cleanup. 2021-02-25 12:26:26 -05:00
Isaac Connor fdf515ca10 rough in a db queue thread. Use it in zm_logger so that we don't have to aquire the db lock 2021-02-24 19:59:55 -05:00
Isaac Connor 6f89eba154 add missing () 2021-02-24 13:48:59 -05:00
Isaac Connor 778a4f1d84 We cannot wait for the db lock. Do not wait. 2021-02-24 13:48:36 -05:00
Isaac Connor 9959464ef7 Fix ]\n being included in the db Logs entry. Also removes a strlen so performance should improve 2021-02-24 12:37:09 -05:00
Isaac Connor 58e3d96f8c Instead of using basename and doing a strdup etc, just use strrchr because the filepath is going to one of the sources files in zm. 2021-02-24 12:23:02 -05:00
Isaac Connor 099ca9251c Only init camera if capturing 2021-02-24 10:33:29 -05:00
Isaac Connor 381b7e1b25 Don't disconnect/reconnect while PrimeCapture is failing. Don't sleep if there is failure in capturing and zm_terminate is set. 2021-02-24 10:29:26 -05:00
Isaac Connor c8abeddc9c swscale is a problem. When to use alignment/padding? Defaulting to alignment=1 makes libvnc work, but is less performant. Some scale operations require padding. 2021-02-24 10:10:37 -05:00
Isaac Connor 3ce0564e9c Code style spacing and cleanups. 2021-02-24 10:10:37 -05:00
Isaac Isaac 3eb67fa2fc We have to Prime every monitor not just the first one. 2021-02-23 13:12:40 -05:00
Isaac Isaac f2143fd092 Improve debug logs 2021-02-23 13:12:09 -05:00
Isaac Isaac 3225851224 Move call to Initialise into Constructor making sure that it only gets called once. Move channel switching out of PostCapture into just after capturing image in order to free up more time for image to stabilise while we do other things like timestamping etc which happen in Capture. 2021-02-23 13:11:34 -05:00
Isaac Connor 0ac3e6fd5b remove unneeded strlen 2021-02-22 20:40:30 -05:00
Isaac Connor 64c601fc7b Must fix_deprecations on both values 2021-02-22 20:40:30 -05:00
Isaac Connor 62da77db50 Don't set a default crf. Many codecs don't support it. Failure to open encoder should only be a warning if we have specified it 2021-02-22 20:40:30 -05:00
Isaac Connor 730cd815d3 Add frame format to debug logging. Use fix_deprecated_fmt to fix when ctx->fmt is yuvj420p instead of yuv420p 2021-02-22 15:48:16 -05:00
Isaac Connor 8a417bb8d2 Add override to processCommand declarations. Remove unused fd var 2021-02-22 08:15:48 -05:00
Isaac Connor 5f207664d5 Add override to processCommand declarations. 2021-02-22 08:15:36 -05:00
Isaac Connor 6c013f0e65 Put back includes needed on FreeBSD. Fixes #3165 2021-02-22 08:03:10 -05:00
Isaac Connor 88f3d732b4 Always use AV_TIME_BASE_Q in video encoding mode as we use packet->timestamp instead of pts. Fixes duration problems with encoded video. Fixes #3160 2021-02-22 11:17:17 -05:00
Isaac Connor 7a17a6f9e8 Fix always returning YUV420P despite being valid format. 2021-02-22 11:14:00 -05:00
Isaac Connor 7c042c7837 If doing encoding, we don't care about keyframe 2021-02-21 20:24:36 -05:00
Isaac Connor e562888ed0 Fix crash when decoder returns 0 and when are using hwaccel 2021-02-19 21:03:10 -05:00
Isaac Connor bf0ae8b270 use fix_deprecated_pix_fmt function. Fix logic on out_buffer_size. 2021-02-19 20:43:24 -05:00
Isaac Connor 86d424baf0 Move closeEvent to Close(). If we are closing the camera, we have to close the event as well. 2021-02-19 20:42:36 -05:00
Isaac Connor f440ecb235 Add dlcose, and a resize() function to allocate the framebuffer our own way 2021-02-19 20:42:07 -05:00
Isaac Connor a5ad7462e0 add dlclose 2021-02-19 20:41:41 -05:00
Isaac Connor 16773573ad Since audio encoding uses it's own pts counting, we don't need to copy the ipkt. 2021-02-19 16:36:06 -05:00
Isaac Connor 2f917b4fac Must copy input packet before modifying pts/dts. 2021-02-19 15:58:49 -05:00
Isaac Connor 507cbf7f0f Remove some debugging 2021-02-19 15:56:42 -05:00
Isaac Connor b9669ad69f Log new signal on signal change 2021-02-19 15:56:30 -05:00
Isaac Connor d8e37945a3 TRY OUT SWS_POINT|SWS_BITEXACT scaling 2021-02-19 13:44:37 -05:00
Isaac Connor 415dd83d06 spacing 2021-02-19 12:44:24 -05:00
Isaac Connor 551e35b4bf dump incoming video packet for debug 2021-02-19 12:44:24 -05:00
Isaac Connor d85e4121ef set pts of dest_frame to make debug less confusing 2021-02-19 12:44:24 -05:00
Isaac Connor ed6fc9fca6 use av_frame_copy_props to copy frame members instead of doing it manually 2021-02-19 12:44:24 -05:00
Isaac Connor 2c0261bef4 Include time_base in DUMP_PACKET 2021-02-19 12:44:24 -05:00
Isaac Connor 124d9bf798 Fix logging when holding db lock 2021-02-19 12:09:02 -05:00
Isaac Connor 3dab7d3ecc Don't need to Disconnect when Capture will return -1, as we will call Close() which calls Disconnect() 2021-02-19 12:08:48 -05:00
Isaac Connor 4ba290a9ca Use zmDbDo where appropriate and fix some logging while holding the lock 2021-02-19 12:08:19 -05:00
Isaac Connor d8afd58072 Remove 1 seconds sleeps from db timeout loops. 1 second is a long time. Remove UpdateFramesDelta code which is no longer needed 2021-02-19 12:07:59 -05:00
Isaac Connor a8e63e4f20 watch for zm_terminate in db while loops 2021-02-19 12:07:12 -05:00
Isaac Connor 964b3dd05a Merge branch 'master' of github.com:zoneminder/ZoneMinder 2021-02-19 09:03:31 -05:00
Isaac Connor 045cd219f8 Move clear packetqueue logic to it's own function and call it from the analysis thread. 2021-02-18 19:25:40 -05:00
Isaac Connor 78a5e78e4c Add locking to get_event_start_it. Packets could get deleted while we are figuring this out. 2021-02-18 16:59:17 -05:00
Isaac Connor 0b0df96271 Merge branch 'master' of github.com:ZoneMinder/zoneminder 2021-02-18 16:05:10 -05:00
Isaac Connor 5ad9244a73 Use new db utility functions to simplify event creation code 2021-02-18 16:01:45 -05:00
Isaac Connor 63a45888a0 Introduce utility functions zmDbDo and zmDbDoInsert. 2021-02-18 16:01:30 -05:00
Isaac Connor bc41cd944e Add missing db_lock.unlock() 2021-02-18 15:00:30 -05:00
Isaac Connor 9502762ce8 WIP cleanup. Don't need to malloc ram as rfbInit will do it. We may need to allocated a larger buffer though, so may need to give vncserver a different malloc function 2021-02-18 13:47:27 -05:00
Isaac Connor a4d8ef5d8f Use new version of fix_deprecated_pix_fmt 2021-02-18 13:47:27 -05:00
Isaac Connor 6d8a7a7a4c add SWSCale::GetBufferSize to reduce duplicated lines of code. Makes input buffer size not have to match the aligned size. Reading from doesn't generally cause a crash. 2021-02-18 13:47:27 -05:00
Isaac Connor 127e15ba3a Don't crash if we ask for packet count of an invalid stream 2021-02-18 13:47:27 -05:00
Isaac Connor c7dede0083 Cleanups in connect/disconnect 2021-02-18 13:47:27 -05:00
Isaac Connor 8a329df5ec change how fix_deprecated_pix_fmt works to return a value so we can use it elsewhere 2021-02-18 13:47:27 -05:00
Isaac Connor 04c13c6ff3 Handle value of auto for encoder 2021-02-18 13:30:38 -05:00
Isaac Connor 0d59584250 Only set DefaultVideo if we are successful at opening videoStore. Set save_jpegs flag in db record if we turn it on after failing videoStore. 2021-02-18 13:30:05 -05:00
Isaac Connor f05488ee49 better error message when can't set crf 2021-02-18 11:55:09 -05:00
Isaac Connor b40a31d76f Move content of setMaxVideoPcakets into .cpp 2021-02-18 11:54:50 -05:00
Isaac Connor b1f337b6e7 Move setMaxVideoPackets down to where pre_event_count has a value 2021-02-18 11:54:32 -05:00
Isaac Connor 3e10c3a8a4 Fix return codes 2021-02-17 16:42:48 -05:00
Isaac Connor 2a49bd124f Add VNC monitor type 2021-02-17 16:39:16 -05:00
Isaac Connor cf6d2caef7 Make setting fmt non fatal. 2021-02-17 16:34:19 -05:00
Isaac Connor cf9406a1e8 undef max if defined in rfb/rdbclient.h 2021-02-17 13:40:12 -05:00
Isaac Connor 33b9dae0f2 fix use of uint32_t for buffer indexes 2021-02-17 13:38:52 -05:00
Isaac Connor f061c25183 Make failure to set video standard non-fatal. 2021-02-17 11:02:56 -05:00
Isaac Connor 519e39b4f4 Reloading has to stop other threads while we are re-initing the logs. So move it down 2021-02-17 10:07:36 -05:00
Isaac Connor 59cdf971fa convert last_read_index and last_write_index to int32_t so that we can have -1 as a value in other functions. 2021-02-16 14:43:52 -05:00
Isaac Connor 41dc0212e0 Move include of algorithm up to top to hopefully fix issues with min and max being defined elsewhere and so compile fails 2021-02-16 10:39:04 -05:00
Isaac Connor a82247b105 Some cleanups in disconnect 2021-02-16 10:39:04 -05:00
Isaac Connor a56d78bb04 Don't sleep if Analyse returns false and we are terminating 2021-02-16 10:39:04 -05:00
Isaac Connor 9c3bf0af1d Always default to mp4 for now 2021-02-14 09:49:30 -05:00
Isaac Connor 99264e4072 Fix swscale failing on resolution change. Fixes #3161 2021-02-12 11:55:25 -05:00
Isaac Connor 5a910c4a4b use lock_guard instead of unique_lock 2021-02-12 10:45:32 -05:00
Isaac Connor 2cb6d21faf get rid of while loop in ::Analyze. Switch login on if Ready() to bail early so we don't indent so much. 2021-02-12 10:38:21 -05:00
Isaac Connor 4915e940b7 clean out old mutex. Add event_mutex to protect around event creation/deletion 2021-02-12 10:14:35 -05:00
Peter Keresztes Schmidt 3d759e1fe0 Monitor: Some reformatting of previously touched lines 2021-02-11 20:02:08 +01:00
Peter Keresztes Schmidt c0151caa64 Monitor: Signal by making the camera a unique_ptr the ownership relation
In addition we get RAII and thus automatic destruction of the camera when the monitor is destructed.

Monitor API change: getCamera -> LoadCamera
If additional properties of the camera are needed externally they should be exposed directly via Monitor.
2021-02-11 19:22:22 +01:00
Peter Keresztes Schmidt 35514649c9 Monitor: Make audio and video streams directly accessible
Also remove Camera::getId() which returend the monitor ID. Since a camera is owned by an monitor, there is no need for this. Also it causes a circular include.
2021-02-11 19:22:22 +01:00
Peter Keresztes Schmidt ede811df50 zmc: Simplify Monitor's shutdown procedure
disconnect() is already called in the destructor. Since `monitors` goes out of scope all instances will get automatically destructed. There is no need to manually call disconnect().
2021-02-11 19:22:22 +01:00
Peter Keresztes Schmidt 91aeb325dd Monitor: Close monitor on destruction
This ensures the proper shutdown sequence when not calling Close() externally (e.g when reconnecting).
2021-02-11 19:22:22 +01:00
Peter Keresztes Schmidt 0a665c0710 Monitor: Close the associated camera when closing the monitor
The camera is owned by the monitor. There is no reason to keep the camera open, when the owner is closed.
2021-02-11 19:22:22 +01:00
Isaac Connor 2742485a61
Merge pull request #3157 from Carbenium/zmc-deadlock
Fix a possible deadlock on zmc shutdown and reconnect
2021-02-11 11:28:36 -05:00
Peter Keresztes Schmidt 42484e6434 zmc: Fix a deadlock on shutdown/reconnection
First stop the analysis threads, then close the monitors and thus drain the packet queues before trying to join the analysis threads since they might hang while waiting for the next packet to arrive.
2021-02-11 15:48:22 +01:00
Isaac Connor cca4d18d26 need <algorithm> for std::max 2021-02-10 17:29:51 -05:00
Isaac Connor 51f2d120e4 Free raw image after motion detection when doing passthrough and not saving jpegs 2021-02-10 17:07:58 -05:00
Isaac Connor 393e8b582a Move the logic of whether to queue a packet into packetqueue::queuePacket 2021-02-10 14:11:00 -05:00
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