Mediasite.namespace("MediaPlayer"),Mediasite.namespace("MediaPlayer.Views"),Mediasite.MediaPlayer.ModelHtml5Ramp=function(n){function shouldEnableHLSjsLogging(){return Mediasite.GetQueryParam("logHLSjs",Mediasite.GetQueryParam.AsBool)}function makeReceiverLogic(){var t=new RampReceiverLogic;return t.logger=r,t.receiverAddress=n.selectedVideoSource.MulticastReceiverUrl,t.receiverKeyStore=n.selectedVideoSource.MulticastReceiverKeyStore,t.multicastIP=n.selectedVideoSource.MulticastAddress,t.multicastPort=n.selectedVideoSource.MulticastPort,t.diagnosticsAddress=n.selectedVideoSource.MulticastDiagnosticsServer,t.readyDelegate=function(t){setVideoSourceParam(u,t,n.selectedVideoSource.MimeType)},t.receiverCommErrorDelegate=function(){onMulticastLoadFailure(Mediasite.Player.Localization.MediaPlayer.MulticastReceiverCommunicationError)},t.progressErrorDelegate=function(){onMulticastLoadFailure(Mediasite.Player.Localization.MediaPlayer.MulticastProgressError)},t}function onMulticastLoadFailure(i){n.selectedVideoSource.MulticastOnly?t.raiseMediaError(i):(r.Info("Failing over to unicast HLS."),setVideoSourceParam(u,n.selectedVideoSource.Location,n.selectedVideoSource.MimeType))}function getCurrentBitrate(){var n=u.get(0);return n&&n.paused?0:!i||!i.levels||i.levels.length!==1?0:i.levels[0].realBitrate}function isNewBitrate(n){return Math.abs(n-o)>o*a}function reportBitrate(n){o=n,t.updateBitrate(n),r.Info("Media quality changed. -- bitrate: "+n)}function pollForBitrateChange(){var n;clearTimeout(s),s=setTimeout(pollForBitrateChange,l),n=getCurrentBitrate(),isNewBitrate(n)&&reportBitrate(n)}function setVideoSourceParam(n,t){var u=n.get(0);i&&i.destroy(),i=new Hls({debug:shouldEnableHLSjsLogging()}),e.attach(i),pollForBitrateChange(),i.attachMedia(u),i.loadSource(t)}function RampReceiverLogic(){function getMulticastAddress(){return n.multicastIP+":"+n.multicastPort+"/16"}function getAddressKey(){return n.multicastIP+"~"+n.multicastPort+"~~"}function getStartUrl(){return n.receiverAddress+"rme/start"}function getStatusUrl(){return n.receiverAddress+"rme/status?maddr="+getMulticastAddress()+"&_="+ +new Date}function initReceiver(){t||$.ajax({url:getStartUrl(),type:"POST",data:JSON.stringify({bufferMs:"1000",nativeMode:"false",senderSubjectDNSuffix:"",maddr:getMulticastAddress(),diagnosticsServer:n.diagnosticsAddress,diagnosticsIntervalMs:"15000",dvrDurationMs:"900000",dontOutputDiscontinuitySequence:"false",resetDvrOnStreamSwap:"dash",receiverKeyStore:n.receiverKeyStore}),success:function(){t||(n.logger.Info("Ramp Receiver start request was successful."),checkStatus())},error:function(){t||(i+=1,i
e&&(u=i,e=n),t>o&&(f=i,o=t),s=i-u,h=i-f,s>v)?(r.Info("Not enough packet progress."),!1):h>a&&!isWithinLiveStartSegmentGrace()?(r.Info("Not enough segment progress."),!1):!0}function resetProgressTracking(){u=+new Date,f=+new Date,e=-1,o=-1}function isWithinLiveStartSegmentGrace(){var t=new Date-n.liveStartTime;return t