Commit Graph

3878 Commits

Author SHA1 Message Date
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