mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 09:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
public class DVRCastConstants
|
||||
{
|
||||
|
||||
public static const RPC_GET_STREAM_INFO:String = "DVRGetStreamInfo";
|
||||
|
||||
public static const RPC_SUBSCRIBE:String = "DVRSubscribe";
|
||||
|
||||
public static const RPC_UNSUBSCRIBE:String = "DVRUnsubscribe";
|
||||
|
||||
public static const RESULT_GET_STREAM_INFO_SUCCESS:String = "NetStream.DVRStreamInfo.Success";
|
||||
|
||||
public static const RESULT_GET_STREAM_INFO_RETRY:String = "NetStream.DVRStreamInfo.Retry";
|
||||
|
||||
public static const STREAM_INFO_KEY:String = "http://www.osmf.org/dvrCast/1.0/streamInfo";
|
||||
|
||||
public static const RECORDING_INFO_KEY:String = "http://www.osmf.org/dvrCast/1.0/recordingInfo";
|
||||
|
||||
public static const STREAM_INFO_UPDATE_DELAY:Number = 3000;
|
||||
|
||||
public static const LOCAL_DURATION_UPDATE_INTERVAL:Number = 500;
|
||||
|
||||
public static const LIVE_POSITION_SEEK_DELAY:Number = 1.5;
|
||||
|
||||
public function DVRCastConstants()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.Event;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import flash.utils.Timer;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.DVRTrait;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
internal class DVRCastDVRTrait extends DVRTrait
|
||||
{
|
||||
|
||||
private var connection:NetConnection;
|
||||
|
||||
private var stream:NetStream;
|
||||
|
||||
private var streamInfo:DVRCastStreamInfo;
|
||||
|
||||
private var recordingInfo:DVRCastRecordingInfo;
|
||||
|
||||
private var streamInfoUpdateTimer:Timer;
|
||||
|
||||
private var streamInfoRetriever:DVRCastStreamInfoRetriever;
|
||||
|
||||
private var offset:Number;
|
||||
|
||||
public function DVRCastDVRTrait(param1:NetConnection, param2:NetStream, param3:MediaResourceBase)
|
||||
{
|
||||
if(param1 != null && param2 != null)
|
||||
{
|
||||
this.stream = param2;
|
||||
this.streamInfo = param3.getMetadataValue(DVRCastConstants.STREAM_INFO_KEY) as DVRCastStreamInfo;
|
||||
this.recordingInfo = param3.getMetadataValue(DVRCastConstants.RECORDING_INFO_KEY) as DVRCastRecordingInfo;
|
||||
this.streamInfoRetriever = new DVRCastStreamInfoRetriever(param1,this.streamInfo.streamName);
|
||||
this.streamInfoRetriever.addEventListener(Event.COMPLETE,this.onStreamInfoRetrieverComplete);
|
||||
this.streamInfoUpdateTimer = new Timer(DVRCastConstants.STREAM_INFO_UPDATE_DELAY);
|
||||
this.streamInfoUpdateTimer.addEventListener(TimerEvent.TIMER,this.onStreamInfoUpdateTimer);
|
||||
this.streamInfoUpdateTimer.start();
|
||||
super(this.streamInfo.isRecording);
|
||||
this.updateProperties();
|
||||
return;
|
||||
}
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.NULL_PARAM));
|
||||
}
|
||||
|
||||
override protected function isRecordingChangeStart(param1:Boolean) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
this.recordingInfo.startDuration = this.streamInfo.currentLength;
|
||||
this.recordingInfo.startTime = new Date();
|
||||
}
|
||||
}
|
||||
|
||||
private function updateProperties() : void
|
||||
{
|
||||
setIsRecording(this.streamInfo.isRecording);
|
||||
}
|
||||
|
||||
private function onStreamInfoUpdateTimer(param1:TimerEvent) : void
|
||||
{
|
||||
this.streamInfoRetriever.retrieve();
|
||||
}
|
||||
|
||||
private function onStreamInfoRetrieverComplete(param1:Event) : void
|
||||
{
|
||||
if(this.streamInfoRetriever.streamInfo != null)
|
||||
{
|
||||
this.streamInfo.readFromDVRCastStreamInfo(this.streamInfoRetriever.streamInfo);
|
||||
this.updateProperties();
|
||||
}
|
||||
else
|
||||
{
|
||||
dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.DVRCAST_STREAM_INFO_RETRIEVAL_FAILED)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.Responder;
|
||||
import flash.utils.Dictionary;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.NetConnectionFactoryEvent;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.net.DynamicStreamingItem;
|
||||
import org.osmf.net.DynamicStreamingResource;
|
||||
import org.osmf.net.NetConnectionFactory;
|
||||
import org.osmf.net.NetConnectionFactoryBase;
|
||||
import org.osmf.net.NetStreamUtils;
|
||||
import org.osmf.net.StreamingURLResource;
|
||||
|
||||
public class DVRCastNetConnectionFactory extends NetConnectionFactoryBase
|
||||
{
|
||||
|
||||
private var innerFactory:NetConnectionFactoryBase;
|
||||
|
||||
private var subscribedStreams:Dictionary = new Dictionary();
|
||||
|
||||
public function DVRCastNetConnectionFactory(param1:NetConnectionFactoryBase = null)
|
||||
{
|
||||
this.innerFactory = param1 || new NetConnectionFactory();
|
||||
this.innerFactory.addEventListener(NetConnectionFactoryEvent.CREATION_COMPLETE,this.onCreationComplete);
|
||||
this.innerFactory.addEventListener(NetConnectionFactoryEvent.CREATION_ERROR,this.onCreationError);
|
||||
super();
|
||||
}
|
||||
|
||||
override public function create(param1:URLResource) : void
|
||||
{
|
||||
this.innerFactory.create(param1);
|
||||
}
|
||||
|
||||
override public function closeNetConnection(param1:NetConnection) : void
|
||||
{
|
||||
var _loc2_:String = this.subscribedStreams[param1];
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
param1.call(DVRCastConstants.RPC_UNSUBSCRIBE,null,_loc2_);
|
||||
delete this.subscribedStreams[param1];
|
||||
}
|
||||
this.innerFactory.closeNetConnection(param1);
|
||||
}
|
||||
|
||||
private function onCreationComplete(param1:NetConnectionFactoryEvent) : void
|
||||
{
|
||||
var urlIncludesFMSApplicationInstance:Boolean;
|
||||
var dynamicResource:DynamicStreamingResource;
|
||||
var responder:Responder;
|
||||
var urlResource:URLResource = null;
|
||||
var netConnection:NetConnection = null;
|
||||
var streamNames:Vector.<String> = null;
|
||||
var totalRpcSubscribeInvocation:int = 0;
|
||||
var streamingResource:StreamingURLResource = null;
|
||||
var onStreamSubscriptionResult:Function = null;
|
||||
var onStreamInfoRetrieverComplete:Function = null;
|
||||
var onServerCallError:Function = null;
|
||||
var items:Vector.<DynamicStreamingItem> = null;
|
||||
var i:int = 0;
|
||||
var event:NetConnectionFactoryEvent = param1;
|
||||
onStreamSubscriptionResult = function(param1:Object):void
|
||||
{
|
||||
var _loc2_:DVRCastStreamInfoRetriever = null;
|
||||
--totalRpcSubscribeInvocation;
|
||||
if(totalRpcSubscribeInvocation <= 0)
|
||||
{
|
||||
_loc2_ = new DVRCastStreamInfoRetriever(netConnection,streamNames[0]);
|
||||
_loc2_.addEventListener(Event.COMPLETE,onStreamInfoRetrieverComplete);
|
||||
_loc2_.retrieve();
|
||||
}
|
||||
};
|
||||
onStreamInfoRetrieverComplete = function(param1:Event):void
|
||||
{
|
||||
var _loc3_:DVRCastRecordingInfo = null;
|
||||
var _loc2_:DVRCastStreamInfoRetriever = param1.target as DVRCastStreamInfoRetriever;
|
||||
removeEventListener(NetConnectionFactoryEvent.CREATION_COMPLETE,onCreationComplete);
|
||||
if(_loc2_.streamInfo != null)
|
||||
{
|
||||
if(_loc2_.streamInfo.offline == true)
|
||||
{
|
||||
dispatchEvent(new NetConnectionFactoryEvent(NetConnectionFactoryEvent.CREATION_ERROR,false,false,netConnection,urlResource,new MediaError(MediaErrorCodes.DVRCAST_CONTENT_OFFLINE)));
|
||||
i = 0;
|
||||
while(i < streamNames.length)
|
||||
{
|
||||
netConnection.call(DVRCastConstants.RPC_UNSUBSCRIBE,null,streamNames[i]);
|
||||
++i;
|
||||
}
|
||||
netConnection = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = new DVRCastRecordingInfo();
|
||||
_loc3_.startDuration = _loc2_.streamInfo.currentLength;
|
||||
_loc3_.startOffset = calculateOffset(_loc2_.streamInfo);
|
||||
_loc3_.startTime = new Date();
|
||||
streamingResource.addMetadataValue(DVRCastConstants.STREAM_INFO_KEY,_loc2_.streamInfo);
|
||||
streamingResource.addMetadataValue(DVRCastConstants.RECORDING_INFO_KEY,_loc3_);
|
||||
subscribedStreams[netConnection] = streamNames[0];
|
||||
dispatchEvent(new NetConnectionFactoryEvent(NetConnectionFactoryEvent.CREATION_COMPLETE,false,false,netConnection,urlResource));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
onServerCallError(_loc2_.error);
|
||||
}
|
||||
};
|
||||
onServerCallError = function(param1:Object):void
|
||||
{
|
||||
dispatchEvent(new NetConnectionFactoryEvent(NetConnectionFactoryEvent.CREATION_ERROR,false,false,netConnection,urlResource,new MediaError(MediaErrorCodes.DVRCAST_SUBSCRIBE_FAILED,param1 ? param1.message : "")));
|
||||
};
|
||||
urlResource = event.resource as URLResource;
|
||||
netConnection = event.netConnection;
|
||||
streamNames = new Vector.<String>();
|
||||
totalRpcSubscribeInvocation = 0;
|
||||
event.stopImmediatePropagation();
|
||||
streamingResource = urlResource as StreamingURLResource;
|
||||
urlIncludesFMSApplicationInstance = streamingResource ? streamingResource.urlIncludesFMSApplicationInstance : false;
|
||||
dynamicResource = streamingResource as DynamicStreamingResource;
|
||||
if(dynamicResource != null)
|
||||
{
|
||||
items = dynamicResource.streamItems;
|
||||
totalRpcSubscribeInvocation = int(items.length);
|
||||
i = 0;
|
||||
while(i < items.length)
|
||||
{
|
||||
streamNames.push(items[i].streamName);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
totalRpcSubscribeInvocation = 1;
|
||||
streamNames.push(NetStreamUtils.getStreamNameFromURL(urlResource.url,urlIncludesFMSApplicationInstance));
|
||||
}
|
||||
responder = new TestableResponder(onStreamSubscriptionResult,onServerCallError);
|
||||
i = 0;
|
||||
while(i < streamNames.length)
|
||||
{
|
||||
event.netConnection.call(DVRCastConstants.RPC_SUBSCRIBE,responder,streamNames[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
private function onCreationError(param1:NetConnectionFactoryEvent) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
|
||||
private function calculateOffset(param1:DVRCastStreamInfo) : Number
|
||||
{
|
||||
return DVRUtils.calculateOffset(param1.beginOffset,param1.endOffset,param1.currentLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.net.NetStreamLoadTrait;
|
||||
import org.osmf.net.NetStreamUtils;
|
||||
import org.osmf.net.StreamType;
|
||||
import org.osmf.net.StreamingURLResource;
|
||||
import org.osmf.net.rtmpstreaming.RTMPDynamicStreamingNetLoader;
|
||||
import org.osmf.traits.LoadState;
|
||||
|
||||
public class DVRCastNetLoader extends RTMPDynamicStreamingNetLoader
|
||||
{
|
||||
|
||||
public function DVRCastNetLoader(param1:DVRCastNetConnectionFactory = null)
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
param1 = new DVRCastNetConnectionFactory();
|
||||
}
|
||||
super(param1);
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
var _loc2_:Boolean = false;
|
||||
var _loc3_:StreamingURLResource = null;
|
||||
if(super.canHandleResource(param1))
|
||||
{
|
||||
_loc3_ = param1 as StreamingURLResource;
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc2_ = _loc3_.streamType == StreamType.DVR && NetStreamUtils.isRTMPStream(_loc3_.url);
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
override protected function createNetStream(param1:NetConnection, param2:URLResource) : NetStream
|
||||
{
|
||||
return new DVRCastNetStream(param1,param2);
|
||||
}
|
||||
|
||||
override protected function processFinishLoading(param1:NetStreamLoadTrait) : void
|
||||
{
|
||||
param1.setTrait(new DVRCastDVRTrait(param1.connection,param1.netStream,param1.resource));
|
||||
param1.setTrait(new DVRCastTimeTrait(param1.connection,param1.netStream,param1.resource));
|
||||
updateLoadTrait(param1,LoadState.READY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import flash.net.NetStreamPlayOptions;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
|
||||
public class DVRCastNetStream extends NetStream
|
||||
{
|
||||
|
||||
private var recordingInfo:DVRCastRecordingInfo;
|
||||
|
||||
public function DVRCastNetStream(param1:NetConnection, param2:MediaResourceBase)
|
||||
{
|
||||
super(param1);
|
||||
this.recordingInfo = param2.getMetadataValue(DVRCastConstants.RECORDING_INFO_KEY) as DVRCastRecordingInfo;
|
||||
}
|
||||
|
||||
override public function play(... rest) : void
|
||||
{
|
||||
super.play(rest[0],this.recordingInfo.startOffset,-1);
|
||||
}
|
||||
|
||||
override public function play2(param1:NetStreamPlayOptions) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
param1.start = this.recordingInfo.startOffset;
|
||||
param1.len = -1;
|
||||
}
|
||||
super.play2(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
public class DVRCastRecordingInfo
|
||||
{
|
||||
|
||||
public var startTime:Date = null;
|
||||
|
||||
public var startDuration:Number;
|
||||
|
||||
public var startOffset:Number;
|
||||
|
||||
public function DVRCastRecordingInfo()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class DVRCastStreamInfo
|
||||
{
|
||||
|
||||
public var callTime:Date;
|
||||
|
||||
public var offline:Boolean;
|
||||
|
||||
public var beginOffset:Number;
|
||||
|
||||
public var endOffset:Number;
|
||||
|
||||
public var recordingStart:Date;
|
||||
|
||||
public var recordingEnd:Date;
|
||||
|
||||
public var isRecording:Boolean;
|
||||
|
||||
public var streamName:String;
|
||||
|
||||
public var lastUpdate:Date;
|
||||
|
||||
public var currentLength:Number;
|
||||
|
||||
public var maxLength:Number;
|
||||
|
||||
public function DVRCastStreamInfo(param1:Object)
|
||||
{
|
||||
super();
|
||||
this.readFromDynamicObject(param1);
|
||||
}
|
||||
|
||||
public function readFromDynamicObject(param1:Object) : void
|
||||
{
|
||||
var value:Object = param1;
|
||||
try
|
||||
{
|
||||
this.callTime = value.callTime;
|
||||
this.offline = value.offline;
|
||||
this.beginOffset = value.begOffset;
|
||||
this.endOffset = value.endOffset;
|
||||
this.recordingStart = value.startRec;
|
||||
this.recordingEnd = value.stopRec;
|
||||
this.isRecording = value.isRec;
|
||||
this.streamName = value.streamName;
|
||||
this.lastUpdate = value.lastUpdate;
|
||||
this.currentLength = value.currLen;
|
||||
this.maxLength = value.maxLen;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.INVALID_PARAM));
|
||||
}
|
||||
}
|
||||
|
||||
public function readFromDVRCastStreamInfo(param1:DVRCastStreamInfo) : void
|
||||
{
|
||||
var value:DVRCastStreamInfo = param1;
|
||||
try
|
||||
{
|
||||
this.callTime = value.callTime;
|
||||
this.offline = value.offline;
|
||||
this.beginOffset = value.beginOffset;
|
||||
this.endOffset = value.endOffset;
|
||||
this.recordingStart = value.recordingStart;
|
||||
this.recordingEnd = value.recordingEnd;
|
||||
this.isRecording = value.isRecording;
|
||||
this.streamName = value.streamName;
|
||||
this.lastUpdate = value.lastUpdate;
|
||||
this.currentLength = value.currentLength;
|
||||
this.maxLength = value.maxLength;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.INVALID_PARAM));
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "callTime: " + this.callTime + "\noffline: " + this.offline + "\nbeginOffset: " + this.beginOffset + "\nendOffset: " + this.endOffset + "\nrecordingStart: " + this.recordingStart + "\nrecordingEnd: " + this.recordingEnd + "\nisRecording: " + this.isRecording + "\nstreamName: " + this.streamName + "\nlastUpdate: " + this.lastUpdate + "\ncurrentLength: " + this.currentLength + "\nmaxLength: " + this.maxLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.Responder;
|
||||
import flash.utils.Timer;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
internal class DVRCastStreamInfoRetriever extends EventDispatcher
|
||||
{
|
||||
|
||||
private var connection:NetConnection;
|
||||
|
||||
private var streamName:String;
|
||||
|
||||
private var retries:Number;
|
||||
|
||||
private var timer:Timer;
|
||||
|
||||
private var _streamInfo:DVRCastStreamInfo;
|
||||
|
||||
private var _error:Object;
|
||||
|
||||
public function DVRCastStreamInfoRetriever(param1:NetConnection, param2:String)
|
||||
{
|
||||
super();
|
||||
if(param1 == null || param2 == null)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.NULL_PARAM));
|
||||
}
|
||||
this.connection = param1;
|
||||
this.streamName = param2;
|
||||
}
|
||||
|
||||
public function get streamInfo() : DVRCastStreamInfo
|
||||
{
|
||||
return this._streamInfo;
|
||||
}
|
||||
|
||||
public function get error() : Object
|
||||
{
|
||||
return this._error;
|
||||
}
|
||||
|
||||
public function retrieve(param1:int = 5, param2:Number = 3) : void
|
||||
{
|
||||
if(isNaN(this.retries))
|
||||
{
|
||||
param1 ||= 1;
|
||||
this._streamInfo = null;
|
||||
this._error = this._error = {"message":OSMFStrings.getString(OSMFStrings.DVR_MAXIMUM_RPC_ATTEMPTS).replace("%i",param1)};
|
||||
this.retries = param1;
|
||||
this.timer = new Timer(param2 * 1000,1);
|
||||
this.getStreamInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private function getStreamInfo() : void
|
||||
{
|
||||
var _loc1_:Responder = new TestableResponder(this.onGetStreamInfoResult,this.onServerCallError);
|
||||
--this.retries;
|
||||
this.connection.call(DVRCastConstants.RPC_GET_STREAM_INFO,_loc1_,this.streamName);
|
||||
}
|
||||
|
||||
private function onGetStreamInfoResult(param1:Object) : void
|
||||
{
|
||||
if(Boolean(param1) && param1.code == DVRCastConstants.RESULT_GET_STREAM_INFO_SUCCESS)
|
||||
{
|
||||
this._error = null;
|
||||
this._streamInfo = new DVRCastStreamInfo(param1.data);
|
||||
this.complete();
|
||||
}
|
||||
else if(Boolean(param1) && param1.code == DVRCastConstants.RESULT_GET_STREAM_INFO_RETRY)
|
||||
{
|
||||
if(this.retries != 0)
|
||||
{
|
||||
this.timer.addEventListener(TimerEvent.TIMER_COMPLETE,this.onTimerComplete);
|
||||
this.timer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._error = {"message":OSMFStrings.getString(OSMFStrings.DVR_UNEXPECTED_SERVER_RESPONSE) + param1.code};
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
|
||||
private function onServerCallError(param1:Object) : void
|
||||
{
|
||||
this._error = param1;
|
||||
this.complete();
|
||||
}
|
||||
|
||||
private function onTimerComplete(param1:TimerEvent) : void
|
||||
{
|
||||
this.timer.removeEventListener(TimerEvent.TIMER_COMPLETE,this.onTimerComplete);
|
||||
this.getStreamInfo();
|
||||
}
|
||||
|
||||
private function complete() : void
|
||||
{
|
||||
this.retries = NaN;
|
||||
this.timer = null;
|
||||
dispatchEvent(new Event(Event.COMPLETE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import flash.utils.Timer;
|
||||
import org.osmf.events.TimeEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.TimeTrait;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
internal class DVRCastTimeTrait extends TimeTrait
|
||||
{
|
||||
|
||||
private var durationUpdateTimer:Timer;
|
||||
|
||||
private var oldDuration:Number;
|
||||
|
||||
private var stream:NetStream;
|
||||
|
||||
private var streamInfo:DVRCastStreamInfo;
|
||||
|
||||
private var recordingInfo:DVRCastRecordingInfo;
|
||||
|
||||
public function DVRCastTimeTrait(param1:NetConnection, param2:NetStream, param3:MediaResourceBase)
|
||||
{
|
||||
super(NaN);
|
||||
if(param1 == null || param2 == null)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.NULL_PARAM));
|
||||
}
|
||||
this.stream = param2;
|
||||
param2.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatus);
|
||||
this.durationUpdateTimer = new Timer(DVRCastConstants.LOCAL_DURATION_UPDATE_INTERVAL);
|
||||
this.durationUpdateTimer.addEventListener(TimerEvent.TIMER,this.onDurationUpdateTimer);
|
||||
this.durationUpdateTimer.start();
|
||||
this.streamInfo = param3.getMetadataValue(DVRCastConstants.STREAM_INFO_KEY) as DVRCastStreamInfo;
|
||||
this.recordingInfo = param3.getMetadataValue(DVRCastConstants.RECORDING_INFO_KEY) as DVRCastRecordingInfo;
|
||||
}
|
||||
|
||||
override public function get duration() : Number
|
||||
{
|
||||
var _loc1_:Number = NaN;
|
||||
if(this.streamInfo.isRecording)
|
||||
{
|
||||
_loc1_ = this.recordingInfo.startDuration - this.recordingInfo.startOffset + (new Date().time - this.recordingInfo.startTime.time) / 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_ = this.streamInfo.currentLength - this.recordingInfo.startOffset;
|
||||
}
|
||||
return isNaN(_loc1_) ? NaN : Math.max(0,_loc1_);
|
||||
}
|
||||
|
||||
override public function get currentTime() : Number
|
||||
{
|
||||
return this.stream.time;
|
||||
}
|
||||
|
||||
private function onDurationUpdateTimer(param1:TimerEvent) : void
|
||||
{
|
||||
var _loc2_:Number = this.duration;
|
||||
if(_loc2_ != this.oldDuration)
|
||||
{
|
||||
this.oldDuration = _loc2_;
|
||||
dispatchEvent(new TimeEvent(TimeEvent.DURATION_CHANGE,false,false,_loc2_));
|
||||
}
|
||||
}
|
||||
|
||||
private function onNetStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
if(param1.info.code == "NetStream.Play.Stop")
|
||||
{
|
||||
if(this.durationUpdateTimer)
|
||||
{
|
||||
this.durationUpdateTimer.stop();
|
||||
}
|
||||
signalComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
public class DVRUtils
|
||||
{
|
||||
|
||||
public function DVRUtils()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function calculateOffset(param1:Number, param2:Number, param3:Number) : Number
|
||||
{
|
||||
var _loc4_:Number = 0;
|
||||
if(param2 != 0)
|
||||
{
|
||||
if(param3 > param2)
|
||||
{
|
||||
_loc4_ = param3 - param2;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = Math.min(param1,param3);
|
||||
}
|
||||
}
|
||||
else if(param1 != 0)
|
||||
{
|
||||
_loc4_ = Math.min(param1,param3);
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.net.Responder;
|
||||
|
||||
internal class TestableResponder extends Responder
|
||||
{
|
||||
|
||||
private var _result:Function;
|
||||
|
||||
private var _status:Function;
|
||||
|
||||
public function TestableResponder(param1:Function, param2:Function = null)
|
||||
{
|
||||
this._result = param1;
|
||||
this._status = param2;
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
internal function get result() : Function
|
||||
{
|
||||
return this._result;
|
||||
}
|
||||
|
||||
internal function get status() : Function
|
||||
{
|
||||
return this._status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user