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.

1384 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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
1 hour 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. LOG_ERROR("Error Send Packet to Decoder!");
  474. };
  475. while ( ret >= 0 ) {
  476. ret = avcodec_receive_frame( m_pCodecContext, m_pFrame );
  477. if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
  478. // EAGAIN: Need more input packets
  479. // EOF: Decoder flushed
  480. break;
  481. } else if (ret < 0) {
  482. // Handle decoding error
  483. break;
  484. };
  485. // LOG( "Picture decoded" );
  486. got_picture = 1;
  487. sws_scale( m_pSwsContext, m_pFrame->data, m_pFrame->linesize, 0, m_pCodecContext->height, m_pRGBFrame->data, m_pRGBFrame->linesize);
  488. memcpy( m_pRGB->data, m_pRGBFrame->data[0], m_pRGBFrame->linesize[0] * m_nOutHeight );
  489. m_pSession->consumeFrame( m_pRGB );
  490. m_iFrameIndex++;
  491. };
  492. if ( ret == AVERROR_EOF ) {
  493. //End
  494. };
  495. };
  496. av_packet_unref(&m_sAvPkt);
  497. if ((m_pSession->getWM() & MS_MODE_STREAM_PROXY) && m_pH264 != NULL)
  498. {
  499. if (m_pSession->getWM() & MS_MODE_OVERLAYED_LOOPS)
  500. {
  501. // Sega - Mega - Drive
  502. };
  503. // write packet
  504. #if (0)
  505. // We've just received a frame of data. (Optionally) print out information about it:
  506. #ifdef DEBUG_PRINT_EACH_RECEIVED_FRAME
  507. if (fStreamId != NULL)
  508. {
  509. envir() << "Stream \"" << fStreamId << "\"; ";
  510. }
  511. envir() << fSubsession.mediumName() << "/" << fSubsession.codecName() << ":\tReceived " << frameSize << " bytes";
  512. if (numTruncatedBytes > 0)
  513. {
  514. envir() << " (with " << numTruncatedBytes << " bytes truncated)";
  515. }
  516. char uSecsStr[6 + 1]; // used to output the 'microseconds' part of the presentation time
  517. sprintf(uSecsStr, "%06u", (unsigned) presentationTime.tv_usec);
  518. envir() << ".\tPresentation time: " << (int) presentationTime.tv_sec << "." << uSecsStr;
  519. if (fSubsession.rtpSource() != NULL && ! fSubsession.rtpSource()->hasBeenSynchronizedUsingRTCP())
  520. {
  521. envir() << "!"; // mark the debugging output to indicate that this presentation time is not RTCP-synchronized
  522. }
  523. #ifdef DEBUG_PRINT_NPT
  524. envir() << "\tNPT: " << fSubsession.getNormalPlayTime(presentationTime);
  525. #endif
  526. envir() << "\n";
  527. #endif
  528. #else
  529. //*
  530. // printf("__FUNCTION__ = %s\n", __FUNCTION__ );
  531. // if(0 == strncmp(fSubsession.codecName(), "H264", 16) ){
  532. unsigned char nalu_header[4] = {0, 0, 0, 1};
  533. unsigned char extraData[256];
  534. unsigned int num = 0;
  535. SPropRecord * pSPropRecord;
  536. pSPropRecord = parseSPropParameterSets(m_sSubSession.fmtp_spropparametersets(), num);
  537. unsigned int extraLen;
  538. extraLen = 0;
  539. // p_record[0] is sps
  540. // p+record[1] is pps
  541. for (unsigned int i = 0; i < num; i++)
  542. {
  543. memcpy(&extraData[extraLen], &nalu_header[0], 4);
  544. extraLen += 4;
  545. memcpy(&extraData[extraLen], pSPropRecord[i].sPropBytes, pSPropRecord[i].sPropLength);
  546. extraLen += pSPropRecord[i].sPropLength;
  547. };
  548. memcpy(&extraData[extraLen], &nalu_header[0], 4);
  549. extraLen += 4;
  550. delete[] pSPropRecord;
  551. memcpy(m_pH264, &extraData[0], extraLen);
  552. memcpy(m_pH264 + extraLen, m_pReceiveBuffer, frameSize);
  553. int totalSize;
  554. totalSize = extraLen + frameSize;
  555. if (m_pOutFile[m_nCurrentOutFile] == NULL)
  556. {
  557. // m_pOutFile[m_nCurrentOutFile] = fopen("saved.h264", "wb" );
  558. LOG("Opening");
  559. // m_pOutFile[m_nCurrentOutFile] = popen("ffmpeg -y -hide_banner -i - -vcodec copy -movflags faststart -an ./ttt123.mp4", "w" );
  560. m_pOutFile[m_nCurrentOutFile] = popen("ffmpeg -y -hide_banner -i - -vcodec copy -reserve_index_space 50k -an ./ttt123.mkv", "w");
  561. if (m_pOutFile[m_nCurrentOutFile] == NULL)
  562. {
  563. LOG("Error !!");
  564. };
  565. };
  566. if (m_pOutFile[m_nCurrentOutFile] != NULL)
  567. {
  568. fwrite(m_pH264, 1, totalSize, m_pOutFile[m_nCurrentOutFile]);
  569. fflush(m_pOutFile[m_nCurrentOutFile]);
  570. // fclose( fp );
  571. };
  572. // qtOut->addData( m_pH264, totalSize, presentationTime );
  573. // printf("\tsaved %d bytes\n", totalSize );
  574. // }/*if 0 == strncmp(fSubsession.codecName(), "H264", 16)*/
  575. // if( got_picture ) {
  576. if (m_pOutFormatCtx != NULL)
  577. {
  578. m_sAvPkt.duration = durationInMicroseconds;
  579. if (got_picture)
  580. {
  581. m_sAvPkt.flags |= AV_PKT_FLAG_KEY;
  582. }
  583. m_sAvPkt.stream_index = m_pOutStream->index;
  584. m_sAvPkt.size = totalSize;
  585. m_sAvPkt.data = m_pH264;
  586. // m_sAvPkt.size = frameSize;
  587. // m_sAvPkt.data = m_pReceiveBuffer;
  588. // av_packet_rescale_ts( &avpkt, m_pOutCodec->time_base, time_base );
  589. int r = av_write_frame(m_pOutFormatCtx, &m_sAvPkt);
  590. if (r < 0)
  591. {
  592. char tB[256];
  593. av_strerror(r, tB, 256);
  594. LOG_ERROR("Trouble with Video Output!");
  595. LOG_ERROR(tB);
  596. };
  597. }
  598. //}
  599. #endif
  600. };
  601. #ifdef DEBUG
  602. }
  603. else
  604. {
  605. LOG("Codec Not Handled!");
  606. LOG(m_sSubSession.codecName());
  607. #endif
  608. };
  609. // Then continue, to request the next frame of data:
  610. continuePlaying();
  611. }
  612. Boolean DummySink::continuePlaying()
  613. {
  614. if (fSource == NULL)
  615. {
  616. return False; // sanity check (should not happen)
  617. }
  618. // Request the next frame of data from our input source. "afterGettingFrame()" will get called later, when it arrives:
  619. fSource->getNextFrame(m_pReceiveBuffer, DUMMY_SINK_RECEIVE_BUFFER_SIZE, afterGettingFrame, this, onSourceClosure, this);
  620. return True;
  621. }
  622. void DummySink::setSprop(const u_int8_t * prop, unsigned size)
  623. {
  624. uint8_t * buf;
  625. uint8_t * buf_start;
  626. LOG("setSprop");
  627. buf = (uint8_t *) malloc(1004);
  628. buf_start = buf + 4;
  629. m_sAvPkt.data = buf;
  630. m_sAvPkt.data[0] = 0;
  631. m_sAvPkt.data[1] = 0;
  632. m_sAvPkt.data[2] = 0;
  633. m_sAvPkt.data[3] = 1;
  634. if (size > 1000)
  635. {
  636. LOG_ERROR("Data Chunk too large!! Increase Mem!");
  637. free(buf);
  638. m_sAvPkt.data = NULL;
  639. m_sAvPkt.size = 0;
  640. return;
  641. };
  642. memcpy(buf_start, prop, size);
  643. m_sAvPkt.size = size + 4;
  644. if ((m_pSession->getWM() & MS_MODE_DECODE_FRAMES) && canDecode()){
  645. int ret = avcodec_send_packet( m_pCodecContext, &m_sAvPkt );
  646. if( ret < 0 ){
  647. LOG_ERROR("Error Send Packet to Decoder!");
  648. };
  649. while ( ret >= 0 ) {
  650. ret = avcodec_receive_frame( m_pCodecContext, m_pFrame );
  651. if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
  652. LOG_ERROR("EAGAIN/EOF while decoding frame");
  653. break;
  654. } else if (ret < 0) {
  655. LOG_ERROR("Error while decoding frame");
  656. break;
  657. };
  658. };
  659. };
  660. LOG("after setSprop");
  661. free(buf);
  662. m_sAvPkt.data = NULL;
  663. m_sAvPkt.size = 0;
  664. }
  665. #undef LOG_ERROR
  666. #undef MLOG
  667. #undef LOG
  668. #define LOG(X) m_pLog->Log("LIVE555_SRC", this, X)
  669. #define MLOG(X) ME->m_pLog->Log("LIVE555_SRC", ME, X)
  670. #ifdef DEBUG
  671. #define LOG_ERROR(X) \
  672. { \
  673. char _tBfrErrMSG2w34[1024]; \
  674. sprintf(_tBfrErrMSG2w34, "In file %s[%d] in func:%s %s", __FILE__, __LINE__, __func__, X); \
  675. m_pLog->Log("LIVE555_SRC", this, _LOG_ERROR, _tBfrErrMSG2w34); \
  676. }
  677. #else
  678. #define LOG_ERROR(X) m_pLog->Log("LIVE555_SRC", this, _LOG_ERROR, X);
  679. #endif
  680. void videoLIVE555Source::initMembers(void)
  681. {
  682. m_pLog = basicLogCollection::getInstance();
  683. m_pRtspClient = NULL;
  684. m_pSink = NULL;
  685. m_pMediaSession = NULL;
  686. fSubsession = NULL;
  687. fStreamId = NULL;
  688. fReceiveBuffer = NULL;
  689. _eventLoopWatchVariable = 0;
  690. m_tEventLoopThread = pthread_t();
  691. m_pScheduler = BasicTaskScheduler::createNew();
  692. m_pUsageEnvironment = BasicUsageEnvironment::createNew(*m_pScheduler);
  693. }
  694. videoLIVE555Source::videoLIVE555Source(void * opaque ): basicMediaSource(), /* MediaSink(*m_pUsageEnvironment),*/ basicThread(){
  695. initMembers();
  696. m_bIsParamsSet = false;
  697. m_pOpaque = opaque;
  698. // Default -> only decode frames
  699. m_eWM = MS_MODE_DECODE_FRAMES;
  700. m_nOutWidth = m_nInWidth = m_nOutHeight = m_nInHeight = -1;
  701. initLibAV();
  702. }
  703. videoLIVE555Source::videoLIVE555Source(CSTR URI, void * opaque, MS_WORK_MODE mode): basicMediaSource(),/* MediaSink(*m_pUsageEnvironment),*/ basicThread(){
  704. initMembers();
  705. m_pOpaque = opaque;
  706. m_bIsParamsSet = true;
  707. m_eWM = mode;
  708. m_nOutWidth = m_nInWidth = m_nOutHeight = m_nInHeight = -1;
  709. if(!initLibAV() ) return;
  710. _open(URI);
  711. }
  712. /*
  713. The destructor crashed the application:
  714. - _stop() -> shutdownStream() ran on the caller's thread while the live555 thread was still inside
  715. doEventLoop(): the RTSP client and the task scheduler were deleted under the running loop;
  716. - the scheduler / environment were deleted there and dereferenced again by a second shutdown
  717. (_close() then the destructor, or a shutdown from a live555 callback then the destructor);
  718. - m_pRtspClient was not initialized: a source that was never opened (or failed to open) shut
  719. down a random pointer;
  720. - ~basicThread joins only after this object is destroyed: the thread still ran our members.
  721. Now: stop the loop and join the thread first, then close the stream on this thread, and the
  722. environment / scheduler only here, once.
  723. */
  724. videoLIVE555Source::~videoLIVE555Source(){
  725. _stop();
  726. if (m_pUsageEnvironment != NULL)
  727. {
  728. m_pUsageEnvironment->reclaim(); // deletes it once no live555 object uses it any more
  729. m_pUsageEnvironment = NULL;
  730. };
  731. delete m_pScheduler;
  732. m_pScheduler = NULL;
  733. }
  734. void videoLIVE555Source::m_fThreadProc(void)
  735. {
  736. LOG("Start Thread");
  737. // _eventLoopWatchVariable is reset by _open(): resetting it here lost a _stop() issued
  738. // before the thread got to run (the loop then never ended)
  739. m_tEventLoopThread = pthread_self();
  740. m_bThreadStatus = TH_WORKING;
  741. pthread_setname_np(pthread_self(), "Live555 Source");
  742. // while ( m_bThreadStatus == TH_WORKING ) {
  743. m_pScheduler->doEventLoop(&_eventLoopWatchVariable);
  744. // streamTimerHandler( m_pRtspClient );
  745. // SLEEP(3);
  746. //};
  747. LOG("Rtsp event finished");
  748. // m_pUsageEnvironment->reclaim();
  749. // m_pUsageEnvironment = NULL;
  750. // delete m_pScheduler;
  751. // m_pScheduler = NULL;
  752. LOG("End Thread");
  753. }
  754. Boolean videoLIVE555Source::continuePlaying()
  755. {
  756. return False;
  757. }
  758. void videoLIVE555Source::continueAfterDESCRIBE(RTSPClient * rtspClient, int resultCode, char * resultString)
  759. {
  760. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  761. videoLIVE555Source * ME = (videoLIVE555Source *) MM->getSession();
  762. MLOG("After Describe EVT");
  763. do
  764. {
  765. UsageEnvironment & env = rtspClient->envir(); // alias
  766. StreamClientState & scs = MM->getStreamClientState(); // alias
  767. if (resultCode != 0)
  768. {
  769. MLOG("Failed to get a SDP description: ");
  770. MLOG(resultString);
  771. delete[] resultString;
  772. break;
  773. };
  774. char * const sdpDescription = resultString;
  775. MLOG("Got a SDP description:");
  776. MLOG(sdpDescription);
  777. // Create a media session object from this SDP description:
  778. scs.session = MediaSession::createNew(env, sdpDescription);
  779. delete[] sdpDescription; // because we don't need it anymore
  780. if (scs.session == NULL)
  781. {
  782. MLOG("Failed to create a MediaSession object from the SDP description:");
  783. MLOG(env.getResultMsg());
  784. break;
  785. }
  786. else if (! scs.session->hasSubsessions())
  787. {
  788. MLOG("This session has no media subsessions (i.e., no \"m=\" lines)");
  789. break;
  790. };
  791. ME->m_pMediaSession = scs.session;
  792. // Then, create and set up our data source objects for the session. We do this by iterating over the session's 'subsessions',
  793. // calling "MediaSubsession::initiate()", and then sending a RTSP "SETUP" command, on each one.
  794. // (Each 'subsession' will have its own data source.)
  795. scs.iter = new MediaSubsessionIterator(*scs.session);
  796. ME->setupNextSubsession(rtspClient);
  797. return;
  798. }
  799. while (0);
  800. // An unrecoverable error occurred with this stream.
  801. ME->shutdownStream(rtspClient);
  802. }
  803. void videoLIVE555Source::continueAfterSETUP(RTSPClient * rtspClient, int resultCode, char * resultString)
  804. {
  805. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  806. videoLIVE555Source * ME = (videoLIVE555Source *) MM->getSession();
  807. MLOG("After Setup EVT");
  808. do
  809. {
  810. UsageEnvironment & env = rtspClient->envir(); // alias
  811. StreamClientState & streamClientState = MM->getStreamClientState(); // alias
  812. if (resultCode != 0)
  813. {
  814. MLOG("Failed to set up the subsession:");
  815. MLOG(streamClientState.subsession->mediumName());
  816. MLOG(streamClientState.subsession->codecName());
  817. MLOG(resultString);
  818. break;
  819. };
  820. MLOG("Set up the subsession");
  821. MLOG(streamClientState.subsession->mediumName());
  822. MLOG(streamClientState.subsession->codecName());
  823. if (streamClientState.subsession->rtcpIsMuxed())
  824. {
  825. char tB[128];
  826. sprintf(tB, "client port %d", streamClientState.subsession->clientPortNum());
  827. MLOG(tB);
  828. }
  829. else
  830. {
  831. char tB[128];
  832. sprintf(tB, "client ports %d-%d", streamClientState.subsession->clientPortNum(), streamClientState.subsession->clientPortNum() + 1);
  833. MLOG(tB);
  834. };
  835. const char * sprop = streamClientState.subsession->fmtp_spropparametersets();
  836. const uint8_t * sps = NULL;
  837. unsigned spsSize = 0;
  838. const uint8_t * pps = NULL;
  839. unsigned ppsSize = 0;
  840. if (sprop != NULL)
  841. {
  842. unsigned numSPropRecords;
  843. SPropRecord * sPropRecords = parseSPropParameterSets(sprop, numSPropRecords);
  844. for (unsigned i = 0; i < numSPropRecords; ++i)
  845. {
  846. if (sPropRecords[i].sPropLength == 0)
  847. {
  848. continue; // bad data
  849. }
  850. u_int8_t nal_unit_type = (sPropRecords[i].sPropBytes[0]) & 0x1F;
  851. if (nal_unit_type == 7 /*SPS*/)
  852. {
  853. sps = sPropRecords[i].sPropBytes;
  854. spsSize = sPropRecords[i].sPropLength;
  855. }
  856. else if (nal_unit_type == 8 /*PPS*/)
  857. {
  858. pps = sPropRecords[i].sPropBytes;
  859. ppsSize = sPropRecords[i].sPropLength;
  860. }
  861. }
  862. }
  863. // Having successfully setup the subsession, create a data sink for it, and call "startPlaying()" on it.
  864. // (This will prepare the data sink to receive data; the actual flow of data from the client won't start happening until later,
  865. // after we've sent a RTSP "PLAY" command.)
  866. streamClientState.subsession->sink = DummySink::createNew(ME, env, *streamClientState.subsession, rtspClient->url(), ME->m_nInWidth, ME->m_nInHeight, ME->m_nOutWidth, ME->m_nOutHeight);
  867. // perhaps use your own custom "MediaSink" subclass instead
  868. if (streamClientState.subsession->sink == NULL)
  869. {
  870. MLOG("Failed to create a data sink for the subsession");
  871. MLOG(streamClientState.subsession->mediumName());
  872. MLOG(streamClientState.subsession->codecName());
  873. MLOG(env.getResultMsg());
  874. break;
  875. };
  876. MLOG("Created a data sink for the subsession");
  877. // MLOG( streamClientState.subsession->mediumName() );
  878. // MLOG( streamClientState.subsession->codecName() );
  879. streamClientState.subsession->miscPtr = rtspClient; // a hack to let subsession handler functions get the "RTSPClient" from the subsession
  880. if (sps != NULL)
  881. {
  882. ((DummySink *) streamClientState.subsession->sink)->setSprop(sps, spsSize);
  883. }
  884. if (pps != NULL)
  885. {
  886. ((DummySink *) streamClientState.subsession->sink)->setSprop(pps, ppsSize);
  887. }
  888. streamClientState.subsession->sink->startPlaying(*(streamClientState.subsession->readSource()), subsessionAfterPlaying, streamClientState.subsession);
  889. // Also set a handler to be called if a RTCP "BYE" arrives for this subsession:
  890. if (streamClientState.subsession->rtcpInstance() != NULL)
  891. {
  892. streamClientState.subsession->rtcpInstance()->setByeHandler(subsessionByeHandler, streamClientState.subsession);
  893. }
  894. }
  895. while (0);
  896. delete[] resultString;
  897. // Set up the next subsession, if any:
  898. ME->setupNextSubsession(rtspClient);
  899. MLOG("Done ContAfterSetup");
  900. }
  901. void videoLIVE555Source::continueAfterPLAY(RTSPClient * rtspClient, int resultCode, char * resultString)
  902. {
  903. Boolean success = False;
  904. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  905. videoLIVE555Source * ME = (videoLIVE555Source *) MM->getSession();
  906. MLOG("After Play EVT");
  907. do
  908. {
  909. UsageEnvironment & env = rtspClient->envir(); // alias
  910. StreamClientState & scs = ((CustomRTSPClient *) rtspClient)->getStreamClientState(); // alias
  911. if (resultCode != 0)
  912. {
  913. MLOG("Failed to start playing session: ");
  914. MLOG(resultString);
  915. break;
  916. };
  917. // Set a timer to be handled at the end of the stream's expected duration (if the stream does not already signal its end
  918. // using a RTCP "BYE"). This is optional. If, instead, you want to keep the stream active - e.g., so you can later
  919. // 'seek' back within it and do another RTSP "PLAY" - then you can omit this code.
  920. // (Alternatively, if you don't want to receive the entire stream, you could set this timer for some shorter value.)
  921. if (scs.duration > 0)
  922. {
  923. const unsigned delaySlop = 2; // number of seconds extra to delay, after the stream's expected duration. (This is optional.)
  924. scs.duration += delaySlop;
  925. unsigned uSecsToDelay = (unsigned) (scs.duration * 1000000);
  926. scs.streamTimerTask = env.taskScheduler().scheduleDelayedTask(uSecsToDelay, (TaskFunc *) streamTimerHandler, rtspClient);
  927. }
  928. MLOG("Started playing session");
  929. // if (scs.duration > 0) {
  930. // env << " (for up to " << scs.duration << " seconds)";
  931. // }
  932. success = True;
  933. }
  934. while (0);
  935. delete[] resultString;
  936. if (! success)
  937. {
  938. MLOG("Shutdown!");
  939. // An unrecoverable error occurred with this stream.
  940. ME->shutdownStream(rtspClient);
  941. };
  942. }
  943. // Other event handler functions:
  944. // called when a stream's subsession (e.g., audio or video substream) ends
  945. void videoLIVE555Source::subsessionAfterPlaying(void * clientData)
  946. {
  947. MediaSubsession * subsession = (MediaSubsession *) clientData;
  948. RTSPClient * rtspClient = (RTSPClient *) (subsession->miscPtr);
  949. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  950. videoLIVE555Source * ME = (videoLIVE555Source *) MM->getSession();
  951. // Begin by closing this subsession's stream:
  952. Medium::close(subsession->sink);
  953. subsession->sink = NULL;
  954. // Next, check whether *all* subsessions' streams have now been closed:
  955. MediaSession & session = subsession->parentSession();
  956. MediaSubsessionIterator iter(session);
  957. while ((subsession = iter.next()) != NULL)
  958. {
  959. if (subsession->sink != NULL)
  960. {
  961. return; // this subsession is still active
  962. }
  963. }
  964. // All subsessions' streams have now been closed, so shutdown the client:
  965. ME->shutdownStream(rtspClient);
  966. }
  967. void videoLIVE555Source::sessionAfterPlaying(void * clientData)
  968. {
  969. MediaSession * session = (MediaSession *) clientData;
  970. if (session->hasSubsessions())
  971. {
  972. MediaSubsessionIterator * itr = new MediaSubsessionIterator(*session);
  973. if (itr != NULL)
  974. {
  975. MediaSubsession * subsession = itr->next();
  976. while (subsession != NULL)
  977. {
  978. RTSPClient * rtspClient = (RTSPClient *) subsession->miscPtr;
  979. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  980. videoLIVE555Source * ME = (videoLIVE555Source *) MM->getSession();
  981. //UsageEnvironment & env = rtspClient->envir();
  982. MLOG("sessionAfterPlaying!");
  983. subsession = itr->next();
  984. };
  985. delete itr;
  986. };
  987. };
  988. }
  989. // called when a RTCP "BYE" is received for a subsession
  990. void videoLIVE555Source::subsessionByeHandler(void * clientData)
  991. { //, char const* reason ){
  992. MediaSubsession * subsession = (MediaSubsession *) clientData;
  993. RTSPClient * rtspClient = (RTSPClient *) subsession->miscPtr;
  994. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  995. videoLIVE555Source * ME = (videoLIVE555Source *) MM->getSession();
  996. //UsageEnvironment & env = rtspClient->envir(); // alias
  997. MLOG("Received RTCP \"BYE\" on subsession");
  998. MLOG(subsession->mediumName());
  999. MLOG(subsession->codecName());
  1000. // Now act as if the subsession had closed:
  1001. subsessionAfterPlaying(subsession);
  1002. }
  1003. void videoLIVE555Source::streamTimerHandler(void * clientData)
  1004. {
  1005. CustomRTSPClient * rtspClient = (CustomRTSPClient *) clientData;
  1006. StreamClientState & scs = rtspClient->getStreamClientState(); // alias
  1007. videoLIVE555Source * ME = (videoLIVE555Source *) rtspClient->getSession();
  1008. scs.streamTimerTask = NULL;
  1009. // Shut down the stream:
  1010. ME->shutdownStream(rtspClient);
  1011. }
  1012. // The main streaming routine (for each "rtsp://" URL):
  1013. void videoLIVE555Source::openURL(UsageEnvironment & env, const char * progName, const char * rtspURL)
  1014. {
  1015. int a = 0;
  1016. if ( env.getErrno() ) a = 1;
  1017. if ( progName ) a = 2;
  1018. if ( rtspURL ) a = 3;
  1019. a = a - 1;
  1020. if ( a ) a = 0;
  1021. LOG("openURL Called!");
  1022. }
  1023. // Used to iterate through each stream's 'subsessions', setting up each one:
  1024. void videoLIVE555Source::setupNextSubsession(RTSPClient * rtspClient)
  1025. {
  1026. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  1027. videoLIVE555Source * ME = (videoLIVE555Source *) MM->getSession();
  1028. MLOG("Next Subsession EVT");
  1029. UsageEnvironment & env = rtspClient->envir(); // alias
  1030. StreamClientState & scs = MM->getStreamClientState(); // alias
  1031. scs.subsession = scs.iter->next();
  1032. if (scs.subsession != NULL)
  1033. {
  1034. if (! scs.subsession->initiate())
  1035. {
  1036. MLOG("Failed to initiate the subsession:");
  1037. MLOG(scs.subsession->mediumName());
  1038. MLOG(scs.subsession->codecName());
  1039. MLOG(env.getResultMsg());
  1040. setupNextSubsession(rtspClient); // give up on this subsession; go to the next one
  1041. }
  1042. else
  1043. {
  1044. MLOG("Initiated the subsession");
  1045. MLOG(scs.subsession->mediumName());
  1046. MLOG(scs.subsession->codecName());
  1047. if (strstr(scs.subsession->mediumName(), "video") != NULL)
  1048. {
  1049. if (scs.subsession->rtcpIsMuxed())
  1050. {
  1051. char tB[64];
  1052. sprintf(tB, "client port %d", scs.subsession->clientPortNum());
  1053. MLOG(tB);
  1054. }
  1055. else
  1056. {
  1057. char tB[64];
  1058. sprintf(tB, "client ports %d-%d", scs.subsession->clientPortNum(), scs.subsession->clientPortNum() + 1);
  1059. MLOG(tB);
  1060. };
  1061. // Continue setting up this subsession, by sending a RTSP "SETUP" command:
  1062. rtspClient->sendSetupCommand(*scs.subsession, continueAfterSETUP, False, REQUEST_STREAMING_OVER_TCP);
  1063. }
  1064. else
  1065. {
  1066. // Skip all Not Video subsession go to the next one
  1067. setupNextSubsession(rtspClient);
  1068. };
  1069. };
  1070. return;
  1071. };
  1072. // We've finished setting up all of the subsessions. Now, send a RTSP "PLAY" command to start the streaming:
  1073. if (scs.session->absStartTime() != NULL)
  1074. {
  1075. // Special case: The stream is indexed by 'absolute' time, so send an appropriate "PLAY" command:
  1076. rtspClient->sendPlayCommand(*scs.session, continueAfterPLAY, scs.session->absStartTime(), scs.session->absEndTime());
  1077. }
  1078. else
  1079. {
  1080. scs.duration = scs.session->playEndTime() - scs.session->playStartTime();
  1081. rtspClient->sendPlayCommand(*scs.session, continueAfterPLAY);
  1082. };
  1083. }
  1084. // Used to shut down and close a stream (including its "RTSPClient" object).
  1085. // Runs either on the live555 thread (from a live555 callback) or, once that thread was joined,
  1086. // on the thread that stops the source - never on both at once. It does not delete the
  1087. // scheduler / environment (the event loop may still be using them): the destructor does that.
  1088. void videoLIVE555Source::shutdownStream(RTSPClient * rtspClient, int exitCode)
  1089. {
  1090. if ( exitCode ) exitCode = exitCode;
  1091. if (rtspClient == NULL || rtspClient != m_pRtspClient)
  1092. {
  1093. _eventLoopWatchVariable = 1;
  1094. return; // already closed (a second shutdown closed a deleted client before)
  1095. };
  1096. CustomRTSPClient * MM = (CustomRTSPClient *) rtspClient;
  1097. #ifdef DEBUG
  1098. LOG("Shutdown EVT");
  1099. #endif
  1100. StreamClientState & streamClientState = MM->getStreamClientState(); // alias
  1101. // First, check whether any subsessions have still to be closed (as live555 testRTSPClient):
  1102. // the sinks were never closed before - they leaked and kept reading a deleted source
  1103. if (streamClientState.session != NULL)
  1104. {
  1105. Boolean someSubsessionsWereActive = False;
  1106. MediaSubsessionIterator iter(*streamClientState.session);
  1107. MediaSubsession * subsession;
  1108. while ((subsession = iter.next()) != NULL)
  1109. {
  1110. if (subsession->sink != NULL)
  1111. {
  1112. Medium::close(subsession->sink);
  1113. subsession->sink = NULL;
  1114. if (subsession->rtcpInstance() != NULL)
  1115. {
  1116. subsession->rtcpInstance()->setByeHandler(NULL, NULL); // in case the server sends a RTCP "BYE" while handling "TEARDOWN"
  1117. };
  1118. someSubsessionsWereActive = True;
  1119. };
  1120. };
  1121. if (someSubsessionsWereActive)
  1122. {
  1123. // Send a RTSP "TEARDOWN" command, to tell the server to shutdown the stream.
  1124. // Don't bother handling the response to the "TEARDOWN".
  1125. LOG("sendTearDown");
  1126. rtspClient->sendTeardownCommand(*streamClientState.session, NULL);
  1127. };
  1128. };
  1129. LOG("Close Client");
  1130. m_pRtspClient = NULL;
  1131. m_pMediaSession = NULL; // closed with the client (StreamClientState destructor)
  1132. Medium::close(rtspClient);
  1133. _eventLoopWatchVariable = 1; // ends doEventLoop()
  1134. m_eMediaStatus = MS_CLOSED;
  1135. LOG("All Done!");
  1136. }
  1137. // https://chowdera.com/2021/01/20210102084512591N.html
  1138. // https://github.com/drriguz/Kamera
  1139. bool videoLIVE555Source::_open(CSTR URI, bool ShowDeviceMenu, float framerate, int inputPin, int width, int height, int s_width, int s_height)
  1140. {
  1141. if ( ShowDeviceMenu ) ShowDeviceMenu = false;
  1142. if ( framerate ) framerate = framerate;
  1143. if ( inputPin ) inputPin = inputPin;
  1144. if (URI == NULL)
  1145. {
  1146. LOG_ERROR("Trying to open MediaSource without MRL!");
  1147. return false;
  1148. };
  1149. // if( !m_bIsParamsSet ) {
  1150. // LOG_ERROR("Trying to open MediaSource without all needded parameters!");
  1151. // return false;
  1152. // };
  1153. m_nInHeight = height;
  1154. m_nInWidth = width;
  1155. m_nOutHeight = s_height;
  1156. m_nOutWidth = s_width;
  1157. m_pRtspClient = CustomRTSPClient::createNew(this, *m_pUsageEnvironment, URI, RTSP_CLIENT_VERBOSITY_LEVEL, "ARGUS CLIENT");
  1158. if (m_pRtspClient == NULL)
  1159. {
  1160. char tB[256];
  1161. sprintf(tB, "Failed to create a RTSP client for URL \"%s\":%s", URI, m_pUsageEnvironment->getResultMsg());
  1162. LOG_ERROR(tB);
  1163. return false;
  1164. };
  1165. _eventLoopWatchVariable = 0;
  1166. m_pRtspClient->sendDescribeCommand(continueAfterDESCRIBE);
  1167. if (! init())
  1168. {
  1169. LOG_ERROR("Can not start the live555 thread!");
  1170. shutdownStream(m_pRtspClient); // no event loop is running: safe on this thread
  1171. return false;
  1172. };
  1173. return true;
  1174. }
  1175. void videoLIVE555Source::consumeFrame(cv::Mat * frm)
  1176. {
  1177. if (m_pMediaDestination == NULL)
  1178. {
  1179. return;
  1180. }
  1181. if (! m_pMediaDestination->pushFrame(*frm, m_pOpaque))
  1182. {
  1183. m_pMediaDestination = NULL;
  1184. LOG_ERROR("Error Consume Frame by Media Destination!");
  1185. };
  1186. }
  1187. bool videoLIVE555Source::_close(void)
  1188. {
  1189. LOG("CLOSE!");
  1190. return _stop();
  1191. }
  1192. bool videoLIVE555Source::_stop(void)
  1193. {
  1194. LOG("STOP!");
  1195. // live555 is single threaded: never touch its objects while its event loop runs on the other
  1196. // thread. Stop the loop and wait for the thread, then close what is left here.
  1197. _eventLoopWatchVariable = 1;
  1198. if (isEventLoopThread())
  1199. {
  1200. return true; // called from a live555 callback: shutdown after the loop is left (destructor / _stop)
  1201. };
  1202. waitThreadEnd(true);
  1203. shutdownStream(m_pRtspClient); // no-op when a live555 callback closed it already
  1204. return true;
  1205. }
  1206. bool videoLIVE555Source::isEventLoopThread(void)
  1207. {
  1208. // m_bThreadStatus: getStatus() of this class is the media status
  1209. return m_bThreadStatus == TH_WORKING && pthread_equal(pthread_self(), m_tEventLoopThread);
  1210. }
  1211. bool videoLIVE555Source::isFinished(void)
  1212. {
  1213. return (m_eMediaStatus == MS_CLOSED);
  1214. }
  1215. MediaStateStatus videoLIVE555Source::getStatus(void)
  1216. {
  1217. return m_eMediaStatus;
  1218. }
  1219. bool videoLIVE555Source::setSize(int Width, int Height)
  1220. {
  1221. if( Width || Height ) return false;
  1222. return false;
  1223. }
  1224. bool videoLIVE555Source::setProportionalByWidth(int Width)
  1225. {
  1226. if( !Width ) return false;
  1227. return false;
  1228. }
  1229. bool videoLIVE555Source::setProportionalByHeight(int Height)
  1230. {
  1231. if( !Height ) return false;
  1232. return false;
  1233. }
  1234. bool videoLIVE555Source::setFPS(int A )
  1235. {
  1236. if( !A ) return false;
  1237. return false;
  1238. }
  1239. bool videoLIVE555Source::setName(CSTR Name)
  1240. {
  1241. if( !Name ) return false;
  1242. return false;
  1243. }
  1244. bool videoLIVE555Source::setFrameAspectRatio(FrameAspectRatio AspectRatio)
  1245. {
  1246. if( AspectRatio ) AspectRatio = AspectRatio;
  1247. return false;
  1248. }
  1249. #undef MLOG
  1250. #undef LOG
  1251. #undef LOG_ERROR
  1252. #undef FF_DISABLE_DEPRECATION_WARNINGS
  1253. #endif //!LRF_PROXY_ONLY