Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fetch mpd/dash playlists too #35

Merged
merged 6 commits into from
Sep 5, 2019
Merged

Conversation

brandonocasey
Copy link
Contributor

Closes #34

package.json Outdated Show resolved Hide resolved
src/walk-manifest.js Outdated Show resolved Hide resolved
requestRetryDelay = 5000
} = options;

let resources = [];
const manifest = {};
const manifest = {parent};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dash needs access to the parent manifest on child playlists

@@ -147,125 +168,160 @@ const walkPlaylist = function(options) {
visitedUrls = [],
requestTimeout = 1500,
requestRetryMaxAttempts = 5,
dashPlaylist = null,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In mpd-parser we really only mock child playlists. So if we see dashPlaylist here we know:

  1. That this playlist won't have a uri, or anything to download
  2. That this playlist has already been parsed

src/walk-manifest.js Outdated Show resolved Hide resolved
resources.push(manifest);
visitedUrls.push(manifest.uri);
if (dashPlaylist) {
requestPromise = Promise.resolve({statusCode: 200});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only request when needed.


let dash;

if (!dashPlaylist) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only parse when needed.

@@ -68,15 +68,15 @@ const WriteData = function(decrypt, concurrency, resources) {
operations.push(function() {
return writeFile(r.file, r.content);
});
} else if (r.key && decrypt) {
} else if (r.uri && r.key && decrypt) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore any file that does not have a uri, such as dash playlists.

@gkatsev
Copy link
Member

gkatsev commented Aug 30, 2019

Looks like this works for simple mpds, it didn't work for the SIDX mpd that we have linked in VHS master.
Also, seems like decryption is broken?

@brandonocasey
Copy link
Contributor Author

Fixed the sidx case and decryption, seems like aes-decrypter expects a Uint8Array and not an ArrayBuffer, not sure when this happened.

if (err) {
return reject(err);
}
return resolve(new Buffer(bytes));
return resolve(Buffer.from(bytes));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new Buffer is deprecated in current nodejs and this is now the reccomended usage.

};

const decryptFile = function(content, encryption) {
return new Promise(function(resolve, reject) {
/* eslint-disable no-new */
// this is how you use it, its kind of bad but :shrug:
new AesDecrypter(toArrayBuffer(content), encryption.bytes, encryption.iv, function(err, bytes) {
new AesDecrypter(toUint8Array(content), encryption.bytes, encryption.iv, function(err, bytes) {
Copy link
Contributor Author

@brandonocasey brandonocasey Sep 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AesDecrypter expects a Uint8Array

}
return ab;
const toUint8Array = function(nodeBuffer) {
return new Uint8Array(nodeBuffer.buffer, nodeBuffer.byteOffset, nodeBuffer.byteLength / Uint8Array.BYTES_PER_ELEMENT);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nodes Buffer object to Uint8Array.

Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SIDX and decryption is working now. LGTM.

@brandonocasey brandonocasey merged commit f6b4101 into master Sep 5, 2019
@brandonocasey brandonocasey deleted the feat/fetch-dash branch September 5, 2019 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Download Dash using mpd-parser
2 participants