Skip to content

Commit

Permalink
Add config files and rtmp&hls player
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingliang Chen committed Oct 19, 2015
1 parent a688490 commit 1447858
Show file tree
Hide file tree
Showing 12 changed files with 716 additions and 0 deletions.
83 changes: 83 additions & 0 deletions conf/mime.types
Original file line number Diff line number Diff line change
@@ -0,0 1,83 @@

types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/x-javascript js;
application/atom xml atom;
application/rss xml rss;

text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;

image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg xml svg svgz;
image/webp webp;

application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.ms-excel xls;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml xml xhtml;
application/zip zip;

application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;

audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;

video/3gpp 3gpp 3gp;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
video/mp2t ts;
application/vnd.apple.mpegurl m3u8;

}
54 changes: 54 additions & 0 deletions conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 1,54 @@
worker_processes 1;

error_log logs/error.log debug;

events {
worker_connections 1024;
}

rtmp {
server {
listen 1935;

application live {
live on;
}

This comment has been minimized.

Copy link
@DRUPY1977

DRUPY1977 Sep 4, 2020

btvstreaming


application hls {
live on;
hls on;
hls_path temp/hls;
hls_fragment 8s;

This comment has been minimized.

Copy link
@DRUPY1977

DRUPY1977 Sep 4, 2020

btvstreaming

}
}
}

http {
server {
listen 8080;

location / {

This comment has been minimized.

Copy link
@DRUPY1977

DRUPY1977 Sep 4, 2020

btvstreaming

root www;
}

This comment has been minimized.

Copy link
@DRUPY1977

DRUPY1977 Sep 4, 2020


location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}

location /stat.xsl {
root www;
}

location /hls {
#server hls fragments
types{
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
alias temp/hls;
expires -1;
}

}
}
Empty file added logs/access.log
Empty file.
Empty file added logs/error.log
Empty file.
Empty file added temp/temp.txt
Empty file.
Binary file added www/GrindPlayer.swf
Binary file not shown.
91 changes: 91 additions & 0 deletions www/ParsedQueryString.js
Original file line number Diff line number Diff line change
@@ -0,0 1,91 @@
/*******************************************************************************
*
* ParsedQueryString version 1.0
* Copyright 2007, Jeff Mott <[email protected]>. All rights reserved.
*
* Redistribution and use in source and binary forms with or without
* modification are permitted provided that the above copyright notice,
* this condition, and the following disclaimer are retained.
*
* THIS SOFTWARE IS PROVIDED AS IS, AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT
* LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/

function ParsedQueryString() {
this._init();
}

ParsedQueryString.version = '1.0';

ParsedQueryString.prototype =
{
_init:
function ()
{
this._parameters = {};

if (location.search.length <= 1)
return;
var pairs = location.search.substr(1).split(/[&;]/);
for (var i = 0; i < pairs.length; i )
{
var pair = pairs[i].split(/=/);
var name = this._decodeURL(pair[0]);
if (Boolean(pair[1]))
{
var value = this._decodeURL(pair[1]);
if (Boolean(this._parameters[name]))
this._parameters[name].push(value);
else
this._parameters[name] = [value];
}
}
},

_decodeURL:
function (url) {
return decodeURIComponent(url.replace(/\ /g, " "));
},

param:
function (name)
{
if (Boolean(this._parameters[name]))
return this._parameters[name][0];
else
return "";
},

params:
function (name)
{
if (Boolean(name))
{
if (Boolean(this._parameters[name]))
{
var values = [];
for (var i = 0; i < this._parameters[name].length; i )
values.push(this._parameters[name][i]);
return values;
}
else
return [];
}
else
{
var names = [];
for (var name in this._parameters)
names.push(name);
return names;
}
}
};
3 changes: 3 additions & 0 deletions www/crossdomain.xml
Original file line number Diff line number Diff line change
@@ -0,0 1,3 @@
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>
Binary file added www/flashlsOSMF.swf
Binary file not shown.
126 changes: 126 additions & 0 deletions www/index.html
Original file line number Diff line number Diff line change
@@ -0,0 1,126 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Rtmp & HLS Player</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<script type="text/javascript" src="/swfobject.js"></script>
<script type="text/javascript" src="/ParsedQueryString.js"></script>
<script type="text/javascript">
var player = null;

function loadStream(url) {
player.setMediaResourceURL(url);
}

function getlink(url) {
return "/index.html?src=" encodeURIComponent(url);
}

function jsbridge(playerId, event, data) {
if (player == null) {
player = document.getElementById(playerId);
}
switch(event) {
case "onJavaScriptBridgeCreated":
listStreams(teststreams,"streamlist");
break;
case "timeChange":
case "timeupdate":
case "progress":
break;
default:
console.log(event, data);
}
}

// Collect query parameters in an object that we can
// forward to SWFObject:

var pqs = new ParsedQueryString();
var parameterNames = pqs.params(false);
var parameters = {
// src: "rtmp://192.168.0.10/live/demo",
autoPlay: "true",
verbose: true,
controlBarAutoHide: "true",
controlBarPosition: "bottom",
poster: "images/poster.png",
javascriptCallbackFunction: "jsbridge",
plugin_hls: "/flashlsOSMF.swf",
hls_minbufferlength: -1,
hls_maxbufferlength: 30,
hls_lowbufferlength: 3,
hls_seekmode: "KEYFRAME",
hls_startfromlevel: -1,
hls_seekfromlevel: -1,
hls_live_flushurlcache: false,
hls_info: true,
hls_debug: false,
hls_debug2: false,
hls_warn: true,
hls_error: true,
hls_fragmentloadmaxretry : -1,
hls_manifestloadmaxretry : -1,
hls_capleveltostage : false,
hls_maxlevelcappingmode : "downscale"
};

for (var i = 0; i < parameterNames.length; i ) {
var parameterName = parameterNames[i];
parameters[parameterName] = pqs.param(parameterName) ||
parameters[parameterName];
}

var wmodeValue = "direct";
var wmodeOptions = ["direct", "opaque", "transparent", "window"];
if (parameters.hasOwnProperty("wmode"))
{
if (wmodeOptions.indexOf(parameters.wmode) >= 0)
{
wmodeValue = parameters.wmode;
}
delete parameters.wmode;
}

// Embed the player SWF:
swfobject.embedSWF(
"GrindPlayer.swf"
, "GrindPlayer"
, 640
, 480
, "10.1.0"
, "expressInstall.swf"
, parameters
, {
allowFullScreen: "true",
wmode: wmodeValue
}
, {
name: "GrindPlayer"
}
);

</script>
<h1>Nginx-Rtmp-Server</h1>
<p>
<a href="/stat" target="_blank">RTMP 流监控</a> <a href="http://www.nodemedia.cn/" target="_blank">获取Android & iOS RTMP 开发SDK</a>
</p>
<div id="GrindPlayer">
<p>
Alternative content
</p>
</div>
<br>
<input id="userInput" value="rtmp://192.168.0.10/live/demo" size="80"> <button onclick="userSubmit()">Play RTMP Stream</button><br>
<input id="userInput" value="http://192.168.0.10:8080/hls/demo.m3u8" size="80"> <button onclick="userSubmit()">Play HLS Stream</button><br>

<p>
<script type="text/javascript">
function userSubmit() {
window.location = getlink(document.getElementById('userInput').value);
}
</script>
</body>
</html>
Loading

0 comments on commit 1447858

Please sign in to comment.