diff --git a/trunk/research/players/js/srs.js b/trunk/research/players/js/srs.js
index ac1305112..beea0b633 100755
--- a/trunk/research/players/js/srs.js
+++ b/trunk/research/players/js/srs.js
@@ -116,11 +116,10 @@ function srs_init(rtmp_url, hls_url, modal_player) {
/**
* the SrsPlayer object.
* @param container the html container id.
-* @param stream_url the url of stream, rtmp or http.
* @param width a float value specifies the width of player.
* @param height a float value specifies the height of player.
*/
-function SrsPlayer(container, stream_url, width, height) {
+function SrsPlayer(container, width, height) {
if (!SrsPlayer.__id) {
SrsPlayer.__id = 100;
}
@@ -131,12 +130,12 @@ function SrsPlayer(container, stream_url, width, height) {
SrsPlayer.__players.push(this);
this.container = container;
- this.stream_url = stream_url;
this.width = width;
this.height = height;
this.id = SrsPlayer.__id++;
- this.callbackObj = null;
+ this.stream_url = null;
this.buffer_time = 0.8; // default to 0.8
+ this.callbackObj = null;
// callback set the following values.
this.meatadata = {}; // for on_player_metadata
@@ -178,7 +177,12 @@ SrsPlayer.prototype.start = function() {
return this;
}
-SrsPlayer.prototype.play = function() {
+/**
+* play the stream.
+* @param stream_url the url of stream, rtmp or http.
+*/
+SrsPlayer.prototype.play = function(url) {
+ this.stream_url = url;
this.callbackObj.ref.__play(this.stream_url, this.width, this.height, this.buffer_time);
}
SrsPlayer.prototype.stop = function() {
@@ -233,7 +237,6 @@ SrsPlayer.prototype.set_bt = function(buffer_time) {
this.callbackObj.ref.__set_bt(buffer_time);
}
SrsPlayer.prototype.on_player_ready = function() {
- this.play();
}
SrsPlayer.prototype.on_player_metadata = function(metadata) {
// ignore.
@@ -286,4 +289,131 @@ function __srs_on_player_timer(id, time, buffer_length) {
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
+/**
+* the SrsPublisher object.
+* @param container the html container id.
+* @param width a float value specifies the width of publisher.
+* @param height a float value specifies the height of publisher.
+*/
+function SrsPublisher(container, width, height) {
+ if (!SrsPublisher.__id) {
+ SrsPublisher.__id = 100;
+ }
+ if (!SrsPublisher.__publishers) {
+ SrsPublisher.__publishers = [];
+ }
+
+ SrsPublisher.__publishers.push(this);
+
+ this.container = container;
+ this.width = width;
+ this.height = height;
+ this.id = SrsPublisher.__id++;
+ this.callbackObj = null;
+
+ // set the values when publish.
+ this.url = null;
+ this.vcodec = {};
+ this.acodec = {};
+
+ // callback set the following values.
+ this.cameras = [];
+ this.microphones = [];
+ this.code = 0;
+
+ // error code defines.
+ this.error_device_muted = 100;
+}
+/**
+* user can set some callback, then start the publisher.
+* callbacks:
+* on_publisher_ready(cameras, microphones):int, when srs publisher ready, user can publish.
+* on_publisher_error(code):int, when srs publisher error, callback this method.
+*/
+SrsPublisher.prototype.start = function() {
+ // embed the flash.
+ var flashvars = {};
+ flashvars.id = this.id;
+ flashvars.on_publisher_ready = "__srs_on_publisher_ready";
+ flashvars.on_publisher_error = "__srs_on_publisher_error";
+
+ var params = {};
+ params.wmode = "opaque";
+ params.allowFullScreen = "true";
+ params.allowScriptAccess = "always";
+
+ var attributes = {};
+
+ var self = this;
+
+ swfobject.embedSWF(
+ "srs_publisher/release/srs_publisher.swf", this.container,
+ this.width, this.height,
+ "11.1", "js/AdobeFlashPlayerInstall.swf",
+ flashvars, params, attributes,
+ function(callbackObj){
+ self.callbackObj = callbackObj;
+ }
+ );
+
+ return this;
+}
+/**
+* publish stream to server.
+* @param url a string indicates the rtmp url to publish.
+* @param vcodec an object contains the video codec info.
+* @param acodec an object contains the audio codec info.
+*/
+SrsPublisher.prototype.publish = function(url, vcodec, acodec) {
+ this.url = url;
+ this.vcodec = vcodec;
+ this.acodec = acodec;
+
+ this.callbackObj.ref.__publish(url, this.width, this.height, vcodec, acodec);
+}
+SrsPublisher.prototype.stop = function() {
+ this.callbackObj.ref.__stop();
+}
+/**
+* when publisher ready.
+* @param cameras a string array contains the names of cameras.
+* @param microphones a string array contains the names of microphones.
+*/
+SrsPublisher.prototype.on_publisher_ready = function(cameras, microphones) {
+}
+/**
+* when publisher error.
+* @code the error code.
+*/
+SrsPublisher.prototype.on_publisher_error = function(code) {
+ throw new Error("publisher error. code=" + code);
+}
+function __srs_find_publisher(id) {
+ for (var i = 0; i < SrsPublisher.__publishers.length; i++) {
+ var publisher = SrsPublisher.__publishers[i];
+
+ if (publisher.id != id) {
+ continue;
+ }
+
+ return publisher;
+ }
+
+ throw new Error("publisher not found. id=" + id);
+}
+function __srs_on_publisher_ready(id, cameras, microphones) {
+ var publisher = __srs_find_publisher(id);
+
+ publisher.cameras = cameras;
+ publisher.microphones = microphones;
+
+ publisher.on_publisher_ready(cameras, microphones);
+}
+function __srs_on_publisher_error(id, code) {
+ var publisher = __srs_find_publisher(id);
+
+ publisher.code = code;
+
+ publisher.on_publisher_error(code);
+}
diff --git a/trunk/research/players/jwplayer6.html b/trunk/research/players/jwplayer6.html
index 793925939..946cdcfda 100755
--- a/trunk/research/players/jwplayer6.html
+++ b/trunk/research/players/jwplayer6.html
@@ -35,14 +35,13 @@
$("#main_modal").on("show", function(){
$("#div_container").remove();
- var obj = $("
");
- $(obj).attr("id", "div_container");
+ var div_container = $("");
+ $(div_container).attr("id", "div_container");
+ $("#player").append(div_container);
var player = $("");
- $(obj).append(player);
- $(obj).attr("id", "player_id");
-
- $("#player").append(obj);
+ $(player).attr("id", "player_id");
+ $(div_container).append(player);
var conf = {
file: _url,
diff --git a/trunk/research/players/osmf.html b/trunk/research/players/osmf.html
index 97fa21333..0ad4eb520 100755
--- a/trunk/research/players/osmf.html
+++ b/trunk/research/players/osmf.html
@@ -21,14 +21,13 @@
function osmf_play(url) {
$("#div_container").remove();
- var obj = $("");
- $(obj).attr("id", "div_container");
+ var div_container = $("");
+ $(div_container).attr("id", "div_container");
+ $("#player").append(div_container);
var player = $("");
- $(obj).append(player);
- $(obj).attr("id", "player_id");
-
- $("#player").append(obj);
+ $(player).attr("id", "player_id");
+ $(div_container).append(player);
var flashvars = {};
flashvars.src = url;
diff --git a/trunk/research/players/srs_player.html b/trunk/research/players/srs_player.html
index 312633d7a..7d1b75987 100755
--- a/trunk/research/players/srs_player.html
+++ b/trunk/research/players/srs_player.html
@@ -80,28 +80,26 @@
$("#div_container").remove();
- var obj = $("");
- $(obj).attr("id", "div_container");
+ var div_container = $("");
+ $(div_container).attr("id", "div_container");
+ $("#player").append(div_container);
var player = $("");
- $(obj).append(player);
- $(obj).attr("id", "player_id");
-
- $("#player").append(obj);
+ $(player).attr("id", "player_id");
+ $(div_container).append(player);
var url = $("#txt_url").val();
- srs_player = new SrsPlayer("player_id", url,
- srs_get_player_width(), srs_get_player_height());
+ srs_player = new SrsPlayer("player_id", srs_get_player_width(), srs_get_player_height());
srs_player.on_player_ready = function() {
select_buffer_time("#btn_bt_0_8", 0.8);
- srs_player.play();
- }
+ srs_player.play(url);
+ };
srs_player.on_player_metadata = function(metadata) {
$("#btn_dar_original").text("视频原始比例" + "(" + metadata.width + ":" + metadata.height + ")");
select_dar("#btn_dar_original", 0, 0);
select_fs_size("#btn_fs_size_screen_100", "screen", 100);
- }
+ };
srs_player.on_player_timer = function(time, buffer_length) {
var buffer = buffer_length / srs_player.buffer_time * 100;
$("#pb_buffer").width(Number(buffer).toFixed(1) + "%");
@@ -124,7 +122,7 @@
time_str += padding(parseInt(time), 2, '0');
// show
$("#txt_time").val(time_str);
- }
+ };
srs_player.start();
});
@@ -218,6 +216,11 @@
select_buffer_time("#btn_bt_30", 30);
});
}
+
+ var query = parse_query_string();
+ if (query.autostart == "true") {
+ $("#main_modal").modal({show:true, keyboard:false});
+ }
});
diff --git a/trunk/research/players/srs_player/release/srs_player.swf b/trunk/research/players/srs_player/release/srs_player.swf
index a4076939e..9db9c8ac6 100755
Binary files a/trunk/research/players/srs_player/release/srs_player.swf and b/trunk/research/players/srs_player/release/srs_player.swf differ
diff --git a/trunk/research/players/srs_player/src/srs_player.as b/trunk/research/players/srs_player/src/srs_player.as
index 5be20f65e..c1cc708fd 100755
--- a/trunk/research/players/srs_player/src/srs_player.as
+++ b/trunk/research/players/srs_player/src/srs_player.as
@@ -258,6 +258,10 @@ package
* function for js to call: to stop the stream. ignore if not play.
*/
private function js_call_stop():void {
+ if (this.media_video) {
+ this.removeChild(this.media_video);
+ this.media_video = null;
+ }
if (this.media_stream) {
this.media_stream.close();
this.media_stream = null;
@@ -266,10 +270,6 @@ package
this.media_conn.close();
this.media_conn = null;
}
- if (this.media_video) {
- this.removeChild(this.media_video);
- this.media_video = null;
- }
}
/**
diff --git a/trunk/research/players/srs_publisher.html b/trunk/research/players/srs_publisher.html
index 565909bad..fb836178e 100755
--- a/trunk/research/players/srs_publisher.html
+++ b/trunk/research/players/srs_publisher.html
@@ -14,9 +14,174 @@
}
@@ -38,6 +203,187 @@
+
+
+ Usage:
+ 输入地址后点击发布按钮
+
+
+
+
+
+
+