Cheetah
Atom.class.php
Go to the documentation of this file.
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3 
65 class Atom
66 {
73  private $_is64 = false;
74 
81  private $_type = '';
82 
89  private $_size = 0;
90 
97  private $_offset = 0;
98 
102  const FTYP_ATOM = 'ftyp';
103  const MOOV_ATOM = 'moov';
104  const CMOV_ATOM = 'cmov';
105  const STCO_ATOM = 'stco';
106  const CO64_ATOM = 'co64';
107  const URL_ATOM = 'url ';
108  const XML_ATOM = 'xml ';
109 
110  protected static $validAtoms = array(
111  self::FTYP_ATOM,
112  self::MOOV_ATOM,
113  self::CMOV_ATOM,
114  self::STCO_ATOM,
115  self::CO64_ATOM,
116  self::URL_ATOM,
117  self::XML_ATOM,
118  'pdin',
119  'mvhd',
120  'trak',
121  'tkhd',
122  'tref',
123  'edts',
124  'elst',
125  'mdia',
126  'mdhd',
127  'hdlr',
128  'minf',
129  'vmhd',
130  'smhd',
131  'hmhd',
132  'nmhd',
133  'dinf',
134  'dref',
135  'stbl',
136  'stsd',
137  'stts',
138  'ctts',
139  'stsc',
140  'stsz',
141  'stz2',
142  'stss',
143  'stsh',
144  'padb',
145  'stdp',
146  'sdtp',
147  'sbgp',
148  'sgpd',
149  'subs',
150  'mvex',
151  'mehd',
152  'trex',
153  'ipmc',
154  'moof',
155  'mfhd',
156  'traf',
157  'tfhd',
158  'trun',
159  'mfra',
160  'tfra',
161  'mfro',
162  'mdat',
163  'free',
164  'skip',
165  'udta',
166  'cprt',
167  'meta',
168  'dinf',
169  'ipmc',
170  'iloc',
171  'ipro',
172  'sinf',
173  'frma',
174  'imif',
175  'schm',
176  'schi',
177  'iinf',
178  'bxml',
179  'pitm'
180  );
181 
182 
187  public static function isValidAtom($fourByteString)
188  {
189  if (preg_match('/[@a-zA-Z][a-zA-Z0-9][a-zA-Z0-9 ][a-zA-Z0-9 ]/', $fourByteString) &&
190  in_array($fourByteString, self::$validAtoms)) {
191  return true;
192  } else {
193  return false;
194  }
195  }
196 
197 
202  public function getType()
203  {
204  return $this->_type;
205  }
206 
211  public function setType($type)
212  {
213  $this->_type = $type;
214  }
215 
216 
220  public function getSize()
221  {
222  return $this->_size;
223  }
224 
228  public function setSize($value)
229  {
230  $this->_size = $value;
231  if ($value == 1) {
232  $this->_is64 = true;
233  }
234  }
235 
236 
241  public function getOffset()
242  {
243  return $this->_offset;
244  }
245 
250  public function setOffset($value)
251  {
252  $this->_offset = $value;
253  }
254 
255 
259  public function toString()
260  {
261  return '[type: ' . $this->_type . ',size: ' . $this->_size . ',offset: ' . $this->_offset . ']';
262  }
263 }
264 
265 ?>
Atom\MOOV_ATOM
const MOOV_ATOM
Definition: Atom.class.php:103
Atom\setOffset
setOffset($value)
Definition: Atom.class.php:250
Atom\FTYP_ATOM
const FTYP_ATOM
Definition: Atom.class.php:102
php
Atom\$validAtoms
static $validAtoms
Definition: Atom.class.php:110
Atom\XML_ATOM
const XML_ATOM
Definition: Atom.class.php:108
Atom\getSize
getSize()
Definition: Atom.class.php:220
Atom\getType
getType()
Definition: Atom.class.php:202
Atom\setSize
setSize($value)
Definition: Atom.class.php:228
Atom\toString
toString()
Definition: Atom.class.php:259
Atom\URL_ATOM
const URL_ATOM
Definition: Atom.class.php:107
Atom\setType
setType($type)
Definition: Atom.class.php:211
Atom\getOffset
getOffset()
Definition: Atom.class.php:241
Atom\CMOV_ATOM
const CMOV_ATOM
Definition: Atom.class.php:104
Atom\CO64_ATOM
const CO64_ATOM
Definition: Atom.class.php:106
Atom
Definition: Atom.class.php:66
Atom\STCO_ATOM
const STCO_ATOM
Definition: Atom.class.php:105
Atom\isValidAtom
static isValidAtom($fourByteString)
Definition: Atom.class.php:187