mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-09 06:01:08 +02:00
Added test rtmp publisher
This commit is contained in:
parent
4cbe407bd3
commit
45c9b7e225
14
test/rtmp-publisher/README.md
Normal file
14
test/rtmp-publisher/README.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# RTMP Publisher
|
||||
|
||||
Simple RTMP publisher.
|
||||
|
||||
Edit the following flashvars in demo.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
|
108
test/rtmp-publisher/RtmpPublisher.mxml
Normal file
108
test/rtmp-publisher/RtmpPublisher.mxml
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?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:Declarations>
|
||||
<!-- Place non-visual elements (e.g., services, value objects) here -->
|
||||
</fx:Declarations>
|
||||
|
||||
<fx:Script>
|
||||
<![CDATA[
|
||||
import mx.controls.Alert;
|
||||
import mx.core.FlexGlobals;
|
||||
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 function toggleFeedListener(event:MouseEvent):void {
|
||||
if(toggleFeed.label == 'Start Feed') {
|
||||
toggleFeed.label = 'Stop Feed';
|
||||
stream.publish(file, 'live');
|
||||
videoDisplay.attachCamera(camera);
|
||||
toggleVideo.enabled = true;
|
||||
toggleAudio.enabled = true;
|
||||
} else {
|
||||
toggleFeed.label = 'Start Feed';
|
||||
stream.close();
|
||||
videoDisplay.attachCamera(null);
|
||||
toggleVideo.enabled = false;
|
||||
toggleAudio.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function toggleVideoListener(event:MouseEvent):void {
|
||||
if(toggleVideo.label == 'Start Video') {
|
||||
toggleVideo.label = 'Stop Video';
|
||||
videoDisplay.attachCamera(camera);
|
||||
stream.attachCamera(camera);
|
||||
} else {
|
||||
toggleVideo.label = 'Start Video';
|
||||
videoDisplay.attachCamera(null);
|
||||
stream.attachCamera(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function toggleAudioListener(event:MouseEvent):void {
|
||||
if(toggleAudio.label == 'Start Audio') {
|
||||
toggleAudio.label = 'Stop Audio';
|
||||
stream.attachAudio(microphone);
|
||||
} else {
|
||||
toggleAudio.label = 'Start Audio';
|
||||
stream.attachAudio(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function initListeners():void {
|
||||
toggleFeed.addEventListener(MouseEvent.CLICK, toggleFeedListener);
|
||||
toggleVideo.addEventListener(MouseEvent.CLICK, toggleVideoListener);
|
||||
toggleAudio.addEventListener(MouseEvent.CLICK, toggleAudioListener);
|
||||
}
|
||||
|
||||
private function netStatusHander(event:NetStatusEvent):void {
|
||||
switch(event.info.code) {
|
||||
case 'NetConnection.Connect.Success':
|
||||
stream = new NetStream(connection);
|
||||
stream.attachCamera(camera);
|
||||
stream.attachAudio(microphone);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function init():void {
|
||||
streamer = FlexGlobals.topLevelApplication.parameters.streamer;
|
||||
file = FlexGlobals.topLevelApplication.parameters.file;
|
||||
if(file == null) {
|
||||
Alert.show('Missing flashvars: file');
|
||||
return;
|
||||
}
|
||||
if(streamer == null) {
|
||||
Alert.show('Missing flashvars: streamer');
|
||||
return;
|
||||
}
|
||||
initListeners();
|
||||
|
||||
camera = Camera.getCamera();
|
||||
microphone = Microphone.getMicrophone();
|
||||
connection = new NetConnection();
|
||||
connection.connect(streamer);
|
||||
connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHander);
|
||||
|
||||
}
|
||||
]]>
|
||||
</fx:Script>
|
||||
<s:Panel x="0" y="0" width="100%" height="100%" title="RTMP Publisher">
|
||||
<mx:VideoDisplay width="100%" height="100%" id="videoDisplay">
|
||||
</mx:VideoDisplay>
|
||||
<s:controlBarContent>
|
||||
<s:Button label="Start Feed" id="toggleFeed"></s:Button>
|
||||
<s:Spacer width="100%" height="100%"/>
|
||||
<s:Button label="Stop Video" id="toggleVideo" enabled="false"></s:Button>
|
||||
<s:Button label="Stop Audio" id="toggleAudio" enabled="false"></s:Button>
|
||||
</s:controlBarContent>
|
||||
</s:Panel>
|
||||
</s:Application>
|
BIN
test/rtmp-publisher/RtmpPublisher.swf
Normal file
BIN
test/rtmp-publisher/RtmpPublisher.swf
Normal file
Binary file not shown.
19
test/rtmp-publisher/demo.html
Normal file
19
test/rtmp-publisher/demo.html
Normal 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", "500", "400", "9.0.0", null, flashVars);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="rtmp-publisher">
|
||||
<p>Flash not installed</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
4
test/rtmp-publisher/swfobject.js
Normal file
4
test/rtmp-publisher/swfobject.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue