Commit RELEASE-NOTES line for the wgCategories js variable I added some time ago.
[lhc/web/wiklou.git] / js2 / mwEmbed / libEmbedVideo / binPlayers / omtk-fx / src / as / org / omtk / ogg / OggPage.as
1 /*
2
3 Copyright 2008 Tor-Einar Jarnbjo
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17 */
18
19 package org.omtk.ogg {
20
21 import flash.net.*;
22 import flash.utils.ByteArray;
23
24 public class OggPage {
25
26 private var _version:int;
27 private var _continued:Boolean;
28 private var _bos:Boolean;
29 private var _eos:Boolean;
30 private var _absoluteGranulePosition:int;
31 private var _streamSerialNumber:int;
32 private var _pageSequenceNumber:int;
33 private var _pageCheckSum:int;
34 private var _segmentOffsets:Array;
35 private var _segmentLengths:Array;
36 private var _totalLength:int;
37 private var _data:ByteArray;
38
39 public function OggPage(stream:URLStream) {
40
41 var capture:int = stream.readInt();
42 if(capture != 0x5367674f) {
43 throw new Error("Ogg page does not start with 'OggS': "+capture);
44 }
45
46 _version = stream.readByte()&0xff;
47 var tmp:int = stream.readByte();
48
49 _continued = (tmp&1)!=0;;
50 _bos = (tmp&2)!=0;
51 _eos = (tmp&4)!=0;
52
53 // absoluteGranulePosition is really 64 bits
54 _absoluteGranulePosition = stream.readUnsignedInt();
55 stream.readUnsignedInt(); // last 32 bits of _absoluteGranulePosition
56
57 _streamSerialNumber = stream.readUnsignedInt();
58 _pageSequenceNumber = stream.readUnsignedInt();
59 _pageCheckSum = stream.readUnsignedInt();
60
61 //trace("_pageSequenceNumber: " + _pageSequenceNumber);
62
63 var pageSegments:int = stream.readUnsignedByte();
64
65 //stream.waitFor(pageSegments);
66
67 _segmentOffsets = [];
68 _segmentLengths = [];
69 _data = new ByteArray();
70
71 var totalLength:int;
72
73 var i:int;
74 var l:int;
75
76 for( i= 0 ; i < pageSegments ; i++ ) {
77 l = stream.readUnsignedByte();
78 _segmentLengths.push( l );
79 _segmentOffsets.push( totalLength );
80 totalLength += l;
81 }
82
83 stream.readBytes(_data, 0, totalLength);
84 }
85
86 public function get absoluteGranulePosition():int {
87 return _absoluteGranulePosition;
88 }
89
90 public function get segmentOffsets():Array {
91 return _segmentOffsets;
92 }
93
94 public function get segmentLengths():Array {
95 return _segmentLengths;
96 }
97
98 public function get data():ByteArray {
99 return _data;
100 }
101
102 public function get eos():Boolean {
103 return _eos;
104 }
105
106 public function get bos():Boolean {
107 return _bos;
108 }
109
110 public function get continued():Boolean {
111 return _continued;
112 }
113
114 }
115
116 }