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

inspector.js

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inspector.js - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

package-lock.json

5

package.json
{
"name": "inspector.js",
"version": "0.0.2",
"version": "0.0.3",
"description": "Javascript Library that implements MpegTS and MP4 demuxers.",

@@ -33,3 +33,2 @@ "main": "index.ts",

"extract-text-webpack-plugin": "^2.1.2",
"hls.js": "^0.7.11",
"html-webpack-externals-plugin": "^3.4.0",

@@ -47,5 +46,5 @@ "html-webpack-plugin": "^2.29.0",

"webpack-dashboard": "^0.3.0",
"webpack-dev-server": "^2.4.2"
"webpack-dev-server": "2.7.1"
},
"dependencies": {}
}

28

src/demuxer/mp4/mp4-track.ts

@@ -8,3 +8,2 @@ import Track from '../track';

export default class Mp4Track extends Track {
public frames: Frame[];
private sidx: Sidx;

@@ -16,18 +15,18 @@ private trun: Trun;

super(id, type, mimeType);
this.frames = [];
this.lastPts = 0;
}
public getFrames(): Frame[] {
return this.frames;
}
public getFrames(): Frame[] {
return this.frames;
}
public setSidxAtom(atom: Atom): void {
this.sidx = atom as Sidx;
this.lastPts = 1000000 * this.sidx.earliestPresentationTime / this.sidx.timescale;
}
public setSidxAtom(atom: Atom): void {
this.sidx = atom as Sidx;
this.lastPts = 1000000 * this.sidx.earliestPresentationTime / this.sidx.timescale;
}
public setTrunAtom(atom: Atom): void {
this.trun = atom as Trun;
for ( const sample of this.trun.samples) {
public setTrunAtom(atom: Atom): void {
this.trun = atom as Trun;
this.duration = 0;
for (const sample of this.trun.samples) {
if (sample.flags) {

@@ -38,5 +37,6 @@ this.frames.push(new Frame(sample.flags.isSyncFrame ? Frame.IDR_FRAME : Frame.P_FRAME, this.lastPts));

this.lastPts += sample.duration;
this.duration += sample.duration;
}
}
}
}
}
}

@@ -18,16 +18,21 @@ import Frame from './frame';

constructor(public id: number, private type: string, private mimeType: string) {
public frames: Frame[];
public duration: number;
constructor(public id: number, public type: string, public mimeType: string) {
this.frames = [];
}
public getType(): string {
return this.type;
public getFrames(): Frame[] {
return [];
}
public getMimeType(): string {
return this.mimeType;
public getDuration(): number {
return this.duration;
}
public getFrames(): Frame[] {
return [];
public update(): void {
this.frames = this.getFrames();
this.duration = this.getDuration();
}
}

@@ -5,2 +5,3 @@ import BitReader from '../../utils/bit-reader';

import Track from '../track';
import ITrackInfo from '../track-info';
import IDemuxer from '../demuxer';

@@ -35,3 +36,3 @@

public append(data: Uint8Array): void {
public append(data: Uint8Array): ITrackInfo[] {
if (!this.data || this.data.byteLength === 0 || this.dataOffset >= this.data.byteLength) {

@@ -64,4 +65,23 @@ this.data = data;

}
return this.getTracksInfo();
}
public getTracksInfo(): ITrackInfo[] {
const trackInfos: ITrackInfo[] = [];
for (var trackId in this.tracks) {
if (this.tracks.hasOwnProperty(trackId)) {
const track: Track = this.tracks[trackId];
track.update();
trackInfos.push({
id: track.id,
mimeType: track.mimeType,
type: track.type,
frames: track.frames,
duration: track.duration,
});
}
}
return trackInfos;
}
public end(): void {

@@ -152,3 +172,3 @@ for (let id in this.tracks) {

if (adaptationField > 1) {
length = packetParser.readByte();
const length: number = packetParser.readByte();
if (length > 0) {

@@ -202,3 +222,23 @@ packetParser.skipBytes(length);

const pes: PESReader = new PESReader(elementaryPid, streamType);
this.tracks[elementaryPid] = new TSTrack(elementaryPid, '', '', pes);
let type: string;
let mimeType: string;
if (streamType === PESReader.TS_STREAM_TYPE_AAC) {
type = Track.TYPE_AUDIO;
mimeType = Track.MIME_TYPE_AAC;
} else if (streamType === PESReader.TS_STREAM_TYPE_H264) {
type = Track.TYPE_VIDEO;
mimeType = Track.MIME_TYPE_AVC;
} else if (streamType === PESReader.TS_STREAM_TYPE_ID3) {
type = Track.TYPE_TEXT;
mimeType = Track.MIME_TYPE_ID3;
} else if (streamType === PESReader.TS_STREAM_TYPE_MPA || streamType === PESReader.TS_STREAM_TYPE_MPA_LSF) {
type = Track.TYPE_AUDIO;
mimeType = Track.MIME_TYPE_MPEG;
} else if (streamType === PESReader.TS_STREAM_TYPE_METADATA) {
// do nothing
} else {
type = Track.TYPE_UNKNOWN;
mimeType = Track.MIME_TYPE_UNKNOWN;
}
this.tracks[elementaryPid] = new TSTrack(elementaryPid, type, mimeType, pes);
}

@@ -205,0 +245,0 @@ }

@@ -10,20 +10,2 @@ import Track from '../track';

public getType(): string {
const mimeType: string = this.getMimeType();
if (mimeType) {
const pos: number = mimeType.indexOf('/');
if (pos > 0) {
return mimeType.substring(0, pos);
}
}
return '';
}
public getMimeType(): string {
if (this.pes && this.pes.payloadReader) {
return this.pes.payloadReader.getMimeType();
}
return super.getMimeType();
}
public getDuration(): number {

@@ -30,0 +12,0 @@ if (this.pes && this.pes.payloadReader) {

@@ -103,3 +103,3 @@ export default class BitReader {

const workingBytes: Uint8Array = new Uint8Array(4);
const availableBytes: number = Math.min(4, this.workingBytesAvailable);
const availableBytes: number = Math.min(4, this.remainingBytes());

@@ -106,0 +106,0 @@ if (availableBytes === 0) {

@@ -38,3 +38,4 @@ const path = require("path");

// source when the user debugs the application
devtool: 'source-map',
// devtool: 'source-map',
devtool: 'eval', // https://github.com/webpack/webpack/issues/1487#issuecomment-209299242
plugins: [

@@ -77,7 +78,2 @@ // Apply minification only on the second bundle by

},
{
module: 'hls.js',
entry: 'dist/hls.min.js',
global: 'Hls'
},
],

@@ -84,0 +80,0 @@ })

Sorry, the diff of this file is not supported yet

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