@@ -8,22 +8,9 @@ use hang::moq_lite;
88use once_cell:: sync:: Lazy ;
99use std:: sync:: LazyLock ;
1010use std:: sync:: Mutex ;
11- use std:: collections:: HashMap ;
12- use std:: sync:: Arc ;
13- use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
14-
1511static CAT : Lazy < gst:: DebugCategory > =
1612 Lazy :: new ( || gst:: DebugCategory :: new ( "hang-src" , gst:: DebugColorFlags :: empty ( ) , Some ( "Hang Source Element" ) ) ) ;
1713
18- #[ derive( Clone ) ]
19- struct SharedConfig {
20- tls_disable_verify : bool ,
21- ref_count : Arc < std:: sync:: atomic:: AtomicUsize > ,
22- }
23-
24- type ConfigMap = HashMap < String , SharedConfig > ;
25- static CONFIG_MANAGER : Lazy < Arc < Mutex < ConfigMap > > > = Lazy :: new ( || Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ) ;
26-
2714#[ derive( Default , Clone ) ]
2815struct Settings {
2916 pub url : Option < String > ,
@@ -35,7 +22,6 @@ struct Settings {
3522pub struct HangSrc {
3623 settings : Mutex < Settings > ,
3724 runtime : Mutex < Option < tokio:: runtime:: Runtime > > ,
38- connection_url : Mutex < Option < String > > ,
3925}
4026
4127#[ glib:: object_subclass]
@@ -177,37 +163,11 @@ impl HangSrc {
177163 let settings = self . settings . lock ( ) . unwrap ( ) ;
178164 let url = url:: Url :: parse ( settings. url . as_ref ( ) . expect ( "url is required" ) ) ?;
179165 let name = settings. broadcast . as_ref ( ) . expect ( "broadcast is required" ) . clone ( ) ;
180- let url_key = url. to_string ( ) ;
181-
182- // Check if we already have config for this URL
183- let tls_disable_verify = {
184- let mut configs = CONFIG_MANAGER . lock ( ) . unwrap ( ) ;
185- if let Some ( existing) = configs. get ( & url_key) {
186- gst:: info!( CAT , "Reusing existing config for URL: {}" , url_key) ;
187- // Increment reference count
188- existing. ref_count . fetch_add ( 1 , Ordering :: SeqCst ) ;
189- existing. tls_disable_verify
190- } else {
191- gst:: info!( CAT , "Creating new config for URL: {}" , url_key) ;
192-
193- let config = SharedConfig {
194- tls_disable_verify : settings. tls_disable_verify ,
195- ref_count : Arc :: new ( AtomicUsize :: new ( 1 ) ) ,
196- } ;
197-
198- let tls_setting = config. tls_disable_verify ;
199- configs. insert ( url_key. clone ( ) , config) ;
200- tls_setting
201- }
202- } ;
203-
204- // Store the connection URL for cleanup
205- * self . connection_url . lock ( ) . unwrap ( ) = Some ( url_key) ;
206166
207167 // Create a dedicated connection for this broadcast
208168 let client = moq_native:: ClientConfig {
209169 tls : moq_native:: ClientTls {
210- disable_verify : Some ( tls_disable_verify) ,
170+ disable_verify : Some ( settings . tls_disable_verify ) ,
211171 ..Default :: default ( )
212172 } ,
213173 ..Default :: default ( )
@@ -427,18 +387,5 @@ impl HangSrc {
427387
428388 fn cleanup ( & self ) {
429389 // TODO kill spawned tasks
430-
431- // Cleanup config reference
432- if let Some ( url_key) = self . connection_url . lock ( ) . unwrap ( ) . take ( ) {
433- let mut configs = CONFIG_MANAGER . lock ( ) . unwrap ( ) ;
434- if let Some ( config) = configs. get ( & url_key) {
435- let ref_count = config. ref_count . fetch_sub ( 1 , Ordering :: SeqCst ) ;
436- if ref_count == 1 {
437- // This was the last reference, remove the config
438- gst:: info!( CAT , "Removing config for URL: {}" , url_key) ;
439- configs. remove ( & url_key) ;
440- }
441- }
442- }
443390 }
444391}
0 commit comments