@lumen5/beamcoder 0.0.21 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,122 +0,0 @@
1
- /*
2
- Aerostat Beam Coder - Node.js native bindings for FFmpeg.
3
- Copyright (C) 2019 Streampunk Media Ltd.
4
-
5
- This program is free software: you can redistribute it and/or modify
6
- it under the terms of the GNU General Public License as published by
7
- the Free Software Foundation, either version 3 of the License, or
8
- (at your option) any later version.
9
-
10
- This program is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- GNU General Public License for more details.
14
-
15
- You should have received a copy of the GNU General Public License
16
- along with this program. If not, see <https://www.gnu.org/licenses/>.
17
-
18
- https://www.streampunk.media/ mailto:furnace@streampunk.media
19
- 14 Ormiscaig, Aultbea, Achnasheen, IV22 2JJ U.K.
20
- */
21
-
22
- const test = require('tape');
23
- const beamcoder = require('../index.js');
24
-
25
- test('Create a packet', t => {
26
- let pkt = beamcoder.packet();
27
- t.ok(pkt, 'is truthy.');
28
- t.equal(typeof pkt._packet, 'object', 'external value present.');
29
- t.deepEqual(pkt, { type: 'Packet',
30
- pts: null,
31
- dts: null,
32
- data: null,
33
- size: 0,
34
- stream_index: 0,
35
- flags:
36
- { KEY: false,
37
- CORRUPT: false,
38
- DISCARD: false,
39
- TRUSTED: false,
40
- DISPOSABLE: false },
41
- side_data: null,
42
- duration: 0,
43
- pos: -1 }, 'has expected minimal value.');
44
- t.end();
45
- });
46
-
47
- test('Minimal JSON serialization', t => {
48
- let pkt = beamcoder.packet();
49
- t.equal(typeof pkt.toJSON, 'function', 'has hidden toJSON function.');
50
- let ps = JSON.stringify(pkt);
51
- t.equal(typeof ps, 'string', 'stringify created a string.');
52
- let pps = JSON.parse(ps);
53
- t.deepEqual(pps, { type: 'Packet', stream_index: 0 }, 'made minimal value.');
54
- let rpkt = beamcoder.packet(ps);
55
- t.ok(rpkt, 'roundtrip packet is truthy.');
56
- t.deepEqual(rpkt, { type: 'Packet',
57
- pts: null,
58
- dts: null,
59
- data: null,
60
- size: 0,
61
- stream_index: 0,
62
- flags:
63
- { KEY: false,
64
- CORRUPT: false,
65
- DISCARD: false,
66
- TRUSTED: false,
67
- DISPOSABLE: false },
68
- side_data: null,
69
- duration: 0,
70
- pos: -1 }, 'has expected minimal value.');
71
- t.end();
72
- });
73
-
74
- test('Maximal JSON serialization', t => {
75
- let pkt = beamcoder.packet({ type: 'Packet',
76
- pts: 42,
77
- dts: 43,
78
- data: Buffer.from('wibble'),
79
- stream_index: 7,
80
- flags:
81
- { KEY: true,
82
- CORRUPT: false,
83
- DISCARD: false,
84
- TRUSTED: true,
85
- DISPOSABLE: false },
86
- side_data: { replaygain: Buffer.from('wobble') },
87
- duration: 44,
88
- pos: 45 });
89
- let ps = JSON.stringify(pkt);
90
- t.equal(typeof ps, 'string', 'stringify created a string.');
91
- let rpkt = beamcoder.packet(ps);
92
- t.ok(rpkt, 'roundtrip packet is truthy.');
93
- t.deepEqual(rpkt, { type: 'Packet',
94
- pts: 42,
95
- dts: 43,
96
- data: null,
97
- size: 0,
98
- stream_index: 7,
99
- flags:
100
- { KEY: true,
101
- CORRUPT: false,
102
- DISCARD: false,
103
- TRUSTED: true,
104
- DISPOSABLE: false },
105
- side_data:
106
- { type: 'PacketSideData',
107
- replaygain: Buffer.from([0x77, 0x6f, 0x62, 0x62, 0x6c, 0x65]) },
108
- duration: 44,
109
- pos: 45 }, 'roundtrips expected values.');
110
- t.end();
111
- });
112
-
113
- test('Reset packet data', t => {
114
- let p = beamcoder.packet({ pts: 42, size: 4321, data: Buffer.alloc(4321 + beamcoder.AV_INPUT_BUFFER_PADDING_SIZE) });
115
- t.ok(Buffer.isBuffer(p.data), 'data is a buffer.');
116
- t.notEqual(p.data.length, p.size, 'data length is greater than the packet size.');
117
- t.equal(p.data.length, 4321 + beamcoder.AV_INPUT_BUFFER_PADDING_SIZE, 'length is as expected.');
118
- p.data = null;
119
- t.equal(p.data, null, 'after reset, packet data is set to null.');
120
- t.equal(p.size, 4321, 'after reset, size remains at original value.');
121
- t.end();
122
- });