Commit Graph

4745 Commits

Author SHA1 Message Date
Isaac Connor ebd29a3cb9 use the timeout version of read_into so that we don't stay blocked while we have been told to exit. If getNextFrame returns -1 sleep for a second. 2021-03-05 14:18:12 -05:00
Isaac Connor 07339e443b Add RTSP Server shutdown code 2021-03-05 14:13:24 -05:00
Isaac Connor f99b8896ec Don't unlock the mutex around openFile. It is a recursive mutex so we should be able to stay locked 2021-03-05 14:13:10 -05:00
Isaac Connor 0af68a0914 Implement read_into with a timeout 2021-03-05 14:12:44 -05:00
Isaac Connor 1ff4e5bc8d Fix not keeping enough video packets in packetqueue to satisfy pre_event_count 2021-03-05 10:02:21 -05:00
Admin fa22129966
Make last_alarm_count last alarmed frame while only in ALARM state to make post_event_count counts since here not alone alarmed frames that don't shot alarms. 2021-03-04 20:20:02 +01:00
Isaac Connor 5f476df194 Fix invalid read when no mAudioStream 2021-03-04 13:35:39 -05:00
Isaac Connor d20521569d Only add width and height if they have a value 2021-03-04 13:26:10 -05:00
Isaac Connor 7da1e48456 Fix delete=>delete[] on header. If we read_into the buffer more all our pointers can be invalidated. So use offsets instead 2021-03-04 13:26:10 -05:00
Isaac Connor eb36c9e919 add getFrequencyIndex and use it to correctly set the frequency index 2021-03-04 13:26:10 -05:00
Isaac Connor 1adeda6241 Add debugging of sql 2021-03-04 13:26:10 -05:00
Peter Keresztes Schmidt 5ffaebf70d RtpCtrlThread: Add a missing include 2021-03-04 19:21:09 +01:00
Isaac Connor 0a8b34843c
Merge pull request #3188 from Carbenium/drop-zm-thread
Drop our custom threading code
2021-03-04 13:02:51 -05:00
Isaac Connor 5259b78065 Fix event notes not getting populated. 2021-03-04 11:12:27 -05:00
Isaac Connor f986b6a5e2 Clear packet counts on clear so that camera restarts don't incremenet the stream_id's and cause memory consumption 2021-03-04 07:46:39 -05:00
Peter Keresztes Schmidt d9568a98c0 Drop zm_thread which has been replaced by STL implementations 2021-03-04 10:55:46 +01:00
Peter Keresztes Schmidt 15bb9969da Timer: Unused, let's remove it
Currently there is no need for this functionality.
Since it depends on Thread and ThreadData (which will be removed) let's drop this as well.
If need would arise for such functionality a new implementation with a modern API should be written.
2021-03-03 23:38:15 +01:00
Peter Keresztes Schmidt a78236d05c Fifo: Fix some missing c_str()s for formatting logs 2021-03-03 23:31:53 +01:00
Peter Keresztes Schmidt 69185e2204 RtpSource: Convert ThreadData with std::condition_variable 2021-03-03 23:31:53 +01:00
Peter Keresztes Schmidt 1dfa41923b Fifo: F_{G,S}ETPIPE_SZ is Linux specific 2021-03-03 23:31:53 +01:00
Peter Keresztes Schmidt c7f9cc3368 LibvlcCamera: Convert ThreadData with std::condition_variable 2021-03-03 23:31:53 +01:00
Peter Keresztes Schmidt c78e174e78 RTSPServerThread: Convert to std::thread 2021-03-03 23:31:53 +01:00
Peter Keresztes Schmidt 8f0431d85b RtpDataThread: Convert to std::thread 2021-03-03 23:31:53 +01:00
Peter Keresztes Schmidt 71edb9d830 RtpCtrlThread: Convert to std::thread 2021-03-03 23:31:53 +01:00
Peter Keresztes Schmidt ff2bfb58da RtspThread: Fix an unguarded SQL query causing race conditions 2021-03-03 23:31:53 +01:00
Peter Keresztes Schmidt 8f941c75cd RtspThread: Convert to std::thread 2021-03-03 23:31:53 +01:00
Peter Keresztes Schmidt e67626b4e2 logger: Move log_mutex to std::recursive_mutex 2021-03-03 23:31:53 +01:00
Isaac Connor 20fe6153d5 Don't treat data packets as video 2021-03-03 15:52:39 -05:00
Isaac Connor d34d2e2398 Use a define to deal with the codec/codecpar version problem 2021-03-03 15:43:59 -05:00
Isaac Connor 253ed928ec Fix using wrong stream to set codec_type 2021-03-03 15:24:11 -05:00
Isaac Connor 8a33fb6665 Include codec_type in stream and packet dumps 2021-03-03 15:23:58 -05:00
Isaac Connor eaaf04420a Keep track of stream last_pts. So we can at least try to sync streams 2021-03-03 12:45:05 -05:00
Isaac Connor 3149ba276f audio_in_stream_id is dprecated 2021-03-03 12:44:45 -05:00
Isaac Connor b87d859f72 Set the packet's stream_index to the packetqueue stream. Rename get_ functions to get 2021-03-03 12:06:34 -05:00
Isaac Connor a90ec5b15d Deprecate video_in_stream_index and audio_in_stream_index as they are not useful 2021-03-03 12:03:36 -05:00
Isaac Connor a01a24ec36 Add loading SecondPath in monitor 2021-03-03 09:56:33 -05:00
Isaac Connor 9310825d93 Add get_video_stream and get_audio_stream. 2021-03-03 09:56:31 -05:00
Isaac Connor e31c87193d Make Open() return 1 instead of 0 2021-03-03 09:55:57 -05:00
Isaac Connor 4cc1da8b89 Add SecondFormatContext and open it using an FFmpeg_Input 2021-03-03 09:55:57 -05:00
Isaac Connor 86541779d9 Add SecondFormatContext 2021-03-03 09:55:57 -05:00
Isaac Connor 95fe689d58 WIP, rabbit hole too deep 2021-03-03 09:55:57 -05:00
Isaac Connor 0550e69224 Fix compile on old avcodec 2021-03-03 09:55:57 -05:00
Isaac Connor dcd1804b4d add get_format_context() 2021-03-03 09:52:44 -05:00
Isaac Connor 46ec4e75d4 Check codec type instead of stream_index to determine video/audio 2021-03-03 09:52:27 -05:00
Isaac Connor cf27482ebe Change api of packetqueue. stream_index will not be incoming stream_index it will be a packetqueue specific stream_index. 2021-03-03 09:52:13 -05:00
Isaac Connor 9f5f215ef4 Check codec type instead of stream_index to determine video/audio 2021-03-03 09:51:43 -05:00
Isaac Connor 53425257cb Handle old avcodec 2021-03-02 16:20:57 -05:00
Admin 4ff016c991
Make capturing/analysing log lines follow same pattern 2021-03-02 20:51:16 +01:00
Isaac Connor be1b439dcc Add State_Strings and code cleanup. Fix not going into alarm state when already recording. Fixes #3184 2021-03-02 14:42:54 -05:00
Isaac Connor 1c40145e89 not finding space for pts is debug now and show the contents of header 2021-03-02 12:41:26 -05:00
Isaac Connor f35a1c70c0 fix build with old avcodec for xenial 2021-03-02 12:07:51 -05:00
Isaac Connor c03d9b2987 Set state before we write packets to event so that the event knows that it is alarmed 2021-03-02 11:47:55 -05:00
Isaac Connor f8b7ec8cb9 Save frames when in ALARM state so that pre-event frames get stored 2021-03-02 11:47:38 -05:00
Isaac Connor 71d65685b9 Can't clear image data early. Might be needed for snapshot and pre alarm farmes 2021-03-02 11:12:57 -05:00
Isaac Connor 3dc4bf265e Use braces 2021-03-02 10:15:21 -05:00
Isaac Connor 205ed4c510 EAGAIN happens when no one is listening. Make it a debug 2021-03-02 10:14:25 -05:00
Isaac Connor 46743ebaab Silence compile warning 2021-03-02 10:00:48 -05:00
Isaac Connor 832eabbd79 Don't both updating analysis fps unless we are doing motion detection 2021-03-02 09:59:32 -05:00
Isaac Connor d92da5f633
Merge pull request #3185 from Carbenium/jwt-cpp
dep/jwt-cpp: Update to version 0.5
2021-03-01 18:42:25 -05:00
Peter Keresztes Schmidt 37817f6ba4 dep/jwt-cpp: Update to version 0.5
Fixes some compile warnings. Unit tests pass with this version as well.
2021-03-01 23:14:56 +01:00
Isaac Connor 1bc5abb9e9 Only include video packets in analysis_image_count 2021-03-01 17:07:09 -05:00
Isaac Connor 7c71c1c543 fix rebase error 2021-03-01 17:06:53 -05:00
Isaac Connor 51c19912f8 Use analysis_image_count in opening new event log line 2021-03-01 16:56:47 -05:00
Isaac Connor 82dcd87a22 Add generic fifo_audio_source 2021-03-01 16:49:27 -05:00
Isaac Connor 8f001413f2 Handle hevc as the codec name as well as h265 2021-03-01 16:49:27 -05:00
Isaac Connor 53059aebf3 rename numChannels to getChannels and samplingFrequency to getFrequency 2021-03-01 16:49:27 -05:00
Isaac Connor b86e7eefbf fix needed line break before dimensions. Update h265 auxline processing to match h264 2021-03-01 16:49:27 -05:00
Isaac Connor d33540c962 Fix logic on clearing frame queue 2021-03-01 16:49:27 -05:00
Isaac Connor 495e2a4827 Add setting up the config string and population of mAuxLine 2021-03-01 16:49:27 -05:00
Isaac Connor b2ff9af238 Add setting of frequency and channels for audio stream 2021-03-01 16:49:27 -05:00
Isaac Connor b09fe1d17c Create fifo if it doesn't exist already 2021-03-01 16:49:27 -05:00
Isaac Connor 9302c9506e Add audio_frequency and audio_channels to shared mem and set them in PrimeCapture 2021-03-01 16:49:27 -05:00
Isaac Connor 8500c7ee94 Add audio_frequency and audio_channels to shared mem 2021-03-01 16:49:27 -05:00
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
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
Isaac Connor ce53552dda require audio_in_ctx as well as audio_in_stream 2021-01-27 16:14:07 -05:00
Isaac Connor 6271971912 Use get_videoStream in zm_camera 2021-01-27 16:13:43 -05:00
Isaac Connor 4ca9c9fe69 code cleanup 2021-01-27 16:13:03 -05:00
Isaac Connor 608afcbbd2 return bytes consumed by decode 2021-01-27 16:12:49 -05:00
Isaac Connor 4c933f82b8 All cameras will have an mFormatConext, CodecContext etc. Consolidate code in zm_camera. Fix remote rtsp decoding 2021-01-27 16:12:32 -05:00
Isaac Connor 666299d5fa code style 2021-01-27 16:11:24 -05:00
Isaac Connor fbe22d29ba Don't crash if can't add any streams 2021-01-27 12:50:40 -05:00
Isaac Connor 518270a9ac Must set keyframe and codec_type of zm_packet 2021-01-27 12:50:17 -05:00
Isaac Connor 1ca93c4211 accept packets with image as video 2021-01-27 12:49:54 -05:00
Isaac Connor 6df865cd08 spacing 2021-01-27 12:49:37 -05:00
Isaac Connor d741f4ba04 accept packets with image data 2021-01-27 12:49:27 -05:00
Isaac Connor e28c724742 fix return values of Prime, Pre and PostCapture 2021-01-27 12:07:35 -05:00
Isaac Connor be893fe9e4 Since we loop in here, need to lock the packetqueue 2021-01-27 11:48:32 -05:00
Isaac Connor bbba0f679b Don't need to set timebase. Continue supporting old ffmpeg 2021-01-27 11:48:32 -05:00
Isaac Connor f3ea237af1 Fix build without RTSP 2021-01-27 10:50:07 -05:00
Isaac Connor ef3440e5b8 Fix including rtsp server code 2021-01-27 10:08:42 -05:00
Isaac Connor 905912a8dd Don't need to checkInitialized in event stream. We don't assign a monitor and don't need to connect to it 2021-01-27 10:07:57 -05:00
Isaac Connor d594fbcd49 Some fixes for unused code (will be used in future) 2021-01-26 18:29:34 -05:00
Isaac Connor 27011ab49b Fix bulid without liveMedia 2021-01-26 18:29:02 -05:00
Isaac Connor 42abe5c917 include hwcontext in zm_ffmpeg.h so that it gets included where needed 2021-01-26 18:28:11 -05:00
Isaac Connor 4dcce4ac95 Merge branch 'rtsp_server' 2021-01-26 14:22:10 -05:00
Isaac Connor bfaed28cff use config.min_rtsp_port to determine if we start up the rtsp server. Move the sleep on failure to capture down below shutting everything down. 2021-01-26 14:20:03 -05:00
Isaac Connor 33f934b9ab Use config.min_rtsp_port instead of hard coded base port 2021-01-26 14:14:29 -05:00
Isaac Connor 4159baac06 Use 10 seconds of queue instead of a fixed packet count. Audio generates more frames than video so they get way out of sync. 2021-01-26 14:14:05 -05:00
Isaac Connor 7e11d28031 Remove duplicated debug 2021-01-26 12:25:11 -05:00
Isaac Connor a209d493ef Handle null video_in_ctx. Better debug. Always flush codecs 2021-01-26 12:24:43 -05:00
Isaac Connor e73e6aaabc check for terminating before locking packetqueue. Handle when pre_event_count==0 2021-01-26 12:23:44 -05:00
Isaac Connor e4831909d6 get_packet can return null if we are terminating 2021-01-26 12:22:26 -05:00
Isaac Connor 7cc21b0d0b Always load AvFrame to RGBA 2021-01-26 12:22:07 -05:00
Isaac Connor e226618300 better debug of video/audio frames 2021-01-26 12:21:51 -05:00
Isaac Connor cd9b3fb1f6 add static Mode_Strings 2021-01-26 12:21:21 -05:00
Isaac Connor 0ecbe29ac0 Handle no frame/duration information more gracefully 2021-01-26 12:20:55 -05:00
Isaac Connor e10d15fa91 Only write db entries for video frames but do write them even if no decoded image 2021-01-26 12:20:32 -05:00
Isaac Connor f731a5dc8f Add StreamMode_Strings for printing out mode 2021-01-26 09:50:41 -05:00
Isaac Connor 835cc8076e Cleanup constructor, using initializers. Pass in CodecContexts as well. We need them for timebases. Fixes passthrough timestamps. 2021-01-25 18:50:35 -05:00
Isaac Connor 6394c620ad add stream index to debug 2021-01-25 13:23:57 -05:00
Isaac Connor a0df09dcaa Have to check for lock on video keyframe as well 2021-01-25 12:07:56 -05:00
Isaac Connor baf39b0d4f add adts_source 2021-01-24 20:16:54 -05:00
Isaac Connor 8a1686076a break long line 2021-01-22 20:24:29 -05:00
Isaac Connor 7feb252f81 code style 2021-01-22 20:24:12 -05:00
Isaac Connor 9d2598da13 cleanup and add AAC support. Also stop source threads 2021-01-22 20:23:30 -05:00
Isaac Connor afc7c86eac add AAC support 2021-01-22 20:22:50 -05:00
Isaac Connor 2561a07d86 provide a simple SDP line 2021-01-22 20:21:28 -05:00
Isaac Connor d03e5fbe20 cleanup 2021-01-22 19:29:19 -05:00
Isaac Connor 71ebae27eb Use codecpar instead of codec which is deprecated 2021-01-22 19:29:01 -05:00
Isaac Connor c7b8d7bda9 get rid of useThread. We will always have a thread 2021-01-22 19:26:00 -05:00
Isaac Connor afd57ec307 Add a base extractFrame that just treats the entire buffer as a frame 2021-01-22 19:25:38 -05:00
Isaac Connor c94e2c0f13 cleanup 2021-01-22 19:24:27 -05:00
Isaac Connor 08165c06df Add audio details to zm_dump_codecpar 2021-01-22 19:24:15 -05:00
Isaac Connor 1a400be11c add zm_rtsp_server_adts_source.cpp to build 2021-01-22 19:23:36 -05:00
Isaac Connor ea8f264724 Merge branch 'release-1.34' 2021-01-22 15:54:06 -05:00
Terry Sanders c21e02e3c7 Fixed issue where mysql_free_result can get called twice when a vaild username with an incorrect password is used. 2021-01-22 12:23:38 -05:00
Isaac Connor f9fc10b394 When not capturing don't try to create mmap. Fixes #3112 2021-01-22 12:23:13 -05:00
Isaac Connor f1686cfe9a When not capturing don't try to create mmap. Fixes #3112 2021-01-22 12:11:43 -05:00
Isaac Connor 01ec57f902 remove test for negative pts. Negative pts is ok. Have been running this in master for a while with no negative effects. 2021-01-22 12:07:47 -05:00
Isaac Connor a30a473981 fix passing in audiostream 2021-01-21 10:27:15 -05:00
Isaac Connor b8eac366b7 pts is an int 2021-01-21 10:27:02 -05:00
Isaac Connor d0380fb89b cleanup, start roughing in audio stream support 2021-01-21 10:26:46 -05:00
Isaac Connor 44245a9a4f spacing typos 2021-01-21 10:25:26 -05:00
Isaac Connor 8a9111d0b3 spacing 2021-01-21 10:25:09 -05:00
Isaac Connor 35c72b32dd Cleanup. Remove stats stuff. Code now works so remove other options. Re-implement extractFrame as it was broken. It would skip shortmarkers. 2021-01-21 10:23:30 -05:00
Isaac Connor 66c78e5a9b Merge branch 'zma_to_thread' into rtsp_server 2021-01-19 13:43:25 -05:00
Terry Sanders ef006ca407 Fixed issue where mysql_free_result can get called twice when a vaild username with an incorrect password is used. 2021-01-19 14:47:11 +00:00
Isaac Connor b1b72ec85b Improve debugging. Add parenthesis to fix test for end. I think the * dereference is not being applied at the right time. 2021-01-19 09:46:08 -05:00
Isaac Connor 256080abb1 Fix crash of Reload() due to Load() clearing shared_data and mem_ptr. Load() shouldn't do these kinds of initialisations. 2021-01-19 09:44:53 -05:00
Isaac Connor fec3dc763f Cleanups. Apply crf to encoding to fix encoding video 2021-01-15 17:02:26 -05:00
Isaac Connor 430d64ba67 create fix_deprecated_pix_fmt function to adjust deprecated pixfmts 2021-01-15 17:01:59 -05:00
Isaac Connor 0f7c46e2cc Merge branch 'master' into zma_to_thread 2021-01-15 14:56:00 -05:00
Isaac Connor 0f276887ad When can't connect to monitor send an image saying so 2021-01-15 14:43:44 -05:00
Isaac Connor 0a0c99ce7a fix double free of mysql result 2021-01-15 14:43:31 -05:00
Isaac Connor 23305be8bf break lone lines. Move sendTextFrame to public so that we can use it to send error message in image form. 2021-01-15 14:43:07 -05:00
Isaac Connor 3d234427e0 initialize packetqueue, analysis_it, storage and videostore in Monitor constructor initializer. Only delete packetqeuue if it has been created. 2021-01-15 14:42:30 -05:00
Isaac Connor 68b0f7e1b5 initialize packetqueue, analysis_it, storage and videostore in Monitor constructor initializer. Only delete packetqeuue if it has been created. 2021-01-15 14:42:26 -05:00
Isaac Connor 27e10c2ed9 cleanup encoding code. Update logging 2021-01-15 11:55:46 -05:00
Isaac Connor 10e56df53c analysis_limit > cpature fps: only log a warning if we have actually been capturing for a while. If doing passthrough, need to start continuous event from last keyframe 2021-01-15 11:54:36 -05:00
Isaac Connor 83c60b7317 Make the error message clearer by actually printing the time. 2021-01-15 11:53:25 -05:00
hax0kartik 6845c2cab4 Fix padding issue in timestamp code 2021-01-15 11:46:30 +05:30
Isaac Connor e530a51af7 WHen ret=0 is not failure, not success. Don't log error. Return the return code instead of -1 2021-01-14 10:31:55 -05:00
Isaac Connor f44f920bf2 spacing 2021-01-14 10:31:29 -05:00
Isaac Connor ef2f126eaa Merge branch 'master' into zma_to_thread 2021-01-12 14:37:25 -05:00
Isaac Connor e496679efd Set transaction isolation level to READ COMMITTED so that concurrent event inserts don't deadlock 2021-01-12 14:19:04 -05:00
Isaac Connor 3423d8ed05 Only delete packets up to the next video keyframe. Don't be too aggressive 2021-01-12 14:13:12 -05:00
Isaac Connor 5b7fc210fe Only use direct to rgb0 when image colours are 4 2021-01-12 14:12:09 -05:00
Isaac Connor 164a0f5a44 Need to use get_packet so that packets getting written to event are locked. Because queuePacket might delete them. 2021-01-12 14:11:47 -05:00
Isaac Connor 04c02dd1ef Spacing 2021-01-12 14:11:06 -05:00
Isaac Connor e706b4ba33 Hitting beginning of queue can happen on stream startup. So in that case make it a debug. Once the stream has been going for a while there should always be enough packets in the queue so make it a warning 2021-01-11 17:18:14 -05:00
Isaac Connor 605319a290 Remove old LOG line 2021-01-11 13:46:50 -05:00
Isaac Connor b2c5860062 dumpPacket when addPacket 2021-01-11 13:46:50 -05:00
Isaac Connor 649114ed39 further disable rtsp_server 2021-01-11 13:46:50 -05:00
Isaac Connor f7be54fe11 Add detecting target pixfmt and if rgb0 is supported, use it to do the transfer direct to the Image. 2021-01-11 13:46:50 -05:00
Isaac Connor e8d06f702c Handle signal loss, improve debugging 2021-01-11 13:46:50 -05:00
Isaac Connor f3c4bb0027 Add AVBufferRef setup when Populating AVFrame from Image. This allows hwtranfer to work because it relies on AVBuffer AVFrame. Please note that we don't want AVBuffer to free the buffer so we pass an empty function to it. 2021-01-11 13:46:50 -05:00
Isaac Connor 9fb8e51ff2 Set imagePixFormat everywhere. Add PopulateFrame which creates and AVFrame pointing to the image's buffer. Will do this with proper refcounting eventually 2021-01-11 13:46:50 -05:00
Isaac Connor 9740b635dd Fix missing comma 2021-01-11 13:46:50 -05:00
Isaac Connor 67f4359242 clean up code giving warning when no starttime is given 2021-01-11 13:46:50 -05:00
Isaac Connor 9cad82e916 include kleyframe status in zm_dump_video_frame 2021-01-11 13:46:50 -05:00
Isaac Connor 1ec2198d2b remove unused var temp 2021-01-11 13:46:50 -05:00
Isaac Connor fdf9975deb break long line 2021-01-11 13:46:50 -05:00
Isaac Connor c958a2c00b Code style 2021-01-11 13:46:50 -05:00
Isaac Connor 46a8bb22fb get camera if we havn't already. Don't delete the timestamp in shared zmpackets because it is just a pointer to shmem. Set it to null instead so that ~ZMpacket doesn't try to free it 2021-01-11 13:46:50 -05:00
Isaac Connor b6b92115d1 allocate our own CodecContext for decoding. Reusing the existing one doesn't work for hwaccel. Add hwaccel flags to let it use Constrained Baseline for Baseline profile streams. Try without specified device if hwdevice_ctx_create fails. 2021-01-11 13:46:50 -05:00
Isaac Connor 497b91f7c6 disable rtsp_server 2021-01-11 13:46:50 -05:00
Isaac Connor ebe3a9b6a7 Must notify before waiting in destructor. Fix leaks 2021-01-11 13:46:50 -05:00
Isaac Connor 09264a52ff use zm_av_send_packet_receive_frame and fixup hwaccel support 2021-01-11 13:46:50 -05:00
Isaac Connor 13d7e612e3 improve hwaccel support 2021-01-11 13:46:50 -05:00
Isaac Connor 34009ca59b remove unused directbuffer 2021-01-11 13:46:50 -05:00
Isaac Connor 97dff2fb28 Open/CLose RTSP with analysis thread when opening and closing monitor. We have to have successfully PrimeCapture before adding streams to RTSP Server and need to shut it down when closing the monitor because the packetqueue goes away 2021-01-11 13:46:50 -05:00
Isaac Connor 1316c6ea86 Update codec opening to properly handle passthrough 2021-01-11 13:46:50 -05:00
Isaac Connor 894ad11816 change outputFd which is unused to stream_id which is the stream_id to concern ourselves with when getting packets from the packetqueue. Add more tests for zm_terminate. Add testing for AV_CODEC_ID instead of v4l2 PIX_FMT to determine stream type 2021-01-11 13:46:50 -05:00
Isaac Connor 514e0d2e93 remove analysis_it and correctly manage external iterators. Fix testing for ability to remove packets from packetqueue. Fix some cases where the order of testing zm_terminate and packet locking is important 2021-01-11 13:46:50 -05:00
Isaac Connor 9187b08b7a add missing and mix order of Packet initializers 2021-01-11 13:46:50 -05:00
Isaac Connor b3ca0ac2d9 add missing and mix order of Packet initializers 2021-01-11 13:46:50 -05:00
Isaac Connor 65fc5bf478 move code from Load for purpose==ANALYSIS because it will never run. Analysis is a thread now and must assume that PrimeCapture has already succeeded. 2021-01-11 13:46:50 -05:00
Isaac Connor 824cbb7879 spacing and NULL=>nullptr 2021-01-11 13:46:50 -05:00
Isaac Connor f842e9e2ed NULL=>nullptr 2021-01-11 13:46:50 -05:00
Isaac Connor 02f65cec4d Don't need to get_ref_image anymore. It will block waiting for a capture packet and the ref image will be set by capture thread 2021-01-11 13:46:50 -05:00
Isaac Connor 432bb338e8 Rename H264PASSTHROUGH to just PASSTHROUGH. Add an analysis_it to the Monitor object as it will no longer exist in the packetqueue 2021-01-11 13:46:50 -05:00
Isaac Connor da7a50c92d Rename H264PASSTHROUGH to just PASSTHROUGH. Start with last_signal set to true so that we don't have a signal change event on startup. Use new generic packetqueue functions 2021-01-11 13:46:50 -05:00
Isaac Connor 22ae83a0d6 Rename H264PASSTHROUGH to just PASSTHROUGH 2021-01-11 13:46:50 -05:00
Isaac Connor 705959d1ec Set codec_type in zm_packet 2021-01-11 13:46:50 -05:00
Isaac Connor 510cbd8b19 Add AVPacket parsing queue and other files for rtsp_server 2021-01-11 13:46:50 -05:00
Isaac Connor 3f5bc97e6e continue roughing in rtsp server. Fix not adding session to rtspServer. 2021-01-11 13:46:50 -05:00
Isaac Connor 92ac012324 Add rtsp_server files to CMakeLists.txt 2021-01-11 13:46:50 -05:00
Isaac Connor 60fa3f9ec1 cleanup. Add h264_vaapi codec support 2021-01-11 13:46:50 -05:00
Isaac Connor 0cc123a460 small cleanup in logging 2021-01-11 13:46:50 -05:00
Isaac Connor fe7007cc2b Remove old LOG line 2021-01-11 13:45:37 -05:00
Isaac Connor 62ffc20c98 dumpPacket when addPacket 2021-01-11 13:45:21 -05:00
Isaac Connor 2fe325efe7 further disable rtsp_server 2021-01-11 13:38:22 -05:00
Isaac Connor 1b1438bf7a Add detecting target pixfmt and if rgb0 is supported, use it to do the transfer direct to the Image. 2021-01-11 13:36:51 -05:00
Isaac Connor e1f6f5984d Handle signal loss, improve debugging 2021-01-11 13:35:48 -05:00
Isaac Connor 70090f7edc Add AVBufferRef setup when Populating AVFrame from Image. This allows hwtranfer to work because it relies on AVBuffer AVFrame. Please note that we don't want AVBuffer to free the buffer so we pass an empty function to it. 2021-01-11 13:35:23 -05:00
Isaac Connor f625734c82 Set imagePixFormat everywhere. Add PopulateFrame which creates and AVFrame pointing to the image's buffer. Will do this with proper refcounting eventually 2021-01-11 11:57:34 -05:00
Isaac Connor 29255d1528 Fix missing comma 2021-01-11 11:15:22 -05:00
Isaac Connor ab9583cbdf clean up code giving warning when no starttime is given 2021-01-11 10:06:54 -05:00
Isaac Connor dd4685ecf2 include kleyframe status in zm_dump_video_frame 2021-01-10 19:13:02 -05:00
Isaac Connor 4b90eb992d remove unused var temp 2021-01-08 16:45:16 -05:00
Isaac Connor 9e353a8837 break long line 2021-01-08 16:45:03 -05:00
Isaac Connor c0a2286dee Code style 2021-01-08 15:49:21 -05:00
Isaac Connor a6aefcf477 get camera if we havn't already. Don't delete the timestamp in shared zmpackets because it is just a pointer to shmem. Set it to null instead so that ~ZMpacket doesn't try to free it 2021-01-08 15:49:09 -05:00
Isaac Connor 736b14327e allocate our own CodecContext for decoding. Reusing the existing one doesn't work for hwaccel. Add hwaccel flags to let it use Constrained Baseline for Baseline profile streams. Try without specified device if hwdevice_ctx_create fails. 2021-01-08 15:48:01 -05:00
Isaac Connor 81d6f8c1ee disable rtsp_server 2021-01-07 15:13:02 -05:00
Isaac Connor c70e2ccfc2 Must notify before waiting in destructor. Fix leaks 2021-01-07 15:12:44 -05:00
Isaac Connor 514201c7b2 use zm_av_send_packet_receive_frame and fixup hwaccel support 2021-01-07 15:12:27 -05:00
Isaac Connor f729034e9f improve hwaccel support 2021-01-07 15:11:46 -05:00
Isaac Connor 655e54db17 remove unused directbuffer 2021-01-07 09:50:45 -05:00
Isaac Connor 595bb2f565 Open/CLose RTSP with analysis thread when opening and closing monitor. We have to have successfully PrimeCapture before adding streams to RTSP Server and need to shut it down when closing the monitor because the packetqueue goes away 2021-01-07 09:47:53 -05:00
Isaac Connor c6d15f193a Update codec opening to properly handle passthrough 2021-01-07 09:46:35 -05:00
Isaac Connor 5cca440bee change outputFd which is unused to stream_id which is the stream_id to concern ourselves with when getting packets from the packetqueue. Add more tests for zm_terminate. Add testing for AV_CODEC_ID instead of v4l2 PIX_FMT to determine stream type 2021-01-07 09:46:06 -05:00
Isaac Connor abc402878b remove analysis_it and correctly manage external iterators. Fix testing for ability to remove packets from packetqueue. Fix some cases where the order of testing zm_terminate and packet locking is important 2021-01-07 09:43:53 -05:00
Isaac Connor 3b8266a6f0 add missing and mix order of Packet initializers 2021-01-07 09:41:08 -05:00
Isaac Connor 0d450f4f85 add missing and mix order of Packet initializers 2021-01-07 09:41:02 -05:00
Isaac Connor ff3bc981de move code from Load for purpose==ANALYSIS because it will never run. Analysis is a thread now and must assume that PrimeCapture has already succeeded. 2021-01-07 09:40:24 -05:00
Isaac Connor 7afaf00202 spacing and NULL=>nullptr 2021-01-07 09:36:54 -05:00
Isaac Connor e30f0245ef NULL=>nullptr 2021-01-07 09:36:33 -05:00
Isaac Connor c9641063ca Don't need to get_ref_image anymore. It will block waiting for a capture packet and the ref image will be set by capture thread 2021-01-07 09:36:18 -05:00
Isaac Connor 315dccdaec Rename H264PASSTHROUGH to just PASSTHROUGH. Add an analysis_it to the Monitor object as it will no longer exist in the packetqueue 2021-01-06 11:32:09 -05:00
Isaac Connor e93a895f28 Rename H264PASSTHROUGH to just PASSTHROUGH. Start with last_signal set to true so that we don't have a signal change event on startup. Use new generic packetqueue functions 2021-01-06 11:31:31 -05:00
Isaac Connor d6c217c1ec Rename H264PASSTHROUGH to just PASSTHROUGH 2021-01-06 11:30:42 -05:00
Isaac Connor 08a28e6960 Set codec_type in zm_packet 2021-01-06 11:30:03 -05:00
Isaac Connor 7c049afc61 Add AVPacket parsing queue and other files for rtsp_server 2021-01-06 11:26:08 -05:00
Isaac Connor 770cf5703d continue roughing in rtsp server. Fix not adding session to rtspServer. 2021-01-06 11:24:52 -05:00
Isaac Connor d6b59c0abf Add rtsp_server files to CMakeLists.txt 2021-01-06 10:48:52 -05:00
Isaac Connor b6c11538c2 cleanup. Add h264_vaapi codec support 2020-12-31 09:15:49 -05:00
Isaac Connor 48dcb23af0 small cleanup in logging 2020-12-31 09:14:03 -05:00
Isaac Connor 6d036629d3 clean up cruft. NULL=>nullptr. Fix some codec_context allocation. Try to solve h264_encoder_close crash. 2020-12-30 21:25:12 -05:00
Isaac Connor 9d532df9c7 need to include zm_video for Encoder Parameter passing 2020-12-30 21:24:09 -05:00
Isaac Connor f61210c91f remove old code using image_buffer in zm_packets 2020-12-30 21:23:29 -05:00
Isaac Connor 6c696f4025 Return avcodec errors codes instead of 0/1 2020-12-30 21:22:55 -05:00
Isaac Connor 64deff7486 include std::string don't include zm_video.h. Remove old videoWriter references 2020-12-30 21:22:33 -05:00
Isaac Connor 00aae0b68f Use proper c++ initializers 2020-12-30 21:21:59 -05:00
Isaac Connor 019f02e9de remove old sigblocking code 2020-12-30 21:21:41 -05:00
Isaac Connor 284b9f963f Merge branch 'master' into zma_to_thread 2020-12-29 12:18:26 -05:00
Isaac Connor dc487f35a9 set packet codec_type 2020-12-27 12:36:33 -05:00
Isaac Connor 9be7547c8b Look at stream index instead of image_index when finding first keyframe in packetqueue 2020-12-27 12:32:46 -05:00
Isaac Connor e58c06e60f Don't need keyframes when saving jpegs. 2020-12-27 12:32:06 -05:00
Isaac Connor af94473eb1 remove debug lines about nalType=1 2020-12-27 12:25:23 -05:00
Isaac Connor 085d83b250 frames are allocated in zm_packet now, so remove them 2020-12-27 12:24:34 -05:00
Isaac Connor c8d2eb9c0f Must stop threads before Closing monitor 2020-12-27 12:04:35 -05:00
Isaac Connor a440ab3ef0 need to copy parameters to codecpar 2020-12-27 12:04:17 -05:00
Isaac Connor 16662f79ce spacing and code stylez 2020-12-27 12:03:44 -05:00
Isaac Connor 57542b01d5 Remove all the scaling and conversion stuff. Use packet->decode. Set keyframe flag. return codes of functions are now -1 for failure, 0 for failure but no error and 1 for success. 2020-12-27 12:02:02 -05:00
Isaac Connor 7c9db96acc spacing and NULL=>nullptr 2020-12-27 12:01:01 -05:00
Isaac Connor 3f2d088f8c Delete image if image_index == -1 2020-12-27 12:00:45 -05:00
Isaac Connor 197f9bdd9e indenting fix. Don't update reference image if not doing motion detection. Decouple the image buffer from the packetqueue. So always allocate a new image. Then copy decoded image to image buffer if required. 2020-12-27 12:00:18 -05:00
Isaac Connor 63687c8e44 code style 2020-12-27 11:57:50 -05:00
Isaac Connor 61bffdb249 fix compiler warning 2020-12-27 11:57:23 -05:00
Isaac Connor 5624a0bef4 NULL->nullptr 2020-12-27 11:56:59 -05:00
Isaac Connor d6bbc9bbbb Set codec_type in ffmpeg_camera instead of in monitor 2020-12-27 11:56:44 -05:00
Isaac Connor 0521d05295 Can only output jpegs if we are doing decoding. 2020-12-27 11:55:53 -05:00
Isaac Connor 9b916a15a2 Only get ref image if we are doing motion detection. 2020-12-27 11:55:14 -05:00
Isaac Connor ddf66bc9b5
Merge pull request #3100 from vertigeaux/share_frame_scores
save frame scores to SharedData for use with linked monitors
2020-12-24 11:08:25 -05:00
Isaac Connor 48d9b4d5a5 Remove unused variables 2020-12-23 18:50:52 -05:00
Isaac Connor f934a6bbaf spacing and change last_fps_time and last_analysis_time to doubles 2020-12-23 18:50:38 -05:00
Isaac Connor 1ffc233593 Move some initialisation into MOnitor() initialisation. Update UpdateAnalysisFPS to use more doubles instead of integers to get better numbers. Move capture FPS updating to UpdateCaptureFPS and use doubles there too. remove some dead code and add some debugging 2020-12-23 18:50:07 -05:00
Isaac Connor 3893e97e94 Quieten compiler warnings 2020-12-23 18:18:30 -05:00
Isaac Connor ee8f940acf Add some debug 2020-12-23 18:18:16 -05:00
Isaac Connor fb2793d337 use nullptr instead of 0 when init'ing event 2020-12-23 09:11:33 -05:00
Isaac Connor a1917d83d0 Merge branch 'master' into zma_to_thread 2020-12-22 19:52:09 -05:00
Vertigeaux 1416cbb03c save frame scores to SharedData for use with linked monitors 2020-12-22 17:44:53 -06:00
Isaac Connor d6486d1a7e use nullptr instead of 0 when init'ing event 2020-12-22 15:44:07 -05:00
Isaac Connor 400e0de609 When updating Monitor_Status, reset FPS on Prime 2020-12-22 10:22:52 -05:00
Isaac Connor 4bea286cfe Use new get_event_start_packet_it function to start the new event with the right packet. 2020-12-22 10:22:28 -05:00
Isaac Connor 91057b9546 Clean up video_packet_count stuff. use packet_counts instead. Use more efficient logic for managing the # of video packets on the queue. Rewrite clearQueue to not use reverse iterators. Implement get_starting_packet to return an iterator to the packet that SHOULD start an event. So it takes into account pre_event_count and keyframe rules. 2020-12-22 10:20:44 -05:00
Isaac Connor d89cbebbdf AddPacket should just take a packet. score and alarm_image are members of the packet 2020-12-22 10:18:15 -05:00
Isaac Connor bc03afa166 Merge branch 'rtsp_server' into zma_to_thread 2020-12-17 10:21:51 -05:00
Isaac Connor 8d52baeee2 Merge branch 'master' into rtsp_server
Cleanup Analysis a bit. We can't skip packets just because they are audio. Clean up the state machine transitions a bit to make them a little more readable.
Change logic of PrimeCapture, success MUST return 1.  0 means no error but also no success.
Debugging and braces improvements in local_camera.
2020-12-17 10:16:54 -05:00
Isaac Connor 08d82fb86a use nullptr instead of 0 when init'ing event 2020-12-15 18:25:17 -05:00
Isaac Connor 6e2cfa6ca9 Add R and W short form options 2020-12-15 16:57:27 -05:00
Isaac Connor b306f1b2e8 Add R and W short form options 2020-12-15 16:55:28 -05:00
Isaac Connor 89eacbc8a8 NODECT needs an analysis thread to check for triggers and linked monitors. Turn off RTSP for now 2020-12-15 16:55:12 -05:00
Isaac Connor fbbfb20c41 Move orientation setting down. output_stream hasn't been allocated yet so that would crash. 2020-12-15 16:54:35 -05:00
Isaac Connor b7cc5dde54 Merge branch 'master' of github.com:ZoneMinder/zoneminder 2020-12-15 16:50:09 -05:00
Isaac Connor 46bbbb7dff Merge branch 'fix_zone_instead_of_ignore' 2020-12-15 16:33:58 -05:00
Isaac Connor e9d3449929 Allow altering polygon coordinates 2020-12-15 16:32:41 -05:00
Isaac Connor a88ccf793b correct zone points instead of skipping zone 2020-12-15 16:32:19 -05:00
Isaac Connor 5dbe8d35ad Debug the start of rtsp server thread run 2020-12-15 16:01:34 -05:00
Isaac Connor a502a86b00 Instead of pointing analsysis_it to begin, point it to the end, which is the newly pushed packet. Add back queue clearing 2020-12-15 16:01:18 -05:00
Isaac Connor da18305729 Remove some dead code and debugging 2020-12-15 15:59:46 -05:00
Isaac Connor 39212d8ca0 Remove or increase debug level 2020-12-15 15:59:22 -05:00
Isaac Connor 8a2d4c7512 Debug the start of thread run in analysisthread. Sleep for appropriate amount of time. 2020-12-15 15:57:40 -05:00
Isaac Connor aaea6c6ead Store endtime for each packet 2020-12-15 15:57:01 -05:00
Isaac Connor 0702b64cc4 Merge branch 'master' into zma_to_thread 2020-12-15 10:51:40 -05:00
Isaac Connor 99e7ae3505 Merge branch 'master' into rtsp_server 2020-12-15 10:14:19 -05:00
Isaac Connor f544c18541 add debug testing 2020-12-12 18:53:12 -05:00
Isaac Connor 97b0ea2b73 Add missing columns to sql to load monitors. Add code to do DecodeEnabled. Handle audio packets 2020-12-12 18:52:57 -05:00
Isaac Connor f77292e6cc Move the decoding_enabled logic to constructor to save a few cycles 2020-12-10 16:23:08 -05:00
Isaac Connor 7b1ca0e66d Use the new DecodingEnabled function 2020-12-10 14:05:57 -05:00
Isaac Connor 7f72d5399f add decoding_enabled and DecodingEnabled function 2020-12-10 14:05:46 -05:00
Isaac Connor c65e63798d Don't do decode when in RECORD OR NODECT and passthrough and no jpegs 2020-12-10 13:47:30 -05:00
Isaac Connor c9bd09ae7b report both capture_fps and analysis_fps 2020-12-09 15:03:18 -05:00
Isaac Connor 9d43b64d4a Add debug and rtsp_server 2020-12-09 15:03:00 -05:00
Isaac Connor 03903d2dad spacing 2020-12-09 15:01:35 -05:00
Isaac Connor f54b8fff44 use mutex and condition_variable to manage signalling. Lots of debugging and fixes 2020-12-09 15:01:24 -05:00
Isaac Connor 02dd1d4cc5 Use recursive_mutex for mutex because we need to hold the lock twice 2020-12-09 15:00:57 -05:00
Isaac Connor 50e1e4391a Include capture_fps and analysis_fps in status 2020-12-09 15:00:29 -05:00
Isaac Connor 6bf5d1b5a1 Fixes to analysis_fps vs analysis_fps_limit. Fixes to logic in analysis. Make capture_fps and analysis_fps be part of shared mem. 2020-12-09 15:00:11 -05:00
Isaac Connor 282c020d86 spacing code style 2020-12-09 12:21:41 -05:00
Isaac Connor 697f9a50fe Terminate thread also when zm_terminate is true 2020-12-09 12:21:31 -05:00
Isaac Connor a3ff81b279 Add zm_rtsp_server_thread.cpp to CMakeLists.txt 2020-12-09 12:20:01 -05:00
Isaac Connor 054e1b583d Rough in code for the RTSP Server thread 2020-12-09 12:19:35 -05:00
Isaac Connor b261fbb397 Merge branch 'master' into zma_to_thread 2020-12-07 16:26:26 -05:00
Isaac Connor aaf4b37439 spacing, don't need to set packet.size=0 2020-12-07 15:53:09 -05:00
Isaac Connor 36b5702c50 Increase LinkedMonitor debugging. Fix LinkedMonitors. Fixes #3091 2020-12-05 19:36:44 -05:00
Isaac Connor 4d33667a85 Merge branch 'release-1.34' 2020-12-05 16:51:42 -05:00
hax0kartik 8012438573 Fix font rendering issue 2020-12-04 05:22:54 +05:30