Merge develop

This commit is contained in:
winlin 2025-10-23 20:02:14 -04:00
commit 1fe9c158c8
100 changed files with 250 additions and 175 deletions

View File

@ -304,6 +304,14 @@ build_and_development:
working_directory: "trunk/3rdparty/srs-bench"
testing:
utest_file_naming:
description: "Unit test file naming indicates ownership and maintenance responsibility"
patterns:
- "srs_utest_ai*.cpp - AI-managed, AI has full autonomy"
- "srs_utest_workflow_*.cpp - Human-dominated with AI help, human maintains"
- "srs_utest_manual_*.cpp - Human-written, AI should NOT modify without permission"
error_handling_macros:
- Use HELPER_EXPECT_SUCCESS(x) when expecting a function to succeed (returns srs_success)
- Use HELPER_EXPECT_FAILED(x) when expecting a function to fail (returns non-srs_success error)

20
trunk/configure vendored
View File

@ -375,20 +375,20 @@ fi
#
# utest, the unit-test cases of srs, base on gtest1.6
if [[ $SRS_UTEST == YES ]]; then
MODULE_FILES=("srs_utest" "srs_utest_amf0" "srs_utest_kernel" "srs_utest_core" "srs_utest_srt"
"srs_utest_config" "srs_utest_rtmp" "srs_utest_http" "srs_utest_avc" "srs_utest_reload"
"srs_utest_mp4" "srs_utest_service" "srs_utest_app_rtc2rtmp" "srs_utest_rtc" "srs_utest_config2"
"srs_utest_protocol" "srs_utest_protocol2" "srs_utest_kernel2" "srs_utest_st" "srs_utest_fmp4"
"srs_utest_source_lock" "srs_utest_stream_token" "srs_utest_rtc_recv_track" "srs_utest_st2"
"srs_utest_hevc_structs" "srs_utest_coworkers" "srs_utest_pithy_print" "srs_utest_protocol3"
"srs_utest_app" "srs_utest_mock" "srs_utest_rtc_playstream" "srs_utest_rtc_publishstream"
"srs_utest_rtc_conn" "srs_utest_rtmp_conn" "srs_utest_srt_conn" "srs_utest_http_conn")
MODULE_FILES=("srs_utest" "srs_utest_manual_amf0" "srs_utest_manual_kernel" "srs_utest_manual_core" "srs_utest_manual_srt"
"srs_utest_manual_config" "srs_utest_manual_rtmp" "srs_utest_manual_http" "srs_utest_manual_avc" "srs_utest_manual_reload"
"srs_utest_manual_mp4" "srs_utest_manual_service" "srs_utest_manual_app_rtc2rtmp" "srs_utest_manual_rtc" "srs_utest_manual_config2"
"srs_utest_manual_protocol" "srs_utest_manual_protocol2" "srs_utest_manual_kernel2" "srs_utest_manual_st" "srs_utest_manual_fmp4"
"srs_utest_manual_source_lock" "srs_utest_manual_stream_token" "srs_utest_manual_rtc_recv_track" "srs_utest_manual_st2"
"srs_utest_manual_hevc_structs" "srs_utest_manual_coworkers" "srs_utest_manual_pithy_print" "srs_utest_manual_protocol3"
"srs_utest_manual_app" "srs_utest_manual_mock" "srs_utest_workflow_rtc_playstream" "srs_utest_workflow_rtc_publishstream"
"srs_utest_workflow_rtc_conn" "srs_utest_workflow_rtmp_conn" "srs_utest_workflow_srt_conn" "srs_utest_workflow_http_conn")
MODULE_FILES+=("srs_utest_ai01" "srs_utest_ai02" "srs_utest_ai03" "srs_utest_ai04" "srs_utest_ai05"
"srs_utest_ai06" "srs_utest_ai07" "srs_utest_ai08" "srs_utest_ai09" "srs_utest_ai10" "srs_utest_ai11"
"srs_utest_ai12" "srs_utest_ai13" "srs_utest_ai14" "srs_utest_ai15" "srs_utest_ai16" "srs_utest_ai17"
"srs_utest_ai18" "srs_utest_ai19" "srs_utest_ai20" "srs_utest_forward")
"srs_utest_ai18" "srs_utest_ai19" "srs_utest_ai20" "srs_utest_workflow_forward")
if [[ $SRS_GB28181 == YES ]]; then
MODULE_FILES+=("srs_utest_gb28181" "srs_utest_ai23")
MODULE_FILES+=("srs_utest_manual_gb28181" "srs_utest_ai23")
fi
if [[ $SRS_RTSP == YES ]]; then
MODULE_FILES+=("srs_utest_ai21" "srs_utest_ai22")

View File

@ -33,7 +33,7 @@ using namespace std;
#include <srs_protocol_conn.hpp>
// Include headers for all the mocks.
#include <srs_utest_mock.hpp>
#include <srs_utest_manual_mock.hpp>
// we add an empty macro for upp to show the smart tips.
#define VOID

View File

@ -10,6 +10,6 @@
/*
#include <srs_utest_ai01.hpp>
*/
#include <srs_utest_config.hpp>
#include <srs_utest_manual_config.hpp>
#endif

View File

