hlx-lib
Version:
A library for processing HLS streams
21 lines (18 loc) • 577 B
JavaScript
const {Readable} = require('stream');
const {createReadStream} = require('hlx-file-reader');
const {createUrlRewriter} = require('hlx-url-rewriter');
function createSource(location, options = {}) {
const urlRewriter = createUrlRewriter(options);
let head;
if (location instanceof Readable) {
head = location;
} else {
const defaultOpts = {rawResponse: true};
head = createReadStream(location, Object.assign(defaultOpts, options));
}
if (options.noUriConversion) {
return head;
}
return head.pipe(urlRewriter);
}
module.exports = createSource;