Upload Modules

This commit is contained in:
mxd
2026-05-17 11:34:54 +08:00
commit 9f28fed00a
171 changed files with 53743 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
# RTMP Publisher
Simple RTMP publisher.
Edit the following flashvars in publisher.html & player.html to suite your needs.
streamer: RTMP endpoint
file: live stream name
## Compile
Install flex sdk http://www.adobe.com/devnet/flex/flex-sdk-download.html
mxmlc RtmpPublisher.mxml
mxmlc RtmpPlayer.mxml

View File

@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="500" minHeight="350" creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.core.FlexGlobals;
import flash.display.StageDisplayState;
import mx.managers.SystemManager;
private var streamer:String;
private var file:String;
private function playButtonListener(event:MouseEvent):void {
if(playButton.label == 'Play') {
playButton.label = 'Stop';
videoDisplay.source = streamer + "/" + file;
videoDisplay.play();
} else {
playButton.label = 'Play';
videoDisplay.source = "";
//videoDisplay.close();
}
}
private function fullscreenButtonListener(event:MouseEvent):void {
try {
switch (systemManager.stage.displayState) {
case StageDisplayState.FULL_SCREEN:
stage.displayState = StageDisplayState.NORMAL;
break;
default:
stage.displayState = StageDisplayState.FULL_SCREEN;
break;
}
} catch (err:SecurityError) {
// ignore
}
}
private function init():void {
videoDisplay.mx_internal::videoPlayer.bufferTime = 1;
streamer = FlexGlobals.topLevelApplication.parameters.streamer;
if(streamer == null) {
Alert.show('Missing flashvars: streamer');
return;
}
file = FlexGlobals.topLevelApplication.parameters.file;
if(file == null) {
Alert.show('Missing flashvars: file');
return;
}
playButton.addEventListener(MouseEvent.CLICK, playButtonListener);
fullscreenButton.addEventListener(MouseEvent.CLICK, fullscreenButtonListener);
}
]]>
</fx:Script>
<s:BorderContainer x="0" y="0" width="100%" height="100%">
<s:VideoDisplay width="100%" height="100%" id="videoDisplay"></s:VideoDisplay>
<s:Button label="Play" id="playButton" horizontalCenter="0" bottom="10"></s:Button>
<s:Button label="[ ]" id="fullscreenButton" right="10" bottom="10"></s:Button>
</s:BorderContainer>
</s:Application>

Binary file not shown.

View File

@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="500" minHeight="350" creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.core.FlexGlobals;
import flash.display.StageDisplayState;
import mx.managers.SystemManager;
import org.osmf.events.MediaPlayerStateChangeEvent;
import org.osmf.events.TimeEvent;
import org.osmf.media.MediaPlayerState;
private var streamer:String;
private var file:String;
private var videoEventsDisabled:Boolean;
private var previousVideoTime:Number;
private function fullscreenListener(event:MouseEvent):void {
try {
switch (stage.displayState) {
case StageDisplayState.FULL_SCREEN:
stage.displayState = StageDisplayState.NORMAL;
break;
default:
stage.displayState = StageDisplayState.FULL_SCREEN;
break;
}
} catch (err:SecurityError) {
Alert.show('Fullsceen error: ' + err);
}
}
private function resetVideo():void {
videoEventsDisabled = true;
try {
videoDisplay.source = "";
} catch (any:*) {}
setTimeout(resetVideoSource, 5000);
}
private function resetVideoSource():void {
videoEventsDisabled = false;
previousVideoTime = NaN;
videoDisplay.source = streamer + "/" + file;
}
protected function stateChangeListener(event:MediaPlayerStateChangeEvent):void {
if (videoEventsDisabled) {
return;
}
if (event.state == MediaPlayerState.PLAYBACK_ERROR) {
resetVideo();
}
}
protected function timeChangeListener(event:TimeEvent):void {
if (videoEventsDisabled) {
return;
}
if (isNaN(event.time) && !isNaN(previousVideoTime)) {
resetVideo();
} else {
previousVideoTime = event.time;
}
}
private function init():void {
videoDisplay.mx_internal::videoPlayer.bufferTime = 1;
streamer = FlexGlobals.topLevelApplication.parameters.streamer;
if(streamer == null) {
Alert.show('Missing flashvars: streamer');
return;
}
file = FlexGlobals.topLevelApplication.parameters.file;
if(file == null) {
Alert.show('Missing flashvars: file');
return;
}
videoDisplay.addEventListener(MouseEvent.DOUBLE_CLICK, fullscreenListener);
videoDisplay.addEventListener("MediaPlayerStateChange", stateChangeListener);
videoDisplay.addEventListener("currentTimeChange", timeChangeListener);
resetVideoSource();
}
]]>
</fx:Script>
<s:BorderContainer x="0" y="0" width="100%" height="100%">
<s:VideoDisplay doubleClickEnabled="true" width="100%" height="100%" id="videoDisplay"></s:VideoDisplay>
</s:BorderContainer>
</s:Application>

