@torrent-tv/proxy 2.72.2 → 2.73.0
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.
- package/CHANGELOG.md +11 -0
- package/docs/container-architecture.md +66 -0
- package/package.json +1 -1
- package/routes/api/sources/warm/post.js +19 -0
- package/routes/stream/get.js +18 -1
- package/server.js +25 -1
- package/services/container/AviContainer.js +36 -0
- package/services/container/Container.js +41 -0
- package/services/container/MatroskaContainer.js +186 -1
- package/services/container/Mp4Container.js +158 -29
- package/services/container-index/ebml-reader.js +30 -0
- package/services/hls-session-manager.js +167 -37
- package/services/orchestrators/ContainerOrchestrator.js +22 -0
- package/services/torrent-pool.js +46 -0
- package/services/torrent-worker/client.js +21 -0
- package/services/torrent-worker/container-tracks.js +134 -0
- package/services/torrent-worker/fastest-wires.js +29 -6
- package/services/torrent-worker/piece-reader.js +11 -4
- package/services/torrent-worker/pool-adapter.js +35 -0
- package/services/torrent-worker/protocol.js +12 -0
- package/services/torrent-worker/worker.js +45 -1
- package/test/container-media-info.test.js +228 -0
- package/test/resume-warm.test.js +39 -0
- package/test/tail-duplication.test.js +48 -4
|
@@ -60,7 +60,7 @@ test("the missing blocks are freed and asked of a second wire", () => {
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
test("at most one duplicate per wire, however long the tail", () => {
|
|
63
|
-
const target = piece(512,
|
|
63
|
+
const target = piece(512, 16);
|
|
64
64
|
const torrent = {
|
|
65
65
|
pieces: [target],
|
|
66
66
|
wires: [wire(), wire()],
|
|
@@ -73,7 +73,29 @@ test("at most one duplicate per wire, however long the tail", () => {
|
|
|
73
73
|
assert.equal(target.cancelled.length, 2, "and no reservation is freed that nobody was asked for");
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
test("a
|
|
76
|
+
test("a piece still arriving normally is not duplicated at all", () => {
|
|
77
|
+
// Forty blocks outstanding is not a tail, it is a piece in transit. Asking
|
|
78
|
+
// for a second copy of it would spend the shared link on bytes that are
|
|
79
|
+
// already on their way — which is the whole difference between this and the
|
|
80
|
+
// 2-14 blocks a blocked reader was measured waiting on.
|
|
81
|
+
const target = piece(512, 40);
|
|
82
|
+
const torrent = {
|
|
83
|
+
pieces: [target],
|
|
84
|
+
wires: [wire(), wire()],
|
|
85
|
+
_request: () => true
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const result = duplicateTailFor(torrent, 0);
|
|
89
|
+
|
|
90
|
+
assert.equal(result.duplicated, 0);
|
|
91
|
+
assert.equal(target.cancelled.length, 0, "and nothing is freed either");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("a wire whose pipeline is full does not end the attempt", () => {
|
|
95
|
+
// Pipelines are per wire, so one wire being full says nothing about the next.
|
|
96
|
+
// This used to stop the whole pass on the first refusal, on the stated
|
|
97
|
+
// reasoning that the remaining wires were "no emptier" — an assumption about
|
|
98
|
+
// other peers' queues that nothing measures.
|
|
77
99
|
const target = piece(512, 5);
|
|
78
100
|
const torrent = {
|
|
79
101
|
pieces: [target],
|
|
@@ -88,11 +110,33 @@ test("a wire whose pipeline is full ends the attempt", () => {
|
|
|
88
110
|
assert.equal(result.duplicated, 0);
|
|
89
111
|
assert.equal(
|
|
90
112
|
target.cancelled.length,
|
|
91
|
-
|
|
92
|
-
"
|
|
113
|
+
3,
|
|
114
|
+
"every wire was offered a block; a freed reservation nobody took is handed to whoever asks next"
|
|
93
115
|
);
|
|
94
116
|
});
|
|
95
117
|
|
|
118
|
+
test("a refusal by one wire does not cost the block a faster wire would have taken", () => {
|
|
119
|
+
const target = piece(512, 3);
|
|
120
|
+
const placed = [];
|
|
121
|
+
const torrent = {
|
|
122
|
+
pieces: [target],
|
|
123
|
+
wires: [wire({ speed: 900_000 }), wire({ speed: 800_000 })],
|
|
124
|
+
_request: (wireAsked, index) => {
|
|
125
|
+
// The first wire is full; the second is not.
|
|
126
|
+
if (wireAsked === torrent.wires[0]) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
placed.push(index);
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const result = duplicateTailFor(torrent, 0);
|
|
135
|
+
|
|
136
|
+
assert.equal(result.duplicated, 1);
|
|
137
|
+
assert.deepEqual(placed, [0], "the second wire was still asked");
|
|
138
|
+
});
|
|
139
|
+
|
|
96
140
|
test("a piece with nothing missing is left alone", () => {
|
|
97
141
|
const target = piece(4, 0);
|
|
98
142
|
const torrent = { pieces: [target], wires: [wire()], _request: () => true };
|