@ -12,7 +12,7 @@ using namespace std;
#include <srs_app_utility.hpp>
#include <srs_kernel_error.hpp>
#include <srs_kernel_utility.hpp>
#include <srs_utest_config.hpp>
#include <srs_utest_manual_config.hpp>
VOID TEST(ConfigHttpsStreamTest, CheckHttpsStreamListensDefault)
{

View File

@ -11,7 +11,7 @@
#include <srs_kernel_error.hpp>
#include <srs_kernel_rtc_rtp.hpp>
#include <srs_utest_service.hpp>
#include <srs_utest_manual_service.hpp>
#include <chrono>
#include <vector>

View File

@ -10,7 +10,7 @@
#include <srs_core_autofree.hpp>
#include <srs_kernel_rtc_rtp.hpp>
#include <srs_protocol_st.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_manual_kernel.hpp>
// Helper function to create a mock RTP packet for testing
SrsRtpPacket *mock_create_audio_rtp_packet(uint16_t sequence, uint32_t timestamp, const char *payload_data = NULL, int payload_size = 10)
@ -211,19 +211,21 @@ VOID TEST(RTC3AudioCacheTest, PacketLossWithTimeout)
// Should not process yet, waiting for missing packets
EXPECT_EQ(0, (int)ready_packets.size());
// Sleep for 10ms to exceed the 1ms timeout
srs_usleep(10 * SRS_UTIME_MILLISECONDS);
// Process another packet to trigger timeout check
SrsUniquePtr<SrsRtpPacket> pkt4(mock_create_audio_rtp_packet(104, 1080));
HELPER_EXPECT_SUCCESS(cache.process_packet(pkt4.get(), ready_packets));
// Should process packet 103 despite missing 101, 102 due to timeout
bool found_103 = false;
for (size_t i = 0; i < ready_packets.size(); i++) {
if (ready_packets[i]->header_.get_sequence() == 103) {
found_103 = true;
break;
for (int i = 0; i < 10 && !found_103; i++) {
// Sleep for N ms to exceed the 1ms timeout
srs_usleep(3 * SRS_UTIME_MILLISECONDS);
// Process another packet to trigger timeout check
SrsUniquePtr<SrsRtpPacket> pkt4(mock_create_audio_rtp_packet(104, 1080));
HELPER_EXPECT_SUCCESS(cache.process_packet(pkt4.get(), ready_packets));
// Should process packet 103 despite missing 101, 102 due to timeout
for (size_t i = 0; i < ready_packets.size(); i++) {
if (ready_packets[i]->header_.get_sequence() == 103) {
found_103 = true;
break;
}
}
}
EXPECT_TRUE(found_103);

View File

@ -23,7 +23,7 @@
#include <srs_kernel_st.hpp>
#include <srs_kernel_stream.hpp>
#include <srs_kernel_utility.hpp>
#include <srs_utest_protocol.hpp>
#include <srs_utest_manual_protocol.hpp>
#include <algorithm>

View File

@ -16,7 +16,7 @@
#include <srs_kernel_io.hpp>
#include <srs_kernel_resource.hpp>
#include <srs_kernel_rtc_queue.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_manual_kernel.hpp>
// Mock classes for IO testing
class MockSrsReader : public ISrsReader

View File

@ -19,7 +19,7 @@ using namespace std;
#include <srs_protocol_rtmp_conn.hpp>
#include <srs_protocol_rtp.hpp>
#include <srs_protocol_st.hpp>
#include <srs_utest_http.hpp>
#include <srs_utest_manual_http.hpp>
VOID TEST(HTTPClientTest, HTTPClientUtility)
{

View File

@ -3291,17 +3291,17 @@ VOID TEST(StreamBridgeTest, SrsRtcRtpBuilder_OnAudioFormatConsumeError)
SrsUniquePtr<SrsMediaPacket> invalid_frame(new SrsMediaPacket());
invalid_frame->message_type_ = SrsFrameTypeAudio;
// Create invalid audio data (empty payload)
// Create invalid audio data with unsupported codec (Linear PCM, codec ID 0)
char *invalid_data = new char[1];
invalid_data[0] = 0x00; // Invalid audio format
invalid_data[0] = 0x00; // Linear PCM codec (ID=0) - unsupported
invalid_frame->wrap(invalid_data, 1);
invalid_frame->timestamp_ = 1000;
// Test on_frame which calls on_audio internally
// This should call format_->on_audio(msg) but the format parsing should handle gracefully
// Note: SrsFormat::on_audio returns success for invalid data, just doesn't parse codec
HELPER_EXPECT_SUCCESS(builder.on_frame(invalid_frame.get()));
// This should call format_->on_audio(msg) which will return error for unsupported codec
// SrsFormat::on_audio now returns error for codecs that are not MP3/AAC/Opus
HELPER_EXPECT_FAILED(builder.on_frame(invalid_frame.get()));
// Test with NULL payload data
SrsUniquePtr<SrsMediaPacket> null_frame(new SrsMediaPacket());
@ -3334,7 +3334,7 @@ VOID TEST(StreamBridgeTest, SrsRtcRtpBuilder_OnAudioNoAcodecParsed)
HELPER_EXPECT_SUCCESS(builder.initialize(req.get()));
// Test with audio data that has unknown/unsupported codec
// This will cause format_->on_audio() to succeed but not parse acodec_
// This will cause format_->on_audio() to return error for unsupported codec
SrsUniquePtr<SrsMediaPacket> unknown_codec_frame(new SrsMediaPacket());
unknown_codec_frame->message_type_ = SrsFrameTypeAudio;
@ -3349,23 +3349,18 @@ VOID TEST(StreamBridgeTest, SrsRtcRtpBuilder_OnAudioNoAcodecParsed)
unknown_codec_frame->timestamp_ = 1000;
// Test on_frame which calls on_audio internally
// This should call format_->on_audio(msg) successfully, but format_->acodec_ will be NULL
// because ADPCM is not supported, so the method should return early at line 1033-1035
HELPER_EXPECT_SUCCESS(builder.on_frame(unknown_codec_frame.get()));
// This should call format_->on_audio(msg) which returns error for unsupported codec
// SrsFormat::on_audio now validates codec and returns error for non-MP3/AAC/Opus codecs
HELPER_EXPECT_FAILED(builder.on_frame(unknown_codec_frame.get()));
// Test with very short audio data that can't be parsed
SrsUniquePtr<SrsMediaPacket> short_frame(new SrsMediaPacket());
short_frame->message_type_ = SrsFrameTypeAudio;
// Test with NULL payload - this should succeed as format handles NULL gracefully
SrsUniquePtr<SrsMediaPacket> null_frame(new SrsMediaPacket());
null_frame->message_type_ = SrsFrameTypeAudio;
null_frame->timestamp_ = 2000;
// Don't wrap any data, payload will be NULL
// Create very short audio data (less than minimum required)
char *short_data = new char[1];
short_data[0] = 0xFF; // Some data but too short to parse properly
short_frame->wrap(short_data, 1);
short_frame->timestamp_ = 2000;
// This should also result in format_->acodec_ being NULL after parsing
HELPER_EXPECT_SUCCESS(builder.on_frame(short_frame.get()));
// This should call format_->on_audio(msg) with NULL payload which returns success
HELPER_EXPECT_SUCCESS(builder.on_frame(null_frame.get()));
// Verify that frames were processed successfully
EXPECT_TRUE(true); // Basic test passed - no crash occurred
@ -3424,8 +3419,8 @@ VOID TEST(StreamBridgeTest, SrsRtcRtpBuilder_OnAudioUnsupportedCodec)
speex_frame->wrap(speex_data, 6);
speex_frame->timestamp_ = 2000;
// This should also fail the codec validation since Speex is not AAC or MP3
HELPER_EXPECT_SUCCESS(builder.on_frame(speex_frame.get()));
// This should fail the codec validation since Speex is not MP3/AAC/Opus
HELPER_EXPECT_FAILED(builder.on_frame(speex_frame.get()));
// Test with Linear PCM codec (codec ID 0)
SrsUniquePtr<SrsMediaPacket> pcm_frame(new SrsMediaPacket());
@ -3443,8 +3438,8 @@ VOID TEST(StreamBridgeTest, SrsRtcRtpBuilder_OnAudioUnsupportedCodec)
pcm_frame->wrap(pcm_data, 6);
pcm_frame->timestamp_ = 3000;
// This should also fail the codec validation since Linear PCM is not AAC or MP3
HELPER_EXPECT_SUCCESS(builder.on_frame(pcm_frame.get()));
// This should also fail the codec validation since Linear PCM is not MP3/AAC/Opus
HELPER_EXPECT_FAILED(builder.on_frame(pcm_frame.get()));
// Verify that frames were processed successfully
EXPECT_TRUE(true); // Basic test passed - no crash occurred
@ -3577,8 +3572,7 @@ VOID TEST(StreamBridgeTest, SrsRtcRtpBuilder_OnAudioCodecValidationFailure)
// This should succeed and set up format_->acodec_
HELPER_EXPECT_SUCCESS(builder.on_frame(aac_frame.get()));
// Now test with Linear PCM codec (ID=0) which is not supported by RTC builder
// but could theoretically be parsed (though format_ doesn't actually support it either)
// Now test with Linear PCM codec (ID=0) which is not supported by format
SrsUniquePtr<SrsMediaPacket> pcm_frame(new SrsMediaPacket());
pcm_frame->message_type_ = SrsFrameTypeAudio;
@ -3593,9 +3587,9 @@ VOID TEST(StreamBridgeTest, SrsRtcRtpBuilder_OnAudioCodecValidationFailure)
pcm_frame->wrap(pcm_data, 6);
pcm_frame->timestamp_ = 2000;
// This should call format_->on_audio() which will not parse Linear PCM (returns early),
// so format_->acodec_ will remain NULL, covering the path at lines 1033-1035
HELPER_EXPECT_SUCCESS(builder.on_frame(pcm_frame.get()));
// This should call format_->on_audio() which will return error for unsupported codec
// SrsFormat::on_audio validates codec and returns error for non-MP3/AAC/Opus codecs
HELPER_EXPECT_FAILED(builder.on_frame(pcm_frame.get()));
// Verify that frames were processed successfully
EXPECT_TRUE(true); // Test passed - covered codec validation paths
@ -3626,7 +3620,7 @@ VOID TEST(StreamBridgeTest, SrsRtcRtpBuilder_OnAudioComprehensiveCoverage)
// This covers the path where format_->on_audio() handles NULL/empty data gracefully
HELPER_EXPECT_SUCCESS(builder.on_frame(empty_frame.get()));
// Test 2: Invalid codec data - covers format_->acodec_ being NULL after parsing
// Test 2: Invalid codec data - covers format_->on_audio() returning error for unsupported codec
SrsUniquePtr<SrsMediaPacket> invalid_frame(new SrsMediaPacket());
invalid_frame->message_type_ = SrsFrameTypeAudio;
@ -3637,8 +3631,8 @@ VOID TEST(StreamBridgeTest, SrsRtcRtpBuilder_OnAudioComprehensiveCoverage)
invalid_frame->wrap(invalid_data, 2);
invalid_frame->timestamp_ = 2000;
// This covers the path where format_->acodec_ is NULL (lines 1033-1035)
HELPER_EXPECT_SUCCESS(builder.on_frame(invalid_frame.get()));
// This covers the path where format_->on_audio() returns error for unsupported codec
HELPER_EXPECT_FAILED(builder.on_frame(invalid_frame.get()));
// Test 3: OPUS codec - covers format_->on_audio() error path
SrsUniquePtr<SrsMediaPacket> opus_frame(new SrsMediaPacket());

View File

@ -23,7 +23,7 @@
#include <srs_app_statistic.hpp>
#include <srs_protocol_sdp.hpp>
#include <srs_utest_ai07.hpp>
#include <srs_utest_protocol3.hpp>
#include <srs_utest_manual_protocol3.hpp>
// Mock ISrsResourceManager for testing SrsGbMediaTcpConn::bind_session
class MockResourceManagerForBindSession : public ISrsResourceManager

View File

@ -18,7 +18,7 @@
#include <srs_utest_ai05.hpp>
#include <srs_utest_ai07.hpp>
#include <srs_utest_ai11.hpp>
#include <srs_utest_service.hpp>
#include <srs_utest_manual_service.hpp>
// Mock video recv track for testing check_send_nacks
class MockRtcVideoRecvTrackForNack : public SrsRtcVideoRecvTrack

View File

@ -15,7 +15,7 @@ using namespace std;
#include <srs_kernel_file.hpp>
#include <srs_kernel_utility.hpp>
#include <srs_protocol_amf0.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_manual_kernel.hpp>
// Mock app config implementation for HLS notify testing
MockAppConfigForHlsNotify::MockAppConfigForHlsNotify()

View File

@ -16,7 +16,7 @@
#include <srs_app_hls.hpp>
#include <srs_app_rtmp_source.hpp>
#include <srs_utest_ai11.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_manual_kernel.hpp>
// Extended mock app config for HLS notify testing
class MockAppConfigForHlsNotify : public MockAppConfig

View File

@ -25,9 +25,9 @@ using namespace std;
#include <srs_utest_ai11.hpp>
#include <srs_utest_ai13.hpp>
#include <srs_utest_ai22.hpp>
#include <srs_utest_config.hpp>
#include <srs_utest_coworkers.hpp>
#include <srs_utest_protocol2.hpp>
#include <srs_utest_manual_config.hpp>
#include <srs_utest_manual_coworkers.hpp>
#include <srs_utest_manual_protocol2.hpp>
MockMediaPacketForJitter::MockMediaPacketForJitter(int64_t timestamp, bool is_av)
{

View File

@ -27,6 +27,22 @@ using namespace std;
#include <srs_utest_ai14.hpp>
#include <sys/socket.h>
// Mock PID file locker implementation for SrsServer::initialize() testing
MockPidFileLocker::MockPidFileLocker()
{
}
MockPidFileLocker::~MockPidFileLocker()
{
}
srs_error_t MockPidFileLocker::acquire()
{
// Mock implementation that always succeeds without actually locking a file
// This allows tests to run even when a real SRS server is running
return srs_success;
}
// Mock config implementation for SrsServer::listen() testing
MockAppConfigForServerListen::MockAppConfigForServerListen()
{
@ -170,6 +186,11 @@ VOID TEST(SrsServerTest, InitializeSuccess)
SrsUniquePtr<SrsServer> server(new SrsServer());
EXPECT_TRUE(server.get() != NULL);
// Replace the PID file locker with a mock to avoid conflicts with running SRS server
SrsPidFileLocker *original_locker = server->pid_file_locker_;
MockPidFileLocker *mock_locker = new MockPidFileLocker();
server->pid_file_locker_ = mock_locker;
// Call initialize() - this is the main test
// This will initialize all server components in the correct sequence:
// 1. PID file locker acquisition
@ -188,6 +209,10 @@ VOID TEST(SrsServerTest, InitializeSuccess)
// The fact that initialize() returned success means all components
// were initialized properly without errors
EXPECT_TRUE(server.get() != NULL);
// Restore original locker and cleanup mock
server->pid_file_locker_ = original_locker;
srs_freep(mock_locker);
}
// Test SrsServer::listen() method to verify proper listener setup for RTMP protocol.
@ -212,6 +237,11 @@ VOID TEST(SrsServerTest, ListenRtmpSuccess)
// Inject mock config
server->config_ = &mock_config;
// Replace the PID file locker with a mock to avoid conflicts with running SRS server
SrsPidFileLocker *original_locker = server->pid_file_locker_;
MockPidFileLocker *mock_locker = new MockPidFileLocker();
server->pid_file_locker_ = mock_locker;
// Initialize server first (required before listen)
HELPER_EXPECT_SUCCESS(server->initialize());
@ -228,6 +258,10 @@ VOID TEST(SrsServerTest, ListenRtmpSuccess)
// - Socket binding succeeded on the random port
// - Connection manager started successfully
EXPECT_TRUE(server.get() != NULL);
// Restore original locker and cleanup mock
server->pid_file_locker_ = original_locker;
srs_freep(mock_locker);
}
// Test SrsServer::http_handle() method to verify proper HTTP API handler registration.

View File

@ -17,6 +17,7 @@
#include <srs_app_rtc_server.hpp>
#include <srs_app_rtmp_conn.hpp>
#include <srs_app_security.hpp>
#include <srs_app_server.hpp>
#include <srs_kernel_hourglass.hpp>
#include <srs_protocol_http_stack.hpp>
#include <srs_utest_ai11.hpp>
@ -69,6 +70,17 @@ public:
virtual std::string get_exporter_listen();
};
// Mock PID file locker for testing SrsServer::initialize()
class MockPidFileLocker : public SrsPidFileLocker
{
public:
MockPidFileLocker();
virtual ~MockPidFileLocker();
public:
virtual srs_error_t acquire();
};
// Mock ISrsLog for testing SrsServer::on_signal()
class MockLogForSignal : public ISrsLog
{

View File

@ -20,8 +20,8 @@ using namespace std;
#include <srs_protocol_json.hpp>
#include <srs_utest_ai14.hpp>
#include <srs_utest_ai15.hpp>
#include <srs_utest_http.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_manual_http.hpp>
#include <srs_utest_manual_kernel.hpp>
#include <vector>
// External function declarations for testing

View File

@ -23,10 +23,10 @@ using namespace std;
#include <srs_utest_ai15.hpp>
#include <srs_utest_ai16.hpp>
#include <srs_utest_ai23.hpp>
#include <srs_utest_coworkers.hpp>
#include <srs_utest_fmp4.hpp>
#include <srs_utest_http.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_manual_coworkers.hpp>
#include <srs_utest_manual_fmp4.hpp>
#include <srs_utest_manual_http.hpp>
#include <srs_utest_manual_kernel.hpp>
// Mock ISrsMpdWriter implementation
MockMpdWriter::MockMpdWriter()

View File

@ -28,8 +28,8 @@ using namespace std;
#include <srs_protocol_http_stack.hpp>
#include <srs_protocol_rtmp_stack.hpp>
#include <srs_utest_ai05.hpp>
#include <srs_utest_coworkers.hpp>
#include <srs_utest_http.hpp>
#include <srs_utest_manual_coworkers.hpp>
#include <srs_utest_manual_http.hpp>
// Mock ISrsAppConfig implementation
MockAppConfigForUdpCaster::MockAppConfigForUdpCaster()

View File

@ -27,7 +27,7 @@
#include <srs_utest_ai11.hpp>
#include <srs_utest_ai15.hpp>
#include <srs_utest_ai16.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_manual_kernel.hpp>
// Mock ISrsAppConfig for testing SrsUdpCasterListener
class MockAppConfigForUdpCaster : public MockAppConfig

View File

@ -12,7 +12,7 @@ using namespace std;
#include <srs_kernel_consts.hpp>
#include <srs_kernel_error.hpp>
#include <srs_protocol_st.hpp>
#include <srs_utest_mock.hpp>
#include <srs_utest_manual_mock.hpp>
#include <unistd.h>
// Mock ISrsSignalHandler implementation

View File

@ -22,8 +22,8 @@ using namespace std;
#include <srs_utest_ai08.hpp>
#include <srs_utest_ai10.hpp>
#include <srs_utest_ai11.hpp>
#include <srs_utest_config.hpp>
#include <srs_utest_coworkers.hpp>
#include <srs_utest_manual_config.hpp>
#include <srs_utest_manual_coworkers.hpp>
// Mock frame target implementation
MockSrtFrameTarget::MockSrtFrameTarget()

View File

@ -22,10 +22,10 @@ using namespace std;
#include <srs_protocol_utility.hpp>
#include <srs_utest_ai15.hpp>
#include <srs_utest_ai16.hpp>
#include <srs_utest_config.hpp>
#include <srs_utest_fmp4.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_protocol.hpp>
#include <srs_utest_manual_config.hpp>
#include <srs_utest_manual_fmp4.hpp>
#include <srs_utest_manual_kernel.hpp>
#include <srs_utest_manual_protocol.hpp>
// Mock request implementation
MockEdgeRequest::MockEdgeRequest(std::string vhost, std::string app, std::string stream)
@ -1049,7 +1049,7 @@ VOID TEST(EdgeIngesterTest, ProcessPublishMessageAudioVideo)
srs_freep(ingester->upstream_);
ingester->upstream_ = mock_upstream;
// Test 1: Process audio message
// Test 1: Process audio message with valid AAC codec
{
SrsUniquePtr<SrsRtmpCommonMessage> audio_msg(new SrsRtmpCommonMessage());
audio_msg->header_.message_type_ = RTMP_MSG_AudioMessage;
@ -1057,6 +1057,14 @@ VOID TEST(EdgeIngesterTest, ProcessPublishMessageAudioVideo)
audio_msg->header_.timestamp_ = 1000;
audio_msg->create_payload(10);
// Set valid AAC audio data (codec ID 10)
char *payload = audio_msg->payload();
payload[0] = 0xAF; // AAC codec (ID=10), 44kHz, 16-bit, stereo
payload[1] = 0x01; // AAC raw data (not sequence header)
for (int i = 2; i < 10; i++) {
payload[i] = 0x00; // Sample AAC data
}
std::string redirect;
HELPER_EXPECT_SUCCESS(ingester->process_publish_message(audio_msg.get(), redirect));
}

View File

@ -25,9 +25,9 @@ using namespace std;
#include <srs_protocol_rtmp_conn.hpp>
#include <srs_protocol_sdp.hpp>
#include <srs_utest_ai16.hpp>
#include <srs_utest_http.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_protocol.hpp>
#include <srs_utest_manual_http.hpp>
#include <srs_utest_manual_kernel.hpp>
#include <srs_utest_manual_protocol.hpp>
// Mock ISrsGbMuxer implementation
MockGbMuxer::MockGbMuxer()

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_amf0.hpp>
#include <srs_utest_manual_amf0.hpp>
#include <string>
using namespace std;

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_app.hpp>
#include <srs_utest_manual_app.hpp>
using namespace std;

View File

@ -8,7 +8,7 @@
#define SRS_UTEST_APP_HPP
/*
#include <srs_utest_app.hpp>
#include <srs_utest_manual_app.hpp>
*/
#include <srs_utest.hpp>

View File

@ -4,7 +4,7 @@
// SPDX-License-Identifier: MIT
//
#include <srs_utest_app_rtc2rtmp.hpp>
#include <srs_utest_manual_app_rtc2rtmp.hpp>
#include <srs_app_rtc_source.hpp>
#include <srs_app_stream_bridge.hpp>
@ -16,7 +16,7 @@
#include <srs_protocol_rtmp_stack.hpp>
#include <srs_utest_ai09.hpp>
#include <srs_utest_service.hpp>
#include <srs_utest_manual_service.hpp>
#include <vector>
using namespace std;

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_avc.hpp>
#include <srs_utest_manual_avc.hpp>
#include <srs_core_autofree.hpp>
#include <srs_kernel_buffer.hpp>

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_config.hpp>
#include <srs_utest_manual_config.hpp>
using namespace std;
@ -16,7 +16,7 @@ using namespace std;
#include <srs_kernel_utility.hpp>
#include <srs_protocol_rtmp_stack.hpp>
#include <srs_protocol_st.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_manual_kernel.hpp>
MockSrsConfigBuffer::MockSrsConfigBuffer(string buf)
{

View File

@ -8,7 +8,7 @@
#define SRS_UTEST_CONFIG_HPP
/*
#include <srs_utest_config.hpp>
#include <srs_utest_manual_config.hpp>
*/
#include <srs_utest.hpp>

View File

@ -3,13 +3,13 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_config2.hpp>
#include <srs_utest_manual_config2.hpp>
#include <srs_app_utility.hpp>
#include <srs_kernel_error.hpp>
#include <srs_kernel_file.hpp>
#include <srs_kernel_utility.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_manual_kernel.hpp>
VOID TEST(ConfigMainTest, CheckIncludeEmptyConfig)
{

View File

@ -10,6 +10,6 @@
/*
#include <srs_utest_config2.hpp>
*/
#include <srs_utest_config.hpp>
#include <srs_utest_manual_config.hpp>
#endif

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_core.hpp>
#include <srs_utest_manual_core.hpp>
using namespace std;

View File

@ -4,7 +4,7 @@
// SPDX-License-Identifier: MIT
//
#include <srs_utest_coworkers.hpp>
#include <srs_utest_manual_coworkers.hpp>
using namespace std;
@ -14,7 +14,7 @@ using namespace std;
#include <srs_kernel_utility.hpp>
#include <srs_protocol_json.hpp>
#include <srs_protocol_rtmp_stack.hpp>
#include <srs_utest_config.hpp>
#include <srs_utest_manual_config.hpp>
// Use the config from srs_utest_config.hpp

View File

@ -4,7 +4,7 @@
// SPDX-License-Identifier: MIT
//
#include <srs_utest_fmp4.hpp>
#include <srs_utest_manual_fmp4.hpp>
#include <sstream>
using namespace std;
@ -16,7 +16,7 @@ using namespace std;
#include <srs_kernel_stream.hpp>
#include <srs_kernel_utility.hpp>
#include <srs_protocol_rtmp_stack.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_manual_kernel.hpp>
// Mock class implementations
MockFmp4SrsRequest::MockFmp4SrsRequest()

View File

@ -8,7 +8,7 @@
#define SRS_UTEST_FMP4_HPP
/*
#include <srs_utest_fmp4.hpp>
#include <srs_utest_manual_fmp4.hpp>
*/
#include <srs_utest.hpp>

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_gb28181.hpp>
#include <srs_utest_manual_gb28181.hpp>
#include <sstream>
using namespace std;
@ -19,8 +19,8 @@ using namespace std;
#include <srs_protocol_json.hpp>
#include <srs_protocol_sdp.hpp>
#include <srs_protocol_utility.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_protocol.hpp>
#include <srs_utest_manual_kernel.hpp>
#include <srs_utest_manual_protocol.hpp>
VOID TEST(KernelPSTest, PsPacketDecodePartialPesHeader)
{

View File

@ -10,6 +10,6 @@
/*
#include <srs_utest_gb28181.hpp>
*/
#include <srs_utest_http.hpp>
#include <srs_utest_manual_http.hpp>
#endif

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_http.hpp>
#include <srs_utest_manual_http.hpp>
#include <sstream>
using namespace std;
@ -16,8 +16,8 @@ using namespace std;
#include <srs_protocol_http_stack.hpp>
#include <srs_protocol_json.hpp>
#include <srs_protocol_utility.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_protocol.hpp>
#include <srs_utest_manual_kernel.hpp>
#include <srs_utest_manual_protocol.hpp>
MockMSegmentsReader::MockMSegmentsReader()
{

View File

@ -8,13 +8,13 @@
#define SRS_UTEST_PROTO_STACK_HPP
/*
#include <srs_utest_http.hpp>
#include <srs_utest_manual_http.hpp>
*/
#include <srs_utest.hpp>
#include <srs_protocol_http_conn.hpp>
#include <srs_protocol_http_stack.hpp>
#include <srs_utest_protocol.hpp>
#include <srs_utest_manual_protocol.hpp>
#include <string>
using namespace std;

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_kernel.hpp>
#include <srs_utest_manual_kernel.hpp>
using namespace std;

View File

@ -8,7 +8,7 @@
#define SRS_UTEST_KERNEL_HPP
/*
#include <srs_utest_kernel.hpp>
#include <srs_utest_manual_kernel.hpp>
*/
#include <srs_utest.hpp>

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_kernel2.hpp>
#include <srs_utest_manual_kernel2.hpp>
#include <srs_app_utility.hpp>
#include <srs_kernel_buffer.hpp>

View File

@ -12,6 +12,6 @@
*/
#include <srs_utest.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_manual_kernel.hpp>
#endif

View File

@ -4,7 +4,7 @@
// SPDX-License-Identifier: MIT
//
#include <srs_utest_mock.hpp>
#include <srs_utest_manual_mock.hpp>
#include <srs_app_caster_flv.hpp>
#include <srs_app_config.hpp>

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_mp4.hpp>
#include <srs_utest_manual_mp4.hpp>
#include <sstream>
using namespace std;
@ -12,7 +12,7 @@ using namespace std;
#include <srs_core_autofree.hpp>
#include <srs_kernel_error.hpp>
#include <srs_kernel_mp4.hpp>
#include <srs_utest_kernel.hpp>
#include <srs_utest_manual_kernel.hpp>
VOID TEST(KernelMp4Test, PrintPadding)
{

View File

@ -4,7 +4,7 @@
// SPDX-License-Identifier: MIT
//
#include <srs_utest_pithy_print.hpp>
#include <srs_utest_manual_pithy_print.hpp>
using namespace std;

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_protocol.hpp>
#include <srs_utest_manual_protocol.hpp>
using namespace std;

View File

@ -8,7 +8,7 @@
#define SRS_UTEST_PROTOCOL_HPP
/*
#include <srs_utest_protocol.hpp>
#include <srs_utest_manual_protocol.hpp>
*/
#include <srs_utest.hpp>

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_protocol2.hpp>
#include <srs_utest_manual_protocol2.hpp>
using namespace std;

View File

@ -8,8 +8,8 @@
#define SRS_UTEST_PROTOCOL2_HPP
/*
#include <srs_utest_protocol2.hpp>
#include <srs_utest_manual_protocol2.hpp>
*/
#include <srs_utest_protocol.hpp>
#include <srs_utest_manual_protocol.hpp>
#endif

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_protocol3.hpp>
#include <srs_utest_manual_protocol3.hpp>
using namespace std;

View File

@ -8,9 +8,9 @@
#define SRS_UTEST_PROTOCOL3_HPP
/*
#include <srs_utest_protocol3.hpp>
#include <srs_utest_manual_protocol3.hpp>
*/
#include <srs_utest_protocol.hpp>
#include <srs_utest_manual_protocol.hpp>
#include <srs_protocol_conn.hpp>

View File

@ -4,7 +4,7 @@
// SPDX-License-Identifier: MIT
//
#include <srs_utest_reload.hpp>
#include <srs_utest_manual_reload.hpp>
using namespace std;

View File

@ -13,7 +13,7 @@
#include <srs_utest.hpp>
#include <srs_app_reload.hpp>
#include <srs_utest_config.hpp>
#include <srs_utest_manual_config.hpp>
class MockReloadHandler : public ISrsReloadHandler
{

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_rtc.hpp>
#include <srs_utest_manual_rtc.hpp>
#include <srs_app_rtc_conn.hpp>
#include <srs_app_rtc_source.hpp>
@ -16,8 +16,8 @@
#include <srs_protocol_conn.hpp>
#include <srs_utest_ai11.hpp>
#include <srs_utest_protocol3.hpp>
#include <srs_utest_service.hpp>
#include <srs_utest_manual_protocol3.hpp>
#include <srs_utest_manual_service.hpp>
#include <vector>
using namespace std;

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include "srs_utest_rtc_recv_track.hpp"
#include "srs_utest_manual_rtc_recv_track.hpp"
#include <srs_app_rtc_conn.hpp>
#include <srs_app_rtc_dtls.hpp>

View File

@ -11,6 +11,6 @@
#include <srs_utest_rtc_recv_track.hpp>
*/
#include <srs_utest.hpp>
#include <srs_utest_service.hpp>
#include <srs_utest_manual_service.hpp>
#endif

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_rtmp.hpp>
#include <srs_utest_manual_rtmp.hpp>
#include <srs_app_st.hpp>
#include <srs_core_autofree.hpp>

View File

@ -13,7 +13,7 @@
#include <srs_utest.hpp>
#include <srs_protocol_rtmp_stack.hpp>
#include <srs_utest_protocol.hpp>
#include <srs_utest_manual_protocol.hpp>
// Mock classes for RTMP testing
class MockPacket : public SrsRtmpCommand

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_service.hpp>
#include <srs_utest_manual_service.hpp>
using namespace std;
@ -24,8 +24,8 @@ using namespace std;
#include <srs_protocol_rtmp_stack.hpp>
#include <srs_protocol_st.hpp>
#include <srs_protocol_utility.hpp>
#include <srs_utest_http.hpp>
#include <srs_utest_protocol.hpp>
#include <srs_utest_manual_http.hpp>
#include <srs_utest_manual_protocol.hpp>
#include <st.h>
#include <sys/socket.h>

View File

@ -8,7 +8,7 @@
#define SRS_UTEST_SERVICE_HPP
/*
#include <srs_utest_service.hpp>
#include <srs_utest_manual_service.hpp>
*/
#include <srs_utest.hpp>

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_source_lock.hpp>
#include <srs_utest_manual_source_lock.hpp>
using namespace std;

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
//
#include <srs_utest_srt.hpp>
#include <srs_utest_manual_srt.hpp>
#include <srs_app_srt_server.hpp>
#include <srs_core_autofree.hpp>

View File

@ -7,7 +7,7 @@
#include <srs_kernel_error.hpp>
#include <srs_kernel_utility.hpp>
#include <srs_protocol_st.hpp>
#include <srs_utest_st.hpp>
#include <srs_utest_manual_st.hpp>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
@ -83,8 +83,13 @@ VOID TEST(StTest, StUtimePerformance)
EXPECT_GE(gettimeofday_elapsed_time, 0);
EXPECT_GE(st_utime_elapsed_time, 0);
// pass the test, if
EXPECT_LT(gettimeofday_elapsed_time > st_utime_elapsed_time ? gettimeofday_elapsed_time - st_utime_elapsed_time : st_utime_elapsed_time - gettimeofday_elapsed_time, 30);
// Calculate absolute difference between the two elapsed times
int time_diff = gettimeofday_elapsed_time > st_utime_elapsed_time
? gettimeofday_elapsed_time - st_utime_elapsed_time
: st_utime_elapsed_time - gettimeofday_elapsed_time;
// The difference should be less than N clock ticks (microseconds)
EXPECT_LT(time_diff, 100);
}
// check gettimeofday first, then st_utime
@ -104,7 +109,13 @@ VOID TEST(StTest, StUtimePerformance)
EXPECT_GE(gettimeofday_elapsed_time, 0);
EXPECT_GE(st_utime_elapsed_time, 0);
EXPECT_LT(gettimeofday_elapsed_time > st_utime_elapsed_time ? gettimeofday_elapsed_time - st_utime_elapsed_time : st_utime_elapsed_time - gettimeofday_elapsed_time, 30);
// Calculate absolute difference between the two elapsed times
int time_diff = gettimeofday_elapsed_time > st_utime_elapsed_time
? gettimeofday_elapsed_time - st_utime_elapsed_time
: st_utime_elapsed_time - gettimeofday_elapsed_time;
// The difference should be less than N clock ticks (microseconds)
EXPECT_LT(time_diff, 100);
}
// compare st_utime & gettimeofday in a loop
@ -126,7 +137,13 @@ VOID TEST(StTest, StUtimePerformance)
EXPECT_GE(gettimeofday_elapsed_time, 0);
EXPECT_GE(st_utime_elapsed_time, 0);
EXPECT_LT(gettimeofday_elapsed_time > st_utime_elapsed_time ? gettimeofday_elapsed_time - st_utime_elapsed_time : st_utime_elapsed_time - gettimeofday_elapsed_time, 100);
// Calculate absolute difference between the two elapsed times
int time_diff = gettimeofday_elapsed_time > st_utime_elapsed_time
? gettimeofday_elapsed_time - st_utime_elapsed_time
: st_utime_elapsed_time - gettimeofday_elapsed_time;
// The difference should be less than N clock ticks (microseconds)
EXPECT_LT(time_diff, 100);
}
}

View File

@ -4,7 +4,7 @@
// SPDX-License-Identifier: MIT
//
#include <srs_utest_st2.hpp>
#include <srs_utest_manual_st2.hpp>
#include <srs_app_st.hpp>
#include <srs_core_autofree.hpp>

View File

@ -4,7 +4,7 @@
// SPDX-License-Identifier: MIT
//
#include <srs_utest_stream_token.hpp>
#include <srs_utest_manual_stream_token.hpp>
using namespace std;

View File

@ -21,7 +21,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_utest_forward.hpp>
#include <srs_utest_workflow_forward.hpp>
#include <srs_app_utility.hpp>
#include <srs_kernel_error.hpp>

View File

@ -34,7 +34,7 @@
#include <srs_app_forward.hpp>
#include <srs_app_rtmp_source.hpp>
#include <srs_protocol_rtmp_conn.hpp>
#include <srs_utest_mock.hpp>
#include <srs_utest_manual_mock.hpp>
// Mock ISrsAppFactory for testing SrsForwarder
class MockAppFactoryForForwarder : public SrsAppFactory

View File

@ -21,7 +21,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_utest_http_conn.hpp>
#include <srs_utest_workflow_http_conn.hpp>
#include <srs_app_http_conn.hpp>
#include <srs_app_http_stream.hpp>
@ -33,9 +33,9 @@
#include <srs_utest_ai15.hpp>
#include <srs_utest_ai16.hpp>
#include <srs_utest_ai19.hpp>
#include <srs_utest_http.hpp>
#include <srs_utest_mock.hpp>
#include <srs_utest_service.hpp>
#include <srs_utest_manual_http.hpp>
#include <srs_utest_manual_mock.hpp>
#include <srs_utest_manual_service.hpp>
// This test is used to verify the basic workflow of the HTTP connection.
// It's finished with the help of AI, but each step is manually designed

View File

@ -21,7 +21,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_utest_rtc_conn.hpp>
#include <srs_utest_workflow_rtc_conn.hpp>
#include <srs_app_factory.hpp>
#include <srs_app_rtc_conn.hpp>
@ -31,8 +31,8 @@
#include <srs_kernel_error.hpp>
#include <srs_protocol_rtmp_stack.hpp>
#include <srs_utest_ai11.hpp>
#include <srs_utest_mock.hpp>
#include <srs_utest_service.hpp>
#include <srs_utest_manual_mock.hpp>
#include <srs_utest_manual_service.hpp>
MockProtocolUtilityForRtcConn::MockProtocolUtilityForRtcConn(std::string ip)
{

View File

@ -4,14 +4,14 @@
// SPDX-License-Identifier: MIT
//
#include <srs_utest_rtc_playstream.hpp>
#include <srs_utest_workflow_rtc_playstream.hpp>
#include <srs_app_rtc_conn.hpp>
#include <srs_app_rtc_source.hpp>
#include <srs_kernel_error.hpp>
#include <srs_utest_ai11.hpp>
#include <srs_utest_app.hpp>
#include <srs_utest_mock.hpp>
#include <srs_utest_manual_app.hpp>
#include <srs_utest_manual_mock.hpp>
// This test is used to verify the basic workflow of the RTC play stream.
// It's finished with the help of AI, but each step is manually designed

View File

@ -21,13 +21,13 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_utest_rtc_publishstream.hpp>
#include <srs_utest_workflow_rtc_publishstream.hpp>
#include <srs_app_rtc_conn.hpp>
#include <srs_app_rtc_source.hpp>
#include <srs_kernel_error.hpp>
#include <srs_utest_ai11.hpp>
#include <srs_utest_mock.hpp>
#include <srs_utest_manual_mock.hpp>
// This test is used to verify the basic workflow of the RTC publish stream.
// It's finished with the help of AI, but each step is manually designed

View File

@ -21,7 +21,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_utest_rtmp_conn.hpp>
#include <srs_utest_workflow_rtmp_conn.hpp>
#include <srs_app_rtmp_conn.hpp>
#include <srs_protocol_conn.hpp>
@ -32,8 +32,8 @@
#include <srs_utest_ai15.hpp>
#include <srs_utest_ai18.hpp>
#include <srs_utest_ai22.hpp>
#include <srs_utest_mock.hpp>
#include <srs_utest_service.hpp>
#include <srs_utest_manual_mock.hpp>
#include <srs_utest_manual_service.hpp>
#include <sys/socket.h>
#include <unistd.h>

View File

@ -21,7 +21,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_utest_srt_conn.hpp>
#include <srs_utest_workflow_srt_conn.hpp>
#include <srs_app_srt_conn.hpp>
#include <srs_protocol_conn.hpp>
@ -29,8 +29,8 @@
#include <srs_protocol_st.hpp>
#include <srs_utest_ai11.hpp>
#include <srs_utest_ai18.hpp>
#include <srs_utest_mock.hpp>
#include <srs_utest_service.hpp>
#include <srs_utest_manual_mock.hpp>
#include <srs_utest_manual_service.hpp>
#include <sys/socket.h>
#include <unistd.h>