11package io .antmedia ;
22
33import static io .antmedia .rest .RestServiceBase .FETCH_REQUEST_REDIRECTED_TO_ORIGIN ;
4- import static org .bytedeco .ffmpeg .global .avcodec .* ;
4+ import static org .bytedeco .ffmpeg .global .avcodec .avcodec_get_name ;
55
66import java .io .File ;
77import java .io .IOException ;
1414import java .net .http .HttpResponse ;
1515import java .nio .file .Files ;
1616import java .nio .file .Path ;
17- import java .util .*;
17+ import java .util .ArrayList ;
18+ import java .util .Collection ;
19+ import java .util .Collections ;
20+ import java .util .HashMap ;
21+ import java .util .Iterator ;
22+ import java .util .List ;
23+ import java .util .Map ;
1824import java .util .Map .Entry ;
25+ import java .util .Queue ;
26+ import java .util .Random ;
27+ import java .util .Set ;
1928import java .util .concurrent .CompletableFuture ;
2029import java .util .concurrent .ConcurrentHashMap ;
2130import java .util .concurrent .ConcurrentLinkedQueue ;
4756import org .red5 .server .adapter .MultiThreadedApplicationAdapter ;
4857import org .red5 .server .api .scope .IBroadcastScope ;
4958import org .red5 .server .api .scope .IScope ;
50- import org .red5 .server .api .stream .*;
59+ import org .red5 .server .api .stream .IBroadcastStream ;
60+ import org .red5 .server .api .stream .IClientBroadcastStream ;
61+ import org .red5 .server .api .stream .IPlayItem ;
62+ import org .red5 .server .api .stream .IStreamCapableConnection ;
63+ import org .red5 .server .api .stream .IStreamPlaybackSecurity ;
64+ import org .red5 .server .api .stream .IStreamPublishSecurity ;
65+ import org .red5 .server .api .stream .ISubscriberStream ;
5166import org .red5 .server .stream .ClientBroadcastStream ;
5267import org .slf4j .Logger ;
5368import org .slf4j .LoggerFactory ;
7489import io .antmedia .ipcamera .OnvifCamera ;
7590import io .antmedia .logger .LoggerUtils ;
7691import io .antmedia .muxer .IAntMediaStreamHandler ;
77- import io .antmedia .muxer .RtmpProvider ;
7892import io .antmedia .muxer .MuxAdaptor ;
7993import io .antmedia .muxer .Muxer ;
94+ import io .antmedia .muxer .RtmpProvider ;
8095import io .antmedia .plugin .api .IClusterStreamFetcher ;
8196import io .antmedia .plugin .api .IFrameListener ;
8297import io .antmedia .plugin .api .IPacketListener ;
91106import io .antmedia .statistic .IStatsCollector ;
92107import io .antmedia .statistic .StatsCollector ;
93108import io .antmedia .statistic .ViewerStats ;
94- import io .antmedia .statistic .type .RTMPToWebRTCStats ;
95109import io .antmedia .statistic .type .WebRTCAudioReceiveStats ;
96110import io .antmedia .statistic .type .WebRTCAudioSendStats ;
97111import io .antmedia .statistic .type .WebRTCVideoReceiveStats ;
@@ -421,7 +435,6 @@ else if (getServerSettings().getHostAddress().equals(storedSettings.getWarFileOr
421435 break ;
422436 }
423437
424-
425438 for (Broadcast broadcast : playlist )
426439 {
427440 schedulePlayList (now , broadcast );
@@ -432,7 +445,6 @@ else if (getServerSettings().getHostAddress().equals(storedSettings.getWarFileOr
432445 }
433446
434447
435- synchUserVoDFolder (null , appSettings .getVodFolder ());
436448 });
437449
438450
@@ -531,36 +543,7 @@ public Result resetBroadcasts(){
531543 return result ;
532544 }
533545
534- /**
535- * @Deprecated
536- * This method is deprecated. Use {@link #importVoDFolder(String)} {@link #unlinksVoD(String)}
537- * @param oldFolderPath
538- * @param vodFolderPath
539- * @return
540- */
541- public boolean synchUserVoDFolder (String oldFolderPath , String vodFolderPath )
542- {
543- boolean result = false ;
544- File streamsFolder = new File (WEBAPPS_PATH + getScope ().getName () + "/streams" );
545-
546- if (oldFolderPath != null && !oldFolderPath .equals ("" )){
547- deleteSymbolicLink (new File (oldFolderPath ), streamsFolder );
548- }
549-
550-
551- if (vodFolderPath != null && !vodFolderPath .equals ("" ))
552- {
553- File f = new File (vodFolderPath );
554- createSymbolicLink (streamsFolder , f );
555- //if file does not exists, it means reset the vod
556- getDataStore ().fetchUserVodList (f );
557- result = true ;
558- }
559-
560- return result ;
561- }
562-
563- public Result createSymbolicLink (File streamsFolder , File vodFolder ) {
546+ private Result createSymbolicLink (File streamsFolder , File vodFolder ) {
564547 Result result = null ;
565548 try {
566549 if (!streamsFolder .exists ()) {
@@ -715,7 +698,7 @@ else if (file.isDirectory())
715698 * @return
716699 * @throws IOException
717700 */
718- public boolean deleteSymbolicLink (File vodDirectory , File streamsFolder ){
701+ private boolean deleteSymbolicLink (File vodDirectory , File streamsFolder ){
719702 boolean result = false ;
720703 try {
721704 if (vodDirectory != null && streamsFolder != null )
@@ -746,29 +729,6 @@ public String getListenerHookURL(Broadcast broadcast)
746729 return listenerHookURL ;
747730
748731 }
749- /**
750- * This method is used to close the broadcast stream
751- * @deprecated use {@link #closeBroadcast(String, String)}
752- *
753- * @param streamId
754- */
755- @ Deprecated
756- public void closeBroadcast (String streamId ) {
757- closeBroadcast (streamId , null , null );
758- }
759-
760-
761- /**
762- *
763- * @param streamId
764- * @param subscriberId
765- *
766- * @deprecated use {@link #closeBroadcast(String, String, Map)}
767- */
768- @ Deprecated
769- public void closeBroadcast (String streamId , String subscriberId ) {
770- closeBroadcast (streamId , subscriberId , null );
771- }
772732
773733 public void notifyLiveStreamEnded (Broadcast broadcast ,String subscriberId ){
774734 final String listenerHookURL = getListenerHookURL (broadcast );
@@ -847,7 +807,6 @@ public void closeBroadcast(String streamId, String subscriberId, Map<String, Str
847807 for (IStreamListener listener : streamListeners ) {
848808 //keep backward compatibility
849809 try {
850- listener .streamFinished (broadcast .getStreamId ());
851810 listener .streamFinished (broadcast );
852811 } catch (Throwable t ) {
853812 logger .error ("Error invoking streamFinished method on stream listener {} for stream: {}" , listener .getClass ().getName (), streamId , t );
@@ -886,7 +845,6 @@ public static Broadcast saveMainBroadcast(String streamId, String mainTrackId, D
886845 }
887846 mainBroadcast .setZombi (true );
888847 mainBroadcast .setStatus (BROADCAST_STATUS_BROADCASTING );
889- mainBroadcast .getSubTrackStreamIds ().add (streamId );
890848 mainBroadcast .setVirtual (true );
891849 // don't set setOriginAdress because it's not a real stream and it causes extra delay -> mainBroadcast.setOriginAdress(serverSettings.getHostAddress())
892850 mainBroadcast .setStartTime (System .currentTimeMillis ());
@@ -952,7 +910,6 @@ public void updateMainTrackWithRecentlyFinishedBroadcast(Broadcast finishedBroad
952910
953911 if (mainBroadcast != null ) {
954912
955- mainBroadcast .getSubTrackStreamIds ().remove (finishedBroadcast .getStreamId ());
956913
957914 long activeSubtracksCount = getDataStore ().getActiveSubtracksCount (mainBroadcast .getStreamId (), null );
958915
@@ -975,13 +932,6 @@ public void updateMainTrackWithRecentlyFinishedBroadcast(Broadcast finishedBroad
975932 createIdleCheckTimer (mainBroadcast , true );
976933 }
977934 }
978- else {
979- logger .info ("There are {} active subtracks in the main track:{} status to finished. Just removing the subtrack:{}" , activeSubtracksCount , finishedBroadcast .getMainTrackStreamId (), finishedBroadcast .getStreamId ());
980- BroadcastUpdate broadcastUpdate = new BroadcastUpdate ();
981- broadcastUpdate .setSubTrackStreamIds (mainBroadcast .getSubTrackStreamIds ());
982-
983- getDataStore ().updateBroadcastFields (mainBroadcast .getStreamId (), broadcastUpdate );
984- }
985935 }
986936 else {
987937 logger .warn ("Maintrack is null while removing subtrack from maintrack for streamId:{} maintrackId:{}" , finishedBroadcast .getStreamId (), finishedBroadcast .getMainTrackStreamId ());
@@ -1046,19 +996,6 @@ public void streamSubscriberClose(ISubscriberStream stream) {
1046996 });
1047997 }
1048998
1049- /**
1050- * This method is used to start the publish process
1051- * @deprecated use {@link #startPublish(String, long, String, String)}
1052- * @param streamId
1053- * @param absoluteStartTimeMs
1054- * @param publishType
1055- */
1056- @ Override
1057- @ Deprecated
1058- public void startPublish (String streamId , long absoluteStartTimeMs , String publishType ) {
1059- startPublish (streamId , absoluteStartTimeMs , publishType , null , null );
1060- }
1061-
1062999 @ Override
10631000 public void startPublish (String streamId , long absoluteStartTimeMs , String publishType , String subscriberId , Map <String , String > parameters ) {
10641001 vertx .executeBlocking ( () -> {
@@ -1092,7 +1029,6 @@ public void startPublish(String streamId, long absoluteStartTimeMs, String publi
10921029
10931030 for (IStreamListener listener : streamListeners ) {
10941031 try {
1095- listener .streamStarted (broadcast .getStreamId ());
10961032 listener .streamStarted (broadcast );
10971033 } catch (Throwable t ) { // going for Throwable to catch classpath problems too
10981034 logger .error ("Error invoking streamStarted method on stream listener {} for stream: {}" , listener .getClass ().getName (), streamId , t );
@@ -1267,15 +1203,6 @@ public static Broadcast saveBroadcast(Broadcast broadcast, AntMediaApplicationAd
12671203 appAdapter .getAppSettings ().getListenerHookURL (), appAdapter .getServerSettings (), 0 );
12681204 }
12691205
1270-
1271- @ Override
1272- @ Deprecated
1273- public void muxingFinished (String streamId , File File , long startTime , long duration , int resolution ,
1274- String previewFilePath , String vodId )
1275- {
1276- muxingFinished (getDataStore ().get (streamId ), streamId , File , startTime , duration , resolution , previewFilePath , vodId );
1277- }
1278-
12791206 @ Override
12801207 public void muxingFinished (Broadcast broadcast , String streamId , File file , long startTime , long duration , int resolution , String previewFilePath , String vodId ) {
12811208
@@ -2075,15 +2002,6 @@ public void setQualityParameters(String streamId, PublishStatsEvent stats, long
20752002
20762003 }
20772004
2078- @ Override
2079- public void setQualityParameters (String id , String quality , double speed , int pendingPacketSize , long updateTimeMs ) {
2080- PublishStatsEvent stats = new PublishStatsEvent ();
2081- stats .setSpeed (speed );
2082- stats .setInputQueueSize (pendingPacketSize );
2083-
2084- setQualityParameters (id , stats , updateTimeMs );
2085- }
2086-
20872005 @ Override
20882006 public DataStore getDataStore () {
20892007 //vertx should be initialized before calling this method
@@ -2592,9 +2510,7 @@ public synchronized boolean updateSettings(AppSettings newSettings, boolean noti
25922510 updateAppSettingsBean (appSettings , newSettings , notifyCluster );
25932511
25942512 if (notifyCluster && clusterNotifier != null ) {
2595- //we should set to be deleted because app deletion fully depends on the cluster synch TODO remove the following line because toBeDeleted is deprecated
2596- appSettings .setToBeDeleted (newSettings .isToBeDeleted ());
2597-
2513+ //we should set to the status here because app deletion fully depends on the cluster synch
25982514 appSettings .setAppStatus (newSettings .getAppStatus ());
25992515
26002516
@@ -2745,9 +2661,6 @@ public void updateAppSettingsBean(AppSettings appSettings, AppSettings newSettin
27452661 //updateTime is true when the app settings is updated from the REST API or it's first updated when the app starts first in the cluster
27462662 appSettings .setUpdateTime (System .currentTimeMillis ());
27472663 }
2748- String oldVodFolder = appSettings .getVodFolder ();
2749- synchUserVoDFolder (oldVodFolder , newSettings .getVodFolder ());
2750-
27512664
27522665 setStorageclientSettings (newSettings );
27532666
@@ -2799,15 +2712,6 @@ public void setServerSettings(ServerSettings serverSettings) {
27992712 this .serverSettings = serverSettings ;
28002713 }
28012714
2802- /**
2803- * This method is overridden in enterprise edition since RTMP to WebRTC streaming is an enterprise feature.
2804- * @deprecated use the stats on the broadcast object or publish stats
2805- */
2806- @ Deprecated (forRemoval = true , since = "2.13+" )
2807- public RTMPToWebRTCStats getRTMPToWebRTCStats (String streamId ) {
2808- return new RTMPToWebRTCStats (streamId );
2809- }
2810-
28112715 public boolean isDataChannelEnabled () {
28122716 return false ;
28132717 }
@@ -2943,10 +2847,6 @@ public void removeStreamListener(IStreamListener listener) {
29432847 streamListeners .remove (listener );
29442848 }
29452849
2946- public boolean stopPlaying (String viewerId ) {
2947- return false ;
2948- }
2949-
29502850 public CompletableFuture <Result > startHttpSignaling (PublishParameters publishParameters , String sdp , String sessionId ){
29512851 //for enterprise
29522852 return null ;
@@ -2964,11 +2864,6 @@ public boolean stopPublishingBySubscriberId(String subscriberId, String streamId
29642864 return false ;
29652865 }
29662866
2967- @ Override
2968- public void stopPublish (String streamId ) {
2969- stopPublish (streamId , null );
2970- }
2971-
29722867 @ Override
29732868 public void stopPublish (String streamId , String subscriberId ) {
29742869 stopPublish (streamId , subscriberId , null );
0 commit comments