@@ -56,7 +56,7 @@ MockSdpFactory::~MockSdpFactory()
5656{
5757}
5858
59- std::string MockSdpFactory::create_chrome_player_offer ()
59+ std::string MockSdpFactory::create_chrome_player_offer_with_h264 ()
6060{
6161 // Create a real Chrome-like WebRTC SDP offer for a player (subscriber) with H.264 video and Opus audio
6262 // Use member variables for SSRC and payload type values
@@ -104,7 +104,7 @@ std::string MockSdpFactory::create_chrome_player_offer()
104104 return ss.str ();
105105}
106106
107- std::string MockSdpFactory::create_chrome_publisher_offer ()
107+ std::string MockSdpFactory::create_chrome_publisher_offer_with_h264 ()
108108{
109109 // Create a real Chrome-like WebRTC SDP offer with H.264 video and Opus audio
110110 // Use member variables for SSRC and payload type values
@@ -155,6 +155,58 @@ std::string MockSdpFactory::create_chrome_publisher_offer()
155155 return ss.str ();
156156}
157157
158+ std::string MockSdpFactory::create_chrome_publisher_offer_with_av1 ()
159+ {
160+ // Create a real Chrome-like WebRTC SDP offer with AV1 video and Opus audio
161+ // Use member variables for SSRC and payload type values
162+ // AV1 payload type is typically 45 or 96+
163+ uint8_t av1_pt = 45 ;
164+ std::stringstream ss;
165+ ss << " v=0\r\n "
166+ << " o=- 4611731400430051338 2 IN IP4 127.0.0.1\r\n "
167+ << " s=-\r\n "
168+ << " t=0 0\r\n "
169+ << " a=group:BUNDLE 0 1\r\n "
170+ << " a=msid-semantic: WMS stream\r\n "
171+ // Audio media description (Opus)
172+ << " m=audio 9 UDP/TLS/RTP/SAVPF " << (int )audio_pt_ << " \r\n "
173+ << " c=IN IP4 0.0.0.0\r\n "
174+ << " a=rtcp:9 IN IP4 0.0.0.0\r\n "
175+ << " a=ice-ufrag:test1234\r\n "
176+ << " a=ice-pwd:testpassword1234567890\r\n "
177+ << " a=ice-options:trickle\r\n "
178+ << " a=fingerprint:sha-256 AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99\r\n "
179+ << " a=setup:actpass\r\n "
180+ << " a=mid:0\r\n "
181+ << " a=sendonly\r\n "
182+ << " a=rtcp-mux\r\n "
183+ << " a=rtpmap:" << (int )audio_pt_ << " opus/48000/2\r\n "
184+ << " a=fmtp:" << (int )audio_pt_ << " minptime=10;useinbandfec=1\r\n "
185+ << " a=ssrc:" << audio_ssrc_ << " cname:test-audio-cname\r\n "
186+ << " a=ssrc:" << audio_ssrc_ << " msid:stream audio\r\n "
187+ // Video media description (AV1)
188+ << " m=video 9 UDP/TLS/RTP/SAVPF " << (int )av1_pt << " \r\n "
189+ << " c=IN IP4 0.0.0.0\r\n "
190+ << " a=rtcp:9 IN IP4 0.0.0.0\r\n "
191+ << " a=ice-ufrag:test1234\r\n "
192+ << " a=ice-pwd:testpassword1234567890\r\n "
193+ << " a=ice-options:trickle\r\n "
194+ << " a=fingerprint:sha-256 AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99\r\n "
195+ << " a=setup:actpass\r\n "
196+ << " a=mid:1\r\n "
197+ << " a=sendonly\r\n "
198+ << " a=rtcp-mux\r\n "
199+ << " a=rtcp-rsize\r\n "
200+ << " a=rtpmap:" << (int )av1_pt << " AV1/90000\r\n "
201+ << " a=rtcp-fb:" << (int )av1_pt << " nack\r\n "
202+ << " a=rtcp-fb:" << (int )av1_pt << " nack pli\r\n "
203+ << " a=rtcp-fb:" << (int )av1_pt << " transport-cc\r\n "
204+ << " a=ssrc:" << video_ssrc_ << " cname:test-video-cname\r\n "
205+ << " a=ssrc:" << video_ssrc_ << " msid:stream video\r\n " ;
206+
207+ return ss.str ();
208+ }
209+
158210MockDtlsCertificate::MockDtlsCertificate ()
159211{
160212 fingerprint_ = " AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99" ;
@@ -306,6 +358,8 @@ ISrsRequest *MockRtcAsyncCallRequest::as_http()
306358MockRtcSource::MockRtcSource ()
307359{
308360 on_rtp_count_ = 0 ;
361+ rtp_audio_count_ = 0 ;
362+ rtp_video_count_ = 0 ;
309363}
310364
311365MockRtcSource::~MockRtcSource ()
@@ -315,6 +369,14 @@ MockRtcSource::~MockRtcSource()
315369srs_error_t MockRtcSource::on_rtp (SrsRtpPacket *pkt)
316370{
317371 on_rtp_count_++;
372+
373+ // Count audio and video packets separately
374+ if (pkt->frame_type_ == SrsFrameTypeAudio) {
375+ rtp_audio_count_++;
376+ } else if (pkt->frame_type_ == SrsFrameTypeVideo) {
377+ rtp_video_count_++;
378+ }
379+
318380 return SrsRtcSource::on_rtp (pkt);
319381}
320382
@@ -2337,3 +2399,53 @@ void MockAudioTranscoder::aac_codec_header(uint8_t **data, int *len)
23372399 *data = copy;
23382400 *len = size;
23392401}
2402+
2403+ // Mock ISrsProtocolUtility implementation
2404+ MockProtocolUtility::MockProtocolUtility (std::string ip)
2405+ {
2406+ mock_ip_ = ip;
2407+ }
2408+
2409+ MockProtocolUtility::~MockProtocolUtility ()
2410+ {
2411+ clear_ips ();
2412+ }
2413+
2414+ std::vector<SrsIPAddress *> &MockProtocolUtility::local_ips ()
2415+ {
2416+ if (!ips_.empty ()) {
2417+ return ips_;
2418+ }
2419+
2420+ // If mock_ip_ is set (via constructor), create a default IP address
2421+ if (!mock_ip_.empty ()) {
2422+ SrsIPAddress *addr = new SrsIPAddress ();
2423+ addr->ip_ = mock_ip_;
2424+ addr->is_ipv4_ = true ;
2425+ addr->is_loopback_ = false ; // Not loopback
2426+ addr->is_internet_ = true ; // Public IP
2427+ addr->ifname_ = " eth0" ; // Interface name
2428+ ips_.push_back (addr);
2429+ }
2430+
2431+ return ips_;
2432+ }
2433+
2434+ void MockProtocolUtility::add_ip (std::string ip, std::string ifname, bool is_ipv4, bool is_loopback, bool is_internet)
2435+ {
2436+ SrsIPAddress *addr = new SrsIPAddress ();
2437+ addr->ip_ = ip;
2438+ addr->ifname_ = ifname;
2439+ addr->is_ipv4_ = is_ipv4;
2440+ addr->is_loopback_ = is_loopback;
2441+ addr->is_internet_ = is_internet;
2442+ ips_.push_back (addr);
2443+ }
2444+
2445+ void MockProtocolUtility::clear_ips ()
2446+ {
2447+ for (size_t i = 0 ; i < ips_.size (); i++) {
2448+ srs_freep (ips_[i]);
2449+ }
2450+ ips_.clear ();
2451+ }
0 commit comments