mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 17: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,72 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
import org.osmf.net.SwitchingRuleBase;
|
||||
|
||||
public class DownloadRatioRule extends SwitchingRuleBase
|
||||
{
|
||||
|
||||
private var aggressiveUpswitch:Boolean = false;
|
||||
|
||||
public function DownloadRatioRule(param1:HTTPNetStreamMetrics, param2:Boolean = true)
|
||||
{
|
||||
super(param1);
|
||||
this.aggressiveUpswitch = param2;
|
||||
}
|
||||
|
||||
override public function getNewIndex() : int
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc1_:int = -1;
|
||||
if(httpMetrics.downloadRatio < 1)
|
||||
{
|
||||
if(httpMetrics.currentIndex > 0)
|
||||
{
|
||||
_loc2_ = getSwitchRatio(httpMetrics.currentIndex - 1);
|
||||
if(httpMetrics.downloadRatio < _loc2_)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_ = httpMetrics.currentIndex - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(httpMetrics.currentIndex < httpMetrics.maxAllowedIndex)
|
||||
{
|
||||
_loc2_ = getSwitchRatio(httpMetrics.currentIndex + 1);
|
||||
if(httpMetrics.downloadRatio >= _loc2_)
|
||||
{
|
||||
if(httpMetrics.downloadRatio > 100 || !aggressiveUpswitch)
|
||||
{
|
||||
_loc1_ = httpMetrics.currentIndex + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
while(++_loc1_ < httpMetrics.maxAllowedIndex + 1)
|
||||
{
|
||||
_loc2_ = getSwitchRatio(_loc1_);
|
||||
if(httpMetrics.downloadRatio < _loc2_)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
_loc1_--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function getSwitchRatio(param1:int) : Number
|
||||
{
|
||||
return httpMetrics.getBitrateForIndex(param1) / httpMetrics.getBitrateForIndex(metrics.currentIndex);
|
||||
}
|
||||
|
||||
private function get httpMetrics() : HTTPNetStreamMetrics
|
||||
{
|
||||
return metrics as HTTPNetStreamMetrics;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,27 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
import org.osmf.net.NetStreamMetricsBase;
|
||||
|
||||
public class HTTPNetStreamMetrics extends NetStreamMetricsBase
|
||||
{
|
||||
|
||||
private var httpNetStream:HTTPNetStream;
|
||||
|
||||
public function HTTPNetStreamMetrics(param1:HTTPNetStream)
|
||||
{
|
||||
super(param1);
|
||||
httpNetStream = param1;
|
||||
}
|
||||
|
||||
public function get downloadRatio() : Number
|
||||
{
|
||||
return httpNetStream.downloadRatio;
|
||||
}
|
||||
|
||||
public function getBitrateForIndex(param1:int) : Number
|
||||
{
|
||||
return this.resource.streamItems[param1].bitrate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
import flash.net.URLRequest;
|
||||
|
||||
public class HTTPStreamRequest
|
||||
{
|
||||
|
||||
private var _urlRequest:URLRequest;
|
||||
|
||||
private var _quality:int;
|
||||
|
||||
private var _truncateAt:Number;
|
||||
|
||||
private var _retryAfter:Number;
|
||||
|
||||
private var _unpublishNotify:Boolean;
|
||||
|
||||
public function HTTPStreamRequest(param1:String = null, param2:int = -1, param3:Number = -1, param4:Number = -1, param5:Boolean = false)
|
||||
{
|
||||
super();
|
||||
if(param1)
|
||||
{
|
||||
_urlRequest = new URLRequest(HTTPStreamingUtils.normalizeURL(param1));
|
||||
}
|
||||
else
|
||||
{
|
||||
_urlRequest = null;
|
||||
}
|
||||
_quality = param2;
|
||||
_truncateAt = param3;
|
||||
_retryAfter = param4;
|
||||
_unpublishNotify = param5;
|
||||
}
|
||||
|
||||
public function get urlRequest() : URLRequest
|
||||
{
|
||||
return _urlRequest;
|
||||
}
|
||||
|
||||
public function get retryAfter() : Number
|
||||
{
|
||||
return _retryAfter;
|
||||
}
|
||||
|
||||
public function get unpublishNotify() : Boolean
|
||||
{
|
||||
return _unpublishNotify;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.IDataInput;
|
||||
|
||||
public class HTTPStreamingFileHandlerBase extends EventDispatcher
|
||||
{
|
||||
|
||||
public function HTTPStreamingFileHandlerBase()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function beginProcessFile(param1:Boolean, param2:Number) : void
|
||||
{
|
||||
throw new IllegalOperationError("The beginProcessFile() method must be overridden by HttpStreamingFileHandlerBase\'s derived class.");
|
||||
}
|
||||
|
||||
public function get inputBytesNeeded() : Number
|
||||
{
|
||||
throw new IllegalOperationError("The inputBytesNeeded() method must be overridden by HttpStreamingFileHandlerBase\'s derived class.");
|
||||
}
|
||||
|
||||
public function processFileSegment(param1:IDataInput) : ByteArray
|
||||
{
|
||||
throw new IllegalOperationError("The processFileSegment() method must be overridden by HttpStreamingFileHandlerBase\'s derived class.");
|
||||
}
|
||||
|
||||
public function endProcessFile(param1:IDataInput) : ByteArray
|
||||
{
|
||||
throw new IllegalOperationError("The endProcessFile() method must be overridden by HttpStreamingFileHandlerBase\'s derived class.");
|
||||
}
|
||||
|
||||
public function flushFileSegment(param1:IDataInput) : ByteArray
|
||||
{
|
||||
throw new IllegalOperationError("The flushFileSegment() method must be overridden by HttpStreamingFileHandlerBase\'s derived class.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.EventDispatcher;
|
||||
|
||||
public class HTTPStreamingIndexHandlerBase extends EventDispatcher
|
||||
{
|
||||
|
||||
public function HTTPStreamingIndexHandlerBase()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function initialize(param1:Object) : void
|
||||
{
|
||||
throw new IllegalOperationError("The initialize() method must be overridden by the derived class.");
|
||||
}
|
||||
|
||||
public function processIndexData(param1:*, param2:Object) : void
|
||||
{
|
||||
throw new IllegalOperationError("The processIndexData() method must be overridden by the derived class.");
|
||||
}
|
||||
|
||||
public function getFileForTime(param1:Number, param2:int) : HTTPStreamRequest
|
||||
{
|
||||
throw new IllegalOperationError("The getFileForTime() method must be overridden by the derived class.");
|
||||
}
|
||||
|
||||
public function getNextFile(param1:int) : HTTPStreamRequest
|
||||
{
|
||||
throw new IllegalOperationError("The getNextFile() method must be overridden by the derived class.");
|
||||
}
|
||||
|
||||
public function dvrGetStreamInfo(param1:Object) : void
|
||||
{
|
||||
throw new IllegalOperationError("The dvrGetStreamInfo() method must be overridden by the derived class.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
public class HTTPStreamingIndexInfoBase
|
||||
{
|
||||
|
||||
public function HTTPStreamingIndexInfoBase()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import org.osmf.events.DVRStreamInfoEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.metadata.Metadata;
|
||||
import org.osmf.net.DynamicStreamingResource;
|
||||
import org.osmf.net.NetLoader;
|
||||
import org.osmf.net.NetStreamLoadTrait;
|
||||
import org.osmf.net.NetStreamSwitchManager;
|
||||
import org.osmf.net.NetStreamSwitchManagerBase;
|
||||
import org.osmf.net.SwitchingRuleBase;
|
||||
import org.osmf.net.httpstreaming.dvr.DVRInfo;
|
||||
import org.osmf.net.httpstreaming.dvr.HTTPStreamingDVRCastDVRTrait;
|
||||
import org.osmf.net.httpstreaming.dvr.HTTPStreamingDVRCastTimeTrait;
|
||||
import org.osmf.net.httpstreaming.f4f.HTTPStreamingF4FFileHandler;
|
||||
import org.osmf.net.httpstreaming.f4f.HTTPStreamingF4FIndexHandler;
|
||||
import org.osmf.net.rtmpstreaming.DroppedFramesRule;
|
||||
|
||||
public class HTTPStreamingNetLoader extends NetLoader
|
||||
{
|
||||
|
||||
public function HTTPStreamingNetLoader()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
return param1.getMetadataValue("http://www.osmf.org/httpstreaming/1.0") as Metadata != null;
|
||||
}
|
||||
|
||||
override protected function createNetStream(param1:NetConnection, param2:URLResource) : NetStream
|
||||
{
|
||||
var _loc3_:HTTPStreamingFileHandlerBase = new HTTPStreamingF4FFileHandler();
|
||||
var _loc4_:HTTPStreamingIndexHandlerBase = new HTTPStreamingF4FIndexHandler(_loc3_);
|
||||
var _loc5_:HTTPNetStream = new HTTPNetStream(param1,_loc4_,_loc3_);
|
||||
_loc5_.manualSwitchMode = true;
|
||||
_loc5_.indexInfo = HTTPStreamingUtils.createF4FIndexInfo(param2);
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
override protected function createNetStreamSwitchManager(param1:NetConnection, param2:NetStream, param3:DynamicStreamingResource) : NetStreamSwitchManagerBase
|
||||
{
|
||||
var _loc4_:HTTPNetStreamMetrics = null;
|
||||
if(param3 != null)
|
||||
{
|
||||
_loc4_ = new HTTPNetStreamMetrics(param2 as HTTPNetStream);
|
||||
return new NetStreamSwitchManager(param1,param2,param3,_loc4_,getDefaultSwitchingRules(_loc4_));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
override protected function processFinishLoading(param1:NetStreamLoadTrait) : void
|
||||
{
|
||||
var netStream:HTTPNetStream;
|
||||
var loadTrait:NetStreamLoadTrait = param1;
|
||||
var onDVRStreamInfo:* = function(param1:DVRStreamInfoEvent):void
|
||||
{
|
||||
netStream.removeEventListener("DVRStreamInfo",onDVRStreamInfo);
|
||||
loadTrait.setTrait(new HTTPStreamingDVRCastDVRTrait(loadTrait.connection,netStream,param1.info as DVRInfo));
|
||||
loadTrait.setTrait(new HTTPStreamingDVRCastTimeTrait(loadTrait.connection,netStream,param1.info as DVRInfo));
|
||||
updateLoadTrait(loadTrait,"ready");
|
||||
};
|
||||
var resource:URLResource = loadTrait.resource as URLResource;
|
||||
if(!dvrMetadataPresent(resource))
|
||||
{
|
||||
updateLoadTrait(loadTrait,"ready");
|
||||
return;
|
||||
}
|
||||
netStream = loadTrait.netStream as HTTPNetStream;
|
||||
netStream.addEventListener("DVRStreamInfo",onDVRStreamInfo);
|
||||
netStream.DVRGetStreamInfo(null);
|
||||
}
|
||||
|
||||
private function dvrMetadataPresent(param1:URLResource) : Boolean
|
||||
{
|
||||
var _loc2_:Metadata = param1.getMetadataValue("http://www.osmf.org/dvr/1.0") as Metadata;
|
||||
return _loc2_ != null;
|
||||
}
|
||||
|
||||
private function getDefaultSwitchingRules(param1:HTTPNetStreamMetrics) : Vector.<SwitchingRuleBase>
|
||||
{
|
||||
var _loc2_:Vector.<SwitchingRuleBase> = new Vector.<SwitchingRuleBase>();
|
||||
_loc2_.push(new DownloadRatioRule(param1));
|
||||
_loc2_.push(new DroppedFramesRule(param1));
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
internal class HTTPStreamingState
|
||||
{
|
||||
|
||||
internal static const INIT:String = "init";
|
||||
|
||||
internal static const LOAD_SEEK:String = "loadSeek";
|
||||
|
||||
internal static const LOAD_SEEK_RETRY_WAIT:String = "loadSeekRetryWait";
|
||||
|
||||
internal static const LOAD:String = "load";
|
||||
|
||||
internal static const LOAD_WAIT:String = "loadWait";
|
||||
|
||||
internal static const LOAD_NEXT:String = "loadNext";
|
||||
|
||||
internal static const LOAD_NEXT_RETRY_WAIT:String = "loadNextRetryWait";
|
||||
|
||||
internal static const PLAY_START_SEEK:String = "playStartSeek";
|
||||
|
||||
internal static const PLAY_START_NEXT:String = "playStartNext";
|
||||
|
||||
internal static const PLAY_START_COMMON:String = "playStartCommon";
|
||||
|
||||
internal static const PLAY:String = "play";
|
||||
|
||||
internal static const END_SEGMENT:String = "endSegment";
|
||||
|
||||
internal static const SEEK:String = "seek";
|
||||
|
||||
internal static const STOP:String = "stop";
|
||||
|
||||
internal static const HALT:String = "halt";
|
||||
|
||||
public function HTTPStreamingState()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import org.osmf.elements.f4mClasses.BootstrapInfo;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.metadata.Metadata;
|
||||
import org.osmf.net.DynamicStreamingItem;
|
||||
import org.osmf.net.DynamicStreamingResource;
|
||||
import org.osmf.net.httpstreaming.dvr.DVRInfo;
|
||||
import org.osmf.net.httpstreaming.f4f.HTTPStreamingF4FIndexInfo;
|
||||
import org.osmf.net.httpstreaming.f4f.HTTPStreamingF4FStreamInfo;
|
||||
|
||||
public class HTTPStreamingUtils
|
||||
{
|
||||
|
||||
public function HTTPStreamingUtils()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function createHTTPStreamingMetadata(param1:String, param2:ByteArray, param3:Vector.<String>) : Metadata
|
||||
{
|
||||
var _loc4_:Metadata = new Metadata();
|
||||
var _loc5_:BootstrapInfo = new BootstrapInfo();
|
||||
if(param1 != null && param1.length > 0)
|
||||
{
|
||||
_loc5_.url = param1;
|
||||
}
|
||||
_loc5_.data = param2;
|
||||
_loc4_.addValue("bootstrap",_loc5_);
|
||||
if(param3 != null && param3.length > 0)
|
||||
{
|
||||
_loc4_.addValue("serverBaseUrls",param3);
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
public static function createF4FIndexInfo(param1:URLResource) : HTTPStreamingF4FIndexInfo
|
||||
{
|
||||
var _loc2_:* = undefined;
|
||||
var _loc6_:* = undefined;
|
||||
var _loc4_:DVRInfo = null;
|
||||
var _loc3_:HTTPStreamingF4FIndexInfo = null;
|
||||
var _loc5_:Metadata = param1.getMetadataValue("http://www.osmf.org/httpstreaming/1.0") as Metadata;
|
||||
var _loc7_:Metadata = param1.getMetadataValue("http://www.osmf.org/dvr/1.0") as Metadata;
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
_loc2_ = _loc5_.getValue("serverBaseUrls") as Vector.<String>;
|
||||
_loc6_ = generateStreamInfos(param1);
|
||||
_loc4_ = generateDVRInfo(_loc7_);
|
||||
_loc3_ = new HTTPStreamingF4FIndexInfo(_loc2_ != null && _loc2_.length > 0 ? _loc2_[0] : null,_loc6_,_loc4_);
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public static function normalizeURL(param1:String) : String
|
||||
{
|
||||
var _loc4_:String = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc2_:String = "";
|
||||
var _loc3_:String = "";
|
||||
if(param1.indexOf("http://") == 0)
|
||||
{
|
||||
_loc3_ = "http://";
|
||||
}
|
||||
else if(param1.indexOf("https://") == 0)
|
||||
{
|
||||
_loc3_ = "https://";
|
||||
}
|
||||
if(_loc3_.length > 0)
|
||||
{
|
||||
_loc4_ = param1.substr(_loc3_.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = param1;
|
||||
}
|
||||
var _loc7_:Array = _loc4_.split("/");
|
||||
var _loc5_:int = _loc7_.indexOf("..");
|
||||
while(_loc5_ >= 0)
|
||||
{
|
||||
_loc7_.splice(_loc5_ - 1,2);
|
||||
_loc5_ = _loc7_.indexOf("..");
|
||||
}
|
||||
_loc2_ = _loc3_;
|
||||
if(_loc7_.length > 0)
|
||||
{
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc7_.length)
|
||||
{
|
||||
if(_loc6_ != 0)
|
||||
{
|
||||
_loc2_ += "/";
|
||||
}
|
||||
_loc2_ += _loc7_[_loc6_] as String;
|
||||
_loc6_++;
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private static function generateDVRInfo(param1:Metadata) : DVRInfo
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _loc2_:DVRInfo = new DVRInfo();
|
||||
_loc2_.id = "";
|
||||
_loc2_.beginOffset = NaN;
|
||||
_loc2_.endOffset = NaN;
|
||||
_loc2_.offline = false;
|
||||
if(param1.getValue("dvrId") != null)
|
||||
{
|
||||
_loc2_.id = param1.getValue("dvrId") as String;
|
||||
}
|
||||
if(param1.getValue("beginOffset") != null)
|
||||
{
|
||||
_loc2_.beginOffset = param1.getValue("beginOffset") as uint;
|
||||
}
|
||||
if(param1.getValue("endOffset") != null)
|
||||
{
|
||||
_loc2_.endOffset = param1.getValue("endOffset") as uint;
|
||||
}
|
||||
if(param1.getValue("dvrOffline") != null)
|
||||
{
|
||||
_loc2_.offline = param1.getValue("dvrOffline") as Boolean;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private static function generateStreamInfos(param1:URLResource) : Vector.<HTTPStreamingF4FStreamInfo>
|
||||
{
|
||||
var _loc5_:Object = null;
|
||||
var _loc8_:ByteArray = null;
|
||||
var _loc11_:String = null;
|
||||
var _loc10_:Vector.<HTTPStreamingF4FStreamInfo> = new Vector.<HTTPStreamingF4FStreamInfo>();
|
||||
var _loc6_:Metadata = param1.getMetadataValue("http://www.osmf.org/drm/1.0") as Metadata;
|
||||
var _loc9_:Metadata = param1.getMetadataValue("http://www.osmf.org/httpstreaming/1.0") as Metadata;
|
||||
var _loc2_:ByteArray = null;
|
||||
var _loc7_:BootstrapInfo = null;
|
||||
var _loc4_:DynamicStreamingResource = param1 as DynamicStreamingResource;
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
for each(var _loc3_:DynamicStreamingItem in _loc4_.streamItems)
|
||||
{
|
||||
_loc2_ = null;
|
||||
_loc7_ = null;
|
||||
_loc5_ = null;
|
||||
_loc8_ = null;
|
||||
if(_loc6_ != null)
|
||||
{
|
||||
_loc2_ = _loc6_.getValue("DRMAdditionalHeader" + _loc3_.streamName) as ByteArray;
|
||||
}
|
||||
if(_loc9_ != null)
|
||||
{
|
||||
_loc7_ = _loc9_.getValue("bootstrap" + _loc3_.streamName) as BootstrapInfo;
|
||||
_loc5_ = _loc9_.getValue("streamMetadata" + _loc3_.streamName);
|
||||
_loc8_ = _loc9_.getValue("xmpMetadata" + _loc3_.streamName) as ByteArray;
|
||||
}
|
||||
_loc10_.push(new HTTPStreamingF4FStreamInfo(_loc7_,_loc3_.streamName,_loc3_.bitrate,_loc2_,_loc5_,_loc8_));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_loc6_ != null)
|
||||
{
|
||||
_loc2_ = _loc6_.getValue("DRMAdditionalHeader") as ByteArray;
|
||||
}
|
||||
if(_loc9_ != null)
|
||||
{
|
||||
_loc7_ = _loc9_.getValue("bootstrap") as BootstrapInfo;
|
||||
_loc5_ = _loc9_.getValue("streamMetadata");
|
||||
_loc8_ = _loc9_.getValue("xmpMetadata") as ByteArray;
|
||||
}
|
||||
_loc11_ = param1.url;
|
||||
_loc10_.push(new HTTPStreamingF4FStreamInfo(_loc7_,_loc11_,NaN,_loc2_,_loc5_,_loc8_));
|
||||
}
|
||||
return _loc10_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.osmf.net.httpstreaming.dvr
|
||||
{
|
||||
public class DVRInfo
|
||||
{
|
||||
|
||||
public var id:String;
|
||||
|
||||
public var url:String;
|
||||
|
||||
public var beginOffset:uint = 0;
|
||||
|
||||
public var endOffset:uint = 0;
|
||||
|
||||
public var offline:Boolean;
|
||||
|
||||
public var isRecording:Boolean;
|
||||
|
||||
public var curLength:Number;
|
||||
|
||||
public var startTime:Number = NaN;
|
||||
|
||||
public function DVRInfo()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.osmf.net.httpstreaming.dvr
|
||||
{
|
||||
import flash.net.NetConnection;
|
||||
import org.osmf.events.DVRStreamInfoEvent;
|
||||
import org.osmf.net.httpstreaming.HTTPNetStream;
|
||||
import org.osmf.traits.DVRTrait;
|
||||
|
||||
public class HTTPStreamingDVRCastDVRTrait extends DVRTrait
|
||||
{
|
||||
|
||||
private var _connection:NetConnection;
|
||||
|
||||
private var _stream:HTTPNetStream;
|
||||
|
||||
private var _dvrInfo:DVRInfo;
|
||||
|
||||
public function HTTPStreamingDVRCastDVRTrait(param1:NetConnection, param2:HTTPNetStream, param3:DVRInfo)
|
||||
{
|
||||
_connection = param1;
|
||||
_stream = param2;
|
||||
_dvrInfo = param3;
|
||||
_stream.addEventListener("DVRStreamInfo",onDVRStreamInfo);
|
||||
super(param3.isRecording);
|
||||
}
|
||||
|
||||
private function onDVRStreamInfo(param1:DVRStreamInfoEvent) : void
|
||||
{
|
||||
_dvrInfo = param1.info as DVRInfo;
|
||||
setIsRecording(_dvrInfo == null ? false : _dvrInfo.isRecording);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.osmf.net.httpstreaming.dvr
|
||||
{
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.net.NetConnection;
|
||||
import org.osmf.events.DVRStreamInfoEvent;
|
||||
import org.osmf.net.httpstreaming.HTTPNetStream;
|
||||
import org.osmf.traits.TimeTrait;
|
||||
|
||||
public class HTTPStreamingDVRCastTimeTrait extends TimeTrait
|
||||
{
|
||||
|
||||
private var _connection:NetConnection;
|
||||
|
||||
private var _stream:HTTPNetStream;
|
||||
|
||||
private var _dvrInfo:DVRInfo;
|
||||
|
||||
public function HTTPStreamingDVRCastTimeTrait(param1:NetConnection, param2:HTTPNetStream, param3:DVRInfo)
|
||||
{
|
||||
super(NaN);
|
||||
_connection = param1;
|
||||
_stream = param2;
|
||||
_dvrInfo = param3;
|
||||
_stream.addEventListener("DVRStreamInfo",onDVRStreamInfo);
|
||||
_stream.addEventListener("netStatus",onNetStatus);
|
||||
}
|
||||
|
||||
override public function get duration() : Number
|
||||
{
|
||||
if(_dvrInfo == null)
|
||||
{
|
||||
return NaN;
|
||||
}
|
||||
return _dvrInfo.curLength;
|
||||
}
|
||||
|
||||
override public function get currentTime() : Number
|
||||
{
|
||||
return _stream.time;
|
||||
}
|
||||
|
||||
private function onDVRStreamInfo(param1:DVRStreamInfoEvent) : void
|
||||
{
|
||||
_dvrInfo = param1.info as DVRInfo;
|
||||
setDuration(_dvrInfo.curLength);
|
||||
}
|
||||
|
||||
private function onNetStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
var _loc2_:* = param1.info.code;
|
||||
if("NetStream.Play.UnpublishNotify" === _loc2_)
|
||||
{
|
||||
signalComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
public class AdobeBootstrapBox extends FullBox
|
||||
{
|
||||
|
||||
private var _bootstrapVersion:uint;
|
||||
|
||||
private var _profile:uint;
|
||||
|
||||
private var _live:Boolean;
|
||||
|
||||
private var _update:Boolean;
|
||||
|
||||
private var _timeScale:uint;
|
||||
|
||||
private var _currentMediaTime:Number;
|
||||
|
||||
private var _smpteTimeCodeOffset:Number;
|
||||
|
||||
private var _movieIdentifier:String;
|
||||
|
||||
private var _serverEntryCount:uint;
|
||||
|
||||
private var _serverBaseURLs:Vector.<String>;
|
||||
|
||||
private var _qualitySegmentURLModifiers:Vector.<String>;
|
||||
|
||||
private var _drmData:String;
|
||||
|
||||
private var _metadata:String;
|
||||
|
||||
private var _segmentRunTables:Vector.<AdobeSegmentRunTable>;
|
||||
|
||||
private var _fragmentRunTables:Vector.<AdobeFragmentRunTable>;
|
||||
|
||||
public function AdobeBootstrapBox()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get bootstrapVersion() : uint
|
||||
{
|
||||
return _bootstrapVersion;
|
||||
}
|
||||
|
||||
public function set bootstrapVersion(param1:uint) : void
|
||||
{
|
||||
_bootstrapVersion = param1;
|
||||
}
|
||||
|
||||
public function get profile() : uint
|
||||
{
|
||||
return _profile;
|
||||
}
|
||||
|
||||
public function set profile(param1:uint) : void
|
||||
{
|
||||
_profile = param1;
|
||||
}
|
||||
|
||||
public function get live() : Boolean
|
||||
{
|
||||
return _live;
|
||||
}
|
||||
|
||||
public function set live(param1:Boolean) : void
|
||||
{
|
||||
_live = param1;
|
||||
}
|
||||
|
||||
public function get update() : Boolean
|
||||
{
|
||||
return _update;
|
||||
}
|
||||
|
||||
public function set update(param1:Boolean) : void
|
||||
{
|
||||
_update = param1;
|
||||
}
|
||||
|
||||
public function get timeScale() : uint
|
||||
{
|
||||
return _timeScale;
|
||||
}
|
||||
|
||||
public function set timeScale(param1:uint) : void
|
||||
{
|
||||
_timeScale = param1;
|
||||
}
|
||||
|
||||
public function get currentMediaTime() : Number
|
||||
{
|
||||
return _currentMediaTime;
|
||||
}
|
||||
|
||||
public function set currentMediaTime(param1:Number) : void
|
||||
{
|
||||
_currentMediaTime = param1;
|
||||
}
|
||||
|
||||
public function get smpteTimeCodeOffset() : Number
|
||||
{
|
||||
return _smpteTimeCodeOffset;
|
||||
}
|
||||
|
||||
public function set smpteTimeCodeOffset(param1:Number) : void
|
||||
{
|
||||
_smpteTimeCodeOffset = param1;
|
||||
}
|
||||
|
||||
public function get movieIdentifier() : String
|
||||
{
|
||||
return _movieIdentifier;
|
||||
}
|
||||
|
||||
public function set movieIdentifier(param1:String) : void
|
||||
{
|
||||
_movieIdentifier = param1;
|
||||
}
|
||||
|
||||
public function get serverBaseURLs() : Vector.<String>
|
||||
{
|
||||
return _serverBaseURLs;
|
||||
}
|
||||
|
||||
public function set serverBaseURLs(param1:Vector.<String>) : void
|
||||
{
|
||||
_serverBaseURLs = param1;
|
||||
}
|
||||
|
||||
public function get qualitySegmentURLModifiers() : Vector.<String>
|
||||
{
|
||||
return _qualitySegmentURLModifiers;
|
||||
}
|
||||
|
||||
public function set qualitySegmentURLModifiers(param1:Vector.<String>) : void
|
||||
{
|
||||
_qualitySegmentURLModifiers = param1;
|
||||
}
|
||||
|
||||
public function get drmData() : String
|
||||
{
|
||||
return _drmData;
|
||||
}
|
||||
|
||||
public function set drmData(param1:String) : void
|
||||
{
|
||||
_drmData = param1;
|
||||
}
|
||||
|
||||
public function get metadata() : String
|
||||
{
|
||||
return _metadata;
|
||||
}
|
||||
|
||||
public function set metadata(param1:String) : void
|
||||
{
|
||||
_metadata = param1;
|
||||
}
|
||||
|
||||
public function get segmentRunTables() : Vector.<AdobeSegmentRunTable>
|
||||
{
|
||||
return _segmentRunTables;
|
||||
}
|
||||
|
||||
public function set segmentRunTables(param1:Vector.<AdobeSegmentRunTable>) : void
|
||||
{
|
||||
_segmentRunTables = param1;
|
||||
}
|
||||
|
||||
public function get fragmentRunTables() : Vector.<AdobeFragmentRunTable>
|
||||
{
|
||||
return _fragmentRunTables;
|
||||
}
|
||||
|
||||
public function set fragmentRunTables(param1:Vector.<AdobeFragmentRunTable>) : void
|
||||
{
|
||||
var _loc2_:AdobeFragmentRunTable = null;
|
||||
_fragmentRunTables = param1;
|
||||
if(param1 != null && param1.length > 0)
|
||||
{
|
||||
_loc2_ = param1[param1.length - 1];
|
||||
_loc2_.adjustEndEntryDurationAccrued(_currentMediaTime);
|
||||
}
|
||||
}
|
||||
|
||||
public function findSegmentId(param1:uint) : uint
|
||||
{
|
||||
return _segmentRunTables[0].findSegmentIdByFragmentId(param1);
|
||||
}
|
||||
|
||||
public function get totalFragments() : uint
|
||||
{
|
||||
var _loc4_:AdobeFragmentRunTable = _fragmentRunTables[_fragmentRunTables.length - 1];
|
||||
var _loc5_:Vector.<FragmentDurationPair> = _loc4_.fragmentDurationPairs;
|
||||
var _loc1_:FragmentDurationPair = _loc5_[_loc5_.length - 1];
|
||||
if(_loc1_.duration == 0)
|
||||
{
|
||||
_loc1_ = _loc5_[_loc5_.length - 2];
|
||||
}
|
||||
var _loc3_:Number = _currentMediaTime - _loc1_.durationAccrued;
|
||||
var _loc2_:uint = _loc3_ <= 0 ? 0 : _loc3_ / _loc1_.duration;
|
||||
return _loc1_.firstFragment + _loc2_ - 1;
|
||||
}
|
||||
|
||||
public function get totalDuration() : uint
|
||||
{
|
||||
if(_fragmentRunTables == null || _fragmentRunTables.length < 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var _loc1_:AdobeFragmentRunTable = _fragmentRunTables[0];
|
||||
return _currentMediaTime - _loc1_.fragmentDurationPairs[0].durationAccrued;
|
||||
}
|
||||
|
||||
public function contentComplete() : Boolean
|
||||
{
|
||||
var _loc1_:AdobeFragmentRunTable = _fragmentRunTables[_fragmentRunTables.length - 1];
|
||||
return _loc1_.tableComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class AdobeFragmentRandomAccessBox extends FullBox
|
||||
{
|
||||
|
||||
private var _timeScale:uint;
|
||||
|
||||
private var _localRandomAccessEntries:Vector.<LocalRandomAccessEntry>;
|
||||
|
||||
private var _globalRandomAccessEntries:Vector.<GlobalRandomAccessEntry>;
|
||||
|
||||
public function AdobeFragmentRandomAccessBox()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get timeScale() : uint
|
||||
{
|
||||
return _timeScale;
|
||||
}
|
||||
|
||||
public function set timeScale(param1:uint) : void
|
||||
{
|
||||
_timeScale = param1;
|
||||
}
|
||||
|
||||
public function get localRandomAccessEntries() : Vector.<LocalRandomAccessEntry>
|
||||
{
|
||||
return _localRandomAccessEntries;
|
||||
}
|
||||
|
||||
public function set localRandomAccessEntries(param1:Vector.<LocalRandomAccessEntry>) : void
|
||||
{
|
||||
_localRandomAccessEntries = param1;
|
||||
}
|
||||
|
||||
public function get globalRandomAccessEntries() : Vector.<GlobalRandomAccessEntry>
|
||||
{
|
||||
return _globalRandomAccessEntries;
|
||||
}
|
||||
|
||||
public function set globalRandomAccessEntries(param1:Vector.<GlobalRandomAccessEntry>) : void
|
||||
{
|
||||
_globalRandomAccessEntries = param1;
|
||||
}
|
||||
|
||||
public function findNearestKeyFrameOffset(param1:Number) : LocalRandomAccessEntry
|
||||
{
|
||||
var _loc2_:LocalRandomAccessEntry = null;
|
||||
var _loc3_:int = _localRandomAccessEntries.length - 1;
|
||||
while(_loc3_ >= 0)
|
||||
{
|
||||
_loc2_ = _localRandomAccessEntries[_loc3_];
|
||||
if(_loc2_.time <= param1)
|
||||
{
|
||||
return _loc2_;
|
||||
}
|
||||
_loc3_--;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,248 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class AdobeFragmentRunTable extends FullBox
|
||||
{
|
||||
|
||||
private var _timeScale:uint;
|
||||
|
||||
private var _qualitySegmentURLModifiers:Vector.<String>;
|
||||
|
||||
private var _fragmentDurationPairs:Vector.<FragmentDurationPair>;
|
||||
|
||||
public function AdobeFragmentRunTable()
|
||||
{
|
||||
super();
|
||||
_fragmentDurationPairs = new Vector.<FragmentDurationPair>();
|
||||
}
|
||||
|
||||
public function get timeScale() : uint
|
||||
{
|
||||
return _timeScale;
|
||||
}
|
||||
|
||||
public function set timeScale(param1:uint) : void
|
||||
{
|
||||
_timeScale = param1;
|
||||
}
|
||||
|
||||
public function get qualitySegmentURLModifiers() : Vector.<String>
|
||||
{
|
||||
return _qualitySegmentURLModifiers;
|
||||
}
|
||||
|
||||
public function set qualitySegmentURLModifiers(param1:Vector.<String>) : void
|
||||
{
|
||||
_qualitySegmentURLModifiers = param1;
|
||||
}
|
||||
|
||||
public function get fragmentDurationPairs() : Vector.<FragmentDurationPair>
|
||||
{
|
||||
return _fragmentDurationPairs;
|
||||
}
|
||||
|
||||
public function addFragmentDurationPair(param1:FragmentDurationPair) : void
|
||||
{
|
||||
_fragmentDurationPairs.push(param1);
|
||||
}
|
||||
|
||||
public function findFragmentIdByTime(param1:Number, param2:Number, param3:Boolean = false) : FragmentAccessInformation
|
||||
{
|
||||
var _loc5_:* = 0;
|
||||
if(_fragmentDurationPairs.length <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _loc4_:FragmentDurationPair = null;
|
||||
_loc5_ = 1;
|
||||
while(_loc5_ < _fragmentDurationPairs.length)
|
||||
{
|
||||
_loc4_ = _fragmentDurationPairs[_loc5_];
|
||||
if(_loc4_.durationAccrued >= param1)
|
||||
{
|
||||
return validateFragment(calculateFragmentId(_fragmentDurationPairs[_loc5_ - 1],param1),param2,param3);
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
return validateFragment(calculateFragmentId(_fragmentDurationPairs[_fragmentDurationPairs.length - 1],param1),param2,param3);
|
||||
}
|
||||
|
||||
public function validateFragment(param1:uint, param2:Number, param3:Boolean = false) : FragmentAccessInformation
|
||||
{
|
||||
var _loc9_:* = 0;
|
||||
var _loc7_:FragmentDurationPair = null;
|
||||
var _loc8_:FragmentDurationPair = null;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc10_:FragmentDurationPair = null;
|
||||
var _loc5_:uint = _fragmentDurationPairs.length - 1;
|
||||
var _loc11_:FragmentAccessInformation = null;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _loc5_)
|
||||
{
|
||||
_loc7_ = _fragmentDurationPairs[_loc9_];
|
||||
_loc8_ = _fragmentDurationPairs[_loc9_ + 1];
|
||||
if(_loc7_.firstFragment <= param1 && param1 < _loc8_.firstFragment)
|
||||
{
|
||||
if(_loc7_.duration <= 0)
|
||||
{
|
||||
_loc11_ = getNextValidFragment(_loc9_ + 1,param2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc11_ = new FragmentAccessInformation();
|
||||
_loc11_.fragId = param1;
|
||||
_loc11_.fragDuration = _loc7_.duration;
|
||||
_loc11_.fragmentEndTime = _loc7_.durationAccrued + _loc7_.duration * (param1 - _loc7_.firstFragment + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(_loc7_.firstFragment <= param1 && endOfStreamEntry(_loc8_))
|
||||
{
|
||||
if(_loc7_.duration > 0)
|
||||
{
|
||||
_loc6_ = param2 - _loc7_.durationAccrued;
|
||||
_loc12_ = (param1 - _loc7_.firstFragment + 1) * _loc7_.duration;
|
||||
_loc4_ = (param1 - _loc7_.firstFragment) * _loc7_.duration;
|
||||
if(_loc6_ > _loc4_)
|
||||
{
|
||||
if(!param3 || _loc4_ + _loc7_.duration + _loc7_.durationAccrued <= param2)
|
||||
{
|
||||
_loc11_ = new FragmentAccessInformation();
|
||||
_loc11_.fragId = param1;
|
||||
_loc11_.fragDuration = _loc7_.duration;
|
||||
if(_loc6_ >= _loc12_)
|
||||
{
|
||||
_loc11_.fragmentEndTime = _loc7_.durationAccrued + _loc12_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc11_.fragmentEndTime = _loc7_.durationAccrued + _loc6_;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
if(_loc11_ == null)
|
||||
{
|
||||
_loc10_ = _fragmentDurationPairs[_loc5_];
|
||||
if(_loc10_.duration > 0 && param1 >= _loc10_.firstFragment)
|
||||
{
|
||||
_loc6_ = param2 - _loc10_.durationAccrued;
|
||||
_loc12_ = (param1 - _loc10_.firstFragment + 1) * _loc10_.duration;
|
||||
_loc4_ = (param1 - _loc10_.firstFragment) * _loc10_.duration;
|
||||
if(_loc6_ > _loc4_)
|
||||
{
|
||||
if(!param3 || _loc4_ + _loc10_.duration + _loc10_.durationAccrued <= param2)
|
||||
{
|
||||
_loc11_ = new FragmentAccessInformation();
|
||||
_loc11_.fragId = param1;
|
||||
_loc11_.fragDuration = _loc10_.duration;
|
||||
if(_loc6_ >= _loc12_)
|
||||
{
|
||||
_loc11_.fragmentEndTime = _loc10_.durationAccrued + _loc12_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc11_.fragmentEndTime = _loc10_.durationAccrued + _loc6_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc11_;
|
||||
}
|
||||
|
||||
private function getNextValidFragment(param1:uint, param2:Number) : FragmentAccessInformation
|
||||
{
|
||||
var _loc4_:* = 0;
|
||||
var _loc3_:FragmentDurationPair = null;
|
||||
var _loc5_:FragmentAccessInformation = null;
|
||||
_loc4_ = param1;
|
||||
while(_loc4_ < _fragmentDurationPairs.length)
|
||||
{
|
||||
_loc3_ = _fragmentDurationPairs[_loc4_];
|
||||
if(_loc3_.duration > 0)
|
||||
{
|
||||
_loc5_ = new FragmentAccessInformation();
|
||||
_loc5_.fragId = _loc3_.firstFragment;
|
||||
_loc5_.fragDuration = _loc3_.duration;
|
||||
_loc5_.fragmentEndTime = _loc3_.durationAccrued + _loc3_.duration;
|
||||
break;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
private function endOfStreamEntry(param1:FragmentDurationPair) : Boolean
|
||||
{
|
||||
return param1.duration == 0 && param1.discontinuityIndicator == 0;
|
||||
}
|
||||
|
||||
public function fragmentsLeft(param1:uint, param2:Number) : uint
|
||||
{
|
||||
if(_fragmentDurationPairs == null || _fragmentDurationPairs.length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var _loc3_:FragmentDurationPair = _fragmentDurationPairs[fragmentDurationPairs.length - 1] as FragmentDurationPair;
|
||||
return uint((param2 - _loc3_.durationAccrued) / _loc3_.duration + _loc3_.firstFragment - param1 - 1);
|
||||
}
|
||||
|
||||
public function tableComplete() : Boolean
|
||||
{
|
||||
if(_fragmentDurationPairs == null || _fragmentDurationPairs.length <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var _loc1_:FragmentDurationPair = _fragmentDurationPairs[fragmentDurationPairs.length - 1] as FragmentDurationPair;
|
||||
return _loc1_.duration == 0 && _loc1_.discontinuityIndicator == 0;
|
||||
}
|
||||
|
||||
public function adjustEndEntryDurationAccrued(param1:Number) : void
|
||||
{
|
||||
var _loc2_:FragmentDurationPair = _fragmentDurationPairs[_fragmentDurationPairs.length - 1];
|
||||
if(_loc2_.duration == 0)
|
||||
{
|
||||
_loc2_.durationAccrued = param1;
|
||||
}
|
||||
}
|
||||
|
||||
private function findValidFragmentDurationPair(param1:uint) : FragmentDurationPair
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
var _loc2_:FragmentDurationPair = null;
|
||||
_loc3_ = param1;
|
||||
while(param1 < _fragmentDurationPairs.length)
|
||||
{
|
||||
_loc2_ = _fragmentDurationPairs[_loc3_];
|
||||
if(_loc2_.duration > 0)
|
||||
{
|
||||
return _loc2_;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function calculateFragmentId(param1:FragmentDurationPair, param2:Number) : uint
|
||||
{
|
||||
if(param1.duration <= 0)
|
||||
{
|
||||
return param1.firstFragment;
|
||||
}
|
||||
var _loc3_:Number = param2 - param1.durationAccrued;
|
||||
var _loc4_:uint = _loc3_ > 0 ? _loc3_ / param1.duration : 1;
|
||||
if(_loc3_ % param1.duration > 0)
|
||||
{
|
||||
_loc4_++;
|
||||
}
|
||||
return param1.firstFragment + _loc4_ - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class AdobeSegmentRunTable extends FullBox
|
||||
{
|
||||
|
||||
private var _qualitySegmentURLModifiers:Vector.<String>;
|
||||
|
||||
private var _segmentFragmentPairs:Vector.<SegmentFragmentPair>;
|
||||
|
||||
public function AdobeSegmentRunTable()
|
||||
{
|
||||
super();
|
||||
_segmentFragmentPairs = new Vector.<SegmentFragmentPair>();
|
||||
}
|
||||
|
||||
public function get qualitySegmentURLModifiers() : Vector.<String>
|
||||
{
|
||||
return _qualitySegmentURLModifiers;
|
||||
}
|
||||
|
||||
public function set qualitySegmentURLModifiers(param1:Vector.<String>) : void
|
||||
{
|
||||
_qualitySegmentURLModifiers = param1;
|
||||
}
|
||||
|
||||
public function get segmentFragmentPairs() : Vector.<SegmentFragmentPair>
|
||||
{
|
||||
return _segmentFragmentPairs;
|
||||
}
|
||||
|
||||
public function addSegmentFragmentPair(param1:SegmentFragmentPair) : void
|
||||
{
|
||||
var _loc2_:SegmentFragmentPair = _segmentFragmentPairs.length <= 0 ? null : _segmentFragmentPairs[_segmentFragmentPairs.length - 1];
|
||||
var _loc3_:uint = 0;
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc3_ = _loc2_.fragmentsAccrued + (param1.firstSegment - _loc2_.firstSegment) * _loc2_.fragmentsPerSegment;
|
||||
}
|
||||
param1.fragmentsAccrued = _loc3_;
|
||||
_segmentFragmentPairs.push(param1);
|
||||
}
|
||||
|
||||
public function findSegmentIdByFragmentId(param1:uint) : uint
|
||||
{
|
||||
var _loc2_:SegmentFragmentPair = null;
|
||||
var _loc3_:* = 0;
|
||||
if(param1 < 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
_loc3_ = 1;
|
||||
while(_loc3_ < _segmentFragmentPairs.length)
|
||||
{
|
||||
_loc2_ = _segmentFragmentPairs[_loc3_];
|
||||
if(_loc2_.fragmentsAccrued >= param1)
|
||||
{
|
||||
return calculateSegmentId(_segmentFragmentPairs[_loc3_ - 1],param1);
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return calculateSegmentId(_segmentFragmentPairs[_segmentFragmentPairs.length - 1],param1);
|
||||
}
|
||||
|
||||
public function get totalFragments() : uint
|
||||
{
|
||||
return _segmentFragmentPairs[_segmentFragmentPairs.length - 1].fragmentsPerSegment + _segmentFragmentPairs[_segmentFragmentPairs.length - 1].fragmentsAccrued;
|
||||
}
|
||||
|
||||
private function calculateSegmentId(param1:SegmentFragmentPair, param2:uint) : uint
|
||||
{
|
||||
return param1.firstSegment + int((param2 - param1.fragmentsAccrued - 1) / param1.fragmentsPerSegment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class Box
|
||||
{
|
||||
|
||||
private var _size:Number;
|
||||
|
||||
private var _type:String;
|
||||
|
||||
private var _boxLength:uint;
|
||||
|
||||
public function Box()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get size() : Number
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
||||
public function set size(param1:Number) : void
|
||||
{
|
||||
_size = param1;
|
||||
}
|
||||
|
||||
public function get type() : String
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
public function set type(param1:String) : void
|
||||
{
|
||||
_type = param1;
|
||||
}
|
||||
|
||||
public function get boxLength() : uint
|
||||
{
|
||||
return _boxLength;
|
||||
}
|
||||
|
||||
public function set boxLength(param1:uint) : void
|
||||
{
|
||||
_boxLength = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class BoxInfo
|
||||
{
|
||||
|
||||
private var _size:Number;
|
||||
|
||||
private var _type:String;
|
||||
|
||||
public function BoxInfo(param1:Number, param2:String)
|
||||
{
|
||||
super();
|
||||
_size = param1;
|
||||
_type = param2;
|
||||
}
|
||||
|
||||
public function get size() : Number
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
||||
public function set size(param1:Number) : void
|
||||
{
|
||||
_size = param1;
|
||||
}
|
||||
|
||||
public function get type() : String
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,417 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
internal class BoxParser extends EventDispatcher
|
||||
{
|
||||
|
||||
private static const FULL_BOX_FIELD_FLAGS_LENGTH:uint = 3;
|
||||
|
||||
private static const AFRA_MASK_LONG_ID:uint = 128;
|
||||
|
||||
private static const AFRA_MASK_LONG_OFFSET:uint = 64;
|
||||
|
||||
private static const AFRA_MASK_GLOBAL_ENTRIES:uint = 32;
|
||||
|
||||
private var _ba:ByteArray;
|
||||
|
||||
public function BoxParser()
|
||||
{
|
||||
super();
|
||||
_ba = null;
|
||||
}
|
||||
|
||||
public function init(param1:ByteArray) : void
|
||||
{
|
||||
_ba = param1;
|
||||
_ba.position = 0;
|
||||
}
|
||||
|
||||
public function getNextBoxInfo() : BoxInfo
|
||||
{
|
||||
if(_ba == null || _ba.bytesAvailable < 4 + 4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _loc1_:Number = _ba.readUnsignedInt();
|
||||
var _loc2_:String = _ba.readUTFBytes(4);
|
||||
return new BoxInfo(_loc1_,_loc2_);
|
||||
}
|
||||
|
||||
public function getBoxes() : Vector.<Box>
|
||||
{
|
||||
var _loc5_:AdobeBootstrapBox = null;
|
||||
var _loc3_:AdobeFragmentRandomAccessBox = null;
|
||||
var _loc4_:MediaDataBox = null;
|
||||
var _loc1_:Vector.<Box> = new Vector.<Box>();
|
||||
var _loc2_:BoxInfo = getNextBoxInfo();
|
||||
while(_loc2_ != null)
|
||||
{
|
||||
if(_loc2_.type == "abst")
|
||||
{
|
||||
_loc5_ = new AdobeBootstrapBox();
|
||||
parseAdobeBootstrapBox(_loc2_,_loc5_);
|
||||
_loc1_.push(_loc5_);
|
||||
}
|
||||
else if(_loc2_.type == "afra")
|
||||
{
|
||||
_loc3_ = new AdobeFragmentRandomAccessBox();
|
||||
parseAdobeFragmentRandomAccessBox(_loc2_,_loc3_);
|
||||
_loc1_.push(_loc3_);
|
||||
}
|
||||
else if(_loc2_.type == "mdat")
|
||||
{
|
||||
_loc4_ = new MediaDataBox();
|
||||
parseMediaDataBox(_loc2_,_loc4_);
|
||||
_loc1_.push(_loc4_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ba.position = _ba.position + _loc2_.size - (4 + 4);
|
||||
}
|
||||
_loc2_ = getNextBoxInfo();
|
||||
if(_loc2_ != null && _loc2_.size <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function readFragmentRandomAccessBox(param1:BoxInfo) : AdobeFragmentRandomAccessBox
|
||||
{
|
||||
var _loc2_:AdobeFragmentRandomAccessBox = new AdobeFragmentRandomAccessBox();
|
||||
parseAdobeFragmentRandomAccessBox(param1,_loc2_);
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function readAdobeBootstrapBox(param1:BoxInfo) : AdobeBootstrapBox
|
||||
{
|
||||
var _loc2_:AdobeBootstrapBox = new AdobeBootstrapBox();
|
||||
this.parseAdobeBootstrapBox(param1,_loc2_);
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
internal function readLongUIntToNumber() : Number
|
||||
{
|
||||
if(_ba == null || _ba.bytesAvailable < 8)
|
||||
{
|
||||
throw new IllegalOperationError("not enough length for readLongUIntToNumer");
|
||||
}
|
||||
var _loc1_:Number = _ba.readUnsignedInt();
|
||||
_loc1_ *= 4294967296;
|
||||
return _loc1_ + _ba.readUnsignedInt();
|
||||
}
|
||||
|
||||
private function readUnsignedInt() : uint
|
||||
{
|
||||
if(_ba == null || _ba.bytesAvailable < 4)
|
||||
{
|
||||
throw new IllegalOperationError("not enough length for readUnsignedInt");
|
||||
}
|
||||
return _ba.readUnsignedInt();
|
||||
}
|
||||
|
||||
private function readBytes(param1:ByteArray, param2:uint = 0, param3:uint = 0) : void
|
||||
{
|
||||
if(_ba == null || _ba.bytesAvailable < param3)
|
||||
{
|
||||
throw new IllegalOperationError("not enough length for readBytes: " + param3);
|
||||
}
|
||||
return _ba.readBytes(param1,param2,param3);
|
||||
}
|
||||
|
||||
private function readUnsignedByte() : uint
|
||||
{
|
||||
if(_ba == null || _ba.bytesAvailable < 1)
|
||||
{
|
||||
throw new IllegalOperationError("not enough length for readUnsingedByte");
|
||||
}
|
||||
return _ba.readUnsignedByte();
|
||||
}
|
||||
|
||||
private function readBytesToUint(param1:uint) : uint
|
||||
{
|
||||
var _loc4_:* = 0;
|
||||
var _loc3_:* = 0;
|
||||
if(_ba == null || _ba.bytesAvailable < param1)
|
||||
{
|
||||
throw new IllegalOperationError("not enough length for readUnsingedByte");
|
||||
}
|
||||
if(param1 > 4)
|
||||
{
|
||||
throw new IllegalOperationError("number of bytes to read must be equal or less than 4");
|
||||
}
|
||||
var _loc2_:uint = 0;
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < param1)
|
||||
{
|
||||
_loc2_ <<= 8;
|
||||
_loc3_ = _ba.readUnsignedByte();
|
||||
_loc2_ += _loc3_;
|
||||
_loc4_++;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function readString() : String
|
||||
{
|
||||
var _loc1_:* = 0;
|
||||
var _loc2_:uint = _ba.position;
|
||||
while(_ba.position < _ba.length)
|
||||
{
|
||||
_loc1_ = uint(_ba.readByte());
|
||||
if(_loc1_ == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
var _loc3_:uint = _ba.position - _loc2_;
|
||||
_ba.position = _loc2_;
|
||||
return _ba.readUTFBytes(_loc3_);
|
||||
}
|
||||
|
||||
private function parseBox(param1:BoxInfo, param2:Box) : void
|
||||
{
|
||||
var _loc5_:ByteArray = null;
|
||||
var _loc4_:Number = param1.size;
|
||||
var _loc3_:uint = 8;
|
||||
if(param1.size == 1)
|
||||
{
|
||||
_loc4_ = readLongUIntToNumber();
|
||||
_loc3_ += 8;
|
||||
}
|
||||
if(param1.type == "uuid")
|
||||
{
|
||||
_loc5_ = new ByteArray();
|
||||
readBytes(_loc5_,0,16);
|
||||
_loc3_ += 16;
|
||||
}
|
||||
param2.size = _loc4_;
|
||||
param2.type = param1.type;
|
||||
param2.boxLength = _loc3_;
|
||||
}
|
||||
|
||||
private function parseFullBox(param1:BoxInfo, param2:FullBox) : void
|
||||
{
|
||||
parseBox(param1,param2);
|
||||
param2.version = readUnsignedByte();
|
||||
param2.flags = readBytesToUint(3);
|
||||
}
|
||||
|
||||
private function parseAdobeBootstrapBox(param1:BoxInfo, param2:AdobeBootstrapBox) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc14_:AdobeSegmentRunTable = null;
|
||||
var _loc6_:AdobeFragmentRunTable = null;
|
||||
parseFullBox(param1,param2);
|
||||
param2.bootstrapVersion = readUnsignedInt();
|
||||
var _loc3_:uint = readUnsignedByte();
|
||||
param2.profile = _loc3_ >> 6;
|
||||
param2.live = (_loc3_ & 0x20) == 32;
|
||||
param2.update = (_loc3_ & 1) == 1;
|
||||
param2.timeScale = readUnsignedInt();
|
||||
param2.currentMediaTime = readLongUIntToNumber();
|
||||
param2.smpteTimeCodeOffset = readLongUIntToNumber();
|
||||
param2.movieIdentifier = readString();
|
||||
var _loc8_:uint = readUnsignedByte();
|
||||
var _loc10_:Vector.<String> = new Vector.<String>();
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc8_)
|
||||
{
|
||||
_loc10_.push(readString());
|
||||
_loc5_++;
|
||||
}
|
||||
param2.serverBaseURLs = _loc10_;
|
||||
var _loc12_:uint = readUnsignedByte();
|
||||
var _loc13_:Vector.<String> = new Vector.<String>();
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc12_)
|
||||
{
|
||||
_loc13_.push(readString());
|
||||
_loc5_++;
|
||||
}
|
||||
param2.qualitySegmentURLModifiers = _loc13_;
|
||||
param2.drmData = readString();
|
||||
param2.metadata = readString();
|
||||
var _loc11_:uint = readUnsignedByte();
|
||||
var _loc4_:Vector.<AdobeSegmentRunTable> = new Vector.<AdobeSegmentRunTable>();
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc11_)
|
||||
{
|
||||
param1 = getNextBoxInfo();
|
||||
if(param1.type != "asrt")
|
||||
{
|
||||
throw new IllegalOperationError("Unexpected data structure: " + param1.type);
|
||||
}
|
||||
_loc14_ = new AdobeSegmentRunTable();
|
||||
parseAdobeSegmentRunTable(param1,_loc14_);
|
||||
_loc4_.push(_loc14_);
|
||||
_loc5_++;
|
||||
}
|
||||
param2.segmentRunTables = _loc4_;
|
||||
var _loc9_:uint = readUnsignedByte();
|
||||
var _loc7_:Vector.<AdobeFragmentRunTable> = new Vector.<AdobeFragmentRunTable>();
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc9_)
|
||||
{
|
||||
param1 = getNextBoxInfo();
|
||||
if(param1.type != "afrt")
|
||||
{
|
||||
throw new IllegalOperationError("Unexpected data structure: " + param1.type);
|
||||
}
|
||||
_loc6_ = new AdobeFragmentRunTable();
|
||||
parseAdobeFragmentRunTable(param1,_loc6_);
|
||||
_loc7_.push(_loc6_);
|
||||
_loc5_++;
|
||||
}
|
||||
param2.fragmentRunTables = _loc7_;
|
||||
}
|
||||
|
||||
private function parseAdobeSegmentRunTable(param1:BoxInfo, param2:AdobeSegmentRunTable) : void
|
||||
{
|
||||
var _loc6_:* = 0;
|
||||
parseFullBox(param1,param2);
|
||||
var _loc3_:uint = readUnsignedByte();
|
||||
var _loc5_:Vector.<String> = new Vector.<String>();
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc3_)
|
||||
{
|
||||
_loc5_.push(readString());
|
||||
_loc6_++;
|
||||
}
|
||||
param2.qualitySegmentURLModifiers = _loc5_;
|
||||
var _loc4_:uint = readUnsignedInt();
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc4_)
|
||||
{
|
||||
param2.addSegmentFragmentPair(new SegmentFragmentPair(readUnsignedInt(),readUnsignedInt()));
|
||||
_loc6_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function parseAdobeFragmentRunTable(param1:BoxInfo, param2:AdobeFragmentRunTable) : void
|
||||
{
|
||||
var _loc7_:* = 0;
|
||||
var _loc5_:FragmentDurationPair = null;
|
||||
parseFullBox(param1,param2);
|
||||
param2.timeScale = readUnsignedInt();
|
||||
var _loc3_:uint = readUnsignedByte();
|
||||
var _loc6_:Vector.<String> = new Vector.<String>();
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc3_)
|
||||
{
|
||||
_loc6_.push(readString());
|
||||
_loc7_++;
|
||||
}
|
||||
param2.qualitySegmentURLModifiers = _loc6_;
|
||||
var _loc4_:uint = readUnsignedInt();
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc4_)
|
||||
{
|
||||
_loc5_ = new FragmentDurationPair();
|
||||
parseFragmentDurationPair(_loc5_);
|
||||
param2.addFragmentDurationPair(_loc5_);
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function parseFragmentDurationPair(param1:FragmentDurationPair) : void
|
||||
{
|
||||
param1.firstFragment = readUnsignedInt();
|
||||
param1.durationAccrued = readLongUIntToNumber();
|
||||
param1.duration = readUnsignedInt();
|
||||
if(param1.duration == 0)
|
||||
{
|
||||
param1.discontinuityIndicator = readUnsignedByte();
|
||||
}
|
||||
}
|
||||
|
||||
private function parseAdobeFragmentRandomAccessBox(param1:BoxInfo, param2:AdobeFragmentRandomAccessBox) : void
|
||||
{
|
||||
var _loc8_:* = 0;
|
||||
var _loc7_:LocalRandomAccessEntry = null;
|
||||
var _loc12_:GlobalRandomAccessEntry = null;
|
||||
parseFullBox(param1,param2);
|
||||
var _loc5_:uint = readBytesToUint(1);
|
||||
var _loc3_:Boolean = (_loc5_ & 0x80) > 0;
|
||||
var _loc11_:Boolean = (_loc5_ & 0x40) > 0;
|
||||
var _loc6_:Boolean = (_loc5_ & 0x20) > 0;
|
||||
param2.timeScale = readUnsignedInt();
|
||||
var _loc4_:uint = readUnsignedInt();
|
||||
var _loc10_:Vector.<LocalRandomAccessEntry> = new Vector.<LocalRandomAccessEntry>();
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc4_)
|
||||
{
|
||||
_loc7_ = new LocalRandomAccessEntry();
|
||||
parseLocalRandomAccessEntry(_loc7_,_loc11_);
|
||||
_loc10_.push(_loc7_);
|
||||
_loc8_++;
|
||||
}
|
||||
param2.localRandomAccessEntries = _loc10_;
|
||||
var _loc9_:Vector.<GlobalRandomAccessEntry> = new Vector.<GlobalRandomAccessEntry>();
|
||||
if(_loc6_)
|
||||
{
|
||||
_loc4_ = readUnsignedInt();
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc4_)
|
||||
{
|
||||
_loc12_ = new GlobalRandomAccessEntry();
|
||||
parseGlobalRandomAccessEntry(_loc12_,_loc3_,_loc11_);
|
||||
_loc9_.push(_loc12_);
|
||||
_loc8_++;
|
||||
}
|
||||
}
|
||||
param2.globalRandomAccessEntries = _loc9_;
|
||||
}
|
||||
|
||||
private function parseLocalRandomAccessEntry(param1:LocalRandomAccessEntry, param2:Boolean) : void
|
||||
{
|
||||
param1.time = readLongUIntToNumber();
|
||||
if(param2)
|
||||
{
|
||||
param1.offset = readLongUIntToNumber();
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.offset = readUnsignedInt();
|
||||
}
|
||||
}
|
||||
|
||||
private function parseGlobalRandomAccessEntry(param1:GlobalRandomAccessEntry, param2:Boolean, param3:Boolean) : void
|
||||
{
|
||||
param1.time = readLongUIntToNumber();
|
||||
if(param2)
|
||||
{
|
||||
param1.segment = readUnsignedInt();
|
||||
param1.fragment = readUnsignedInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.segment = readBytesToUint(2);
|
||||
param1.fragment = readBytesToUint(2);
|
||||
}
|
||||
if(param3)
|
||||
{
|
||||
param1.afraOffset = readLongUIntToNumber();
|
||||
param1.offsetFromAfra = readLongUIntToNumber();
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.afraOffset = readUnsignedInt();
|
||||
param1.offsetFromAfra = readUnsignedInt();
|
||||
}
|
||||
}
|
||||
|
||||
private function parseMediaDataBox(param1:BoxInfo, param2:MediaDataBox) : void
|
||||
{
|
||||
parseBox(param1,param2);
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
readBytes(_loc3_,0,param2.size - param2.boxLength);
|
||||
param2.data = _loc3_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class F4FConstants
|
||||
{
|
||||
|
||||
internal static const BOX_TYPE_UUID:String = "uuid";
|
||||
|
||||
internal static const BOX_TYPE_ABST:String = "abst";
|
||||
|
||||
internal static const BOX_TYPE_ASRT:String = "asrt";
|
||||
|
||||
internal static const BOX_TYPE_AFRT:String = "afrt";
|
||||
|
||||
internal static const BOX_TYPE_AFRA:String = "afra";
|
||||
|
||||
internal static const BOX_TYPE_MDAT:String = "mdat";
|
||||
|
||||
internal static const BOX_TYPE_MOOF:String = "moof";
|
||||
|
||||
internal static const EXTENDED_TYPE:String = "uuid";
|
||||
|
||||
internal static const FIELD_SIZE_LENGTH:uint = 4;
|
||||
|
||||
internal static const FIELD_TYPE_LENGTH:uint = 4;
|
||||
|
||||
internal static const FIELD_LARGE_SIZE_LENGTH:uint = 8;
|
||||
|
||||
internal static const FIELD_EXTENDED_TYPE_LENGTH:uint = 16;
|
||||
|
||||
internal static const FLAG_USE_LARGE_SIZE:uint = 1;
|
||||
|
||||
public function F4FConstants()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class FragmentAccessInformation
|
||||
{
|
||||
|
||||
public var fragId:uint;
|
||||
|
||||
public var fragmentEndTime:Number;
|
||||
|
||||
public var fragDuration:uint;
|
||||
|
||||
public function FragmentAccessInformation()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class FragmentDurationPair
|
||||
{
|
||||
|
||||
private var _firstFragment:uint;
|
||||
|
||||
private var _duration:uint;
|
||||
|
||||
private var _durationAccrued:Number;
|
||||
|
||||
private var _discontinuityIndicator:uint = 0;
|
||||
|
||||
public function FragmentDurationPair()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get firstFragment() : uint
|
||||
{
|
||||
return _firstFragment;
|
||||
}
|
||||
|
||||
public function set firstFragment(param1:uint) : void
|
||||
{
|
||||
_firstFragment = param1;
|
||||
}
|
||||
|
||||
public function get duration() : uint
|
||||
{
|
||||
return _duration;
|
||||
}
|
||||
|
||||
public function set duration(param1:uint) : void
|
||||
{
|
||||
_duration = param1;
|
||||
}
|
||||
|
||||
public function get durationAccrued() : Number
|
||||
{
|
||||
return _durationAccrued;
|
||||
}
|
||||
|
||||
public function set durationAccrued(param1:Number) : void
|
||||
{
|
||||
_durationAccrued = param1;
|
||||
}
|
||||
|
||||
public function get discontinuityIndicator() : uint
|
||||
{
|
||||
return _discontinuityIndicator;
|
||||
}
|
||||
|
||||
public function set discontinuityIndicator(param1:uint) : void
|
||||
{
|
||||
_discontinuityIndicator = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class FullBox extends Box
|
||||
{
|
||||
|
||||
private var _version:uint;
|
||||
|
||||
private var _flags:uint;
|
||||
|
||||
public function FullBox()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get version() : uint
|
||||
{
|
||||
return _version;
|
||||
}
|
||||
|
||||
public function set version(param1:uint) : void
|
||||
{
|
||||
_version = param1;
|
||||
}
|
||||
|
||||
public function get flags() : uint
|
||||
{
|
||||
return _flags;
|
||||
}
|
||||
|
||||
public function set flags(param1:uint) : void
|
||||
{
|
||||
_flags = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class GlobalRandomAccessEntry
|
||||
{
|
||||
|
||||
private var _time:Number;
|
||||
|
||||
private var _segment:uint;
|
||||
|
||||
private var _fragment:uint;
|
||||
|
||||
private var _afraOffset:Number;
|
||||
|
||||
private var _offsetFromAfra:Number;
|
||||
|
||||
public function GlobalRandomAccessEntry()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get time() : Number
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
|
||||
public function set time(param1:Number) : void
|
||||
{
|
||||
_time = param1;
|
||||
}
|
||||
|
||||
public function get segment() : uint
|
||||
{
|
||||
return _segment;
|
||||
}
|
||||
|
||||
public function set segment(param1:uint) : void
|
||||
{
|
||||
_segment = param1;
|
||||
}
|
||||
|
||||
public function get fragment() : uint
|
||||
{
|
||||
return _fragment;
|
||||
}
|
||||
|
||||
public function set fragment(param1:uint) : void
|
||||
{
|
||||
_fragment = param1;
|
||||
}
|
||||
|
||||
public function get afraOffset() : Number
|
||||
{
|
||||
return _afraOffset;
|
||||
}
|
||||
|
||||
public function set afraOffset(param1:Number) : void
|
||||
{
|
||||
_afraOffset = param1;
|
||||
}
|
||||
|
||||
public function get offsetFromAfra() : Number
|
||||
{
|
||||
return _offsetFromAfra;
|
||||
}
|
||||
|
||||
public function set offsetFromAfra(param1:Number) : void
|
||||
{
|
||||
_offsetFromAfra = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.IDataInput;
|
||||
import org.osmf.events.HTTPStreamingFileHandlerEvent;
|
||||
import org.osmf.net.httpstreaming.HTTPStreamingFileHandlerBase;
|
||||
|
||||
public class HTTPStreamingF4FFileHandler extends HTTPStreamingFileHandlerBase
|
||||
{
|
||||
|
||||
private static const MAX_BYTES_PER_MDAT_READ:uint = 5120;
|
||||
|
||||
private var _afra:AdobeFragmentRandomAccessBox;
|
||||
|
||||
private var _ba:ByteArray;
|
||||
|
||||
private var _boxInfoPending:Boolean;
|
||||
|
||||
private var _bytesNeeded:uint;
|
||||
|
||||
private var _bytesReadSinceAfraStart:uint;
|
||||
|
||||
private var _countingReadBytes:Boolean;
|
||||
|
||||
private var _mdatBytesPending:uint;
|
||||
|
||||
private var _nextBox:BoxInfo;
|
||||
|
||||
private var _parser:BoxParser = new BoxParser();
|
||||
|
||||
private var _seekToTime:Number;
|
||||
|
||||
private var _mdatBytesOffset:Number;
|
||||
|
||||
private var _processRequestWasSeek:Boolean = false;
|
||||
|
||||
public function HTTPStreamingF4FFileHandler()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function beginProcessFile(param1:Boolean, param2:Number) : void
|
||||
{
|
||||
_processRequestWasSeek = param1;
|
||||
_seekToTime = param1 ? param2 : 0;
|
||||
_bytesNeeded = 4 + 4 + 8 + 16;
|
||||
_bytesReadSinceAfraStart = 0;
|
||||
_countingReadBytes = false;
|
||||
_boxInfoPending = true;
|
||||
_nextBox = null;
|
||||
}
|
||||
|
||||
override public function get inputBytesNeeded() : Number
|
||||
{
|
||||
return _bytesNeeded;
|
||||
}
|
||||
|
||||
override public function processFileSegment(param1:IDataInput) : ByteArray
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
var _loc5_:AdobeBootstrapBox = null;
|
||||
if(param1.bytesAvailable < _bytesNeeded)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _loc2_:ByteArray = null;
|
||||
var _loc4_:Number = 8;
|
||||
if(_boxInfoPending)
|
||||
{
|
||||
_ba = new ByteArray();
|
||||
param1.readBytes(_ba,0,_loc4_);
|
||||
if(_countingReadBytes)
|
||||
{
|
||||
_bytesReadSinceAfraStart += _loc4_;
|
||||
}
|
||||
_parser.init(_ba);
|
||||
_nextBox = _parser.getNextBoxInfo();
|
||||
if(_nextBox.size == 1)
|
||||
{
|
||||
_loc4_ += 8;
|
||||
_ba.position = 0;
|
||||
param1.readBytes(_ba,0,8);
|
||||
if(_countingReadBytes)
|
||||
{
|
||||
_bytesReadSinceAfraStart += 8;
|
||||
}
|
||||
_nextBox.size = _parser.readLongUIntToNumber();
|
||||
}
|
||||
_boxInfoPending = false;
|
||||
if(_nextBox.type == "mdat")
|
||||
{
|
||||
_bytesNeeded = 0;
|
||||
_mdatBytesPending = _nextBox.size - _loc4_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_bytesNeeded = _nextBox.size - _loc4_;
|
||||
_mdatBytesPending = 0;
|
||||
if(_nextBox.type == "afra")
|
||||
{
|
||||
_bytesReadSinceAfraStart = _loc4_;
|
||||
_countingReadBytes = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_bytesNeeded > 0)
|
||||
{
|
||||
_loc3_ = _ba.position;
|
||||
param1.readBytes(_ba,_ba.length,_nextBox.size - _loc4_);
|
||||
if(_countingReadBytes)
|
||||
{
|
||||
_bytesReadSinceAfraStart += _nextBox.size - _loc4_;
|
||||
}
|
||||
_ba.position = _loc3_;
|
||||
if(_nextBox.type == "abst")
|
||||
{
|
||||
_loc5_ = _parser.readAdobeBootstrapBox(_nextBox);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingFileHandlerEvent("notifyBootstrapBox",false,false,0,null,false,false,_loc5_));
|
||||
}
|
||||
}
|
||||
else if(_nextBox.type == "afra")
|
||||
{
|
||||
_afra = _parser.readFragmentRandomAccessBox(_nextBox);
|
||||
processSeekToTime();
|
||||
}
|
||||
else if(_nextBox.type == "moof")
|
||||
{
|
||||
}
|
||||
_bytesNeeded = 4 + 4 + 8 + 16;
|
||||
_boxInfoPending = true;
|
||||
_nextBox = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = getMDATBytes(param1,false);
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
override public function endProcessFile(param1:IDataInput) : ByteArray
|
||||
{
|
||||
if(this._bytesNeeded > 0)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingFileHandlerEvent("notifyError",false,false,0,null,false,false,null,true));
|
||||
}
|
||||
return getMDATBytes(param1,true);
|
||||
}
|
||||
|
||||
override public function flushFileSegment(param1:IDataInput) : ByteArray
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getMDATBytes(param1:IDataInput, param2:Boolean) : ByteArray
|
||||
{
|
||||
var _loc4_:ByteArray = null;
|
||||
var _loc3_:* = 0;
|
||||
if(param1 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
skipSeekBytes(param1);
|
||||
if(_mdatBytesPending > 0)
|
||||
{
|
||||
_loc3_ = _mdatBytesPending < param1.bytesAvailable ? _mdatBytesPending : param1.bytesAvailable;
|
||||
if(!param2 && _loc3_ > 5120)
|
||||
{
|
||||
_loc3_ = 5120;
|
||||
}
|
||||
_loc4_ = new ByteArray();
|
||||
_mdatBytesPending -= _loc3_;
|
||||
param1.readBytes(_loc4_,0,_loc3_);
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
private function skipSeekBytes(param1:IDataInput) : void
|
||||
{
|
||||
var _loc2_:* = 0;
|
||||
var _loc3_:ByteArray = null;
|
||||
if(_bytesReadSinceAfraStart < _mdatBytesOffset)
|
||||
{
|
||||
_loc2_ = uint(_mdatBytesOffset - _bytesReadSinceAfraStart);
|
||||
if(param1.bytesAvailable < _loc2_)
|
||||
{
|
||||
_loc2_ = param1.bytesAvailable;
|
||||
}
|
||||
_loc3_ = new ByteArray();
|
||||
param1.readBytes(_loc3_,0,_loc2_);
|
||||
_bytesReadSinceAfraStart += _loc2_;
|
||||
_mdatBytesPending -= _loc2_;
|
||||
}
|
||||
}
|
||||
|
||||
private function processSeekToTime() : void
|
||||
{
|
||||
var _loc2_:Number = 0;
|
||||
var _loc1_:LocalRandomAccessEntry = null;
|
||||
if(_seekToTime <= 0)
|
||||
{
|
||||
_mdatBytesOffset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_ = getMDATBytesOffset(_seekToTime);
|
||||
if(_loc1_ != null)
|
||||
{
|
||||
_mdatBytesOffset = _loc1_.offset;
|
||||
_loc2_ = _loc1_.time;
|
||||
}
|
||||
else
|
||||
{
|
||||
_mdatBytesOffset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getMDATBytesOffset(param1:Number) : LocalRandomAccessEntry
|
||||
{
|
||||
return !isNaN(param1) ? _afra.findNearestKeyFrameOffset(param1 * _afra.timeScale) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,495 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
import flash.net.URLRequest;
|
||||
import flash.utils.ByteArray;
|
||||
import org.osmf.elements.f4mClasses.BootstrapInfo;
|
||||
import org.osmf.events.DVRStreamInfoEvent;
|
||||
import org.osmf.events.HTTPStreamingFileHandlerEvent;
|
||||
import org.osmf.events.HTTPStreamingIndexHandlerEvent;
|
||||
import org.osmf.net.dvr.DVRUtils;
|
||||
import org.osmf.net.httpstreaming.HTTPStreamRequest;
|
||||
import org.osmf.net.httpstreaming.HTTPStreamingFileHandlerBase;
|
||||
import org.osmf.net.httpstreaming.HTTPStreamingIndexHandlerBase;
|
||||
import org.osmf.net.httpstreaming.HTTPStreamingUtils;
|
||||
import org.osmf.net.httpstreaming.flv.FLVTagScriptDataObject;
|
||||
|
||||
public class HTTPStreamingF4FIndexHandler extends HTTPStreamingIndexHandlerBase
|
||||
{
|
||||
|
||||
public static const DEFAULT_FRAGMENTS_THRESHOLD:uint = 5;
|
||||
|
||||
private var pendingIndexLoads:int;
|
||||
|
||||
private var pendingIndexUpdates:int;
|
||||
|
||||
private var bootstrapBoxes:Vector.<AdobeBootstrapBox>;
|
||||
|
||||
private var serverBaseURL:String;
|
||||
|
||||
private var streamInfos:Vector.<HTTPStreamingF4FStreamInfo>;
|
||||
|
||||
private var currentQuality:int;
|
||||
|
||||
private var currentFAI:FragmentAccessInformation;
|
||||
|
||||
private var fragmentsThreshold:uint;
|
||||
|
||||
private var fragmentRunTablesUpdating:Boolean;
|
||||
|
||||
private var f4fIndexInfo:HTTPStreamingF4FIndexInfo;
|
||||
|
||||
private var fileHandler:HTTPStreamingFileHandlerBase;
|
||||
|
||||
private var dvrGetStreamInfoCall:Boolean;
|
||||
|
||||
private var playInProgress:Boolean;
|
||||
|
||||
private var offsetFromCurrent:Number = 5;
|
||||
|
||||
private var delay:Number = 0.05;
|
||||
|
||||
private var pureLiveOffset:Number = NaN;
|
||||
|
||||
public function HTTPStreamingF4FIndexHandler(param1:HTTPStreamingFileHandlerBase, param2:uint = 5)
|
||||
{
|
||||
super();
|
||||
currentQuality = -1;
|
||||
currentFAI = null;
|
||||
fragmentRunTablesUpdating = false;
|
||||
this.fileHandler = param1;
|
||||
this.fragmentsThreshold = param2;
|
||||
dvrGetStreamInfoCall = false;
|
||||
param1.addEventListener("notifyBootstrapBox",onNewBootstrapBox);
|
||||
}
|
||||
|
||||
public function get bootstrapInfo() : AdobeBootstrapBox
|
||||
{
|
||||
return currentQuality < 0 ? null : bootstrapBoxes[currentQuality];
|
||||
}
|
||||
|
||||
override public function dvrGetStreamInfo(param1:Object) : void
|
||||
{
|
||||
dvrGetStreamInfoCall = true;
|
||||
playInProgress = false;
|
||||
initialize(param1);
|
||||
}
|
||||
|
||||
override public function initialize(param1:Object) : void
|
||||
{
|
||||
var _loc4_:AdobeBootstrapBox = null;
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:BootstrapInfo = null;
|
||||
f4fIndexInfo = param1 as HTTPStreamingF4FIndexInfo;
|
||||
if(f4fIndexInfo == null || f4fIndexInfo.streamInfos == null || f4fIndexInfo.streamInfos.length <= 0)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent("notifyError"));
|
||||
return;
|
||||
}
|
||||
bootstrapBoxes = new Vector.<AdobeBootstrapBox>(f4fIndexInfo.streamInfos.length);
|
||||
fragmentRunTablesUpdating = false;
|
||||
playInProgress = false;
|
||||
pendingIndexLoads = 0;
|
||||
pureLiveOffset = NaN;
|
||||
serverBaseURL = f4fIndexInfo.serverBaseURL;
|
||||
streamInfos = f4fIndexInfo.streamInfos;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < streamInfos.length)
|
||||
{
|
||||
_loc3_ = streamInfos[_loc2_].bootstrapInfo;
|
||||
if(_loc3_ == null || _loc3_.url == null && _loc3_.data == null)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent("notifyError"));
|
||||
return;
|
||||
}
|
||||
if(_loc3_.data != null)
|
||||
{
|
||||
_loc4_ = processBootstrapData(_loc3_.data,null);
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent("notifyError"));
|
||||
return;
|
||||
}
|
||||
bootstrapBoxes[_loc2_] = _loc4_;
|
||||
}
|
||||
else
|
||||
{
|
||||
pendingIndexLoads = pendingIndexLoads + 1;
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent("requestLoadIndex",false,false,false,NaN,null,null,new URLRequest(HTTPStreamingUtils.normalizeURL(_loc3_.url)),_loc2_,true));
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
if(pendingIndexLoads == 0)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent("notifyRates",false,false,false,NaN,getStreamNames(streamInfos),getQualityRates(streamInfos)));
|
||||
notifyIndexReady(0);
|
||||
}
|
||||
}
|
||||
|
||||
override public function processIndexData(param1:*, param2:Object) : void
|
||||
{
|
||||
var _loc3_:int = param2 as int;
|
||||
var _loc4_:AdobeBootstrapBox = processBootstrapData(param1,_loc3_);
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent("notifyError"));
|
||||
return;
|
||||
}
|
||||
if(!fragmentRunTablesUpdating)
|
||||
{
|
||||
pendingIndexLoads = pendingIndexLoads - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pendingIndexUpdates = pendingIndexUpdates - 1;
|
||||
if(pendingIndexUpdates == 0)
|
||||
{
|
||||
fragmentRunTablesUpdating = false;
|
||||
dispatchDVRStreamInfo(_loc4_);
|
||||
}
|
||||
}
|
||||
if(bootstrapBoxes[_loc3_] == null || bootstrapBoxes[_loc3_].bootstrapVersion < _loc4_.bootstrapVersion || bootstrapBoxes[_loc3_].currentMediaTime < _loc4_.currentMediaTime)
|
||||
{
|
||||
delay = 0.05;
|
||||
bootstrapBoxes[_loc3_] = _loc4_;
|
||||
}
|
||||
if(pendingIndexLoads == 0 && !fragmentRunTablesUpdating)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent("notifyRates",false,false,false,NaN,getStreamNames(streamInfos),getQualityRates(streamInfos)));
|
||||
notifyIndexReady(_loc3_);
|
||||
}
|
||||
}
|
||||
|
||||
override public function getFileForTime(param1:Number, param2:int) : HTTPStreamRequest
|
||||
{
|
||||
var _loc3_:FragmentDurationPair = null;
|
||||
var _loc4_:* = 0;
|
||||
var _loc5_:String = null;
|
||||
var _loc8_:AdobeBootstrapBox = bootstrapBoxes[param2];
|
||||
var _loc7_:HTTPStreamRequest = null;
|
||||
if(!playInProgress && stopPlaying(_loc8_))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
checkMetadata(param2,_loc8_);
|
||||
var _loc6_:AdobeFragmentRunTable = getFragmentRunTable(_loc8_);
|
||||
if(param1 >= 0 && param1 * _loc8_.timeScale <= _loc8_.currentMediaTime && param2 >= 0 && param2 < streamInfos.length)
|
||||
{
|
||||
currentFAI = _loc6_.findFragmentIdByTime(param1 * _loc8_.timeScale,_loc8_.currentMediaTime,_loc8_.contentComplete() ? false : _loc8_.live);
|
||||
if(currentFAI == null || fragmentOverflow(_loc8_,currentFAI.fragId))
|
||||
{
|
||||
if(_loc8_.contentComplete())
|
||||
{
|
||||
if(_loc8_.live)
|
||||
{
|
||||
return new HTTPStreamRequest(null,param2,-1,-1,true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
adjustDelay();
|
||||
refreshBootstrapInfo(param2);
|
||||
return new HTTPStreamRequest(null,param2,0,delay);
|
||||
}
|
||||
playInProgress = true;
|
||||
_loc3_ = _loc6_.fragmentDurationPairs[0];
|
||||
_loc4_ = _loc8_.findSegmentId(currentFAI.fragId - _loc3_.firstFragment + 1);
|
||||
_loc5_ = "";
|
||||
if((streamInfos[param2].streamName as String).indexOf("http") != 0)
|
||||
{
|
||||
_loc5_ = serverBaseURL + "/" + streamInfos[param2].streamName + "Seg" + _loc4_ + "-Frag" + currentFAI.fragId;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = streamInfos[param2].streamName + "Seg" + _loc4_ + "-Frag" + currentFAI.fragId;
|
||||
}
|
||||
_loc7_ = new HTTPStreamRequest(_loc5_);
|
||||
checkQuality(param2);
|
||||
notifyFragmentDuration(currentFAI.fragDuration / _loc8_.timeScale);
|
||||
}
|
||||
return _loc7_;
|
||||
}
|
||||
|
||||
override public function getNextFile(param1:int) : HTTPStreamRequest
|
||||
{
|
||||
var _loc5_:AdobeFragmentRunTable = null;
|
||||
var _loc6_:FragmentAccessInformation = null;
|
||||
var _loc2_:FragmentDurationPair = null;
|
||||
var _loc3_:* = 0;
|
||||
var _loc4_:String = null;
|
||||
var _loc8_:AdobeBootstrapBox = bootstrapBoxes[param1];
|
||||
var _loc7_:HTTPStreamRequest = null;
|
||||
if(!playInProgress && stopPlaying(_loc8_))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
checkMetadata(param1,_loc8_);
|
||||
if(param1 >= 0 && param1 < streamInfos.length)
|
||||
{
|
||||
_loc5_ = getFragmentRunTable(_loc8_);
|
||||
_loc6_ = currentFAI;
|
||||
currentFAI = _loc5_.validateFragment(currentFAI.fragId + 1,_loc8_.currentMediaTime,_loc8_.contentComplete() ? false : _loc8_.live);
|
||||
if(currentFAI == null || fragmentOverflow(_loc8_,currentFAI.fragId))
|
||||
{
|
||||
if(!_loc8_.live || _loc8_.contentComplete())
|
||||
{
|
||||
if(_loc8_.live)
|
||||
{
|
||||
return new HTTPStreamRequest(null,param1,-1,-1,true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
adjustDelay();
|
||||
currentFAI = _loc6_;
|
||||
refreshBootstrapInfo(param1);
|
||||
return new HTTPStreamRequest(null,param1,0,delay);
|
||||
}
|
||||
playInProgress = true;
|
||||
_loc2_ = _loc5_.fragmentDurationPairs[0];
|
||||
_loc3_ = _loc8_.findSegmentId(currentFAI.fragId - _loc2_.firstFragment + 1);
|
||||
_loc4_ = "";
|
||||
if((streamInfos[param1].streamName as String).indexOf("http") != 0)
|
||||
{
|
||||
_loc4_ = serverBaseURL + "/" + streamInfos[param1].streamName + "Seg" + _loc3_ + "-Frag" + currentFAI.fragId;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = streamInfos[param1].streamName + "Seg" + _loc3_ + "-Frag" + currentFAI.fragId;
|
||||
}
|
||||
_loc7_ = new HTTPStreamRequest(_loc4_);
|
||||
checkQuality(param1);
|
||||
notifyFragmentDuration(currentFAI.fragDuration / _loc8_.timeScale);
|
||||
}
|
||||
return _loc7_;
|
||||
}
|
||||
|
||||
internal function calculateSegmentDuration(param1:AdobeBootstrapBox, param2:Number) : Number
|
||||
{
|
||||
var _loc3_:FragmentDurationPair = null;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc5_:Vector.<FragmentDurationPair> = param1.fragmentRunTables[0].fragmentDurationPairs;
|
||||
var _loc6_:uint = currentFAI.fragId;
|
||||
var _loc7_:int = _loc5_.length - 1;
|
||||
while(_loc7_ >= 0)
|
||||
{
|
||||
_loc3_ = _loc5_[_loc7_];
|
||||
if(_loc3_.firstFragment <= _loc6_)
|
||||
{
|
||||
_loc4_ = _loc3_.duration;
|
||||
_loc8_ = _loc3_.durationAccrued;
|
||||
_loc8_ = _loc8_ + (_loc6_ - _loc3_.firstFragment) * _loc3_.duration;
|
||||
if(param2 > 0)
|
||||
{
|
||||
_loc4_ -= param2 - _loc8_;
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
_loc7_--;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function checkQuality(param1:int) : void
|
||||
{
|
||||
var _loc3_:ByteArray = null;
|
||||
var _loc2_:ByteArray = null;
|
||||
var _loc4_:FLVTagScriptDataObject = null;
|
||||
if(currentQuality != param1)
|
||||
{
|
||||
_loc3_ = currentQuality < 0 ? null : streamInfos[currentQuality].additionalHeader;
|
||||
currentQuality = param1;
|
||||
_loc2_ = streamInfos[currentQuality].additionalHeader;
|
||||
if(_loc2_ != _loc3_ && _loc2_ != null)
|
||||
{
|
||||
_loc4_ = new FLVTagScriptDataObject();
|
||||
_loc4_.data = _loc2_;
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent("notifyScriptData",false,false,false,NaN,null,null,null,null,true,0,_loc4_,true,false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function checkMetadata(param1:int, param2:AdobeBootstrapBox) : void
|
||||
{
|
||||
if(currentQuality != param1)
|
||||
{
|
||||
notifyTotalDuration(param2.totalDuration / param2.timeScale,param1);
|
||||
}
|
||||
}
|
||||
|
||||
private function refreshBootstrapInfo(param1:uint) : void
|
||||
{
|
||||
pendingIndexUpdates = pendingIndexUpdates + 1;
|
||||
fragmentRunTablesUpdating = true;
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent("requestLoadIndex",false,false,false,NaN,null,null,new URLRequest(HTTPStreamingUtils.normalizeURL((streamInfos[param1] as HTTPStreamingF4FStreamInfo).bootstrapInfo.url)),param1,true));
|
||||
}
|
||||
|
||||
private function processBootstrapData(param1:*, param2:Object) : AdobeBootstrapBox
|
||||
{
|
||||
var _loc3_:* = undefined;
|
||||
var _loc5_:AdobeBootstrapBox = null;
|
||||
var _loc4_:BoxParser = new BoxParser();
|
||||
param1.position = 0;
|
||||
_loc4_.init(param1);
|
||||
try
|
||||
{
|
||||
_loc3_ = _loc4_.getBoxes();
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
_loc3_ = null;
|
||||
}
|
||||
if(_loc3_ == null || _loc3_.length < 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_loc5_ = _loc3_[0] as AdobeBootstrapBox;
|
||||
if(_loc5_ == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if(serverBaseURL == null || serverBaseURL.length <= 0)
|
||||
{
|
||||
if(_loc5_.serverBaseURLs == null || _loc5_.serverBaseURLs.length <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
private function getQualityRates(param1:Vector.<HTTPStreamingF4FStreamInfo>) : Array
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:HTTPStreamingF4FStreamInfo = null;
|
||||
var _loc2_:Array = [];
|
||||
if(param1.length >= 1)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
_loc4_ = param1[_loc3_] as HTTPStreamingF4FStreamInfo;
|
||||
_loc2_.push(_loc4_.bitrate);
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function getStreamNames(param1:Vector.<HTTPStreamingF4FStreamInfo>) : Array
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:HTTPStreamingF4FStreamInfo = null;
|
||||
var _loc2_:Array = [];
|
||||
if(param1.length >= 1)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
_loc4_ = param1[_loc3_] as HTTPStreamingF4FStreamInfo;
|
||||
_loc2_.push(_loc4_.streamName);
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function getFragmentRunTable(param1:AdobeBootstrapBox) : AdobeFragmentRunTable
|
||||
{
|
||||
return param1.fragmentRunTables[0];
|
||||
}
|
||||
|
||||
private function notifyTotalDuration(param1:Number, param2:int) : void
|
||||
{
|
||||
var _loc4_:FLVTagScriptDataObject = new FLVTagScriptDataObject();
|
||||
var _loc3_:Object = this.f4fIndexInfo.streamInfos[param2].streamMetadata;
|
||||
if(_loc3_ == null)
|
||||
{
|
||||
_loc3_ = {};
|
||||
}
|
||||
_loc3_.duration = param1;
|
||||
_loc4_.objects = ["onMetaData",_loc3_];
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent("notifyScriptData",false,false,false,NaN,null,null,null,null,false,0,_loc4_,false,true));
|
||||
}
|
||||
|
||||
private function notifyFragmentDuration(param1:Number) : void
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent("notifySegmentDuration",false,false,false,NaN,null,null,null,null,true,param1));
|
||||
}
|
||||
|
||||
private function notifyIndexReady(param1:int) : void
|
||||
{
|
||||
var _loc3_:AdobeBootstrapBox = bootstrapBoxes[param1];
|
||||
var _loc2_:AdobeFragmentRunTable = getFragmentRunTable(_loc3_);
|
||||
dispatchDVRStreamInfo(_loc3_);
|
||||
if(!dvrGetStreamInfoCall)
|
||||
{
|
||||
if(_loc3_.live && f4fIndexInfo.dvrInfo == null && isNaN(pureLiveOffset))
|
||||
{
|
||||
pureLiveOffset = _loc3_.currentMediaTime - offsetFromCurrent * _loc3_.timeScale > 0 ? _loc3_.currentMediaTime / _loc3_.timeScale - offsetFromCurrent : NaN;
|
||||
}
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent("notifyIndexReady",false,false,_loc3_.live,pureLiveOffset));
|
||||
}
|
||||
dvrGetStreamInfoCall = false;
|
||||
}
|
||||
|
||||
private function stopPlaying(param1:AdobeBootstrapBox) : Boolean
|
||||
{
|
||||
var _loc2_:AdobeFragmentRunTable = getFragmentRunTable(param1);
|
||||
if(f4fIndexInfo.dvrInfo == null && param1.live && _loc2_.tableComplete() || f4fIndexInfo.dvrInfo != null && f4fIndexInfo.dvrInfo.offline)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function onNewBootstrapBox(param1:HTTPStreamingFileHandlerEvent) : void
|
||||
{
|
||||
var _loc2_:AdobeBootstrapBox = bootstrapBoxes[currentQuality];
|
||||
if(_loc2_.bootstrapVersion < param1.bootstrapBox.bootstrapVersion || _loc2_.currentMediaTime < param1.bootstrapBox.currentMediaTime)
|
||||
{
|
||||
bootstrapBoxes[currentQuality] = param1.bootstrapBox;
|
||||
dispatchDVRStreamInfo(param1.bootstrapBox);
|
||||
}
|
||||
}
|
||||
|
||||
private function dispatchDVRStreamInfo(param1:AdobeBootstrapBox) : void
|
||||
{
|
||||
var _loc2_:AdobeFragmentRunTable = getFragmentRunTable(param1);
|
||||
if(f4fIndexInfo.dvrInfo != null)
|
||||
{
|
||||
f4fIndexInfo.dvrInfo.isRecording = !_loc2_.tableComplete();
|
||||
if(isNaN(f4fIndexInfo.dvrInfo.startTime))
|
||||
{
|
||||
f4fIndexInfo.dvrInfo.startTime = _loc2_.tableComplete() ? 0 : DVRUtils.calculateOffset(f4fIndexInfo.dvrInfo.beginOffset < 0 || isNaN(f4fIndexInfo.dvrInfo.beginOffset) ? 0 : f4fIndexInfo.dvrInfo.beginOffset,f4fIndexInfo.dvrInfo.endOffset < 0 || isNaN(f4fIndexInfo.dvrInfo.endOffset) ? 0 : f4fIndexInfo.dvrInfo.endOffset,param1.totalDuration / param1.timeScale);
|
||||
f4fIndexInfo.dvrInfo.startTime += _loc2_.fragmentDurationPairs[0].durationAccrued / param1.timeScale;
|
||||
if(f4fIndexInfo.dvrInfo.startTime > param1.currentMediaTime)
|
||||
{
|
||||
f4fIndexInfo.dvrInfo.startTime = param1.currentMediaTime;
|
||||
}
|
||||
}
|
||||
f4fIndexInfo.dvrInfo.curLength = param1.currentMediaTime / param1.timeScale - f4fIndexInfo.dvrInfo.startTime;
|
||||
dispatchEvent(new DVRStreamInfoEvent("DVRStreamInfo",false,false,f4fIndexInfo.dvrInfo));
|
||||
}
|
||||
}
|
||||
|
||||
private function fragmentOverflow(param1:AdobeBootstrapBox, param2:uint) : Boolean
|
||||
{
|
||||
var _loc5_:AdobeFragmentRunTable = param1.fragmentRunTables[0];
|
||||
var _loc3_:FragmentDurationPair = _loc5_.fragmentDurationPairs[0];
|
||||
var _loc4_:AdobeSegmentRunTable = param1.segmentRunTables[0];
|
||||
return _loc4_ == null || _loc4_.totalFragments + _loc3_.firstFragment - 1 < param2;
|
||||
}
|
||||
|
||||
private function adjustDelay() : void
|
||||
{
|
||||
if(delay < 1)
|
||||
{
|
||||
delay *= 2;
|
||||
if(delay > 1)
|
||||
{
|
||||
delay = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
import org.osmf.net.httpstreaming.HTTPStreamingIndexInfoBase;
|
||||
import org.osmf.net.httpstreaming.dvr.DVRInfo;
|
||||
|
||||
public class HTTPStreamingF4FIndexInfo extends HTTPStreamingIndexInfoBase
|
||||
{
|
||||
|
||||
private var _serverBaseURL:String;
|
||||
|
||||
private var _dvrInfo:DVRInfo;
|
||||
|
||||
private var _streamInfos:Vector.<HTTPStreamingF4FStreamInfo>;
|
||||
|
||||
public function HTTPStreamingF4FIndexInfo(param1:String = null, param2:Vector.<HTTPStreamingF4FStreamInfo> = null, param3:DVRInfo = null)
|
||||
{
|
||||
super();
|
||||
_serverBaseURL = param1;
|
||||
_streamInfos = param2;
|
||||
_dvrInfo = param3;
|
||||
}
|
||||
|
||||
public function get serverBaseURL() : String
|
||||
{
|
||||
return _serverBaseURL;
|
||||
}
|
||||
|
||||
public function get streamInfos() : Vector.<HTTPStreamingF4FStreamInfo>
|
||||
{
|
||||
return _streamInfos;
|
||||
}
|
||||
|
||||
public function get dvrInfo() : DVRInfo
|
||||
{
|
||||
return _dvrInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import org.osmf.elements.f4mClasses.BootstrapInfo;
|
||||
|
||||
public class HTTPStreamingF4FStreamInfo
|
||||
{
|
||||
|
||||
private var _streamName:String;
|
||||
|
||||
private var _bitrate:Number;
|
||||
|
||||
private var _bootstrap:BootstrapInfo;
|
||||
|
||||
private var _additionalHeader:ByteArray;
|
||||
|
||||
private var _streamMetadata:Object;
|
||||
|
||||
private var _xmpMetadata:ByteArray;
|
||||
|
||||
public function HTTPStreamingF4FStreamInfo(param1:BootstrapInfo, param2:String, param3:Number, param4:ByteArray, param5:Object, param6:ByteArray)
|
||||
{
|
||||
super();
|
||||
_streamName = param2;
|
||||
_bitrate = param3;
|
||||
_additionalHeader = param4;
|
||||
_bootstrap = param1;
|
||||
_streamMetadata = param5;
|
||||
_xmpMetadata = param6;
|
||||
}
|
||||
|
||||
public function get streamName() : String
|
||||
{
|
||||
return _streamName;
|
||||
}
|
||||
|
||||
public function get bitrate() : Number
|
||||
{
|
||||
return _bitrate;
|
||||
}
|
||||
|
||||
public function get additionalHeader() : ByteArray
|
||||
{
|
||||
return _additionalHeader;
|
||||
}
|
||||
|
||||
public function get bootstrapInfo() : BootstrapInfo
|
||||
{
|
||||
return _bootstrap;
|
||||
}
|
||||
|
||||
public function get streamMetadata() : Object
|
||||
{
|
||||
return _streamMetadata;
|
||||
}
|
||||
|
||||
public function get xmpMetadata() : ByteArray
|
||||
{
|
||||
return _xmpMetadata;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class LocalRandomAccessEntry
|
||||
{
|
||||
|
||||
private var _time:Number;
|
||||
|
||||
private var _offset:Number;
|
||||
|
||||
public function LocalRandomAccessEntry()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get time() : Number
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
|
||||
public function set time(param1:Number) : void
|
||||
{
|
||||
_time = param1;
|
||||
}
|
||||
|
||||
public function get offset() : Number
|
||||
{
|
||||
return _offset;
|
||||
}
|
||||
|
||||
public function set offset(param1:Number) : void
|
||||
{
|
||||
_offset = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
internal class MediaDataBox extends Box
|
||||
{
|
||||
|
||||
private var _data:ByteArray;
|
||||
|
||||
public function MediaDataBox()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get data() : ByteArray
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
public function set data(param1:ByteArray) : void
|
||||
{
|
||||
_data = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class SegmentFragmentPair
|
||||
{
|
||||
|
||||
private var _firstSegment:uint;
|
||||
|
||||
private var _fragmentsPerSegment:uint;
|
||||
|
||||
private var _fragmentsAccrued:uint;
|
||||
|
||||
public function SegmentFragmentPair(param1:uint, param2:uint)
|
||||
{
|
||||
super();
|
||||
_firstSegment = param1;
|
||||
_fragmentsPerSegment = param2;
|
||||
}
|
||||
|
||||
public function get firstSegment() : uint
|
||||
{
|
||||
return _firstSegment;
|
||||
}
|
||||
|
||||
public function get fragmentsPerSegment() : uint
|
||||
{
|
||||
return _fragmentsPerSegment;
|
||||
}
|
||||
|
||||
public function set fragmentsAccrued(param1:uint) : void
|
||||
{
|
||||
_fragmentsAccrued = param1;
|
||||
}
|
||||
|
||||
public function get fragmentsAccrued() : uint
|
||||
{
|
||||
return _fragmentsAccrued;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.IDataInput;
|
||||
import flash.utils.IDataOutput;
|
||||
|
||||
public class FLVHeader
|
||||
{
|
||||
|
||||
public static const MIN_FILE_HEADER_BYTE_COUNT:int = 9;
|
||||
|
||||
private var _hasVideoTags:Boolean = true;
|
||||
|
||||
private var _hasAudioTags:Boolean = true;
|
||||
|
||||
private var offset:uint;
|
||||
|
||||
public function FLVHeader(param1:IDataInput = null)
|
||||
{
|
||||
super();
|
||||
if(param1 != null)
|
||||
{
|
||||
readHeader(param1);
|
||||
readRest(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function get hasAudioTags() : Boolean
|
||||
{
|
||||
return _hasAudioTags;
|
||||
}
|
||||
|
||||
public function set hasAudioTags(param1:Boolean) : void
|
||||
{
|
||||
_hasAudioTags = param1;
|
||||
}
|
||||
|
||||
public function get hasVideoTags() : Boolean
|
||||
{
|
||||
return _hasVideoTags;
|
||||
}
|
||||
|
||||
public function set hasVideoTags(param1:Boolean) : void
|
||||
{
|
||||
_hasVideoTags = param1;
|
||||
}
|
||||
|
||||
public function write(param1:IDataOutput) : void
|
||||
{
|
||||
param1.writeByte(70);
|
||||
param1.writeByte(76);
|
||||
param1.writeByte(86);
|
||||
param1.writeByte(1);
|
||||
var _loc3_:uint = 0;
|
||||
if(_hasAudioTags)
|
||||
{
|
||||
_loc3_ |= 4;
|
||||
}
|
||||
if(_hasVideoTags)
|
||||
{
|
||||
_loc3_ |= 1;
|
||||
}
|
||||
param1.writeByte(_loc3_);
|
||||
var _loc2_:uint = 9;
|
||||
param1.writeUnsignedInt(_loc2_);
|
||||
var _loc4_:uint = 0;
|
||||
param1.writeUnsignedInt(_loc4_);
|
||||
}
|
||||
|
||||
internal function readHeader(param1:IDataInput) : void
|
||||
{
|
||||
if(param1.bytesAvailable < 9)
|
||||
{
|
||||
throw new Error("FLVHeader() input too short");
|
||||
}
|
||||
if(param1.readByte() != 70)
|
||||
{
|
||||
throw new Error("FLVHeader readHeader() Signature[0] not \'F\'");
|
||||
}
|
||||
if(param1.readByte() != 76)
|
||||
{
|
||||
throw new Error("FLVHeader readHeader() Signature[1] not \'L\'");
|
||||
}
|
||||
if(param1.readByte() != 86)
|
||||
{
|
||||
throw new Error("FLVHeader readHeader() Signature[2] not \'V\'");
|
||||
}
|
||||
if(param1.readByte() != 1)
|
||||
{
|
||||
throw new Error("FLVHeader readHeader() Version not 0x01");
|
||||
}
|
||||
var _loc2_:int = param1.readByte();
|
||||
_hasAudioTags = _loc2_ & 4 ? true : false;
|
||||
_hasVideoTags = _loc2_ & 1 ? true : false;
|
||||
offset = param1.readUnsignedInt();
|
||||
if(offset < 9)
|
||||
{
|
||||
throw new Error("FLVHeader() offset smaller than minimum");
|
||||
}
|
||||
}
|
||||
|
||||
internal function readRest(param1:IDataInput) : void
|
||||
{
|
||||
var _loc2_:ByteArray = null;
|
||||
if(offset > 9)
|
||||
{
|
||||
if(offset - 9 < param1.bytesAvailable - 4)
|
||||
{
|
||||
throw new Error("FLVHeader() input too short for nonstandard offset");
|
||||
}
|
||||
_loc2_ = new ByteArray();
|
||||
param1.readBytes(_loc2_,0,offset - 9);
|
||||
}
|
||||
if(param1.bytesAvailable < 4)
|
||||
{
|
||||
throw new Error("FLVHeader() input too short for previousTagSize0");
|
||||
}
|
||||
param1.readUnsignedInt();
|
||||
}
|
||||
|
||||
internal function get restBytesNeeded() : int
|
||||
{
|
||||
return 4 + (offset - 9);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.IDataInput;
|
||||
import flash.utils.IDataOutput;
|
||||
|
||||
public class FLVParser
|
||||
{
|
||||
|
||||
private var state:String;
|
||||
|
||||
private var savedBytes:ByteArray;
|
||||
|
||||
private var currentTag:FLVTag = null;
|
||||
|
||||
private var flvHeader:FLVHeader;
|
||||
|
||||
public function FLVParser(param1:Boolean)
|
||||
{
|
||||
super();
|
||||
savedBytes = new ByteArray();
|
||||
if(param1)
|
||||
{
|
||||
state = "fileHeader";
|
||||
}
|
||||
else
|
||||
{
|
||||
state = "type";
|
||||
}
|
||||
}
|
||||
|
||||
public function flush(param1:IDataOutput) : void
|
||||
{
|
||||
param1.writeBytes(savedBytes);
|
||||
}
|
||||
|
||||
public function parse(param1:IDataInput, param2:Boolean, param3:Function) : void
|
||||
{
|
||||
var _loc5_:IDataInput = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc4_:Boolean = true;
|
||||
while(_loc4_)
|
||||
{
|
||||
switch(state)
|
||||
{
|
||||
case "fileHeader":
|
||||
_loc5_ = byteSource(param1,9);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
flvHeader = new FLVHeader();
|
||||
flvHeader.readHeader(_loc5_);
|
||||
state = "fileHeaderRest";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case "fileHeaderRest":
|
||||
_loc5_ = byteSource(param1,flvHeader.restBytesNeeded);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
flvHeader.readRest(_loc5_);
|
||||
state = "type";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case "type":
|
||||
_loc5_ = byteSource(param1,1);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
switch(_loc6_ = _loc5_.readByte())
|
||||
{
|
||||
case 8:
|
||||
case 40:
|
||||
currentTag = new FLVTagAudio(_loc6_);
|
||||
break;
|
||||
case 9:
|
||||
case 41:
|
||||
currentTag = new FLVTagVideo(_loc6_);
|
||||
break;
|
||||
case 18:
|
||||
case 50:
|
||||
currentTag = new FLVTagScriptDataObject(_loc6_);
|
||||
break;
|
||||
default:
|
||||
currentTag = new FLVTag(_loc6_);
|
||||
}
|
||||
state = "header";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case "header":
|
||||
_loc5_ = byteSource(param1,11 - 1);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
currentTag.readRemainingHeader(_loc5_);
|
||||
if(currentTag.dataSize)
|
||||
{
|
||||
state = "data";
|
||||
}
|
||||
else
|
||||
{
|
||||
state = "prevTag";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case "data":
|
||||
_loc5_ = byteSource(param1,currentTag.dataSize);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
currentTag.readData(_loc5_);
|
||||
state = "prevTag";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case "prevTag":
|
||||
_loc5_ = byteSource(param1,4);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
currentTag.readPrevTag(_loc5_);
|
||||
state = "type";
|
||||
_loc4_ = param3(currentTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error("FLVParser state machine in unknown state");
|
||||
}
|
||||
}
|
||||
if(param2)
|
||||
{
|
||||
param1.readBytes(savedBytes,savedBytes.length);
|
||||
}
|
||||
}
|
||||
|
||||
private function byteSource(param1:IDataInput, param2:int) : IDataInput
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
if(savedBytes.bytesAvailable + param1.bytesAvailable < param2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if(savedBytes.bytesAvailable)
|
||||
{
|
||||
_loc3_ = param2 - savedBytes.bytesAvailable;
|
||||
if(_loc3_ > 0)
|
||||
{
|
||||
param1.readBytes(savedBytes,savedBytes.length,_loc3_);
|
||||
}
|
||||
return savedBytes;
|
||||
}
|
||||
savedBytes.length = 0;
|
||||
return param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
internal class FLVParserState
|
||||
{
|
||||
|
||||
internal static const FILE_HEADER:String = "fileHeader";
|
||||
|
||||
internal static const FILE_HEADER_REST:String = "fileHeaderRest";
|
||||
|
||||
internal static const TYPE:String = "type";
|
||||
|
||||
internal static const HEADER:String = "header";
|
||||
|
||||
internal static const DATA:String = "data";
|
||||
|
||||
internal static const PREV_TAG:String = "prevTag";
|
||||
|
||||
public function FLVParserState()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.IDataInput;
|
||||
import flash.utils.IDataOutput;
|
||||
|
||||
public class FLVTag
|
||||
{
|
||||
|
||||
public static const TAG_TYPE_AUDIO:int = 8;
|
||||
|
||||
public static const TAG_TYPE_VIDEO:int = 9;
|
||||
|
||||
public static const TAG_TYPE_SCRIPTDATAOBJECT:int = 18;
|
||||
|
||||
public static const TAG_FLAG_ENCRYPTED:int = 32;
|
||||
|
||||
public static const TAG_TYPE_ENCRYPTED_AUDIO:int = 40;
|
||||
|
||||
public static const TAG_TYPE_ENCRYPTED_VIDEO:int = 41;
|
||||
|
||||
public static const TAG_TYPE_ENCRYPTED_SCRIPTDATAOBJECT:int = 50;
|
||||
|
||||
internal static const TAG_HEADER_BYTE_COUNT:int = 11;
|
||||
|
||||
internal static const PREV_TAG_BYTE_COUNT:int = 4;
|
||||
|
||||
protected var bytes:ByteArray = null;
|
||||
|
||||
public function FLVTag(param1:int)
|
||||
{
|
||||
super();
|
||||
bytes = new ByteArray();
|
||||
bytes.length = 11;
|
||||
bytes[0] = param1;
|
||||
}
|
||||
|
||||
public function read(param1:IDataInput) : void
|
||||
{
|
||||
readType(param1);
|
||||
readRemainingHeader(param1);
|
||||
readData(param1);
|
||||
readPrevTag(param1);
|
||||
}
|
||||
|
||||
public function readType(param1:IDataInput) : void
|
||||
{
|
||||
if(param1.bytesAvailable < 1)
|
||||
{
|
||||
throw new Error("FLVTag.readType() input too short");
|
||||
}
|
||||
param1.readBytes(bytes,0,1);
|
||||
}
|
||||
|
||||
public function readRemaining(param1:IDataInput) : void
|
||||
{
|
||||
readRemainingHeader(param1);
|
||||
readData(param1);
|
||||
readPrevTag(param1);
|
||||
}
|
||||
|
||||
public function readRemainingHeader(param1:IDataInput) : void
|
||||
{
|
||||
if(param1.bytesAvailable < 10)
|
||||
{
|
||||
throw new Error("FLVTag.readHeader() input too short");
|
||||
}
|
||||
param1.readBytes(bytes,1,11 - 1);
|
||||
}
|
||||
|
||||
public function readData(param1:IDataInput) : void
|
||||
{
|
||||
if(dataSize > 0)
|
||||
{
|
||||
if(param1.bytesAvailable < dataSize)
|
||||
{
|
||||
throw new Error("FLVTag().readData input shorter than dataSize");
|
||||
}
|
||||
param1.readBytes(bytes,11,dataSize);
|
||||
}
|
||||
}
|
||||
|
||||
public function readPrevTag(param1:IDataInput) : void
|
||||
{
|
||||
if(param1.bytesAvailable < 4)
|
||||
{
|
||||
throw new Error("FLVTag.readPrevTag() input too short");
|
||||
}
|
||||
param1.readUnsignedInt();
|
||||
}
|
||||
|
||||
public function write(param1:IDataOutput) : void
|
||||
{
|
||||
param1.writeBytes(bytes,0,11 + dataSize);
|
||||
param1.writeUnsignedInt(11 + dataSize);
|
||||
}
|
||||
|
||||
public function get tagType() : uint
|
||||
{
|
||||
return bytes[0];
|
||||
}
|
||||
|
||||
public function set tagType(param1:uint) : void
|
||||
{
|
||||
bytes[0] = param1;
|
||||
}
|
||||
|
||||
public function get isEncrpted() : Boolean
|
||||
{
|
||||
return bytes[0] & 0x20 ? true : false;
|
||||
}
|
||||
|
||||
public function get dataSize() : uint
|
||||
{
|
||||
return bytes[1] << 16 | bytes[2] << 8 | bytes[3];
|
||||
}
|
||||
|
||||
public function set dataSize(param1:uint) : void
|
||||
{
|
||||
bytes[1] = param1 >> 16 & 0xFF;
|
||||
bytes[2] = param1 >> 8 & 0xFF;
|
||||
bytes[3] = param1 & 0xFF;
|
||||
bytes.length = 11 + param1;
|
||||
}
|
||||
|
||||
public function get timestamp() : uint
|
||||
{
|
||||
return bytes[7] << 24 | bytes[4] << 16 | bytes[5] << 8 | bytes[6];
|
||||
}
|
||||
|
||||
public function set timestamp(param1:uint) : void
|
||||
{
|
||||
bytes[7] = param1 >> 24 & 0xFF;
|
||||
bytes[4] = param1 >> 16 & 0xFF;
|
||||
bytes[5] = param1 >> 8 & 0xFF;
|
||||
bytes[6] = param1 & 0xFF;
|
||||
}
|
||||
|
||||
public function get data() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
_loc1_.writeBytes(bytes,11,dataSize);
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function set data(param1:ByteArray) : void
|
||||
{
|
||||
bytes.length = 11 + param1.length;
|
||||
bytes.position = 11;
|
||||
bytes.writeBytes(param1,0,param1.length);
|
||||
dataSize = param1.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class FLVTagAudio extends FLVTag
|
||||
{
|
||||
|
||||
public static const SOUND_FORMAT_LINEAR:int = 0;
|
||||
|
||||
public static const SOUND_FORMAT_ADPCM:int = 1;
|
||||
|
||||
public static const SOUND_FORMAT_MP3:int = 2;
|
||||
|
||||
public static const SOUND_FORMAT_LINEAR_LE:int = 3;
|
||||
|
||||
public static const SOUND_FORMAT_NELLYMOSER_16K:int = 4;
|
||||
|
||||
public static const SOUND_FORMAT_NELLYMOSER_8K:int = 5;
|
||||
|
||||
public static const SOUND_FORMAT_NELLYMOSER:int = 6;
|
||||
|
||||
public static const SOUND_FORMAT_G711A:int = 7;
|
||||
|
||||
public static const SOUND_FORMAT_G711U:int = 8;
|
||||
|
||||
public static const SOUND_FORMAT_AAC:int = 10;
|
||||
|
||||
public static const SOUND_FORMAT_SPEEX:int = 11;
|
||||
|
||||
public static const SOUND_FORMAT_MP3_8K:int = 14;
|
||||
|
||||
public static const SOUND_FORMAT_DEVICE_SPECIFIC:int = 15;
|
||||
|
||||
public static const SOUND_RATE_5K:Number = 5512.5;
|
||||
|
||||
public static const SOUND_RATE_11K:Number = 11025;
|
||||
|
||||
public static const SOUND_RATE_22K:Number = 22050;
|
||||
|
||||
public static const SOUND_RATE_44K:Number = 44100;
|
||||
|
||||
public static const SOUND_SIZE_8BITS:int = 8;
|
||||
|
||||
public static const SOUND_SIZE_16BITS:int = 16;
|
||||
|
||||
public static const SOUND_CHANNELS_MONO:int = 1;
|
||||
|
||||
public static const SOUND_CHANNELS_STEREO:int = 2;
|
||||
|
||||
public function FLVTagAudio(param1:int = 8)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
public function get soundFormatByte() : int
|
||||
{
|
||||
return bytes[11 + 0];
|
||||
}
|
||||
|
||||
public function set soundFormatByte(param1:int) : void
|
||||
{
|
||||
bytes[11 + 0] = param1;
|
||||
}
|
||||
|
||||
public function get soundFormat() : int
|
||||
{
|
||||
return bytes[11 + 0] >> 4 & 0x0F;
|
||||
}
|
||||
|
||||
public function set soundFormat(param1:int) : void
|
||||
{
|
||||
var _loc2_:Number = 11 + 0;
|
||||
var _loc3_:int = bytes[_loc2_] & 0x0F;
|
||||
bytes[_loc2_] = _loc3_;
|
||||
bytes[11 + 0] |= param1 << 4 & 0xF0;
|
||||
if(param1 == 10)
|
||||
{
|
||||
soundRate = 44100;
|
||||
soundChannels = 2;
|
||||
isAACSequenceHeader = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function get soundRate() : Number
|
||||
{
|
||||
switch(bytes[11 + 0] >> 2 & 3)
|
||||
{
|
||||
case 0:
|
||||
return 5512.5;
|
||||
case 1:
|
||||
return 11025;
|
||||
case 2:
|
||||
return 22050;
|
||||
case 3:
|
||||
return 44100;
|
||||
default:
|
||||
throw new Error("get soundRate() a two-bit number wasn\'t 0, 1, 2, or 3. impossible.");
|
||||
}
|
||||
}
|
||||
|
||||
public function set soundRate(param1:Number) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
switch(param1)
|
||||
{
|
||||
case 5512.5:
|
||||
_loc2_ = 0;
|
||||
break;
|
||||
case 11025:
|
||||
_loc2_ = 1;
|
||||
break;
|
||||
case 22050:
|
||||
_loc2_ = 2;
|
||||
break;
|
||||
case 44100:
|
||||
_loc2_ = 3;
|
||||
break;
|
||||
default:
|
||||
throw new Error("set soundRate valid values 5512.5, 11025, 22050, 44100");
|
||||
}
|
||||
var _loc3_:Number = 11 + 0;
|
||||
var _loc4_:int = bytes[_loc3_] & 0xF3;
|
||||
bytes[_loc3_] = _loc4_;
|
||||
bytes[11 + 0] |= _loc2_ << 2;
|
||||
}
|
||||
|
||||
public function get soundSize() : int
|
||||
{
|
||||
if(bytes[11 + 0] >> 1 & 1)
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
return 8;
|
||||
}
|
||||
|
||||
public function set soundSize(param1:int) : void
|
||||
{
|
||||
switch(param1 - 8)
|
||||
{
|
||||
case 0:
|
||||
var _loc2_:* = 11 + 0;
|
||||
var _loc3_:* = bytes[_loc2_] & 0xFD;
|
||||
bytes[_loc2_] = _loc3_;
|
||||
break;
|
||||
case 8:
|
||||
_loc3_ = 11 + 0;
|
||||
_loc2_ = bytes[_loc3_] | 2;
|
||||
bytes[_loc3_] = _loc2_;
|
||||
break;
|
||||
default:
|
||||
throw new Error("set soundSize valid values 8, 16");
|
||||
}
|
||||
}
|
||||
|
||||
public function get soundChannels() : int
|
||||
{
|
||||
if(bytes[11 + 0] & 1)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function set soundChannels(param1:int) : void
|
||||
{
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
var _loc2_:* = 11 + 0;
|
||||
var _loc3_:* = bytes[_loc2_] & 0xFE;
|
||||
bytes[_loc2_] = _loc3_;
|
||||
break;
|
||||
case 1:
|
||||
_loc3_ = 11 + 0;
|
||||
_loc2_ = bytes[_loc3_] | 1;
|
||||
bytes[_loc3_] = _loc2_;
|
||||
break;
|
||||
default:
|
||||
throw new Error("set soundChannels valid values 1, 2");
|
||||
}
|
||||
}
|
||||
|
||||
public function get isAACSequenceHeader() : Boolean
|
||||
{
|
||||
if(soundFormat != 10)
|
||||
{
|
||||
throw new Error("get isAACSequenceHeader not valid if soundFormat != SOUND_FORMAT_AAC");
|
||||
}
|
||||
if(bytes[11 + 1] == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function set isAACSequenceHeader(param1:Boolean) : void
|
||||
{
|
||||
if(soundFormat != 10)
|
||||
{
|
||||
throw new Error("set isAACSequenceHeader not valid if soundFormat != SOUND_FORMAT_AAC");
|
||||
}
|
||||
if(param1)
|
||||
{
|
||||
bytes[11 + 1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes[11 + 1] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public function get isCodecConfiguration() : Boolean
|
||||
{
|
||||
switch(soundFormat - 10)
|
||||
{
|
||||
case 0:
|
||||
if(isAACSequenceHeader)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override public function get data() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
if(soundFormat == 10)
|
||||
{
|
||||
_loc1_.writeBytes(bytes,11 + 2,dataSize - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_.writeBytes(bytes,11 + 1,dataSize - 1);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
override public function set data(param1:ByteArray) : void
|
||||
{
|
||||
if(soundFormat == 10)
|
||||
{
|
||||
bytes.length = 11 + param1.length + 2;
|
||||
bytes.position = 11 + 2;
|
||||
bytes.writeBytes(param1,0,param1.length);
|
||||
dataSize = param1.length + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes.length = 11 + param1.length + 1;
|
||||
bytes.position = 11 + 1;
|
||||
bytes.writeBytes(param1,0,param1.length);
|
||||
dataSize = param1.length + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
public class FLVTagScriptDataObject extends FLVTag
|
||||
{
|
||||
|
||||
public function FLVTagScriptDataObject(param1:int = 18)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
public function get objects() : Array
|
||||
{
|
||||
var _loc1_:Array = [];
|
||||
bytes.position = 11;
|
||||
while(bytes.bytesAvailable)
|
||||
{
|
||||
_loc1_.push(bytes.readObject());
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function set objects(param1:Array) : void
|
||||
{
|
||||
bytes.objectEncoding = 0;
|
||||
bytes.length = 11;
|
||||
bytes.position = 11;
|
||||
for each(var _loc2_:Object in param1)
|
||||
{
|
||||
bytes.writeObject(_loc2_);
|
||||
}
|
||||
dataSize = bytes.length - 11;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class FLVTagVideo extends FLVTag
|
||||
{
|
||||
|
||||
public static const FRAME_TYPE_KEYFRAME:int = 1;
|
||||
|
||||
public static const FRAME_TYPE_INTER:int = 2;
|
||||
|
||||
public static const FRAME_TYPE_DISPOSABLE_INTER:int = 3;
|
||||
|
||||
public static const FRAME_TYPE_GENERATED_KEYFRAME:int = 4;
|
||||
|
||||
public static const FRAME_TYPE_INFO:int = 5;
|
||||
|
||||
public static const CODEC_ID_JPEG:int = 1;
|
||||
|
||||
public static const CODEC_ID_SORENSON:int = 2;
|
||||
|
||||
public static const CODEC_ID_SCREEN:int = 3;
|
||||
|
||||
public static const CODEC_ID_VP6:int = 4;
|
||||
|
||||
public static const CODEC_ID_VP6_ALPHA:int = 5;
|
||||
|
||||
public static const CODEC_ID_SCREEN_V2:int = 6;
|
||||
|
||||
public static const CODEC_ID_AVC:int = 7;
|
||||
|
||||
public static const AVC_PACKET_TYPE_SEQUENCE_HEADER:int = 0;
|
||||
|
||||
public static const AVC_PACKET_TYPE_NALU:int = 1;
|
||||
|
||||
public static const AVC_PACKET_TYPE_END_OF_SEQUENCE:int = 2;
|
||||
|
||||
public static const INFO_PACKET_SEEK_START:int = 0;
|
||||
|
||||
public static const INFO_PACKET_SEEK_END:int = 1;
|
||||
|
||||
public function FLVTagVideo(param1:int = 9)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
public function get frameType() : int
|
||||
{
|
||||
return bytes[11 + 0] >> 4 & 0x0F;
|
||||
}
|
||||
|
||||
public function set frameType(param1:int) : void
|
||||
{
|
||||
var _loc2_:Number = 11 + 0;
|
||||
var _loc3_:int = bytes[_loc2_] & 0x0F;
|
||||
bytes[_loc2_] = _loc3_;
|
||||
bytes[11 + 0] |= (param1 & 0x0F) << 4;
|
||||
}
|
||||
|
||||
public function get codecID() : int
|
||||
{
|
||||
return bytes[11 + 0] & 0x0F;
|
||||
}
|
||||
|
||||
public function set codecID(param1:int) : void
|
||||
{
|
||||
var _loc2_:Number = 11 + 0;
|
||||
var _loc3_:int = bytes[_loc2_] & 0xF0;
|
||||
bytes[_loc2_] = _loc3_;
|
||||
bytes[11 + 0] |= param1 & 0x0F;
|
||||
}
|
||||
|
||||
public function get infoPacketValue() : int
|
||||
{
|
||||
if(frameType != 5)
|
||||
{
|
||||
throw new Error("get infoPacketValue() not permitted unless frameType is FRAME_TYPE_INFO");
|
||||
}
|
||||
return bytes[11 + 1];
|
||||
}
|
||||
|
||||
public function set infoPacketValue(param1:int) : void
|
||||
{
|
||||
if(frameType != 5)
|
||||
{
|
||||
throw new Error("get infoPacketValue() not permitted unless frameType is FRAME_TYPE_INFO");
|
||||
}
|
||||
bytes[11 + 1] = param1;
|
||||
bytes.length = 11 + 2;
|
||||
dataSize = 2;
|
||||
}
|
||||
|
||||
public function get avcPacketType() : int
|
||||
{
|
||||
if(codecID != 7)
|
||||
{
|
||||
throw new Error("get avcPacketType() not permitted unless codecID is CODEC_ID_AVC");
|
||||
}
|
||||
return bytes[11 + 1];
|
||||
}
|
||||
|
||||
public function set avcPacketType(param1:int) : void
|
||||
{
|
||||
if(codecID != 7)
|
||||
{
|
||||
throw new Error("set avcPacketType() not permitted unless codecID is CODEC_ID_AVC");
|
||||
}
|
||||
bytes[11 + 1] = param1;
|
||||
if(avcPacketType != 1)
|
||||
{
|
||||
bytes[11 + 2] = 0;
|
||||
bytes[11 + 3] = 0;
|
||||
bytes[11 + 4] = 0;
|
||||
bytes.length = 11 + 5;
|
||||
dataSize = 5;
|
||||
}
|
||||
}
|
||||
|
||||
public function get avcCompositionTimeOffset() : int
|
||||
{
|
||||
if(codecID != 7 || avcPacketType != 1)
|
||||
{
|
||||
throw new Error("get avcCompositionTimeOffset() not permitted unless codecID is CODEC_ID_AVC and avcPacketType is AVC NALU");
|
||||
}
|
||||
var _loc1_:int = bytes[11 + 2] << 16;
|
||||
_loc1_ |= bytes[11 + 3] << 8;
|
||||
_loc1_ |= bytes[11 + 4];
|
||||
if(_loc1_ & 0x800000)
|
||||
{
|
||||
_loc1_ |= 4278190080;
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function set avcCompositionTimeOffset(param1:int) : void
|
||||
{
|
||||
if(codecID != 7 || avcPacketType != 1)
|
||||
{
|
||||
throw new Error("set avcCompositionTimeOffset() not permitted unless codecID is CODEC_ID_AVC and avcPacketType is AVC NALU");
|
||||
}
|
||||
bytes[11 + 2] = param1 >> 16 & 0xFF;
|
||||
bytes[11 + 3] = param1 >> 8 & 0xFF;
|
||||
bytes[11 + 4] = param1 & 0xFF;
|
||||
}
|
||||
|
||||
override public function get data() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
if(codecID == 7)
|
||||
{
|
||||
_loc1_.writeBytes(bytes,11 + 5,dataSize - 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_.writeBytes(bytes,11 + 1,dataSize - 1);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
override public function set data(param1:ByteArray) : void
|
||||
{
|
||||
if(codecID == 7)
|
||||
{
|
||||
bytes.length = 11 + param1.length + 5;
|
||||
bytes.position = 11 + 5;
|
||||
bytes.writeBytes(param1,0,param1.length);
|
||||
dataSize = param1.length + 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes.length = 11 + param1.length + 1;
|
||||
bytes.position = 11 + 1;
|
||||
bytes.writeBytes(param1,0,param1.length);
|
||||
dataSize = param1.length + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user