Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 44dfc0e
Showing
8 changed files
with
696 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* ************************************************************************ */ | ||
/* */ | ||
/* haXe Video */ | ||
/* Copyright (c)2007 Nicolas Cannasse */ | ||
/* Copyright (c)2010 af83 */ | ||
/* */ | ||
/* This library is free software; you can redistribute it and/or */ | ||
/* modify it under the terms of the GNU Lesser General Public */ | ||
/* License as published by the Free Software Foundation; either */ | ||
/* version 2.1 of the License, or (at your option) any later version. */ | ||
/* */ | ||
/* This library is distributed in the hope that it will be useful, */ | ||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | ||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ | ||
/* Lesser General Public License or the LICENSE file for more details. */ | ||
/* */ | ||
/* ************************************************************************ */ | ||
|
||
class Main { | ||
static var trace : flash.text.TextField; | ||
static var bpos : Float = 2; | ||
|
||
static function initTrace() { | ||
var mc = flash.Lib.current; | ||
trace = new flash.text.TextField(); | ||
trace.y = 20; | ||
trace.thickness = 2; | ||
trace.width = mc.stage.stageWidth; | ||
trace.height = mc.stage.stageHeight - 20; | ||
trace.selectable = false; | ||
trace.textColor = 0xFFFFFF; | ||
trace.mouseEnabled = false; | ||
trace.filters = [new flash.filters.GlowFilter(0x7F7F7F,90,2,2,10)]; | ||
} | ||
|
||
static function doTrace( v : Dynamic, ?pos : haxe.PosInfos ) { | ||
trace.text += pos.fileName+"("+pos.lineNumber+") : "+Std.string(v)+"\n"; | ||
flash.Lib.current.addChild(trace); | ||
} | ||
|
||
static function main() { | ||
initTrace(); | ||
haxe.Log.trace = doTrace; | ||
var server = flash.Lib.current.loaderInfo.parameters.server; | ||
var stream = flash.Lib.current.loaderInfo.parameters.stream; | ||
flash.net.NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0; | ||
|
||
var cam = flash.media.Camera.getCamera(); | ||
if (cam == null) | ||
{ | ||
throw "webcam not found"; | ||
} | ||
cam.setMode(640, 480, 15, false); | ||
cam.setQuality(0, 100); | ||
if( cam == null ) | ||
doTrace("camera not found"); | ||
var video = new flash.media.Video(cam.width, cam.height); | ||
video.x = 0; | ||
video.y = 0; | ||
video.attachCamera(cam); | ||
flash.Lib.current.addChild(video); | ||
|
||
var webcam = new Webcam(server, stream, "live"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
debug: | ||
haxe -debug video.hxml | ||
|
||
release: | ||
haxe video.hxml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Stream webcam and microphone to a rtmp server | ||
|
||
## Usage | ||
|
||
### vars | ||
|
||
* server | ||
* stream | ||
|
||
### Example | ||
|
||
<embed src="video.swf" | ||
flashvars="server=rtmp://localhost/live&stream=plop" | ||
bgcolor="#ffffff" | ||
width="500" | ||
height="500" | ||
name="haxe" | ||
quality="high" | ||
align="middle" | ||
allowScriptAccess="always" | ||
type="application/x-shockwave-flash" | ||
pluginspage="http://www.macromedia.com/go/getflashplayer" /> | ||
|
||
## Compile | ||
|
||
# debug version | ||
make debug | ||
|
||
# release version | ||
make release | ||
|
||
## License | ||
|
||
LGPL 2.1 | ||
|
||
## Credits | ||
|
||
Original code haXe Video by Nicolas Cannasse | ||
|
||
Copyright (c)2007 Nicolas Cannasse | ||
Copyright (c)2010 af83xs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* ************************************************************************ */ | ||
/* */ | ||
/* haXe Video */ | ||
/* Copyright (c)2007 Nicolas Cannasse */ | ||
/* Copyright (c)2010 af83 */ | ||
/* */ | ||
/* This library is free software; you can redistribute it and/or */ | ||
/* modify it under the terms of the GNU Lesser General Public */ | ||
/* License as published by the Free Software Foundation; either */ | ||
/* version 2.1 of the License, or (at your option) any later version. */ | ||
/* */ | ||
/* This library is distributed in the hope that it will be useful, */ | ||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | ||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ | ||
/* Lesser General Public License or the LICENSE file for more details. */ | ||
/* */ | ||
/* ************************************************************************ */ | ||
class Webcam { | ||
var nc : flash.net.NetConnection; | ||
var ns : flash.net.NetStream; | ||
var cam : flash.media.Camera; | ||
var mic : flash.media.Microphone; | ||
var file : String; | ||
var share : String; | ||
|
||
public function new(host, file,?share) { | ||
this.file = file; | ||
this.share = share; | ||
this.cam = flash.media.Camera.getCamera(); | ||
this.cam.setMode(640, 480, 15, true); | ||
this.mic = flash.media.Microphone.getMicrophone(); | ||
if( this.cam == null ) | ||
throw "Webcam not found"; | ||
this.nc = new flash.net.NetConnection(); | ||
this.nc.addEventListener(flash.events.NetStatusEvent.NET_STATUS,onEvent); | ||
this.nc.connect(host); | ||
} | ||
|
||
function onKey( e : flash.events.KeyboardEvent ) { | ||
ns.send("onMetaData",{ keypress : e.keyCode }); | ||
} | ||
|
||
function onEvent(e) { | ||
if( e.info.code == "NetConnection.Connect.Success" ) { | ||
this.ns = new flash.net.NetStream(nc); | ||
this.ns.addEventListener(flash.events.NetStatusEvent.NET_STATUS,onEvent); | ||
this.ns.publish(this.file,this.share); | ||
} else if (e.info.code == "NetStream.Publish.Start") { | ||
this.ns.attachCamera(this.cam); | ||
this.ns.attachAudio(this.mic); | ||
//this.ns.bufferTime = 1; | ||
} | ||
} | ||
|
||
public function doStop() { | ||
if( ns != null ) | ||
ns.close(); | ||
nc.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<html> | ||
<head><title>haXe Video</title></head> | ||
<body bgcolor="#dddddd"> | ||
|
||
<embed src="video.swf" | ||
flashvars="server=rtmp://localhost/live&stream=plop" | ||
bgcolor="#ffffff" | ||
width="500" | ||
height="500" | ||
name="haxe" | ||
quality="high" | ||
align="middle" | ||
allowScriptAccess="always" | ||
type="application/x-shockwave-flash" | ||
pluginspage="http://www.macromedia.com/go/getflashplayer" /> | ||
|
||
<p> | ||
If you don't see the SWF, check that you have Flash Player 9 installed. | ||
</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-swf9 video.swf | ||
-main Main |
Binary file not shown.