Permalink
Browse files

First commit

  • Loading branch information...
0 parents commit 1b7d59123d1a68b3ffac8ac448f4607bab71641e @Soarez committed Oct 20, 2012
Showing with 76 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +7 −0 LICENSE
  3. +13 −0 README.md
  4. +29 −0 index.js
  5. +26 −0 package.json
@@ -0,0 +1 @@
+node_modules
@@ -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.
@@ -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 });
+
@@ -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);
+};
@@ -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.