1 |
|
---|
2 | Mad.ArrayBuffers.SubStream = Mad.ArrayBuffers.ByteStream.extend({
|
---|
3 | init: function(stream, offset, length) {
|
---|
4 | this.offset = 0;
|
---|
5 | this.start = offset;
|
---|
6 | this.parentStream = stream;
|
---|
7 | this.length = length;
|
---|
8 | },
|
---|
9 |
|
---|
10 | substream: function (offset, length) {
|
---|
11 | return new Mad.SubStream(this.parentStream, this.start + offset, length);
|
---|
12 | },
|
---|
13 |
|
---|
14 | getU8: function(offset, bigEndian) {
|
---|
15 | return this.parentStream.getU8(this.start + offset, bigEndian);
|
---|
16 | },
|
---|
17 |
|
---|
18 | getU16: function(offset, bigEndian) {
|
---|
19 | return this.parentStream.getU16(this.start + offset, bigEndian);
|
---|
20 | },
|
---|
21 |
|
---|
22 | getU32: function(offset, bigEndian) {
|
---|
23 | return this.parentStream.getU32(this.start + offset, bigEndian);
|
---|
24 | },
|
---|
25 |
|
---|
26 | absoluteAvailable: function(n) {
|
---|
27 | return this.parentStream.absoluteAvailable(this.start + n);
|
---|
28 | },
|
---|
29 |
|
---|
30 | seek: function(n) {
|
---|
31 | this.offset += n;
|
---|
32 | },
|
---|
33 |
|
---|
34 | read: function(n) {
|
---|
35 | var result = this.peek(n);
|
---|
36 | this.seek(n);
|
---|
37 | return result;
|
---|
38 | },
|
---|
39 |
|
---|
40 | peek: function(n) {
|
---|
41 | return this.get(this.offset, n);
|
---|
42 | },
|
---|
43 |
|
---|
44 | get: function(offset, length) {
|
---|
45 | return this.parentStream.get(this.start + offset, length);
|
---|
46 | },
|
---|
47 |
|
---|
48 | slice: function(start, end) {
|
---|
49 | return this.parentStream.get(this.start + start, end - start);
|
---|
50 | },
|
---|
51 |
|
---|
52 | requestAbsolute: function(n, callback) {
|
---|
53 | this.parentStream.requestAbsolute(this.start + n)
|
---|
54 | },
|
---|
55 |
|
---|
56 | request: function(n, callback) {
|
---|
57 | this.parentStream.requestAbsolute(this.start + this.offset + n)
|
---|
58 | }
|
---|
59 | });
|
---|