no commit message
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package org.mangui.hls.event {
|
||||
/** Error Identifier **/
|
||||
public class HLSError {
|
||||
public static const OTHER_ERROR : int = 0;
|
||||
public static const MANIFEST_LOADING_CROSSDOMAIN_ERROR : int = 1;
|
||||
public static const MANIFEST_LOADING_IO_ERROR : int = 2;
|
||||
public static const MANIFEST_PARSING_ERROR : int = 3;
|
||||
public static const FRAGMENT_LOADING_CROSSDOMAIN_ERROR : int = 4;
|
||||
public static const FRAGMENT_LOADING_ERROR : int = 5;
|
||||
public static const FRAGMENT_PARSING_ERROR : int = 6;
|
||||
public static const KEY_LOADING_CROSSDOMAIN_ERROR : int = 7;
|
||||
public static const KEY_LOADING_ERROR : int = 8;
|
||||
public static const KEY_PARSING_ERROR : int = 9;
|
||||
public static const TAG_APPENDING_ERROR : int = 10;
|
||||
|
||||
private var _code : int;
|
||||
private var _url : String;
|
||||
private var _msg : String;
|
||||
|
||||
public function HLSError(code : int, url : String, msg : String) {
|
||||
_code = code;
|
||||
_url = url;
|
||||
_msg = msg;
|
||||
}
|
||||
|
||||
public function get code() : int {
|
||||
return _code;
|
||||
}
|
||||
|
||||
public function get msg() : String {
|
||||
return _msg;
|
||||
}
|
||||
|
||||
public function get url() : String {
|
||||
return _url;
|
||||
}
|
||||
|
||||
public function toString() : String {
|
||||
return "HLSError(code/url/msg)=" + _code + "/" + _url + "/" + _msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package org.mangui.hls.event {
|
||||
import org.mangui.hls.model.Level;
|
||||
|
||||
import flash.events.Event;
|
||||
|
||||
/** Event fired when an error prevents playback. **/
|
||||
public class HLSEvent extends Event {
|
||||
/** Identifier for a manifest loading event, triggered after a call to hls.load(url) **/
|
||||
public static const MANIFEST_LOADING : String = "hlsEventManifestLoading";
|
||||
/** Identifier for a manifest parsed event,
|
||||
* triggered after main manifest has been retrieved and parsed.
|
||||
* hls playlist may not be playable yet, in case of adaptive streaming, start level playlist is not downloaded yet at that stage */
|
||||
public static const MANIFEST_PARSED : String = "hlsEventManifestParsed";
|
||||
/** Identifier for a manifest loaded event, when this event is received, main manifest and start level has been retrieved */
|
||||
public static const MANIFEST_LOADED : String = "hlsEventManifestLoaded";
|
||||
/** Identifier for a level loading event **/
|
||||
public static const LEVEL_LOADING : String = "hlsEventLevelLoading";
|
||||
/** Identifier for a level loading aborted event **/
|
||||
public static const LEVEL_LOADING_ABORTED : String = "hlsEventLevelLoadingAborted";
|
||||
/** Identifier for a level loaded event **/
|
||||
public static const LEVEL_LOADED : String = "hlsEventLevelLoaded";
|
||||
/** Identifier for a level switch event. **/
|
||||
public static const LEVEL_SWITCH : String = "hlsEventLevelSwitch";
|
||||
/** Identifier for a level ENDLIST event. **/
|
||||
public static const LEVEL_ENDLIST : String = "hlsEventLevelEndList";
|
||||
/** Identifier for a fragment loading event. **/
|
||||
public static const FRAGMENT_LOADING : String = "hlsEventFragmentLoading";
|
||||
/** Identifier for a fragment loaded event. **/
|
||||
public static const FRAGMENT_LOADED : String = "hlsEventFragmentLoaded";
|
||||
/* Identifier for fragment load aborting for emergency switch down */
|
||||
public static const FRAGMENT_LOAD_EMERGENCY_ABORTED : String = "hlsEventFragmentLoadEmergencyAborted";
|
||||
/** Identifier for a fragment playing event. **/
|
||||
public static const FRAGMENT_PLAYING : String = "hlsEventFragmentPlaying";
|
||||
/** Identifier for a fragment skipping event. **/
|
||||
public static const FRAGMENT_SKIPPED : String = "hlsEventFragmentSkipped";
|
||||
/** Identifier for a audio tracks list change **/
|
||||
public static const AUDIO_TRACKS_LIST_CHANGE : String = "audioTracksListChange";
|
||||
/** Identifier for a audio track switch **/
|
||||
public static const AUDIO_TRACK_SWITCH : String = "audioTrackSwitch";
|
||||
/** Identifier for a audio level loading event **/
|
||||
public static const AUDIO_LEVEL_LOADING : String = "hlsEventAudioLevelLoading";
|
||||
/** Identifier for a audio level loaded event **/
|
||||
public static const AUDIO_LEVEL_LOADED : String = "hlsEventAudioLevelLoaded";
|
||||
/** Identifier for audio/video TAGS loaded event. **/
|
||||
public static const TAGS_LOADED : String = "hlsEventTagsLoaded";
|
||||
/** Identifier when last fragment of playlist has been loaded **/
|
||||
public static const LAST_VOD_FRAGMENT_LOADED : String = "hlsEventLastFragmentLoaded";
|
||||
/** Identifier for a playback warning event. **/
|
||||
public static const WARNING : String = "hlsEventWarning";
|
||||
/** Identifier for a playback error event. **/
|
||||
public static const ERROR : String = "hlsEventError";
|
||||
/** Identifier for a playback media time change event. **/
|
||||
public static const MEDIA_TIME : String = "hlsEventMediaTime";
|
||||
/** Identifier for a playback state switch event. **/
|
||||
public static const PLAYBACK_STATE : String = "hlsPlaybackState";
|
||||
/** Identifier for a seek state switch event. **/
|
||||
public static const SEEK_STATE : String = "hlsSeekState";
|
||||
/** Identifier for stream type changes: VoD or Live, type will be stored in 'streamType' field **/
|
||||
public static const STREAM_TYPE_DID_CHANGE:String = "hlsEventStreamTypeDidChange";
|
||||
/** Identifier for a playback complete event. **/
|
||||
public static const PLAYBACK_COMPLETE : String = "hlsEventPlayBackComplete";
|
||||
/** Identifier for a Playlist Duration updated event **/
|
||||
public static const PLAYLIST_DURATION_UPDATED : String = "hlsPlayListDurationUpdated";
|
||||
/** Identifier for a ID3 updated event **/
|
||||
public static const ID3_UPDATED : String = "hlsID3Updated";
|
||||
/** Identifier for a fps drop event **/
|
||||
public static const FPS_DROP : String = "hlsFPSDrop";
|
||||
/** Identifier for a fps drop level capping event **/
|
||||
public static const FPS_DROP_LEVEL_CAPPING : String = "hlsFPSDropLevelCapping";
|
||||
/** Identifier for a fps drop smooth level switch event **/
|
||||
public static const FPS_DROP_SMOOTH_LEVEL_SWITCH : String = "hlsFPSDropSmoothLevelSwitch";
|
||||
/** Identifier for a live loading stalled event **/
|
||||
public static const LIVE_LOADING_STALLED : String = "hlsLiveLoadingStalled";
|
||||
/** Identifier for a Stage set event **/
|
||||
public static const STAGE_SET : String = "hlsStageSet";
|
||||
//** 新添加的监听,监听加载量**/
|
||||
public static const LOADED_BYTES: String = "loadedBytes";
|
||||
|
||||
/** The current url **/
|
||||
public var url : String;
|
||||
/** The current quality level. **/
|
||||
public var level : int;
|
||||
/** The current playlist duration. **/
|
||||
public var duration : Number;
|
||||
/** The list with quality levels. **/
|
||||
public var levels : Vector.<Level>;
|
||||
/** The error message. **/
|
||||
public var error : HLSError;
|
||||
/** Load Metrics. **/
|
||||
public var loadMetrics : HLSLoadMetrics;
|
||||
/** Play Metrics. **/
|
||||
public var playMetrics : HLSPlayMetrics;
|
||||
/** The time position. **/
|
||||
public var mediatime : HLSMediatime;
|
||||
/** The new playback state. **/
|
||||
public var state : String;
|
||||
/** The new stream type value **/
|
||||
public var streamType: String;
|
||||
/** The current audio track **/
|
||||
public var audioTrack : int;
|
||||
/** a complete ID3 payload from PES, as a hex dump **/
|
||||
public var ID3Data : String;
|
||||
/**新增加的用来监听加载量的**/
|
||||
public var loadedBytes: Number;
|
||||
|
||||
/** Assign event parameter and dispatch. **/
|
||||
public function HLSEvent(type : String, parameter : *=null, parameter2 : *=null) {
|
||||
switch(type) {
|
||||
case MANIFEST_LOADING:
|
||||
case FRAGMENT_LOADING:
|
||||
url = parameter as String;
|
||||
break;
|
||||
case ERROR:
|
||||
case WARNING:
|
||||
error = parameter as HLSError;
|
||||
break;
|
||||
case TAGS_LOADED:
|
||||
case FRAGMENT_LOADED:
|
||||
case FRAGMENT_LOAD_EMERGENCY_ABORTED:
|
||||
case LEVEL_LOADED:
|
||||
case AUDIO_LEVEL_LOADED:
|
||||
loadMetrics = parameter as HLSLoadMetrics;
|
||||
break;
|
||||
case MANIFEST_PARSED:
|
||||
case MANIFEST_LOADED:
|
||||
levels = parameter as Vector.<Level>;
|
||||
if(parameter2) {
|
||||
loadMetrics = parameter2 as HLSLoadMetrics;
|
||||
}
|
||||
break;
|
||||
case MEDIA_TIME:
|
||||
mediatime = parameter as HLSMediatime;
|
||||
break;
|
||||
case PLAYBACK_STATE:
|
||||
case SEEK_STATE:
|
||||
state = parameter as String;
|
||||
break;
|
||||
case LEVEL_LOADING:
|
||||
case LEVEL_LOADING_ABORTED:
|
||||
case LEVEL_SWITCH:
|
||||
case LEVEL_ENDLIST:
|
||||
case AUDIO_LEVEL_LOADING:
|
||||
case FPS_DROP:
|
||||
case FPS_DROP_LEVEL_CAPPING:
|
||||
level = parameter as int;
|
||||
break;
|
||||
case PLAYLIST_DURATION_UPDATED:
|
||||
case FRAGMENT_SKIPPED:
|
||||
duration = parameter as Number;
|
||||
break;
|
||||
case ID3_UPDATED:
|
||||
ID3Data = parameter as String;
|
||||
break;
|
||||
case FRAGMENT_PLAYING:
|
||||
playMetrics = parameter as HLSPlayMetrics;
|
||||
break;
|
||||
case HLSEvent.STREAM_TYPE_DID_CHANGE:
|
||||
// Stream Type is required
|
||||
streamType = String(parameter);
|
||||
break;
|
||||
case LOADED_BYTES:
|
||||
loadedBytes = parameter as Number;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
super(type, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package org.mangui.hls.event {
|
||||
/** Fragment Loading metrics **/
|
||||
public class HLSLoadMetrics {
|
||||
/* Loader Type : refer to HLSLoaderTypes for enumeration */
|
||||
public var type : int;
|
||||
/* level of loaded content */
|
||||
public var level : int;
|
||||
/* id of loaded content : should be SN for fragment, startSN for playlist */
|
||||
public var id : int;
|
||||
/* id2 of loaded content : endSN for playlist, nb tags for tags loaded */
|
||||
public var id2 : int;
|
||||
/** fragment/playlist size **/
|
||||
public var size : int;
|
||||
/** fragment/playlist duration **/
|
||||
public var duration : Number;
|
||||
/** loading request/start/end time **/
|
||||
public var loading_request_time : int;
|
||||
public var loading_begin_time : int;
|
||||
public var loading_end_time : int;
|
||||
/** decryption begin/end time (for fragment only) **/
|
||||
public var decryption_begin_time : int;
|
||||
public var decryption_end_time : int;
|
||||
/** parsing begin/end time (for fragment only) */
|
||||
public var parsing_begin_time : int;
|
||||
public var parsing_end_time : int;
|
||||
|
||||
public function HLSLoadMetrics(type : int) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public function get bandwidth() : int {
|
||||
return size * 8000 / (parsing_end_time - loading_request_time);
|
||||
}
|
||||
|
||||
public function get processing_duration() : int {
|
||||
return parsing_end_time-loading_request_time;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package org.mangui.hls.event {
|
||||
/** Identifiers for the different stream types. **/
|
||||
public class HLSMediatime {
|
||||
/** playback position (in seconds), relative to current playlist start.
|
||||
* this value could be negative in case of live playlist sliding :
|
||||
* this can happen in case current playback position
|
||||
* is in a fragment that has been removed from the playlist
|
||||
*/
|
||||
public var position : Number;
|
||||
/** current playlist duration (in seconds) **/
|
||||
public var duration : Number;
|
||||
/** live main playlist sliding since previous out of buffer seek() (in seconds)**/
|
||||
public var live_sliding_main : Number;
|
||||
/** live altaudio playlist sliding since previous out of buffer seek() (in seconds)**/
|
||||
public var live_sliding_altaudio : Number;
|
||||
/** current buffer duration (in seconds) **/
|
||||
public var buffer : Number;
|
||||
/** current buffer duration (in seconds) **/
|
||||
public var backbuffer : Number;
|
||||
/** total watched duration (in seconds) since hls.load(URL) **/
|
||||
public var watched : Number;
|
||||
|
||||
public function HLSMediatime(position : Number, duration : Number, buffer : Number, backbuffer : Number, live_sliding_main : Number, live_sliding_altaudio : Number, watched : Number) {
|
||||
this.position = position;
|
||||
this.duration = duration;
|
||||
this.buffer = buffer;
|
||||
this.backbuffer = backbuffer;
|
||||
this.live_sliding_main = live_sliding_main;
|
||||
this.live_sliding_altaudio = live_sliding_altaudio;
|
||||
this.watched = watched;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package org.mangui.hls.event {
|
||||
/** playback metrics, notified when playback of a given fragment starts **/
|
||||
public class HLSPlayMetrics {
|
||||
public var level : int;
|
||||
public var seqnum : int;
|
||||
public var continuity_counter : int;
|
||||
public var duration : Number;
|
||||
public var audio_only : Boolean;
|
||||
public var program_date : Number;
|
||||
public var video_width : int;
|
||||
public var video_height : int;
|
||||
public var auto_level : Boolean;
|
||||
public var tag_list : Array;
|
||||
public var id3tag_list : Array;
|
||||
|
||||
public function HLSPlayMetrics(level : int, seqnum : int, cc : int, duration : Number, audio_only : Boolean, program_date : Number, video_width : int, video_height : int, auto_level : Boolean, tag_list : Array, id3tag_list : Array) {
|
||||
this.level = level;
|
||||
this.seqnum = seqnum;
|
||||
this.continuity_counter = cc;
|
||||
this.duration = duration;
|
||||
this.audio_only = audio_only;
|
||||
this.program_date = program_date;
|
||||
this.video_width = video_width;
|
||||
this.video_height = video_height;
|
||||
this.auto_level = auto_level;
|
||||
this.tag_list = tag_list;
|
||||
this.id3tag_list = id3tag_list;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user