You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1385 lines
45 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
2 months ago
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
videoLIVE555Source: fix the crash in the destructor videoLIVE555Source: - _stop() tore the stream down on the caller's thread while the live555 thread was still inside doEventLoop(), and deleted the RTSP client, the environment and the scheduler under the running loop. Now it ends the loop, joins the thread, then closes what is left on its own thread. - shutdownStream() no longer deletes the scheduler/environment (a second shutdown, e.g. _close() then the destructor or a live555 callback then the destructor, used them after they were freed). Only the destructor frees them, once. A second shutdown is a no-op. - m_pRtspClient and the other pointers are initialised: a source that was never opened, or failed to open, shut down a random pointer. - The event-loop flag is reset in _open(), not at thread start, so a stop issued before the thread ran is not lost. - shutdownStream closes the subsession sinks and sends TEARDOWN, as live555 testRTSPClient does. The sinks were never closed and leaked. - continueAfterPLAY frees resultString. DummySink: - Every pointer is NULL-initialised before the constructor can return early. The destructor freed an uninitialised m_pFrame when the codec was not found or in stream-proxy mode. - Decode resources are created whenever DECODE_FRAMES is set, also together with STREAM_PROXY (deviceNodeCamera uses both). They were used uninitialised. Decoding is skipped if any of them is missing. - m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data). - The destructor frees the frames, the RGB buffer, the scaler, the codec context, the output format context and dictionary, and m_pH264. The trailer is written only after a written header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "videoLive555AVLibSource.h"
  2. #ifndef LRF_PROXY_ONLY
  3. #define FF_DISABLE_DEPRECATION_WARNINGS
  4. StreamClientState::StreamClientState() :
  5. iter(NULL),
  6. session(NULL),
  7. subsession(NULL),
  8. streamTimerTask(NULL),
  9. duration(0.0)
  10. {
  11. }
  12. StreamClientState::~StreamClientState()
  13. {
  14. delete iter;
  15. if (session != NULL)
  16. {
  17. // We also need to delete "session", and unschedule "streamTimerTask" (if set)
  18. UsageEnvironment & env = session->envir(); // alias
  19. env.taskScheduler().unscheduleDelayedTask(streamTimerTask);
  20. Medium::close(session);
  21. };
  22. }
  23. CustomRTSPClient * CustomRTSPClient::createNew(videoLIVE555Source * session, UsageEnvironment & env, const char * rtspURL, int verbosityLevel, const char * applicationName, portNumBits tunnelOverHTTPPortNum)
  24. {
  25. return new CustomRTSPClient(session, env, rtspURL, verbosityLevel, applicationName, tunnelOverHTTPPortNum);
  26. }
  27. CustomRTSPClient::CustomRTSPClient(videoLIVE555Source * session, UsageEnvironment & env, const char * rtspURL, int verbosityLevel, const char * applicationName, portNumBits tunnelOverHTTPPortNum) :
  28. RTSPClient(env, rtspURL, verbosityLevel, applicationName, tunnelOverHTTPPortNum, -1),
  29. session(session)
  30. {
  31. }
  32. CustomRTSPClient::~CustomRTSPClient() {}
  33. #define LOG(X) m_pLog->Log("LIVE555_SIN", this, X)
  34. #define MLOG(X) ME->m_pLog->Log("LIVE555_SIN", ME, X)
  35. #ifdef DEBUG
  36. #define LOG_ERROR(X) \
  37. { \
  38. char _tBfrErrMSG2w34[1024]; \
  39. sprintf(_tBfrErrMSG2w34, "In file %s[%d] in func:%s %s", __FILE__, __LINE__, __func__, X); \
  40. m_pLog->Log("LIVE555_SIN", this, _LOG_ERROR, _tBfrErrMSG2w34); \
  41. }
  42. #else
  43. #define LOG_ERROR(X) m_pLog->Log("LIVE555_SIN", this, _LOG_ERROR, X);
  44. #endif
  45. DummySink * DummySink::createNew(videoLIVE555Source * session, UsageEnvironment & env, MediaSubsession & subsession, char const * streamId, int w, int h, int ww, int hh)
  46. {
  47. return new DummySink(session, env, subsession, streamId, w, h, ww, hh);
  48. }
  49. DummySink::DummySink(videoLIVE555Source * session, UsageEnvironment & env, MediaSubsession & subsession, const char * streamId, int w, int h, int ww, int hh) :
  50. MediaSink(env),
  51. m_pRGB(NULL),
  52. m_pSession(session),
  53. //m_iFrameIndex(0),
  54. m_sSubSession(subsession),
  55. qtOut(NULL),
  56. m_pCodec(NULL),
  57. m_pCodecContext(NULL),
  58. m_pOutCodec(NULL),
  59. m_pOutCodecContext(NULL),
  60. m_pOutFormatCtx(NULL),
  61. m_pOutFormatOpts(NULL),
  62. m_pOutStream(NULL),
  63. m_pH264(NULL),
  64. m_pFrame(NULL),
  65. m_pRGBFrame(NULL),
  66. m_pSwsContext(NULL),
  67. m_bOutHeaderWritten(false)
  68. {
  69. m_pLog = basicLogCollection::getInstance();
  70. m_pStreamId = strDup(streamId);
  71. m_iFrameIndex = 0;
  72. m_nCurrentOutFile = 0;
  73. m_pOutFile[0] = m_pOutFile[1] = NULL;
  74. m_nInWidth = w;
  75. m_nInHeight = h;
  76. m_nOutWidth = ww;
  77. m_nOutHeight = hh;
  78. m_pReceiveBuffer = new uint8_t[DUMMY_SINK_RECEIVE_BUFFER_SIZE];
  79. m_pReceiveBufferAV = new uint8_t[DUMMY_SINK_RECEIVE_BUFFER_SIZE + 4];
  80. m_pReceiveBufferAV[0] = 0;
  81. m_pReceiveBufferAV[1] = 0;
  82. m_pReceiveBufferAV[2] = 0;
  83. m_pReceiveBufferAV[3] = 1;
  84. // av_packet_unref() also releases opaque_ref / side_data: every field must be defined
  85. memset(&m_sAvPkt, 0, sizeof(m_sAvPkt));
  86. m_sAvPkt.pts = AV_NOPTS_VALUE;
  87. m_sAvPkt.dts = AV_NOPTS_VALUE;
  88. m_sAvPkt.pos = -1;
  89. m_sAvPkt.duration = 0;
  90. //m_sAvPkt.convergence_duration = 0; //is deprecated
  91. m_sAvPkt.flags = AV_PKT_FLAG_KEY;
  92. m_sAvPkt.stream_index = 0;
  93. m_sAvPkt.buf = NULL;
  94. m_sAvPkt.side_data = NULL;
  95. m_sAvPkt.side_data_elems = 0;
  96. memset(m_aInBuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);
  97. LOG(m_sSubSession.codecName());
  98. m_eCodecProbe = AV_CODEC_ID_NONE;
  99. if (strcmp(m_sSubSession.codecName(), "JPEG") == 0)
  100. {
  101. m_eCodecProbe = AV_CODEC_ID_MJPEG;
  102. }
  103. else if (strcmp(m_sSubSession.codecName(), "H264") == 0)
  104. {
  105. m_eCodecProbe = AV_CODEC_ID_H264;
  106. }
  107. else if (strcmp(m_sSubSession.codecName(), "H265") == 0)
  108. {
  109. m_eCodecProbe = AV_CODEC_ID_HEVC;
  110. };
  111. m_pCodec = avcodec_find_decoder(m_eCodecProbe);
  112. if (m_pCodec == NULL)
  113. {
  114. LOG_ERROR("codec not found!");
  115. return;
  116. };
  117. m_pCodecContext = avcodec_alloc_context3(m_pCodec);
  118. if (m_pCodecContext == NULL)
  119. {
  120. LOG_ERROR("could not allocate codec context!");
  121. return;
  122. };
  123. #if (LIBAVCODEC_VERSION_MAJOR >= 60)
  124. #else
  125. if (m_pCodec->capabilities & AV_CODEC_CAP_TRUNCATED)
  126. {
  127. m_pCodecContext->flags |= AV_CODEC_FLAG_TRUNCATED; // we do not send complete frames
  128. };
  129. #endif // (LIBAVCODEC_VERSION_MAJOR >= 60)
  130. if ((m_sSubSession.videoWidth() > 0) && (m_sSubSession.videoHeight() > 0))
  131. {
  132. m_nInWidth = m_sSubSession.videoWidth();
  133. m_nInHeight = m_sSubSession.videoHeight();
  134. };
  135. m_pCodecContext->width = m_nInWidth;
  136. m_pCodecContext->height = m_nInHeight;
  137. // Must be carefull! and get pix_fmt from stream
  138. m_pCodecContext->pix_fmt = AV_PIX_FMT_YUV420P;
  139. if (avcodec_open2(m_pCodecContext, m_pCodec, NULL) < 0)
  140. {
  141. LOG_ERROR("could not open codec!");
  142. avcodec_free_context(&m_pCodecContext); // NULL: the frames are not decoded
  143. return;
  144. };
  145. if (m_pSession->getWM() & MS_MODE_STREAM_PROXY)
  146. {
  147. m_pH264 = (uint8_t *) malloc(256 * 1024);
  148. m_pOutFormatCtx = NULL;
  149. m_pOutFormatOpts = NULL;
  150. if (avformat_alloc_output_context2(&m_pOutFormatCtx, NULL, NULL, "test.mp4") < 0)
  151. {
  152. LOG_ERROR("VideoFormat Context Memory Allocation Error");
  153. // return false;
  154. }
  155. else
  156. {
  157. m_pOutFormatCtx->oformat = av_guess_format("mp4", NULL, NULL);
  158. if (m_pOutFormatCtx->oformat != NULL)
  159. {
  160. av_dict_set(&m_pOutFormatOpts, "brand", "mp42", 0);
  161. av_dict_set(&m_pOutFormatOpts, "movflags", "faststart", 0);
  162. m_pOutFormatCtx->flags |= AVFMT_NOTIMESTAMPS | AVFMT_TS_NONSTRICT;
  163. m_pOutStream = avformat_new_stream(m_pOutFormatCtx, NULL);
  164. if (m_pOutStream != NULL)
  165. {
  166. // v60
  167. const AVCodec *codec = avcodec_find_decoder( m_pOutStream->codecpar->codec_id );
  168. AVCodecContext * c = avcodec_alloc_context3( codec );//m_pOutStream->codec;
  169. if (c == NULL)
  170. {
  171. LOG_ERROR("Output Codec Context Allocation Error");
  172. }
  173. else
  174. {
  175. c->codec_id = m_eCodecProbe;
  176. c->codec_type = AVMEDIA_TYPE_VIDEO;
  177. /* put sample parameters */
  178. c->bit_rate = m_sSubSession.bandwidth(); // 400000;
  179. /* resolution must be a multiple of two */
  180. c->width = m_sSubSession.videoWidth();
  181. c->height = m_sSubSession.videoHeight();
  182. /* time base: this is the fundamental unit of time (in seconds) in terms
  183. of which frame timestamps are represented. for fixed-fps content,
  184. timebase should be 1/framerate and timestamp increments should be
  185. identically 1. */
  186. c->time_base.den = m_sSubSession.videoFPS();
  187. c->time_base.num = 1;
  188. c->gop_size = 12; /* emit one intra frame every twelve frames at most */
  189. c->pix_fmt = AV_PIX_FMT_YUV420P;
  190. if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO)
  191. {
  192. /* just for testing, we also add B frames */
  193. c->max_b_frames = 2;
  194. }
  195. if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO)
  196. {
  197. /* needed to avoid using macroblocks in which some coeffs overflow
  198. this doesnt happen with normal video, it just happens here as the
  199. motion of the chroma plane doesnt match the luma plane */
  200. c->mb_decision = 2;
  201. }
  202. // some formats want stream headers to be seperate
  203. if (! strcmp(m_pOutFormatCtx->oformat->name, "mp4") || ! strcmp(m_pOutFormatCtx->oformat->name, "mov") || ! strcmp(m_pOutFormatCtx->oformat->name, "3gp"))
  204. {
  205. c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
  206. LOG("Global Header Flag is Set!");
  207. };
  208. avcodec_free_context(&c); // only used to compute the flags above
  209. };
  210. if (avio_open(&m_pOutFormatCtx->pb, "test_99.mp4", AVIO_FLAG_WRITE) < 0)
  211. {
  212. LOG_ERROR("Could not open output file.");
  213. // return false;
  214. }
  215. else if (avformat_write_header(m_pOutFormatCtx, &m_pOutFormatOpts) < 0)
  216. {
  217. LOG_ERROR("Error occurred when writing header to output file.");
  218. // return false;
  219. }
  220. else
  221. {
  222. m_bOutHeaderWritten = true; // av_write_trailer() only after a written header
  223. };
  224. }
  225. };
  226. };
  227. /*
  228. m_pOutCodec = = avcodec_find_encoder( VIDEO_OUTPUT_CODEC );
  229. if( m_pOutCodec == NULL ) {
  230. LOG_ERROR( "output codec not found!" );
  231. //m_pSession->setWM( m_pSession->getWM() & ( ~ MS_MODE_STREAM_PROXY ) );
  232. return;
  233. };
  234. m_pOutCodecContext = avcodec_alloc_context3( m_pOutCodec );
  235. if( m_pOutCodecContext == NULL ){
  236. LOG_ERROR("VideoCodec Context Memory Allocation Error");
  237. return;
  238. } else {
  239. LOG("Codec Context3 Allocated");
  240. };
  241. if( avformat_alloc_output_context2( &m_pOutFormatCtx, NULL, NULL, "test." VIDEO_OUTPUT_CONTAINER ) < 0 ) {
  242. LOG_ERROR("VideoFormat Context Memory Allocation Error");
  243. return;
  244. };
  245. m_pOutFormatCtx->oformat = av_guess_format( VIDEO_OUTPUT_CONTAINER, NULL, NULL );
  246. if( m_pOutFormatCtx->oformat == NULL ){
  247. LOG_ERROR("VideoFormat Format Not Guessed!");
  248. return;
  249. } else {
  250. LOG("Video Container Format Guessed");
  251. };
  252. m_pOutVideoStr = avformat_new_stream( m_pOutFormatCtx, m_pOutCodec );
  253. if( m_pOutVideoStr == NULL){
  254. LOG_ERROR("VideoStream Not Created!");
  255. } else {
  256. LOG("VideoStream is Created");
  257. };
  258. m_pOutCodecContext->codec_id = VIDEO_OUTPUT_CODEC;
  259. m_pOutCodecContext->codec_type = AVMEDIA_TYPE_VIDEO;
  260. m_pOutCodecContext->pix_fmt = VIDEO_OUTPUT_PIX_FMT;
  261. m_pOutCodecContext->bit_rate = VIDEO_OUTPUT_BITRATE;
  262. //m_pOutCodecContext->bit_rate_tolerance = 1;
  263. //m_pOutCodecContext->global_quality = 100;
  264. //m_pOutCodecContext->compression_level = 2;
  265. m_pOutCodecContext->width = m_nWidth;
  266. m_pOutCodecContext->height = m_nHeight;
  267. m_pOutCodecContext->time_base.num = 1;
  268. m_pOutCodecContext->time_base.den = VIDEO_OUTPUT_FPS;
  269. m_pOutCodecContext->gop_size = VIDEO_OUTPUT_GOP; // emit one intra frame every ten frames
  270. //m_pVideoState->m_pCodecCtx->qmin = 15;
  271. //m_pVideoState->m_pCodecCtx->qmax = 30;
  272. m_pOutCodecContext->flags |= CODEC_FLAG_GLOBAL_HEADER;
  273. if( m_pVideoState->m_pCodecCtx->codec_id == AV_CODEC_ID_H264 ){
  274. //Reference for AvFormatContext options : https://ffmpeg.org/doxygen/2.8/movenc_8c_source.html
  275. //Set format's privater options, to be passed to avformat_write_header()
  276. LOG("Begin Options!");
  277. int RetVal = 0;
  278. //RetVal = av_dict_set(&m_pVideoState->m_pFormatOpts, "movflags", "faststart", 0);
  279. //if( RetVal < 0 ){
  280. // LOG_ERROR( "av_dict_set movflags!");
  281. //};
  282. //default brand is "isom", which fails on some devices
  283. RetVal = av_dict_set(&m_pVideoState->m_pFormatOpts, "brand", "mp42", 0);
  284. if( RetVal < 0 ){
  285. LOG_ERROR( "av_dict_set brand!" );
  286. };
  287. //m_pVideoState->m_pCodecCtx->max_b_frames = 1;
  288. m_pVideoState->m_pCodecCtx->level = 31;
  289. RetVal = av_opt_set(m_pVideoState->m_pCodecCtx->priv_data, "crf", "12", 0);
  290. if( RetVal < 0 ){
  291. LOG_ERROR("av_opt_set crf");
  292. };
  293. RetVal = av_opt_set(m_pVideoState->m_pCodecCtx->priv_data, "profile", "main", 0);
  294. if( RetVal < 0 ){
  295. LOG_ERROR("av_opt_set profile");
  296. };
  297. RetVal = av_opt_set(m_pVideoState->m_pCodecCtx->priv_data, "preset", "slow", 0);
  298. if( RetVal < 0 ){
  299. LOG_ERROR("av_opt_set preset");
  300. };
  301. // Disable b-pyramid. CLI options for this is "-b-pyramid 0"
  302. // Because Quicktime (ie. iOS) doesn't support this option
  303. RetVal = av_opt_set(m_pVideoState->m_pCodecCtx->priv_data, "b-pyramid", "0", 0);
  304. if( RetVal < 0 ){
  305. LOG_ERROR("av_opt_set b-pyramid");
  306. };
  307. LOG("End Options!");
  308. };
  309. //See up one page ->
  310. avcodec_get_context_defaults3(m_pVideoState->m_pVideoStr->codec, m_pVideoState->m_pVideoCodec);
  311. const AVRational dst_fps = { VIDEO_OUTPUT_FPS, 1 };
  312. m_pVideoState->m_pVideoStr->codec->width = m_nWidth;
  313. m_pVideoState->m_pVideoStr->codec->height = m_nHeight;
  314. m_pVideoState->m_pVideoStr->codec->pix_fmt = m_pVideoState->m_pVideoCodec->pix_fmts[0];
  315. m_pVideoState->m_pVideoStr->codec->time_base = m_pVideoState->m_pVideoStr->time_base = av_inv_q(dst_fps);
  316. m_pVideoState->m_pVideoStr->r_frame_rate = m_pVideoState->m_pVideoStr->avg_frame_rate = dst_fps;
  317. if (m_pVideoState->m_pFormatCtx->oformat->flags & AVFMT_GLOBALHEADER) m_pVideoState->m_pVideoStr->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
  318. //---->>
  319. if (avcodec_is_open(m_pVideoState->m_pCodecCtx) == 0) {
  320. LOG("output codec context is closed, opening");
  321. int ret = avcodec_open2(m_pVideoState->m_pCodecCtx, m_pVideoState->m_pVideoCodec, NULL);
  322. if (ret < 0) {
  323. LOG_ERROR("Error opening2 encoder");
  324. char buffer[200];
  325. sprintf(buffer, "Error code: %i", ret );
  326. LOG_ERROR(buffer);
  327. return false;
  328. }
  329. }else{
  330. LOG("output codec context is opened");
  331. };
  332. */
  333. // https://github.com/rgaufman/live555/blob/master/testProgs/playCommon.cpp
  334. // http://www.live555.com/liveMedia//doxygen/html/QuickTimeFileSink_8hh_source.html
  335. // qtOut = QuickTimeFileSink::createNew(*env, *session, outFileName,
  336. // fileSinkBufferSize,
  337. // movieWidth, movieHeight,
  338. // movieFPS,
  339. // packetLossCompensate,
  340. // syncStreams,
  341. // generateHintTracks,
  342. // generateMP4Format);
  343. /* qtOut = QuickTimeFileSink::createNew( env, *session->getMS(), "TEST.mp4",
  344. 100000,
  345. subsession.videoWidth(), subsession.videoHeight(),
  346. subsession.videoFPS(),
  347. 0,
  348. 0,
  349. 0,
  350. 1);
  351. */
  352. qtOut = (H264or5VideoFileSink *) H264VideoFileSink::createNew(env, "TEST22.mp4");
  353. if (qtOut != NULL)
  354. {
  355. LOG("Created QTFS ---> Test.mp4");
  356. // qtOut->startPlaying( NULL, NULL );
  357. LOG("QTFS Started Play");
  358. };
  359. };
  360. // Not "else if": afterGettingFrame() decodes whenever DECODE_FRAMES is set, also together with
  361. // STREAM_PROXY - the frames / scaler must exist then (they were used uninitialized)
  362. if (m_pSession->getWM() & MS_MODE_DECODE_FRAMES)
  363. {
  364. // Allocate Mems
  365. m_pFrame = av_frame_alloc();
  366. m_pRGBFrame = av_frame_alloc();
  367. //avpicture_alloc((AVPicture *) m_pRGBFrame, AV_PIX_FMT_BGR24, m_nOutWidth, m_nOutHeight);
  368. int ret = (m_pRGBFrame != NULL) ? av_image_alloc( m_pRGBFrame->data, m_pRGBFrame->linesize, m_nOutWidth, m_nOutHeight, AV_PIX_FMT_BGR24, 32) : -1; // 32 for alignment
  369. if (ret < 0) {
  370. LOG_ERROR("Error Allocating RGBFrame!");
  371. av_frame_free(&m_pRGBFrame); // NULL: no decoding (see canDecode())
  372. };
  373. m_pSwsContext = sws_getContext(m_pCodecContext->width, m_pCodecContext->height, m_pCodecContext->pix_fmt, m_nOutWidth, m_nOutHeight, AV_PIX_FMT_BGR24, SWS_BICUBIC, NULL, NULL, NULL);
  374. if (m_pSwsContext == NULL)
  375. {
  376. LOG_ERROR("Error Creating Scaler!");
  377. };
  378. m_pRGB = new cv::Mat(m_nOutHeight, m_nOutWidth, CV_8UC3, cv::Scalar(255, 0, 255));
  379. }
  380. else
  381. {
  382. LOG("No Decode Frames Mode!");
  383. };
  384. #ifdef DEBUG
  385. char tB[128];
  386. sprintf(tB, "Created Sink [%dx%d]->[%dx%d]", m_pCodecContext->width, m_pCodecContext->height, m_nOutWidth, m_nOutHeight);
  387. LOG(tB);
  388. #endif
  389. }
  390. DummySink::~DummySink()
  391. {
  392. // Every pointer is NULL unless it was allocated (the constructor can return early)
  393. if (m_pOutFormatCtx != NULL)
  394. {
  395. if (m_bOutHeaderWritten)
  396. {
  397. av_write_trailer(m_pOutFormatCtx);
  398. };
  399. if (m_pOutFormatCtx->pb != NULL)
  400. {
  401. avio_closep(&m_pOutFormatCtx->pb);
  402. };
  403. avformat_free_context(m_pOutFormatCtx);
  404. m_pOutFormatCtx = NULL;
  405. };
  406. av_dict_free(&m_pOutFormatOpts);
  407. for (int i = 0; i < 2; i++)
  408. {
  409. if (m_pOutFile[i] != NULL)
  410. {
  411. fflush(m_pOutFile[i]);
  412. pclose(m_pOutFile[i]);
  413. m_pOutFile[i] = NULL;
  414. };
  415. };
  416. if (qtOut != NULL)
  417. {
  418. Medium::close(qtOut);
  419. qtOut = NULL;
  420. };
  421. free(m_pH264);
  422. if (m_pSwsContext != NULL)
  423. {
  424. sws_freeContext(m_pSwsContext);
  425. };
  426. if (m_pRGBFrame != NULL)
  427. {
  428. av_freep(&m_pRGBFrame->data[0]); // av_image_alloc() buffer
  429. av_frame_free(&m_pRGBFrame);
  430. };
  431. av_frame_free(&m_pFrame); // was av_free(): leaked the frame buffers
  432. delete m_pRGB;
  433. avcodec_free_context(&m_pCodecContext); // also closes it
  434. delete[] m_pReceiveBuffer;
  435. delete[] m_pReceiveBufferAV;
  436. delete[] m_pStreamId;
  437. }
  438. bool DummySink::canDecode(void) const
  439. {
  440. return m_pCodecContext != NULL && m_pFrame != NULL && m_pRGBFrame != NULL && m_pSwsContext != NULL && m_pRGB != NULL;
  441. }
  442. void DummySink::afterGettingFrame(void * clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds)
  443. {
  444. DummySink * sink = (DummySink *) clientData;
  445. sink->afterGettingFrame(frameSize, numTruncatedBytes, presentationTime, durationInMicroseconds);
  446. }
  447. void DummySink::afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds)
  448. {
  449. // We've just received a frame of data. (Optionally) print out information about it:
  450. // if (strcmp(fSubsession.codecName(),"H264") == 0) {
  451. //LOG("FRM");
  452. if ( presentationTime.tv_sec ) presentationTime.tv_sec = presentationTime.tv_sec;
  453. if ( numTruncatedBytes ) numTruncatedBytes = numTruncatedBytes;
  454. if ( m_eCodecProbe != AV_CODEC_ID_NONE)
  455. {
  456. int got_picture = 0;
  457. memcpy(m_pReceiveBufferAV + 4, m_pReceiveBuffer, frameSize);
  458. m_sAvPkt.pts = AV_NOPTS_VALUE;
  459. m_sAvPkt.dts = AV_NOPTS_VALUE;
  460. m_sAvPkt.pos = -1;
  461. m_sAvPkt.duration = 0;
  462. //m_sAvPkt.convergence_duration = 0; // is deprecated
  463. m_sAvPkt.flags = AV_PKT_FLAG_KEY;
  464. m_sAvPkt.stream_index = 0;
  465. m_sAvPkt.buf = NULL;
  466. m_sAvPkt.side_data = NULL;
  467. m_sAvPkt.side_data_elems = 0;
  468. m_sAvPkt.size = frameSize + 4;
  469. m_sAvPkt.data = m_pReceiveBufferAV;
  470. if ((m_pSession->getWM() & MS_MODE_DECODE_FRAMES) && canDecode()){
  471. int ret = avcodec_send_packet( m_pCodecContext, &m_sAvPkt );
  472. if( ret < 0 ){
  473. //No error here - just icomplete data to decode frame
  474. //LOG_ERROR("Error Send Packet to Decoder!");
  475. };
  476. while ( ret >= 0 ) {
  477. ret = avcodec_receive_frame( m_pCodecContext, m_pFrame );
  478. if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
  479. // EAGAIN: Need more input packets
  480. // EOF: Decoder flushed
  481. break;
  482. } else if (ret < 0) {
  483. // Handle decoding error
  484. break;
  485. };
  486. // LOG( "Picture decoded" );
  487. got_picture = 1;
  488. sws_scale( m_pSwsContext, m_pFrame->data, m_pFrame->linesize, 0, m_pCodecContext->height, m_pRGBFrame->data, m_pRGBFrame->linesize);
  489. memcpy( m_pRGB->data, m_pRGBFrame->data[0], m_pRGBFrame->linesize[0] * m_nOutHeight );
  490. m_pSession->consumeFrame( m_pRGB );
  491. m_iFrameIndex++;
  492. };
  493. if ( ret == AVERROR_EOF ) {
  494. //End
  495. };
  496. };
  497. av_packet_unref(&m_sAvPkt);
  498. if ((m_pSession->getWM() & MS_MODE_STREAM_PROXY) && m_pH264 != NULL)
  499. {
  500. if (m_pSession->getWM() & MS_MODE_OVERLAYED_LOOPS)
  501. {
  502. // Sega - Mega - Drive
  503. };
  504. // write packet
  505. #if (0)
  506. // We've just received a frame of data. (Optionally) print out information about it:
  507. #ifdef DEBUG_PRINT_EACH_RECEIVED_FRAME
  508. if (fStreamId != NULL)
  509. {
  510. envir() << "Stream \"" << fStreamId << "\"; ";
  511. }
  512. envir() << fSubsession.mediumName() << "/" << fSubsession.codecName() << ":\tReceived " << frameSize << " bytes";
  513. if (numTruncatedBytes > 0)
  514. {
  515. envir() << " (with " << numTruncatedBytes << " bytes truncated)";
  516. }
  517. char uSecsStr[6 + 1]; // used to output the 'microseconds' part of the presentation time
  518. sprintf(uSecsStr, "%06u", (unsigned) presentationTime.tv_usec);
  519. envir() << ".\tPresentation time: " << (int) presentationTime.tv_sec << "." << uSecsStr;
  520. if (fSubsession.rtpSource() != NULL && ! fSubsession.rtpSource()->hasBeenSynchronizedUsingRTCP())
  521. {
  522. envir() << "!"; // mark the debugging output to indicate that this presentation time is not RTCP-synchronized
  523. }
  524. #ifdef DEBUG_PRINT_NPT
  525. envir() << "\tNPT: " << fSubsession.getNormalPlayTime(presentationTime);
  526. #endif
  527. envir() << "\n";
  528. #endif
  529. #else
  530. //*
  531. // printf("__FUNCTION__ = %s\n", __FUNCTION__ );
  532. // if(0 == strncmp(fSubsession.codecName(), "H264", 16) ){
  533. unsigned char nalu_header[4] = {0, 0, 0, 1};
  534. unsigned char extraData[256];
  535. unsigned int num = 0;
  536. SPropRecord * pSPropRecord;
  537. pSPropRecord = parseSPropParameterSets(m_sSubSession.fmtp_spropparametersets(), num);
  538. unsigned int extraLen;
  539. extraLen = 0;
  540. // p_record[0] is sps
  541. // p+record[1] is pps
  542. for (unsigned int i = 0; i < num; i++)
  543. {
  544. memcpy(&extraData[extraLen], &nalu_header[0], 4);
  545. extraLen += 4;
  546. memcpy(&extraData[extraLen], pSPropRecord[i].sPropBytes, pSPropRecord[i].sPropLength);
  547. extraLen += pSPropRecord[i].sPropLength;
  548. };
  549. memcpy(&extraData[extraLen], &nalu_header[0], 4);
  550. extraLen += 4;
  551. delete[] pSPropRecord;
  552. memcpy(m_pH264, &extraData[0], extraLen);
  553. memcpy(m_pH264 + extraLen, m_pReceiveBuffer, frameSize);
  554. int totalSize;
  555. totalSize = extraLen + frameSize;
  556. if (m_pOutFile[m_nCurrentOutFile] == NULL)
  557. {
  558. // m_pOutFile[m_nCurrentOutFile] = fopen("saved.h264", "wb" );
  559. LOG("Opening");
  560. // m_pOutFile[m_nCurrentOutFile] = popen("ffmpeg -y -hide_banner -i - -vcodec copy -movflags faststart -an ./ttt123.mp4", "w" );
  561. m_pOutFile[m_nCurrentOutFile] = popen("ffmpeg -y -hide_banner -i - -vcodec copy -reserve_index_space 50k -an ./ttt123.mkv", "w");
  562. if (m_pOutFile[m_nCurrentOutFile] == NULL)
  563. {
  564. LOG("Error !!");
  565. };
  566. };
  567. if (m_pOutFile[m_nCurrentOutFile] != NULL)
  568. {
  569. fwrite(m_pH264, 1, totalSize, m_pOutFile[m_nCurrentOutFile]);
  570. fflush(m_pOutFile[m_nCurrentOutFile]);
  571. // fclose( fp );
  572. };
  573. // qtOut->addData( m_pH264, totalSize, presentationTime );
  574. // printf("\tsaved %d bytes\n", totalSize );
  575. // }/*if 0 == strncmp(fSubsession.codecName(), "H264", 16)*/
  576. // if( got_picture ) {
  577. if (m_pOutFormatCtx != NULL)
  578. {
  579. m_sAvPkt.duration = durationInMicroseconds;
  580. if (got_picture)
  581. {
  582. m_sAvPkt.flags |= AV_PKT_FLAG_KEY;
  583. }
  584. m_sAvPkt.stream_index = m_pOutStream->index;
  585. m_sAvPkt.size = totalSize;
  586. m_sAvPkt.data = m_pH264;
  587. // m_sAvPkt.size = frameSize;
  588. // m_sAvPkt.data = m_pReceiveBuffer;
  589. // av_packet_rescale_ts( &avpkt, m_pOutCodec->time_base, time_base );
  590. int r = av_write_frame(m_pOutFormatCtx, &m_sAvPkt);
  591. if (r < 0)
  592. {
  593. char tB[256];
  594. av_strerror(r, tB, 256);
  595. LOG_ERROR("Trouble with Video Output!");
  596. LOG_ERROR(tB);
  597. };
  598. }
  599. //}
  600. #endif
  601. };
  602. #ifdef DEBUG
  603. }
  604. else
  605. {
  606. LOG("Codec Not Handled!");
  607. LOG(m_sSubSession.codecName());
  608. #endif
  609. };
  610. // Then continue, to request the next frame of data:
  611. continuePlaying();
  612. }
  613. Boolean DummySink::continuePlaying()
  614. {
  615. if (fSource == NULL)
  616. {
  617. return False; // sanity check (should not happen)
  618. }
  619. // Request the next frame of data from our input source. "afterGettingFrame()" will get called later, when it arrives:
  620. fSource->getNextFrame(m_pReceiveBuffer, DUMMY_SINK_RECEIVE_BUFFER_SIZE, afterGettingFrame, this, onSourceClosure, this);
  621. return True;
  622. }
  623. void DummySink::setSprop(const u_int8_t * prop, unsigned size)
  624. {
  625. uint8_t * buf;
  626. uint8_t * buf_start;
  627. LOG("setSprop");
  628. buf = (uint8_t *) malloc(1004);
  629. buf_start = buf + 4;
  630. m_sAvPkt.data = buf;
  631. m_sAvPkt.data[0] = 0;
  632. m_sAvPkt.data[1] = 0;
  633. m_sAvPkt.data[2] = 0;
  634. m_sAvPkt.data[3] = 1;
  635. if (size > 1000)
  636. {
  637. LOG_ERROR("Data Chunk too large!! Increase Mem!");
  638. free(buf);
  639. m_sAvPkt.data = NULL;
  640. m_sAvPkt.size = 0;
  641. return;
  642. };
  643. memcpy(buf_start, prop, size);
  644. m_sAvPkt.size = size + 4;
  645. if ((m_pSession->getWM() & MS_MODE_DECODE_FRAMES) && canDecode()){
  646. int ret = avcodec_send_packet( m_pCodecContext, &m_sAvPkt );
  647. if( ret < 0 ){
  648. LOG_ERROR("Error Send Packet to Decoder!");
  649. };
  650. while ( ret >= 0 ) {
  651. ret = avcodec_receive_frame( m_pCodecContext, m_pFrame );
  652. if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
  653. LOG_ERROR("EAGAIN/EOF while decoding frame");
  654. break;
  655. } else if (ret < 0) {
  656. LOG_ERROR("Error while decoding frame");
  657. break;
  658. };
  659. };
  660. };
  661. LOG("after setSprop");
  662. free(buf);
  663. m_sAvPkt.data = NULL;
  664. m_sAvPkt.size = 0;
  665. }
  666. #undef LOG_ERROR
  667. #undef MLOG
  668. #undef LOG
  669. #define LOG(X) m_pLog->Log("LIVE555_SRC", this, X)
  670. #define MLOG(X) ME->m_pLog->Log("LIVE555_SRC", ME, X)
  671. #ifdef DEBUG
  672. #define LOG_ERROR(X) \
  673. { \
  674. char _tBfrErrMSG2w34[1024]; \
  675. sprintf(_tBfrErrMSG2w34, "In file %s[%d] in func:%s %s", __FILE__, __LINE__, __func__, X); \
  676. m_pLog->Log("LIVE555_SRC", this, _LOG_ERROR, _tBfrErrMSG2w34); \
  677. }
  678. #else
  679. #define LOG_ERROR(X) m_pLog->Log("LIVE555_SRC", this, _LOG_ERROR, X);
  680. #endif
  681. void videoLIVE555Source::initMembers(void)
  682. {
  683. m_pLog = basicLogCollection::getInstance();
  684. m_pRtspClient = NULL;
  685. m_pSink = NULL;
  686. m_pMediaSession = NULL;
  687. fSubsession = NULL;
  688. fStreamId = NULL;
  689. fReceiveBuffer = NULL;
  690. _eventLoopWatchVariable = 0;
  691. m_tEventLoopThread = pthread_t();
  692. m_pScheduler = BasicTaskScheduler::createNew();
  693. m_pUsageEnvironment = BasicUsageEnvironment::createNew(*m_pScheduler);
  694. }
  695. videoLIVE555Source::videoLIVE555Source(void * opaque ): basicMediaSource(), /* MediaSink(*m_pUsageEnvironment),*/ basicThread(){
  696. initMembers();
  697. m_bIsParamsSet = false;
  698. m_pOpaque = opaque;
  699. // Default -> only decode frames
  700. m_eWM = MS_MODE_DECODE_FRAMES;
  701. m_nOutWidth = m_nInWidth = m_nOutHeight = m_nInHeight = -1;
  702. initLibAV();
  703. }
  704. videoLIVE555Source::videoLIVE555Source(CSTR URI, void * opaque, MS_WORK_MODE mode): basicMediaSource(),/* MediaSink(*m_pUsageEnvironment),*/ basicThread(){
  705. initMembers();
  706. m_pOpaque = opaque;
  707. m_bIsParamsSet = true;
  708. m_eWM = mode;
  709. m_nOutWidth = m_nInWidth = m_nOutHeight = m_nInHeight = -1;
  710. if(!initLibAV() ) return;
  711. _open(URI);
  712. }
  713. /*
  714. The destructor crashed the application:
  715. - _stop() -> shutdownStream() ran on the caller's thread while the live555 thread was still inside
  716. doEventLoop(): the RTSP client and the task scheduler were deleted under the running loop;
  717. - the scheduler / environment were deleted there and dereferenced again by a second shutdown
  718. (_close() then the destructor, or a shutdown from a live555 callback then the destructor);
  719. - m_pRtspClient was not initialized: a source that was never opened (or failed to open) shut
  720. down a random pointer;
  721. - ~basicThread joins only after this object is destroyed: the thread still ran our members.
  722. Now: stop the loop and join the thread first, then close the stream on this thread, and the
  723. environment / scheduler only here, once.
  724. */
  725. videoLIVE555Source::~videoLIVE555Source(){
  726. _stop();
  727. if (m_pUsageEnvironment != NULL)
  728. {
  729. m_pUsageEnvironment->reclaim(); // deletes it once no live555 object uses it any more
  730. m_pUsageEnvironment = NULL;
  731. };
  732. delete m_pScheduler;
  733. m_pScheduler = NULL;
  734. }
  735. void videoLIVE555Source::m_fThreadProc(void)
  736. {
  737. LOG("Start Thread");
  738. // _eventLoopWatchVariable is reset by _open(): resetting it here lost a _stop() issued
  739. // before the thread got to run (the loop then never ended)
  740. m_tEventLoopThread = pthread_self();
  741. m_bThreadStatus = TH_WORKING;
  742. pthread_setname_np(pthread_self(), "Live555 Source");
  743. // while ( m_bThreadStatus == TH_WORKING ) {
  744. m_pScheduler->doEventLoop(&_eventLoopWatchVariable);
  745. // streamTimerHandler( m_pRtspClient );
  746. // SLEEP(3);
  747. //};
  748. LOG("Rtsp event finished");
  749. // m_pUsageEnvironment->reclaim();
  750. // m_pUsageEnvironment = NULL;
  751. // delete m_pScheduler;
  752. // m_pScheduler = NULL;
  753. LOG("End Thread");
  754. }
  755. Boolean videoLIVE555Source::continuePlaying()
  756. {
  757. return False;
  758. }
  759. void videoLIVE555Source::continueAfterDESCRIBE(RTSPClient * rtspClient, int resultCode, char * resultString)
  760. {
  761. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  762. videoLIVE555Source * ME = (videoLIVE555Source *) MM->getSession();
  763. MLOG("After Describe EVT");
  764. do
  765. {
  766. UsageEnvironment & env = rtspClient->envir(); // alias
  767. StreamClientState & scs = MM->getStreamClientState(); // alias
  768. if (resultCode != 0)
  769. {
  770. MLOG("Failed to get a SDP description: ");
  771. MLOG(resultString);
  772. delete[] resultString;
  773. break;
  774. };
  775. char * const sdpDescription = resultString;
  776. MLOG("Got a SDP description:");
  777. MLOG(sdpDescription);
  778. // Create a media session object from this SDP description:
  779. scs.session = MediaSession::createNew(env, sdpDescription);
  780. delete[] sdpDescription; // because we don't need it anymore
  781. if (scs.session == NULL)
  782. {
  783. MLOG("Failed to create a MediaSession object from the SDP description:");
  784. MLOG(env.getResultMsg());
  785. break;
  786. }
  787. else if (! scs.session->hasSubsessions())
  788. {
  789. MLOG("This session has no media subsessions (i.e., no \"m=\" lines)");
  790. break;
  791. };
  792. ME->m_pMediaSession = scs.session;
  793. // Then, create and set up our data source objects for the session. We do this by iterating over the session's 'subsessions',
  794. // calling "MediaSubsession::initiate()", and then sending a RTSP "SETUP" command, on each one.
  795. // (Each 'subsession' will have its own data source.)
  796. scs.iter = new MediaSubsessionIterator(*scs.session);
  797. ME->setupNextSubsession(rtspClient);
  798. return;
  799. }
  800. while (0);
  801. // An unrecoverable error occurred with this stream.
  802. ME->shutdownStream(rtspClient);
  803. }
  804. void videoLIVE555Source::continueAfterSETUP(RTSPClient * rtspClient, int resultCode, char * resultString)
  805. {
  806. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  807. videoLIVE555Source * ME = (videoLIVE555Source *) MM->getSession();
  808. MLOG("After Setup EVT");
  809. do
  810. {
  811. UsageEnvironment & env = rtspClient->envir(); // alias
  812. StreamClientState & streamClientState = MM->getStreamClientState(); // alias
  813. if (resultCode != 0)
  814. {
  815. MLOG("Failed to set up the subsession:");
  816. MLOG(streamClientState.subsession->mediumName());
  817. MLOG(streamClientState.subsession->codecName());
  818. MLOG(resultString);
  819. break;
  820. };
  821. MLOG("Set up the subsession");
  822. MLOG(streamClientState.subsession->mediumName());
  823. MLOG(streamClientState.subsession->codecName());
  824. if (streamClientState.subsession->rtcpIsMuxed())
  825. {
  826. char tB[128];
  827. sprintf(tB, "client port %d", streamClientState.subsession->clientPortNum());
  828. MLOG(tB);
  829. }
  830. else
  831. {
  832. char tB[128];
  833. sprintf(tB, "client ports %d-%d", streamClientState.subsession->clientPortNum(), streamClientState.subsession->clientPortNum() + 1);
  834. MLOG(tB);
  835. };
  836. const char * sprop = streamClientState.subsession->fmtp_spropparametersets();
  837. const uint8_t * sps = NULL;
  838. unsigned spsSize = 0;
  839. const uint8_t * pps = NULL;
  840. unsigned ppsSize = 0;
  841. if (sprop != NULL)
  842. {
  843. unsigned numSPropRecords;
  844. SPropRecord * sPropRecords = parseSPropParameterSets(sprop, numSPropRecords);
  845. for (unsigned i = 0; i < numSPropRecords; ++i)
  846. {
  847. if (sPropRecords[i].sPropLength == 0)
  848. {
  849. continue; // bad data
  850. }
  851. u_int8_t nal_unit_type = (sPropRecords[i].sPropBytes[0]) & 0x1F;
  852. if (nal_unit_type == 7 /*SPS*/)
  853. {
  854. sps = sPropRecords[i].sPropBytes;
  855. spsSize = sPropRecords[i].sPropLength;
  856. }
  857. else if (nal_unit_type == 8 /*PPS*/)
  858. {
  859. pps = sPropRecords[i].sPropBytes;
  860. ppsSize = sPropRecords[i].sPropLength;
  861. }
  862. }
  863. }
  864. // Having successfully setup the subsession, create a data sink for it, and call "startPlaying()" on it.
  865. // (This will prepare the data sink to receive data; the actual flow of data from the client won't start happening until later,
  866. // after we've sent a RTSP "PLAY" command.)
  867. streamClientState.subsession->sink = DummySink::createNew(ME, env, *streamClientState.subsession, rtspClient->url(), ME->m_nInWidth, ME->m_nInHeight, ME->m_nOutWidth, ME->m_nOutHeight);
  868. // perhaps use your own custom "MediaSink" subclass instead
  869. if (streamClientState.subsession->sink == NULL)
  870. {
  871. MLOG("Failed to create a data sink for the subsession");
  872. MLOG(streamClientState.subsession->mediumName());
  873. MLOG(streamClientState.subsession->codecName());
  874. MLOG(env.getResultMsg());
  875. break;
  876. };
  877. MLOG("Created a data sink for the subsession");
  878. // MLOG( streamClientState.subsession->mediumName() );
  879. // MLOG( streamClientState.subsession->codecName() );
  880. streamClientState.subsession->miscPtr = rtspClient; // a hack to let subsession handler functions get the "RTSPClient" from the subsession
  881. if (sps != NULL)
  882. {
  883. ((DummySink *) streamClientState.subsession->sink)->setSprop(sps, spsSize);
  884. }
  885. if (pps != NULL)
  886. {
  887. ((DummySink *) streamClientState.subsession->sink)->setSprop(pps, ppsSize);
  888. }
  889. streamClientState.subsession->sink->startPlaying(*(streamClientState.subsession->readSource()), subsessionAfterPlaying, streamClientState.subsession);
  890. // Also set a handler to be called if a RTCP "BYE" arrives for this subsession:
  891. if (streamClientState.subsession->rtcpInstance() != NULL)
  892. {
  893. streamClientState.subsession->rtcpInstance()->setByeHandler(subsessionByeHandler, streamClientState.subsession);
  894. }
  895. }
  896. while (0);
  897. delete[] resultString;
  898. // Set up the next subsession, if any:
  899. ME->setupNextSubsession(rtspClient);
  900. MLOG("Done ContAfterSetup");
  901. }
  902. void videoLIVE555Source::continueAfterPLAY(RTSPClient * rtspClient, int resultCode, char * resultString)
  903. {
  904. Boolean success = False;
  905. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  906. videoLIVE555Source * ME = (videoLIVE555Source *) MM->getSession();
  907. MLOG("After Play EVT");
  908. do
  909. {
  910. UsageEnvironment & env = rtspClient->envir(); // alias
  911. StreamClientState & scs = ((CustomRTSPClient *) rtspClient)->getStreamClientState(); // alias
  912. if (resultCode != 0)
  913. {
  914. MLOG("Failed to start playing session: ");
  915. MLOG(resultString);
  916. break;
  917. };
  918. // Set a timer to be handled at the end of the stream's expected duration (if the stream does not already signal its end
  919. // using a RTCP "BYE"). This is optional. If, instead, you want to keep the stream active - e.g., so you can later
  920. // 'seek' back within it and do another RTSP "PLAY" - then you can omit this code.
  921. // (Alternatively, if you don't want to receive the entire stream, you could set this timer for some shorter value.)
  922. if (scs.duration > 0)
  923. {
  924. const unsigned delaySlop = 2; // number of seconds extra to delay, after the stream's expected duration. (This is optional.)
  925. scs.duration += delaySlop;
  926. unsigned uSecsToDelay = (unsigned) (scs.duration * 1000000);
  927. scs.streamTimerTask = env.taskScheduler().scheduleDelayedTask(uSecsToDelay, (TaskFunc *) streamTimerHandler, rtspClient);
  928. }
  929. MLOG("Started playing session");
  930. // if (scs.duration > 0) {
  931. // env << " (for up to " << scs.duration << " seconds)";
  932. // }
  933. success = True;
  934. }
  935. while (0);
  936. delete[] resultString;
  937. if (! success)
  938. {
  939. MLOG("Shutdown!");
  940. // An unrecoverable error occurred with this stream.
  941. ME->shutdownStream(rtspClient);
  942. };
  943. }
  944. // Other event handler functions:
  945. // called when a stream's subsession (e.g., audio or video substream) ends
  946. void videoLIVE555Source::subsessionAfterPlaying(void * clientData)
  947. {
  948. MediaSubsession * subsession = (MediaSubsession *) clientData;
  949. RTSPClient * rtspClient = (RTSPClient *) (subsession->miscPtr);
  950. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  951. videoLIVE555Source * ME = (videoLIVE555Source *) MM->getSession();
  952. // Begin by closing this subsession's stream:
  953. Medium::close(subsession->sink);
  954. subsession->sink = NULL;
  955. // Next, check whether *all* subsessions' streams have now been closed:
  956. MediaSession & session = subsession->parentSession();
  957. MediaSubsessionIterator iter(session);
  958. while ((subsession = iter.next()) != NULL)
  959. {
  960. if (subsession->sink != NULL)
  961. {
  962. return; // this subsession is still active
  963. }
  964. }
  965. // All subsessions' streams have now been closed, so shutdown the client:
  966. ME->shutdownStream(rtspClient);
  967. }
  968. void videoLIVE555Source::sessionAfterPlaying(void * clientData)
  969. {
  970. MediaSession * session = (MediaSession *) clientData;
  971. if (session->hasSubsessions())
  972. {
  973. MediaSubsessionIterator * itr = new MediaSubsessionIterator(*session);
  974. if (itr != NULL)
  975. {
  976. MediaSubsession * subsession = itr->next();
  977. while (subsession != NULL)
  978. {
  979. RTSPClient * rtspClient = (RTSPClient *) subsession->miscPtr;
  980. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  981. videoLIVE555Source * ME = (videoLIVE555Source *) MM->getSession();
  982. //UsageEnvironment & env = rtspClient->envir();
  983. MLOG("sessionAfterPlaying!");
  984. subsession = itr->next();
  985. };
  986. delete itr;
  987. };
  988. };
  989. }
  990. // called when a RTCP "BYE" is received for a subsession
  991. void videoLIVE555Source::subsessionByeHandler(void * clientData)
  992. { //, char const* reason ){
  993. MediaSubsession * subsession = (MediaSubsession *) clientData;
  994. RTSPClient * rtspClient = (RTSPClient *) subsession->miscPtr;
  995. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  996. videoLIVE555Source * ME = (videoLIVE555Source *) MM->getSession();
  997. //UsageEnvironment & env = rtspClient->envir(); // alias
  998. MLOG("Received RTCP \"BYE\" on subsession");
  999. MLOG(subsession->mediumName());
  1000. MLOG(subsession->codecName());
  1001. // Now act as if the subsession had closed:
  1002. subsessionAfterPlaying(subsession);
  1003. }
  1004. void videoLIVE555Source::streamTimerHandler(void * clientData)
  1005. {
  1006. CustomRTSPClient * rtspClient = (CustomRTSPClient *) clientData;
  1007. StreamClientState & scs = rtspClient->getStreamClientState(); // alias
  1008. videoLIVE555Source * ME = (videoLIVE555Source *) rtspClient->getSession();
  1009. scs.streamTimerTask = NULL;
  1010. // Shut down the stream:
  1011. ME->shutdownStream(rtspClient);
  1012. }
  1013. // The main streaming routine (for each "rtsp://" URL):
  1014. void videoLIVE555Source::openURL(UsageEnvironment & env, const char * progName, const char * rtspURL)
  1015. {
  1016. int a = 0;
  1017. if ( env.getErrno() ) a = 1;
  1018. if ( progName ) a = 2;
  1019. if ( rtspURL ) a = 3;
  1020. a = a - 1;
  1021. if ( a ) a = 0;
  1022. LOG("openURL Called!");
  1023. }
  1024. // Used to iterate through each stream's 'subsessions', setting up each one:
  1025. void videoLIVE555Source::setupNextSubsession(RTSPClient * rtspClient)
  1026. {
  1027. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  1028. videoLIVE555Source * ME = (videoLIVE555Source *) MM->getSession();
  1029. MLOG("Next Subsession EVT");
  1030. UsageEnvironment & env = rtspClient->envir(); // alias
  1031. StreamClientState & scs = MM->getStreamClientState(); // alias
  1032. scs.subsession = scs.iter->next();
  1033. if (scs.subsession != NULL)
  1034. {
  1035. if (! scs.subsession->initiate())
  1036. {
  1037. MLOG("Failed to initiate the subsession:");
  1038. MLOG(scs.subsession->mediumName());
  1039. MLOG(scs.subsession->codecName());
  1040. MLOG(env.getResultMsg());
  1041. setupNextSubsession(rtspClient); // give up on this subsession; go to the next one
  1042. }
  1043. else
  1044. {
  1045. MLOG("Initiated the subsession");
  1046. MLOG(scs.subsession->mediumName());
  1047. MLOG(scs.subsession->codecName());
  1048. if (strstr(scs.subsession->mediumName(), "video") != NULL)
  1049. {
  1050. if (scs.subsession->rtcpIsMuxed())
  1051. {
  1052. char tB[64];
  1053. sprintf(tB, "client port %d", scs.subsession->clientPortNum());
  1054. MLOG(tB);
  1055. }
  1056. else
  1057. {
  1058. char tB[64];
  1059. sprintf(tB, "client ports %d-%d", scs.subsession->clientPortNum(), scs.subsession->clientPortNum() + 1);
  1060. MLOG(tB);
  1061. };
  1062. // Continue setting up this subsession, by sending a RTSP "SETUP" command:
  1063. rtspClient->sendSetupCommand(*scs.subsession, continueAfterSETUP, False, REQUEST_STREAMING_OVER_TCP);
  1064. }
  1065. else
  1066. {
  1067. // Skip all Not Video subsession go to the next one
  1068. setupNextSubsession(rtspClient);
  1069. };
  1070. };
  1071. return;
  1072. };
  1073. // We've finished setting up all of the subsessions. Now, send a RTSP "PLAY" command to start the streaming:
  1074. if (scs.session->absStartTime() != NULL)
  1075. {
  1076. // Special case: The stream is indexed by 'absolute' time, so send an appropriate "PLAY" command:
  1077. rtspClient->sendPlayCommand(*scs.session, continueAfterPLAY, scs.session->absStartTime(), scs.session->absEndTime());
  1078. }
  1079. else
  1080. {
  1081. scs.duration = scs.session->playEndTime() - scs.session->playStartTime();
  1082. rtspClient->sendPlayCommand(*scs.session, continueAfterPLAY);
  1083. };
  1084. }
  1085. // Used to shut down and close a stream (including its "RTSPClient" object).
  1086. // Runs either on the live555 thread (from a live555 callback) or, once that thread was joined,
  1087. // on the thread that stops the source - never on both at once. It does not delete the
  1088. // scheduler / environment (the event loop may still be using them): the destructor does that.
  1089. void videoLIVE555Source::shutdownStream(RTSPClient * rtspClient, int exitCode)
  1090. {
  1091. if ( exitCode ) exitCode = exitCode;
  1092. if (rtspClient == NULL || rtspClient != m_pRtspClient)
  1093. {
  1094. _eventLoopWatchVariable = 1;
  1095. return; // already closed (a second shutdown closed a deleted client before)
  1096. };
  1097. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  1098. #ifdef DEBUG
  1099. LOG("Shutdown EVT");
  1100. #endif
  1101. StreamClientState & streamClientState = MM->getStreamClientState(); // alias
  1102. // First, check whether any subsessions have still to be closed (as live555 testRTSPClient):
  1103. // the sinks were never closed before - they leaked and kept reading a deleted source
  1104. if (streamClientState.session != NULL)
  1105. {
  1106. Boolean someSubsessionsWereActive = False;
  1107. MediaSubsessionIterator iter(*streamClientState.session);
  1108. MediaSubsession * subsession;
  1109. while ((subsession = iter.next()) != NULL)
  1110. {
  1111. if (subsession->sink != NULL)
  1112. {
  1113. Medium::close(subsession->sink);
  1114. subsession->sink = NULL;
  1115. if (subsession->rtcpInstance() != NULL)
  1116. {
  1117. subsession->rtcpInstance()->setByeHandler(NULL, NULL); // in case the server sends a RTCP "BYE" while handling "TEARDOWN"
  1118. };
  1119. someSubsessionsWereActive = True;
  1120. };
  1121. };
  1122. if (someSubsessionsWereActive)
  1123. {
  1124. // Send a RTSP "TEARDOWN" command, to tell the server to shutdown the stream.
  1125. // Don't bother handling the response to the "TEARDOWN".
  1126. LOG("sendTearDown");
  1127. rtspClient->sendTeardownCommand(*streamClientState.session, NULL);
  1128. };
  1129. };
  1130. LOG("Close Client");
  1131. m_pRtspClient = NULL;
  1132. m_pMediaSession = NULL; // closed with the client (StreamClientState destructor)
  1133. Medium::close(rtspClient);
  1134. _eventLoopWatchVariable = 1; // ends doEventLoop()
  1135. m_eMediaStatus = MS_CLOSED;
  1136. LOG("All Done!");
  1137. }
  1138. // https://chowdera.com/2021/01/20210102084512591N.html
  1139. // https://github.com/drriguz/Kamera
  1140. bool videoLIVE555Source::_open(CSTR URI, bool ShowDeviceMenu, float framerate, int inputPin, int width, int height, int s_width, int s_height)
  1141. {
  1142. if ( ShowDeviceMenu ) ShowDeviceMenu = false;
  1143. if ( framerate ) framerate = framerate;
  1144. if ( inputPin ) inputPin = inputPin;
  1145. if (URI == NULL)
  1146. {
  1147. LOG_ERROR("Trying to open MediaSource without MRL!");
  1148. return false;
  1149. };
  1150. // if( !m_bIsParamsSet ) {
  1151. // LOG_ERROR("Trying to open MediaSource without all needded parameters!");
  1152. // return false;
  1153. // };
  1154. m_nInHeight = height;
  1155. m_nInWidth = width;
  1156. m_nOutHeight = s_height;
  1157. m_nOutWidth = s_width;
  1158. m_pRtspClient = CustomRTSPClient::createNew(this, *m_pUsageEnvironment, URI, RTSP_CLIENT_VERBOSITY_LEVEL, "ARGUS CLIENT");
  1159. if (m_pRtspClient == NULL)
  1160. {
  1161. char tB[256];
  1162. sprintf(tB, "Failed to create a RTSP client for URL \"%s\":%s", URI, m_pUsageEnvironment->getResultMsg());
  1163. LOG_ERROR(tB);
  1164. return false;
  1165. };
  1166. _eventLoopWatchVariable = 0;
  1167. m_pRtspClient->sendDescribeCommand(continueAfterDESCRIBE);
  1168. if (! init())
  1169. {
  1170. LOG_ERROR("Can not start the live555 thread!");
  1171. shutdownStream(m_pRtspClient); // no event loop is running: safe on this thread
  1172. return false;
  1173. };
  1174. return true;
  1175. }
  1176. void videoLIVE555Source::consumeFrame(cv::Mat * frm)
  1177. {
  1178. if (m_pMediaDestination == NULL)
  1179. {
  1180. return;
  1181. }
  1182. if (! m_pMediaDestination->pushFrame(*frm, m_pOpaque))
  1183. {
  1184. m_pMediaDestination = NULL;
  1185. LOG_ERROR("Error Consume Frame by Media Destination!");
  1186. };
  1187. }
  1188. bool videoLIVE555Source::_close(void)
  1189. {
  1190. LOG("CLOSE!");
  1191. return _stop();
  1192. }
  1193. bool videoLIVE555Source::_stop(void)
  1194. {
  1195. LOG("STOP!");
  1196. // live555 is single threaded: never touch its objects while its event loop runs on the other
  1197. // thread. Stop the loop and wait for the thread, then close what is left here.
  1198. _eventLoopWatchVariable = 1;
  1199. if (isEventLoopThread())
  1200. {
  1201. return true; // called from a live555 callback: shutdown after the loop is left (destructor / _stop)
  1202. };
  1203. waitThreadEnd(true);
  1204. shutdownStream(m_pRtspClient); // no-op when a live555 callback closed it already
  1205. return true;
  1206. }
  1207. bool videoLIVE555Source::isEventLoopThread(void)
  1208. {
  1209. // m_bThreadStatus: getStatus() of this class is the media status
  1210. return m_bThreadStatus == TH_WORKING && pthread_equal(pthread_self(), m_tEventLoopThread);
  1211. }
  1212. bool videoLIVE555Source::isFinished(void)
  1213. {
  1214. return (m_eMediaStatus == MS_CLOSED);
  1215. }
  1216. MediaStateStatus videoLIVE555Source::getStatus(void)
  1217. {
  1218. return m_eMediaStatus;
  1219. }
  1220. bool videoLIVE555Source::setSize(int Width, int Height)
  1221. {
  1222. if( Width || Height ) return false;
  1223. return false;
  1224. }
  1225. bool videoLIVE555Source::setProportionalByWidth(int Width)
  1226. {
  1227. if( !Width ) return false;
  1228. return false;
  1229. }
  1230. bool videoLIVE555Source::setProportionalByHeight(int Height)
  1231. {
  1232. if( !Height ) return false;
  1233. return false;
  1234. }
  1235. bool videoLIVE555Source::setFPS(int A )
  1236. {
  1237. if( !A ) return false;
  1238. return false;
  1239. }
  1240. bool videoLIVE555Source::setName(CSTR Name)
  1241. {
  1242. if( !Name ) return false;
  1243. return false;
  1244. }
  1245. bool videoLIVE555Source::setFrameAspectRatio(FrameAspectRatio AspectRatio)
  1246. {
  1247. if( AspectRatio ) AspectRatio = AspectRatio;
  1248. return false;
  1249. }
  1250. #undef MLOG
  1251. #undef LOG
  1252. #undef LOG_ERROR
  1253. #undef FF_DISABLE_DEPRECATION_WARNINGS
  1254. #endif //!LRF_PROXY_ONLY