Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nicercast

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nicercast - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

20

examples/server.js

@@ -1,17 +0,9 @@

var Throttle = require('throttle');
var NicerCast = require('../index.js');
// Stdin is expecting raw PCM data of the format:
var SAMPLE_SIZE = 16 // 16-bit samples, Little-Endian, Signed
, CHANNELS = 2 // 2 channels (left and right)
, SAMPLE_RATE = 44100 // 44,100 Hz sample rate.
var server = new NicerCast(process.stdin, {});
server.start();
// If we're getting raw PCM data as expected, calculate the number of bytes
// that need to be read for `1 Second` of audio data.
var BLOCK_ALIGN = SAMPLE_SIZE / 8 * CHANNELS // Number of 'Bytes per Sample'
, BYTES_PER_SECOND = SAMPLE_RATE * BLOCK_ALIGN
var throttle = new Throttle(BYTES_PER_SECOND);
var stream = process.stdin;
var server = new NicerCast(stream);
server.start();
var x = 0;
setInterval(function() {
server.setMetadata('Test Metadata ' + x++);
}, 1000);

@@ -14,3 +14,3 @@ var express = require('express');

// that need to be read for `1 Second` of audio data.
var BLOCK_ALIGN = SAMPLE_SIZE / 8 * CHANNELS // Number of 'Bytes per Sample'
var BLOCK_ALIGN = SAMPLE_SIZE / 8 * CHANNELS // Number of 'Bytes per Sample'
, BYTES_PER_SECOND = SAMPLE_RATE * BLOCK_ALIGN;

@@ -29,3 +29,3 @@

// stream playlist (points to other endpoint)
app.get('/listen.m3u', function(req, res) {
var playlistEndpoint = function(req, res) {

@@ -37,10 +37,14 @@ var addr = ip.address();

res.send('http://' + addr + ':' + serverPort + '/listen');
});
};
app.get('/', playlistEndpoint);
app.get('/listen.m3u', playlistEndpoint);
app.get('/listen', function(req, res, next) {
var acceptsMetadata = req.headers['icy-metadata'] == 1;
var parsed = require('url').parse(req.url, true);
var acceptsMetadata = req.headers['icy-metadata'] == 1;
var parsed = require('url').parse(req.url, true);
// generate response header
// generate response header
var headers = {

@@ -59,6 +63,6 @@ "Content-Type": 'audio/mpeg',

res = new icecast.IcecastWriteStack(res, 8192);
res.queueMetadata(opts.name);
res.queueMetadata(this.metadata || opts.name);
}
// setup encodervar lame = require('lame');
// setup encoder

@@ -72,5 +76,11 @@ // create the Encoder instance

var prevMetadata = 0;
encoder.on("data", function(chunk) {
if (acceptsMetadata && prevMetadata != this.metadata) {
res.queueMetadata(this.metadata || opts.name);
prevMetadata = this.metadata;
}
res.write(chunk);
});
}.bind(this));

@@ -90,3 +100,2 @@ /*

req.connection.on("close", function() {
// This occurs when the HTTP client closes the connection.

@@ -96,3 +105,3 @@ encoder.end();

});
});
}.bind(this));

@@ -104,4 +113,12 @@ // server methods

}
Server.prototype.setMetadata = function(metadata) {
this.metadata = metadata;
};
Server.prototype.stop = function() {
app.close();
}
}
module.exports = Server;
{
"name": "nicercast",
"version": "0.0.2",
"version": "0.0.3",
"description": "simple icecast compliant streaming server",

@@ -11,3 +11,3 @@ "main": "index.js",

"type": "git",
"url": "https://github.com/StephenCWan/nicercast.git"
"url": "https://github.com/stephen/nicercast.git"
},

@@ -24,5 +24,5 @@ "keywords": [

"bugs": {
"url": "https://github.com/StephenCWan/nicercast/issues"
"url": "https://github.com/stephen/nicercast/issues"
},
"homepage": "https://github.com/StephenCWan/nicercast",
"homepage": "https://github.com/stephen/nicercast",
"dependencies": {

@@ -29,0 +29,0 @@ "express": "~3.5.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc