All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.antmedia.statistic.DashViewerStats Maven / Gradle / Ivy

Go to download

Ant Media Server supports RTMP, RTSP, MP4, HLS, WebRTC, Adaptive Streaming, etc.

There is a newer version: 2.11.3
Show newest version
package io.antmedia.statistic;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import io.antmedia.AntMediaApplicationAdapter;
import io.antmedia.AppSettings;
import io.antmedia.datastore.db.DataStoreFactory;
import io.antmedia.datastore.db.IDataStoreFactory;
import io.antmedia.muxer.IAntMediaStreamHandler;
import io.antmedia.settings.ServerSettings;
import io.vertx.core.Vertx;

public class DashViewerStats extends ViewerStats implements IStreamStats, ApplicationContextAware {

	protected static Logger logger = LoggerFactory.getLogger(DashViewerStats.class);
	
	public static final String BEAN_NAME = "dash.viewerstats";
	
	private Object lock = new Object();


	//TODO: Code duplication(HLSViewerStats) move this method to ViewerStats
	@Override
	public void setApplicationContext(ApplicationContext applicationContext)  {
		dataStoreFactory = (DataStoreFactory) applicationContext.getBean(IDataStoreFactory.BEAN_NAME);
		
		setType(ViewerStats.DASH_TYPE);

		vertx = (Vertx) applicationContext.getBean(IAntMediaStreamHandler.VERTX_BEAN_NAME);

		serverSettings = (ServerSettings)applicationContext.getBean(ServerSettings.BEAN_NAME);

		AppSettings settings = (AppSettings)applicationContext.getBean(AppSettings.BEAN_NAME);
		timeoutMS = getTimeoutMSFromSettings(settings, timeoutMS, DASH_TYPE);
		
		AntMediaApplicationAdapter adapter = (AntMediaApplicationAdapter)applicationContext.getBean(AntMediaApplicationAdapter.BEAN_NAME);
		appName = adapter.getScope().getName();
		
		vertx.setPeriodic(DEFAULT_TIME_PERIOD_FOR_VIEWER_COUNT, yt-> 
		{
			synchronized (lock) {
				updateViewerCountProcess(DASH_TYPE);
			}
		});	
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy