@@ -2206,8 +2206,8 @@ int janus_streaming_init(janus_callbacks *callback, const char *config_path) {
2206
2206
textdata = FALSE;
2207
2207
else {
2208
2208
JANUS_LOG (LOG_ERR , "Can't add 'rtp' mountpoint '%s', invalid data type '%s'...\n" , cat -> name , dt -> value );
2209
- cl = cl -> next ;
2210
- continue ;
2209
+ failed = TRUE ;
2210
+ break ;
2211
2211
}
2212
2212
}
2213
2213
const char * streamcodec = (codec && codec -> value ? codec -> value : NULL );
@@ -2268,6 +2268,7 @@ int janus_streaming_init(janus_callbacks *callback, const char *config_path) {
2268
2268
ml = ml -> next ;
2269
2269
}
2270
2270
if (failed ) {
2271
+ g_list_free_full (streams , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
2271
2272
cl = cl -> next ;
2272
2273
continue ;
2273
2274
}
@@ -2460,6 +2461,7 @@ int janus_streaming_init(janus_callbacks *callback, const char *config_path) {
2460
2461
doaskew , FALSE, FALSE, FALSE, FALSE, FALSE);
2461
2462
if (stream == NULL ) {
2462
2463
JANUS_LOG (LOG_ERR , "Skipping 'audio' stream '%s', error creating source stream...\n" , cat -> name );
2464
+ g_list_free_full (streams , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
2463
2465
cl = cl -> next ;
2464
2466
continue ;
2465
2467
}
@@ -2485,6 +2487,7 @@ int janus_streaming_init(janus_callbacks *callback, const char *config_path) {
2485
2487
dovskew , bufferkf , simulcast , dosvc , FALSE, FALSE);
2486
2488
if (stream == NULL ) {
2487
2489
JANUS_LOG (LOG_ERR , "Skipping 'video' stream '%s', error creating source stream...\n" , cat -> name );
2490
+ g_list_free_full (streams , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
2488
2491
cl = cl -> next ;
2489
2492
continue ;
2490
2493
}
@@ -2505,6 +2508,7 @@ int janus_streaming_init(janus_callbacks *callback, const char *config_path) {
2505
2508
FALSE, FALSE, FALSE, FALSE, textdata , buffermsg );
2506
2509
if (stream == NULL ) {
2507
2510
JANUS_LOG (LOG_ERR , "Skipping 'data' stream '%s', error creating source stream...\n" , cat -> name );
2511
+ g_list_free_full (streams , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
2508
2512
cl = cl -> next ;
2509
2513
continue ;
2510
2514
}
@@ -3478,6 +3482,7 @@ static json_t *janus_streaming_process_synchronous_request(janus_streaming_sessi
3478
3482
JANUS_LOG (LOG_ERR , "Can't add 'rtp' stream '%s', unsupported media type...\n" , (const char * )json_string_value (name ));
3479
3483
error_code = JANUS_STREAMING_ERROR_CANT_CREATE ;
3480
3484
g_snprintf (error_cause , 512 , "Unsupported media type in media stream" );
3485
+ g_list_free_full (streams , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
3481
3486
janus_mutex_lock (& mountpoints_mutex );
3482
3487
g_hash_table_remove (mountpoints_temp , string_ids ? (gpointer )mpid_str : (gpointer )& mpid );
3483
3488
janus_mutex_unlock (& mountpoints_mutex );
@@ -3518,6 +3523,7 @@ static json_t *janus_streaming_process_synchronous_request(janus_streaming_sessi
3518
3523
JANUS_LOG (LOG_ERR , "Can't add 'rtp' stream '%s', invalid network interface configuration for media stream...\n" , (const char * )json_string_value (name ));
3519
3524
error_code = JANUS_STREAMING_ERROR_CANT_CREATE ;
3520
3525
g_snprintf (error_cause , 512 , ifas ? "Invalid network interface configuration for media stream" : "Unable to query network device information" );
3526
+ g_list_free_full (streams , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
3521
3527
janus_mutex_lock (& mountpoints_mutex );
3522
3528
g_hash_table_remove (mountpoints_temp , string_ids ? (gpointer )mpid_str : (gpointer )& mpid );
3523
3529
janus_mutex_unlock (& mountpoints_mutex );
@@ -3558,6 +3564,7 @@ static json_t *janus_streaming_process_synchronous_request(janus_streaming_sessi
3558
3564
JANUS_LOG (LOG_ERR , "Invalid element (datatype can only be text or binary)\n" );
3559
3565
error_code = JANUS_STREAMING_ERROR_INVALID_ELEMENT ;
3560
3566
g_snprintf (error_cause , 512 , "Invalid element (datatype can only be text or binary)" );
3567
+ g_list_free_full (streams , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
3561
3568
janus_mutex_lock (& mountpoints_mutex );
3562
3569
g_hash_table_remove (mountpoints_temp , string_ids ? (gpointer )mpid_str : (gpointer )& mpid );
3563
3570
janus_mutex_unlock (& mountpoints_mutex );
@@ -3575,6 +3582,7 @@ static json_t *janus_streaming_process_synchronous_request(janus_streaming_sessi
3575
3582
JANUS_LOG (LOG_ERR , "Can't add 'rtp' stream '%s', error creating data source stream...\n" , (const char * )json_string_value (name ));
3576
3583
error_code = JANUS_STREAMING_ERROR_CANT_CREATE ;
3577
3584
g_snprintf (error_cause , 512 , "Can't add 'rtp' stream, error creating data source stream" );
3585
+ g_list_free_full (streams , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
3578
3586
janus_mutex_lock (& mountpoints_mutex );
3579
3587
g_hash_table_remove (mountpoints_temp , string_ids ? (gpointer )mpid_str : (gpointer )& mpid );
3580
3588
janus_mutex_unlock (& mountpoints_mutex );
@@ -3613,6 +3621,7 @@ static json_t *janus_streaming_process_synchronous_request(janus_streaming_sessi
3613
3621
error_code , error_cause , TRUE,
3614
3622
JANUS_STREAMING_ERROR_MISSING_ELEMENT , JANUS_STREAMING_ERROR_INVALID_ELEMENT );
3615
3623
if (error_code != 0 ) {
3624
+ g_list_free_full (streams , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
3616
3625
janus_mutex_lock (& mountpoints_mutex );
3617
3626
g_hash_table_remove (mountpoints_temp , string_ids ? (gpointer )mpid_str : (gpointer )& mpid );
3618
3627
janus_mutex_unlock (& mountpoints_mutex );
@@ -3665,6 +3674,7 @@ static json_t *janus_streaming_process_synchronous_request(janus_streaming_sessi
3665
3674
JANUS_LOG (LOG_ERR , "Can't add 'rtp' stream '%s', error creating audio source stream...\n" , (const char * )json_string_value (name ));
3666
3675
error_code = JANUS_STREAMING_ERROR_CANT_CREATE ;
3667
3676
g_snprintf (error_cause , 512 , "Can't add 'rtp' stream, error creating audio source stream" );
3677
+ g_list_free_full (streams , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
3668
3678
janus_mutex_lock (& mountpoints_mutex );
3669
3679
g_hash_table_remove (mountpoints_temp , string_ids ? (gpointer )mpid_str : (gpointer )& mpid );
3670
3680
janus_mutex_unlock (& mountpoints_mutex );
@@ -3683,6 +3693,7 @@ static json_t *janus_streaming_process_synchronous_request(janus_streaming_sessi
3683
3693
error_code , error_cause , TRUE,
3684
3694
JANUS_STREAMING_ERROR_MISSING_ELEMENT , JANUS_STREAMING_ERROR_INVALID_ELEMENT );
3685
3695
if (error_code != 0 ) {
3696
+ g_list_free_full (streams , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
3686
3697
janus_mutex_lock (& mountpoints_mutex );
3687
3698
g_hash_table_remove (mountpoints_temp , string_ids ? (gpointer )mpid_str : (gpointer )& mpid );
3688
3699
janus_mutex_unlock (& mountpoints_mutex );
@@ -3753,6 +3764,7 @@ static json_t *janus_streaming_process_synchronous_request(janus_streaming_sessi
3753
3764
JANUS_LOG (LOG_ERR , "Can't add 'rtp' stream '%s', error creating video source stream...\n" , (const char * )json_string_value (name ));
3754
3765
error_code = JANUS_STREAMING_ERROR_CANT_CREATE ;
3755
3766
g_snprintf (error_cause , 512 , "Can't add 'rtp' stream, error creating video source stream" );
3767
+ g_list_free_full (streams , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
3756
3768
janus_mutex_lock (& mountpoints_mutex );
3757
3769
g_hash_table_remove (mountpoints_temp , string_ids ? (gpointer )mpid_str : (gpointer )& mpid );
3758
3770
janus_mutex_unlock (& mountpoints_mutex );
@@ -3769,6 +3781,7 @@ static json_t *janus_streaming_process_synchronous_request(janus_streaming_sessi
3769
3781
error_code , error_cause , TRUE,
3770
3782
JANUS_STREAMING_ERROR_MISSING_ELEMENT , JANUS_STREAMING_ERROR_INVALID_ELEMENT );
3771
3783
if (error_code != 0 ) {
3784
+ g_list_free_full (streams , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
3772
3785
janus_mutex_lock (& mountpoints_mutex );
3773
3786
g_hash_table_remove (mountpoints_temp , string_ids ? (gpointer )mpid_str : (gpointer )& mpid );
3774
3787
janus_mutex_unlock (& mountpoints_mutex );
@@ -3825,6 +3838,7 @@ static json_t *janus_streaming_process_synchronous_request(janus_streaming_sessi
3825
3838
JANUS_LOG (LOG_ERR , "Can't add 'rtp' stream '%s', error creating data source stream...\n" , (const char * )json_string_value (name ));
3826
3839
error_code = JANUS_STREAMING_ERROR_CANT_CREATE ;
3827
3840
g_snprintf (error_cause , 512 , "Can't add 'rtp' stream, error creating data source stream" );
3841
+ g_list_free_full (streams , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
3828
3842
janus_mutex_lock (& mountpoints_mutex );
3829
3843
g_hash_table_remove (mountpoints_temp , string_ids ? (gpointer )mpid_str : (gpointer )& mpid );
3830
3844
janus_mutex_unlock (& mountpoints_mutex );
@@ -7682,9 +7696,7 @@ janus_streaming_mountpoint *janus_streaming_create_rtp_source(
7682
7696
if (len < SRTP_MASTER_LENGTH ) {
7683
7697
JANUS_LOG (LOG_ERR , "Invalid SRTP crypto (%s)\n" , srtpcrypto );
7684
7698
g_free (decoded );
7685
- janus_mutex_lock (& mountpoints_mutex );
7686
- g_hash_table_remove (mountpoints_temp , & id );
7687
- janus_mutex_unlock (& mountpoints_mutex );
7699
+ g_list_free_full (media , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
7688
7700
g_free (live_rtp_source );
7689
7701
g_free (live_rtp -> name );
7690
7702
g_free (live_rtp -> description );
@@ -7709,9 +7721,7 @@ janus_streaming_mountpoint *janus_streaming_create_rtp_source(
7709
7721
/* Something went wrong... */
7710
7722
JANUS_LOG (LOG_ERR , "Error creating forwarder SRTP session: %d (%s)\n" , res , janus_srtp_error_str (res ));
7711
7723
g_free (decoded );
7712
- janus_mutex_lock (& mountpoints_mutex );
7713
- g_hash_table_remove (mountpoints_temp , & id );
7714
- janus_mutex_unlock (& mountpoints_mutex );
7724
+ g_list_free_full (media , (GDestroyNotify )(janus_streaming_rtp_source_stream_unref ));
7715
7725
g_free (live_rtp_source );
7716
7726
g_free (live_rtp -> name );
7717
7727
g_free (live_rtp -> description );
@@ -7839,17 +7849,11 @@ janus_streaming_mountpoint *janus_streaming_create_file_source(
7839
7849
}
7840
7850
if (!doaudio && !dovideo ) {
7841
7851
JANUS_LOG (LOG_ERR , "Can't add 'file' stream, no audio or video have to be streamed...\n" );
7842
- janus_mutex_lock (& mountpoints_mutex );
7843
- g_hash_table_remove (mountpoints_temp , & id );
7844
- janus_mutex_unlock (& mountpoints_mutex );
7845
7852
return NULL ;
7846
7853
}
7847
7854
/* FIXME We don't support video streaming from file yet */
7848
7855
if (!doaudio || dovideo ) {
7849
7856
JANUS_LOG (LOG_ERR , "Can't add 'file' stream, we only support audio file streaming right now...\n" );
7850
- janus_mutex_lock (& mountpoints_mutex );
7851
- g_hash_table_remove (mountpoints_temp , & id );
7852
- janus_mutex_unlock (& mountpoints_mutex );
7853
7857
return NULL ;
7854
7858
}
7855
7859
/* TODO We should support something more than raw a-Law and mu-Law streams... */
@@ -7860,18 +7864,12 @@ janus_streaming_mountpoint *janus_streaming_create_file_source(
7860
7864
if (!strstr (filename , ".alaw" ) && !strstr (filename , ".mulaw" )) {
7861
7865
JANUS_LOG (LOG_ERR , "Can't add 'file' stream, unsupported format (we only support raw mu-Law and a-Law files right now)\n" );
7862
7866
#endif
7863
- janus_mutex_lock (& mountpoints_mutex );
7864
- g_hash_table_remove (mountpoints_temp , & id );
7865
- janus_mutex_unlock (& mountpoints_mutex );
7866
7867
return NULL ;
7867
7868
}
7868
7869
janus_audiocodec audio_codec = janus_audiocodec_from_name (acodec );
7869
7870
#ifdef HAVE_LIBOGG
7870
7871
if (strstr (filename , ".opus" ) && audio_codec != JANUS_AUDIOCODEC_OPUS ) {
7871
7872
JANUS_LOG (LOG_ERR , "Can't add 'file' stream, opus file is not associated with an opus rtpmap\n" );
7872
- janus_mutex_lock (& mountpoints_mutex );
7873
- g_hash_table_remove (mountpoints_temp , & id );
7874
- janus_mutex_unlock (& mountpoints_mutex );
7875
7873
return NULL ;
7876
7874
}
7877
7875
#endif
@@ -8909,18 +8907,12 @@ janus_streaming_mountpoint *janus_streaming_create_rtsp_source(
8909
8907
/* Now connect to the RTSP server */
8910
8908
if (janus_streaming_rtsp_connect_to_server (live_rtsp ) < 0 ) {
8911
8909
/* Error connecting, get rid of the mountpoint */
8912
- janus_mutex_lock (& mountpoints_mutex );
8913
- g_hash_table_remove (mountpoints_temp , & id );
8914
- janus_mutex_unlock (& mountpoints_mutex );
8915
8910
janus_refcount_decrease (& live_rtsp -> ref );
8916
8911
return NULL ;
8917
8912
}
8918
8913
/* Send an RTSP PLAY, now */
8919
8914
if (janus_streaming_rtsp_play (live_rtsp_source ) < 0 ) {
8920
8915
/* Error trying to play, get rid of the mountpoint */
8921
- janus_mutex_lock (& mountpoints_mutex );
8922
- g_hash_table_remove (mountpoints_temp , & id );
8923
- janus_mutex_unlock (& mountpoints_mutex );
8924
8916
janus_refcount_decrease (& live_rtsp -> ref );
8925
8917
return NULL ;
8926
8918
}
@@ -8952,9 +8944,6 @@ janus_streaming_mountpoint *janus_streaming_create_rtsp_source(
8952
8944
janus_refcount_decrease (& helper -> ref );
8953
8945
/* This extra unref is for the init */
8954
8946
janus_refcount_decrease (& helper -> ref );
8955
- janus_mutex_lock (& mountpoints_mutex );
8956
- g_hash_table_remove (mountpoints_temp , & id );
8957
- janus_mutex_unlock (& mountpoints_mutex );
8958
8947
janus_refcount_decrease (& live_rtsp -> ref );
8959
8948
return NULL ;
8960
8949
}
@@ -8970,9 +8959,6 @@ janus_streaming_mountpoint *janus_streaming_create_rtsp_source(
8970
8959
JANUS_LOG (LOG_ERR , "Got error %d (%s) trying to launch the RTSP thread...\n" ,
8971
8960
error -> code , error -> message ? error -> message : "??" );
8972
8961
g_error_free (error );
8973
- janus_mutex_lock (& mountpoints_mutex );
8974
- g_hash_table_remove (mountpoints_temp , & id );
8975
- janus_mutex_unlock (& mountpoints_mutex );
8976
8962
janus_refcount_decrease (& live_rtsp -> ref ); /* This is for the failed thread */
8977
8963
janus_refcount_decrease (& live_rtsp -> ref );
8978
8964
return NULL ;
0 commit comments