View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="500" minHeight="350" creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.core.FlexGlobals;
import mx.events.FlexEvent;
import spark.skins.spark.PanelSkin;
private var streamer:String;
private var file:String;
private var camera:Camera;
private var microphone:Microphone;
private var connection:NetConnection;
private var stream:NetStream;
private var h264Settings:H264VideoStreamSettings;
private function publishButtonListener(event:MouseEvent):void {
if(publishButton.label == 'Publish') {
publishButton.label = 'Stop';
connection = new NetConnection();
connection.connect(streamer);
connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHander);
} else {
publishButton.label = 'Publish';
stream.close();
connection.close();
stream = null;
connection = null;
}
}
private function netStatusHander(event:NetStatusEvent):void {
switch(event.info.code) {
case 'NetConnection.Connect.Success':
stream = new NetStream(connection);
stream.attachCamera(camera);
stream.attachAudio(microphone);
h264Settings = new H264VideoStreamSettings();
h264Settings.setProfileLevel(H264Profile.BASELINE, H264Level.LEVEL_3_1);
stream.videoStreamSettings = h264Settings;
stream.publish(file, 'live');
break;
}
}
private function init():void {
streamer = FlexGlobals.topLevelApplication.parameters.streamer;
if(streamer == null) {
Alert.show('Missing flashvars: streamer');
return;
}
file = FlexGlobals.topLevelApplication.parameters.file;
if(file == null) {
Alert.show('Missing flashvars: file');
return;
}
publishButton.addEventListener(MouseEvent.CLICK, publishButtonListener);
camera = Camera.getCamera();
camera.setMode(640, 480, 30);
camera.setQuality(131072, 70);
//videoDisplay.attachCamera(camera);
var localCam:Video = new Video(640,480);
localCam.attachCamera(camera);
videoDisplay.addChild(localCam);
microphone = Microphone.getMicrophone();
microphone.setSilenceLevel(0);
microphone.codec = "Speex";
microphone.encodeQuality = 6;
}
]]>
</fx:Script>
<s:BorderContainer x="0" y="0" width="100%" height="100%">
<s:VideoDisplay width="100%" height="100%" id="videoDisplay"></s:VideoDisplay>
<s:Button label="Publish" id="publishButton" horizontalCenter="0" bottom="10"></s:Button>
</s:BorderContainer>
</s:Application>

View File

@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>RTMP Player</title>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var flashVars = {
streamer: 'rtmp://localhost/myapp',
file:'mystream'
};
var params = {};
params.allowfullscreen = "true";
var attributes = {};
swfobject.embedSWF("RtmpPlayer.swf", "rtmp-publisher", "640", "480", "9.0.0", null, flashVars, params, attributes);
</script>
</head>
<body>
<div id="rtmp-publisher">
<p>Flash not installed</p>
</div>
</body>
</html>

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>RTMP Publisher</title>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var flashVars = {
streamer: 'rtmp://localhost/myapp',
file:'mystream'
};
swfobject.embedSWF("RtmpPublisher.swf", "rtmp-publisher", "640", "480", "9.0.0", null, flashVars);
</script>
</head>
<body>
<div id="rtmp-publisher">
<p>Flash not installed</p>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long