Commit 6ea2cd4c authored by Dan Rossi's avatar Dan Rossi
Browse files

- Get the redirection url to obtain the baseurl from using a proxy script....

- Get the redirection url to obtain the baseurl from using a proxy script. This is required because of a limitation in flash obtaining the response url. redirection is configured in a separate file build-redirect.xml and configured using redirectUrl.
parent 06c77954
<project name="httpstreamingm3u8" default="deploy">
<property file="build.generated.properties"/>
<property file="${user.home}/plugin.properties" />
<property file="build.properties" />
<property name="flowplayer_lib" value="${devkit-dir}/flowplayer.swc" />
<!-- <property name="plugin-libs" value="lib/apple-osmf.swc"/> -->
<property name="extra-sources" value="../../lib/common/src/actionscript ${osmf-dir} ../../../apple-osmf/src"/>
<property name="library-path" value=""/>
<property name="compiler-defines" value="-define+=CONFIG::REDIRECT,'true' -define+=CONFIG::LOGGING,'true' -define+=CONFIG::FLASH_10_1,'true'"/>
<property file="${devkit-dir}/plugin-build.properties" />
<import file="${devkit-dir}/plugin-build.xml"/>
<property name="basename" value="flowplayer.httpstreaminghls-redirect" />
<property name="releasedir" value="${basename}" />
<property name="plugin-binary" value="${basename}.swf" />
<property name="plugin-swc" value="${basename}.swc" />
<property name="plugin-binary-versioned" value="${basename}-${version}.swf" />
<property name="plugin-main-class" value="org/electroteque/m3u8/HttpStreamingHlsPlugin.as" />
<target name="release" description="makes a release" depends="build">
<copyrelease targetdir="flowplayer.httpstreaminghls-redirect">
<releasefiles>
<fileset dir="${build-dir}">
<include name="${plugin-binary-versioned}"/>
</fileset>
</releasefiles>
</copyrelease>
</target>
<target name="demo" >
<example player-swf="flowplayer.swf" main-swf="${plugin-binary-versioned}" />
</target>
</project>
\ No newline at end of file
......@@ -8,7 +8,7 @@
<property name="plugin-libs" value="lib/apple-osmf.swc"/>
<property name="extra-sources" value="../../lib/common/src/actionscript ${osmf-dir}"/>
<property name="library-path" value=""/>
<property name="compiler-defines" value="-define+=CONFIG::LOGGING,'true' -define+=CONFIG::FLASH_10_1,'true'"/>
<property name="compiler-defines" value="-define+=CONFIG::REDIRECT,'false' -define+=CONFIG::LOGGING,'true' -define+=CONFIG::FLASH_10_1,'true'"/>
<property file="${devkit-dir}/plugin-build.properties" />
<import file="${devkit-dir}/plugin-build.xml"/>
......
......@@ -221,7 +221,7 @@ flowplayer("bitrate", "@PLAYER_SWF@", {
},
log: {
level: 'debug',
filter: 'org.osmf.*, org.electroteque.m3u8.*, org.flowplayer.bitrateselect.*'
filter: 'at.matthew.*, org.osmf.*, org.electroteque.m3u8.*, org.flowplayer.bitrateselect.*'
}
}).ipad();
......
......@@ -11,6 +11,7 @@ package org.electroteque.m3u8 {
public class Config {
private var _retryInterval:int = 10;
private var _maxRetries:int = 100;
private var _redirectUrl:String;
public function set retryInterval(value:int):void
{
......@@ -31,5 +32,15 @@ package org.electroteque.m3u8 {
{
return _maxRetries;
}
public function set redirectUrl(value:String):void
{
_redirectUrl = value;
}
public function get redirectUrl():String
{
return _redirectUrl;
}
}
}
......@@ -32,6 +32,7 @@ package org.electroteque.m3u8 {
import flash.net.NetConnection;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.utils.setTimeout;
import at.matthew.httpstreaming.parser.HttpStreamingM3U8ManifestParser;
import at.matthew.httpstreaming.model.HttpStreamingM3U8Manifest;
......@@ -48,6 +49,20 @@ package org.electroteque.m3u8 {
import org.osmf.net.httpstreaming.HTTPNetStream;
CONFIG::REDIRECT {
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.IOErrorEvent;
import flash.events.Event;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
}
CONFIG::LOGGING
{
import org.osmf.logging.Log;
}
public class HttpStreamingHlsProvider extends NetStreamControllingStreamProvider implements ClipURLResolver, ErrorHandler, Plugin {
protected var _bufferStart:Number;
protected var _config:Config;
......@@ -74,7 +89,14 @@ package org.electroteque.m3u8 {
*/
override public function onConfig(model:PluginModel):void {
_model = model;
CONFIG::LOGGING
{
Log.loggerFactory = new OsmfLoggerFactory();
}
_config = new PropertyBinder(new Config(), null).copyProperties(model.config) as Config;
}
/**
......@@ -121,7 +143,70 @@ package org.electroteque.m3u8 {
public function resolve(provider:StreamProvider, clip:Clip, successListener:Function):void {
_clip = clip;
_successListener = successListener;
loadM3U8(_clip.completeUrl, onM3U8Loaded);
if (clip.resolvedUrl) {
if (_successListener != null) {
_successListener(_clip);
}
return;
}
if (CONFIG::REDIRECT) {
if (_config.redirectUrl) {
getRedirectUrl(_clip.completeUrl, onM3U8RedirectUrl);
} else {
loadM3U8(_clip.completeUrl, onM3U8Loaded);
}
} else {
loadM3U8(_clip.completeUrl, onM3U8Loaded);
}
//loadM3U8(_clip.completeUrl, onM3U8Loaded);
}
CONFIG::REDIRECT {
/**
* Reload the m3u8 feed with the redirected url
* @param url
*/
private function onM3U8RedirectUrl(url:String):void
{
_clip.setResolvedUrl(null, url);
loadM3U8(_clip.resolvedUrl, onM3U8Loaded);
}
/**
* Get the redirection url to obtain the baseurl from using a proxy script.
* This is required because of a limitation in flash obtaining the response url.
*
* @param m3u8Url
* @param loadedCallback
*/
private function getRedirectUrl(m3u8Url:String, loadedCallback:Function):void {
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, function(event:Event):void {
if (!URLLoader(event.target).data) {
handleStreamNotFound("Redirected url not found");
return;
}
loadedCallback(URLLoader(event.target).data);
});
loader.addEventListener(IOErrorEvent.IO_ERROR, function(event:IOErrorEvent):void {
handleStreamNotFound("Error loading Redirect service");
});
var urlVars:URLVariables = new URLVariables();
urlVars.url = encodeURI(m3u8Url);
var request:URLRequest = new URLRequest(encodeURI(_config.redirectUrl));
request.method = URLRequestMethod.POST;
request.data = urlVars;
loader.load(request);
}
}
......@@ -162,20 +247,20 @@ package org.electroteque.m3u8 {
if (_clip.getCustomProperty("bitrates")) {
bitrateOptions = _clip.getCustomProperty("bitrates");
} else {
bitrateOptions.default = dynResource.streamItems[0].bitrate;
bitrateOptions.default = streamItems[0].bitrate;
if (dynResource.streamItems.length == 2) {
bitrateOptions.sd = dynResource.streamItems[0].bitrate;
bitrateOptions.hd = dynResource.streamItems[dynResource.streamItems.length - 1].bitrate;
if (streamItems.length == 2) {
bitrateOptions.sd = streamItems[0].bitrate;
bitrateOptions.hd = streamItems[streamItems.length - 1].bitrate;
}
}
for (var index:int = 0; index < dynResource.streamItems.length; index++) {
for (var index:int = 0; index < streamItems.length; index++) {
var item:DynamicStreamingItem = streamItems[index];
var bitrateItem:BitrateItem = new BitrateItem();
bitrateItem.url = item.streamName;
bitrateItem.bitrate = item.bitrate / 1000;
bitrateItem.bitrate = item.bitrate;
bitrateItem.index = index;
bitrateItem.width = item.width;
bitrateItem.height = item.height;
......@@ -392,12 +477,15 @@ package org.electroteque.m3u8 {
* @param event
*/
override protected function onNetStatus(event:NetStatusEvent) : void {
log.debug("onNetStatus(), code: " + event.info.code + ", paused? " + paused + ", seeking? " + seeking);
log.error("onNetStatus(), code: " + event.info.code + ", paused? " + paused + ", seeking? " + seeking);
switch(event.info.code){
case "NetStream.Play.Transition":
log.debug("Stream Transition -- " + event.info.details);
dispatchEvent(new ClipEvent(ClipEventType.SWITCH, event.info.details));
break;
case "NetStream.Play.Complete":
clip.dispatchBeforeEvent(new ClipEvent(ClipEventType.FINISH));
break;
}
return;
}
......@@ -411,7 +499,14 @@ package org.electroteque.m3u8 {
override protected function doStop(event:ClipEvent, netStream:NetStream, closeStreamAndConnection:Boolean = false):void {
_currentClip = null;
log.debug("Clearing clip and stopping ");
super.doStop(event, netStream, closeStreamAndConnection);
//netStream.pause();
//this.seek(null, 0);
netStream.close();
this.dispatchEvent(event);
//super.doStop(event, netStream, closeStreamAndConnection);
}
/**
......@@ -423,8 +518,20 @@ package org.electroteque.m3u8 {
override protected function doSeek(event : ClipEvent, netStream : NetStream, seconds : Number) : void {
var seekTime:int = int(seconds);
_bufferStart = seekTime;
log.debug("calling netStream.seek(" + seekTime + ")");
log.error("calling netStream.seek(" + seekTime + ")");
seeking = true;
// if (seekTime <= 0) return;
// if (seekTime == 0) seekTime = -1;
//#515 when seeking on startup set a delay or else the initial time is treated as the clip start time.
if (time <= 0 ) {
setTimeout(function():void {
netStream.seek(seconds);
}, 250);
return;
}
netStream.seek(seekTime);
}
......
/*
* Author: Anssi Piirainen, <api@iki.fi>
*
* Copyright (c) 2009-2011 Flowplayer Oy
*
* This file is part of Flowplayer.
*
* Flowplayer is licensed under the GPL v3 license with an
* Additional Term, see http://flowplayer.org/license_gpl.html
*/
package org.electroteque.m3u8 {
import org.flowplayer.util.Log;
import org.osmf.logging.Logger;
public class OsmfLogger extends Logger {
private var _log:Log;
public function OsmfLogger(category:String) {
super(category);
var pos:int = category.lastIndexOf(".");
var name:String = category.substr(0, pos) + "::" + category.substr(pos + 1);
_log = new Log(name);
}
override public function debug(message:String, ... rest):void {
_log.debug.apply(_log, [message]);
// _log.debug.apply(_log, [message].concat(rest));
}
override public function info(message:String, ... rest):void {
_log.info.apply(_log, [message]);
// _log.info.apply(_log, [message].concat(rest));
}
override public function warn(message:String, ... rest):void {
_log.warn.apply(_log, [message]);
// _log.warn.apply(_log, [message].concat(rest));
}
override public function error(message:String, ... rest):void {
_log.error.apply(_log, [message]);
// _log.error.apply(_log, [message].concat(rest));
}
override public function fatal(message:String, ... rest):void {
_log.error.apply(_log, [message]);
// _log.error.apply(_log, [message].concat(rest));
}
}
}
\ No newline at end of file
/*
* Author: Anssi Piirainen, <api@iki.fi>
*
* Copyright (c) 2009-2011 Flowplayer Oy
*
* This file is part of Flowplayer.
*
* Flowplayer is licensed under the GPL v3 license with an
* Additional Term, see http://flowplayer.org/license_gpl.html
*/
package org.electroteque.m3u8 {
import org.osmf.logging.Logger;
import org.osmf.logging.LoggerFactory;
public class OsmfLoggerFactory extends LoggerFactory {
public function OsmfLoggerFactory() {
}
override public function getLogger(category:String):Logger {
return new OsmfLogger(category);
}
}
}
\ No newline at end of file
<?
include "Zend/Http/Client.php";
$client = new Zend_Http_Client($_POST["url"]);
$response = $client->request();
$finalUrl = $client->getUri()->__toString();
echo $finalUrl;
?>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment