mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-20 01: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,84 @@
|
||||
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.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;
|
||||
streamInfo = param3.getMetadataValue("http://www.osmf.org/dvrCast/1.0/streamInfo") as DVRCastStreamInfo;
|
||||
recordingInfo = param3.getMetadataValue("http://www.osmf.org/dvrCast/1.0/recordingInfo") as DVRCastRecordingInfo;
|
||||
streamInfoRetriever = new DVRCastStreamInfoRetriever(param1,streamInfo.streamName);
|
||||
streamInfoRetriever.addEventListener("complete",onStreamInfoRetrieverComplete);
|
||||
streamInfoUpdateTimer = new Timer(3000);
|
||||
streamInfoUpdateTimer.addEventListener("timer",onStreamInfoUpdateTimer);
|
||||
streamInfoUpdateTimer.start();
|
||||
super(streamInfo.isRecording);
|
||||
updateProperties();
|
||||
return;
|
||||
}
|
||||
throw new IllegalOperationError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
|
||||
override protected function isRecordingChangeStart(param1:Boolean) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
recordingInfo.startDuration = streamInfo.currentLength;
|
||||
recordingInfo.startTime = new Date();
|
||||
}
|
||||
}
|
||||
|
||||
private function updateProperties() : void
|
||||
{
|
||||
setIsRecording(streamInfo.isRecording);
|
||||
}
|
||||
|
||||
private function onStreamInfoUpdateTimer(param1:TimerEvent) : void
|
||||
{
|
||||
streamInfoRetriever.retrieve();
|
||||
}
|
||||
|
||||
private function onStreamInfoRetrieverComplete(param1:Event) : void
|
||||
{
|
||||
if(streamInfoRetriever.streamInfo != null)
|
||||
{
|
||||
streamInfo.readFromDVRCastStreamInfo(streamInfoRetriever.streamInfo);
|
||||
updateProperties();
|
||||
}
|
||||
else
|
||||
{
|
||||
dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(22)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
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.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)
|
||||
{
|
||||
innerFactory = param1 || new NetConnectionFactory();
|
||||
innerFactory.addEventListener("creationComplete",onCreationComplete);
|
||||
innerFactory.addEventListener("creationError",onCreationError);
|
||||
super();
|
||||
}
|
||||
|
||||
override public function create(param1:URLResource) : void
|
||||
{
|
||||
innerFactory.create(param1);
|
||||
}
|
||||
|
||||
override public function closeNetConnection(param1:NetConnection) : void
|
||||
{
|
||||
var _loc2_:String = subscribedStreams[param1];
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
param1.call("DVRUnsubscribe",null,_loc2_);
|
||||
delete subscribedStreams[param1];
|
||||
}
|
||||
innerFactory.closeNetConnection(param1);
|
||||
}
|
||||
|
||||
private function onCreationComplete(param1:NetConnectionFactoryEvent) : void
|
||||
{
|
||||
var streamingResource:StreamingURLResource;
|
||||
var urlIncludesFMSApplicationInstance:Boolean;
|
||||
var dynamicResource:DynamicStreamingResource;
|
||||
var items:Vector.<DynamicStreamingItem>;
|
||||
var i:int;
|
||||
var responder:Responder;
|
||||
var event:NetConnectionFactoryEvent = param1;
|
||||
var onStreamSubscriptionResult:* = function(param1:Object):void
|
||||
{
|
||||
var _loc2_:DVRCastStreamInfoRetriever = null;
|
||||
totalRpcSubscribeInvocation = totalRpcSubscribeInvocation - 1;
|
||||
if(totalRpcSubscribeInvocation <= 0)
|
||||
{
|
||||
_loc2_ = new DVRCastStreamInfoRetriever(netConnection,streamNames[0]);
|
||||
_loc2_.addEventListener("complete",onStreamInfoRetrieverComplete);
|
||||
_loc2_.retrieve();
|
||||
}
|
||||
};
|
||||
var onStreamInfoRetrieverComplete:* = function(param1:Event):void
|
||||
{
|
||||
var _loc2_:DVRCastRecordingInfo = null;
|
||||
var _loc3_:DVRCastStreamInfoRetriever = param1.target as DVRCastStreamInfoRetriever;
|
||||
removeEventListener("creationComplete",onCreationComplete);
|
||||
if(_loc3_.streamInfo != null)
|
||||
{
|
||||
if(_loc3_.streamInfo.offline == true)
|
||||
{
|
||||
dispatchEvent(new NetConnectionFactoryEvent("creationError",false,false,netConnection,urlResource,new MediaError(21)));
|
||||
i = 0;
|
||||
while(i < streamNames.length)
|
||||
{
|
||||
netConnection.call("DVRUnsubscribe",null,streamNames[i]);
|
||||
i = i + 1;
|
||||
}
|
||||
netConnection = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = new DVRCastRecordingInfo();
|
||||
_loc2_.startDuration = _loc3_.streamInfo.currentLength;
|
||||
_loc2_.startOffset = calculateOffset(_loc3_.streamInfo);
|
||||
_loc2_.startTime = new Date();
|
||||
streamingResource.addMetadataValue("http://www.osmf.org/dvrCast/1.0/streamInfo",_loc3_.streamInfo);
|
||||
streamingResource.addMetadataValue("http://www.osmf.org/dvrCast/1.0/recordingInfo",_loc2_);
|
||||
subscribedStreams[netConnection] = streamNames[0];
|
||||
dispatchEvent(new NetConnectionFactoryEvent("creationComplete",false,false,netConnection,urlResource));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
onServerCallError(_loc3_.error);
|
||||
}
|
||||
};
|
||||
var onServerCallError:* = function(param1:Object):void
|
||||
{
|
||||
dispatchEvent(new NetConnectionFactoryEvent("creationError",false,false,netConnection,urlResource,new MediaError(20,param1 ? param1.message : "")));
|
||||
};
|
||||
var urlResource:URLResource = event.resource as URLResource;
|
||||
var netConnection:NetConnection = event.netConnection;
|
||||
var streamNames:Vector.<String> = new Vector.<String>();
|
||||
var totalRpcSubscribeInvocation:int = 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 = i + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
totalRpcSubscribeInvocation = 1;
|
||||
streamNames.push(NetStreamUtils.getStreamNameFromURL(urlResource.url,urlIncludesFMSApplicationInstance));
|
||||
}
|
||||
responder = new TestableResponder(onStreamSubscriptionResult,onServerCallError);
|
||||
i = 0;
|
||||
while(i < streamNames.length)
|
||||
{
|
||||
event.netConnection.call("DVRSubscribe",responder,streamNames[i]);
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
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,52 @@
|
||||
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.StreamingURLResource;
|
||||
import org.osmf.net.rtmpstreaming.RTMPDynamicStreamingNetLoader;
|
||||
|
||||
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 == "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,"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);
|
||||
recordingInfo = param2.getMetadataValue("http://www.osmf.org/dvrCast/1.0/recordingInfo") as DVRCastRecordingInfo;
|
||||
}
|
||||
|
||||
override public function play(... rest) : void
|
||||
{
|
||||
super.play(rest[0],recordingInfo.startOffset,-1);
|
||||
}
|
||||
|
||||
override public function play2(param1:NetStreamPlayOptions) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
param1.start = 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,87 @@
|
||||
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();
|
||||
readFromDynamicObject(param1);
|
||||
}
|
||||
|
||||
public function readFromDynamicObject(param1:Object) : void
|
||||
{
|
||||
try
|
||||
{
|
||||
callTime = param1.callTime;
|
||||
offline = param1.offline;
|
||||
beginOffset = param1.begOffset;
|
||||
endOffset = param1.endOffset;
|
||||
recordingStart = param1.startRec;
|
||||
recordingEnd = param1.stopRec;
|
||||
isRecording = param1.isRec;
|
||||
streamName = param1.streamName;
|
||||
lastUpdate = param1.lastUpdate;
|
||||
currentLength = param1.currLen;
|
||||
maxLength = param1.maxLen;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
}
|
||||
|
||||
public function readFromDVRCastStreamInfo(param1:DVRCastStreamInfo) : void
|
||||
{
|
||||
try
|
||||
{
|
||||
callTime = param1.callTime;
|
||||
offline = param1.offline;
|
||||
beginOffset = param1.beginOffset;
|
||||
endOffset = param1.endOffset;
|
||||
recordingStart = param1.recordingStart;
|
||||
recordingEnd = param1.recordingEnd;
|
||||
isRecording = param1.isRecording;
|
||||
streamName = param1.streamName;
|
||||
lastUpdate = param1.lastUpdate;
|
||||
currentLength = param1.currentLength;
|
||||
maxLength = param1.maxLength;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "callTime: " + callTime + "\noffline: " + offline + "\nbeginOffset: " + beginOffset + "\nendOffset: " + endOffset + "\nrecordingStart: " + recordingStart + "\nrecordingEnd: " + recordingEnd + "\nisRecording: " + isRecording + "\nstreamName: " + streamName + "\nlastUpdate: " + lastUpdate + "\ncurrentLength: " + currentLength + "\nmaxLength: " + maxLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
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("nullParam"));
|
||||
}
|
||||
this.connection = param1;
|
||||
this.streamName = param2;
|
||||
}
|
||||
|
||||
public function get streamInfo() : DVRCastStreamInfo
|
||||
{
|
||||
return _streamInfo;
|
||||
}
|
||||
|
||||
public function get error() : Object
|
||||
{
|
||||
return _error;
|
||||
}
|
||||
|
||||
public function retrieve(param1:int = 5, param2:Number = 3) : void
|
||||
{
|
||||
if(isNaN(this.retries))
|
||||
{
|
||||
if(!param1)
|
||||
{
|
||||
param1 = 1;
|
||||
}
|
||||
_streamInfo = null;
|
||||
_error = _error = {"message":OSMFStrings.getString("dvrMaximumRPCAttempts").replace("%i",param1)};
|
||||
this.retries = param1;
|
||||
timer = new Timer(param2 * 1000,1);
|
||||
getStreamInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private function getStreamInfo() : void
|
||||
{
|
||||
var _loc1_:Responder = new TestableResponder(onGetStreamInfoResult,onServerCallError);
|
||||
retries = retries - 1;
|
||||
connection.call("DVRGetStreamInfo",_loc1_,streamName);
|
||||
}
|
||||
|
||||
private function onGetStreamInfoResult(param1:Object) : void
|
||||
{
|
||||
if(param1 && param1.code == "NetStream.DVRStreamInfo.Success")
|
||||
{
|
||||
_error = null;
|
||||
_streamInfo = new DVRCastStreamInfo(param1.data);
|
||||
complete();
|
||||
}
|
||||
else if(param1 && param1.code == "NetStream.DVRStreamInfo.Retry")
|
||||
{
|
||||
if(retries != 0)
|
||||
{
|
||||
timer.addEventListener("timerComplete",onTimerComplete);
|
||||
timer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
complete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_error = {"message":OSMFStrings.getString("dvrUnexpectedServerResponse") + param1.code};
|
||||
complete();
|
||||
}
|
||||
}
|
||||
|
||||
private function onServerCallError(param1:Object) : void
|
||||
{
|
||||
_error = param1;
|
||||
complete();
|
||||
}
|
||||
|
||||
private function onTimerComplete(param1:TimerEvent) : void
|
||||
{
|
||||
timer.removeEventListener("timerComplete",onTimerComplete);
|
||||
getStreamInfo();
|
||||
}
|
||||
|
||||
private function complete() : void
|
||||
{
|
||||
retries = NaN;
|
||||
timer = null;
|
||||
dispatchEvent(new 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("nullParam"));
|
||||
}
|
||||
this.stream = param2;
|
||||
param2.addEventListener("netStatus",onNetStatus);
|
||||
durationUpdateTimer = new Timer(500);
|
||||
durationUpdateTimer.addEventListener("timer",onDurationUpdateTimer);
|
||||
durationUpdateTimer.start();
|
||||
streamInfo = param3.getMetadataValue("http://www.osmf.org/dvrCast/1.0/streamInfo") as DVRCastStreamInfo;
|
||||
recordingInfo = param3.getMetadataValue("http://www.osmf.org/dvrCast/1.0/recordingInfo") as DVRCastRecordingInfo;
|
||||
}
|
||||
|
||||
override public function get duration() : Number
|
||||
{
|
||||
var _loc1_:Number = NaN;
|
||||
if(streamInfo.isRecording)
|
||||
{
|
||||
_loc1_ = recordingInfo.startDuration - recordingInfo.startOffset + (new Date().time - recordingInfo.startTime.time) / 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_ = streamInfo.currentLength - recordingInfo.startOffset;
|
||||
}
|
||||
return isNaN(_loc1_) ? NaN : Math.max(0,_loc1_);
|
||||
}
|
||||
|
||||
override public function get currentTime() : Number
|
||||
{
|
||||
return stream.time;
|
||||
}
|
||||
|
||||
private function onDurationUpdateTimer(param1:TimerEvent) : void
|
||||
{
|
||||
var _loc2_:Number = duration;
|
||||
if(_loc2_ != oldDuration)
|
||||
{
|
||||
oldDuration = _loc2_;
|
||||
dispatchEvent(new TimeEvent("durationChange",false,false,_loc2_));
|
||||
}
|
||||
}
|
||||
|
||||
private function onNetStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
if(param1.info.code == "NetStream.Play.Stop")
|
||||
{
|
||||
if(durationUpdateTimer)
|
||||
{
|
||||
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)
|
||||
{
|
||||
_result = param1;
|
||||
_status = param2;
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
internal function get result() : Function
|
||||
{
|
||||
return _result;
|
||||
}
|
||||
|
||||
internal function get status() : Function
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user