Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Soarez committed Oct 20, 2012
0 parents commit 1b7d591
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules
7 changes: 7 additions & 0 deletions LICENSE
@@ -0,0 +1,7 @@
Copyright (c) 2012 Igor Soarez <igor@soarez.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13 changes: 13 additions & 0 deletions README.md
@@ -0,0 +1,13 @@
# ar-drone-png-stream

#### *HTTP png stream from nodecopter using `multipart/x-mixed-replace`.*

Usage:

`client` should be an instance of [`ar-drone`](https://github.com/felixge/node-ar-drone)

var arDrone = require('ar-drone');
var client = arDrone.createClient();

require('ar-drone-png-stream')(client, { port: 8000 });

29 changes: 29 additions & 0 deletions index.js
@@ -0,0 +1,29 @@
var http = require('http');

module.exports = function(client, opts) {
var png = null;

opts = opts || {};

var server = http.createServer(function(req, res) {

if (!png) {
png = client.createPngStream({ log : process.stderr });
png.on('error', function (err) {
console.error('png stream ERROR: ' + err);
});
}

res.writeHead(200, { 'Content-Type': 'multipart/x-mixed-replace; boundary=--daboundary' });

png.on('data', sendPng);

function sendPng(buffer) {
console.log(buffer.length);
res.write('--daboundary\nContent-Type: image/png\nContent-length: ' + buffer.length + '\n\n');
res.write(buffer);
}
});

server.listen(opts.port || 8000);
};
26 changes: 26 additions & 0 deletions package.json
@@ -0,0 +1,26 @@
{
"name": "ar-drone-png-stream",
"version": "1.0.0",
"description": "HTTP png stream from nodecopter using multipart/x-mixed-replace",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/Soarez/ar-drone-png-stream"
},
"keywords": [
"ar-drone",
"nodecopter",
"png",
"stream",
"x-mixed-replace",
"multipart"
],
"dependencies": {
"ar-drone": "*"
},
"author": "Igor Soarez <igorsoarez@gmail.com> (http://soarez.com/)",
"license": "MIT"
}

0 comments on commit 1b7d591

Please sign in to comment.