示例#1
0
 /**
  * Writes the object data.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     if ($this->getSize() == 0) {
         $this->setSize(24);
     }
     $writer->writeGuid($this->getIdentifier())->writeInt64LE($this->getSize())->write(str_pad('', $this->getSize() - 24, ""));
 }
示例#2
0
 /**
  * Writes the object data.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     require_once 'HausDesign/Io/StringWriter.php';
     $objectsWriter = new HausDesign_Io_StringWriter();
     foreach ($this->getObjects() as $objects) {
         foreach ($objects as $object) {
             $object->write($objectsWriter);
         }
     }
     $this->setSize(24 + 22 + $objectsWriter->getSize());
     $writer->writeGuid($this->getIdentifier())->writeInt64LE($this->getSize())->writeGuid($this->_reserved1)->writeUInt16LE($this->_reserved2)->writeUInt32LE($objectsWriter->getSize())->write($objectsWriter->toString());
 }
示例#3
0
 /**
  * Constructs the HausDesign_Io_FileWriter class with given path to the file. By
  * default the file is opened in write mode without altering its content
  * (ie r+b mode if the file exists, and wb mode if not).
  *
  * @param string $filename The path to the file.
  * @throws HausDesign_Io_Exception if the file cannot be written
  */
 public function __construct($filename, $mode = null)
 {
     if ($mode === null) {
         $mode = file_exists($filename) ? 'r+b' : 'wb';
     }
     if (($fd = fopen($filename, $mode)) === false) {
         require_once 'HausDesign/Io/Exception.php';
         throw new HausDesign_Io_Exception('Unable to open file for writing: ' . $filename);
     }
     parent::__construct($fd);
 }
 /**
  * Writes the object data.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     require_once 'HausDesign/Io/StringWriter.php';
     $buffer = new HausDesign_Io_StringWriter();
     $buffer->writeUInt32LE(strlen($this->_secretData))->write($this->_secretData)->writeUInt32LE($len = strlen($this->_protectionType) + 1)->writeString8($this->_protectionType, $len)->writeUInt32LE($len = strlen($this->_keyId) + 1)->writeString8($this->_keyId, $len)->writeUInt32LE($len = strlen($this->_licenseUrl) + 1)->writeString8($this->_licenseUrl, $len);
     $this->setSize(24 + $buffer->getSize());
     $writer->writeGuid($this->getIdentifier())->writeInt64LE($this->getSize())->write($buffer->toString());
 }
示例#5
0
 /**
  * Writes the tag data.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 private function _writeData($writer)
 {
     $this->clearOption('unsynchronisation');
     $buffer = new HausDesign_Io_StringWriter();
     foreach ($this->_frames as $frames) {
         foreach ($frames as $frame) {
             $frame->write($buffer);
         }
     }
     $frameData = $buffer->toString();
     $frameDataLength = strlen($frameData);
     $paddingLength = 0;
     // ID3v2.4.0 supports frame level unsynchronisation while
     // ID3v2.3.0 supports only tag level unsynchronisation.
     if ($this->getOption('version', 4) < 4 && $this->getOption('compat', false) !== true) {
         $frameData = $this->_encodeUnsynchronisation($frameData);
         if (($len = strlen($frameData)) != $frameDataLength) {
             $frameDataLength = $len;
             $this->_header->setFlags($this->_header->getFlags() | HausDesign_Media_Id3_Header::UNSYNCHRONISATION);
         } else {
             $this->_header->setFlags($this->_header->getFlags() & ~HausDesign_Media_Id3_Header::UNSYNCHRONISATION);
         }
     }
     // The tag padding is calculated as follows. If the tag can be written
     // in the space of the previous tag, the remaining space is used for
     // padding. If there is no previous tag or the new tag is bigger than
     // the space taken by the previous tag, the padding is a constant
     // 4096 bytes.
     if ($this->hasFooter() === false) {
         if ($this->_reader !== null && $frameDataLength < $this->_header->getSize()) {
             $paddingLength = $this->_header->getSize() - $frameDataLength;
         } else {
             $paddingLength = 4096;
         }
     }
     /* ID3v2.4.0 CRC calculated w/ padding */
     if ($this->getOption('version', 4) >= 4) {
         $frameData = str_pad($frameData, $frameDataLength += $paddingLength, "");
     }
     $extendedHeaderData = '';
     $extendedHeaderDataLength = 0;
     if ($this->hasExtendedHeader()) {
         $this->_extendedHeader->setPadding($paddingLength);
         if ($this->_extendedHeader->hasFlag(HausDesign_Media_Id3_ExtendedHeader::CRC32)) {
             $crc = crc32($frameData);
             if ($crc & 0x80000000) {
                 $crc = -(($crc ^ 0xffffffff) + 1);
             }
             $this->_extendedHeader->setCrc($crc);
         }
         $buffer = new HausDesign_Io_StringWriter();
         $this->_extendedHeader->write($buffer);
         $extendedHeaderData = $buffer->toString();
         $extendedHeaderDataLength = strlen($extendedHeaderData);
     }
     /* ID3v2.3.0 CRC calculated w/o padding */
     if ($this->getOption('version', 4) < 4) {
         $frameData = str_pad($frameData, $frameDataLength += $paddingLength, "");
     }
     $this->_header->setSize($extendedHeaderDataLength + $frameDataLength);
     $writer->write('ID3');
     $this->_header->write($writer);
     $writer->write($extendedHeaderData);
     $writer->write($frameData);
     if ($this->hasFooter()) {
         $writer->write('3DI');
         $this->_footer->write($writer);
     }
 }
 /**
  * Writes the object data.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     require_once 'HausDesign/Io/StringWriter.php';
     $contentDescriptorsCount = count($this->_contentDescriptors);
     $contentDescriptorsWriter = new HausDesign_Io_StringWriter();
     foreach ($this->_contentDescriptors as $name => $value) {
         $descriptor = iconv($this->getOption('encoding'), 'utf-16le', $name ? $name . "" : '');
         $contentDescriptorsWriter->writeUInt16LE(strlen($descriptor))->writeString16($descriptor);
         if (is_string($value)) {
             /* There is no way to distinguish byte arrays from unicode
              * strings and hence the need for a list of fields of type
              * byte array */
             static $byteArray = array("WM/MCDI", "WM/UserWebURL", "WM/Lyrics_Synchronised", "WM/Picture");
             // TODO: Add to the list if you encounter one
             if (in_array($descriptor, $byteArray)) {
                 $contentDescriptorsWriter->writeUInt16LE(1)->writeUInt16LE(strlen($value))->write($value);
             } else {
                 $value = iconv($this->getOption('encoding'), 'utf-16le', $value) . "";
                 $contentDescriptorsWriter->writeUInt16LE(0)->writeUInt16LE(strlen($value))->writeString16($value);
             }
         } else {
             if (is_bool($value)) {
                 $contentDescriptorsWriter->writeUInt16LE(2)->writeUInt16LE(4)->writeUInt32LE($value ? 1 : 0);
             } else {
                 if (is_int($value)) {
                     $contentDescriptorsWriter->writeUInt16LE(3)->writeUInt16LE(4)->writeUInt32LE($value);
                 } else {
                     if (is_float($value)) {
                         $contentDescriptorsWriter->writeUInt16LE(4)->writeUInt16LE(8)->writeInt64LE($value);
                     } else {
                         // Invalid value and there is nothing to be done
                         require_once 'HausDesign/Media/Asf/Exception.php';
                         throw new HausDesign_Media_Asf_Exception('Invalid data type');
                     }
                 }
             }
         }
     }
     $this->setSize(24 + 2 + $contentDescriptorsWriter->getSize());
     $writer->writeGuid($this->getIdentifier())->writeInt64LE($this->getSize())->writeUInt16LE($contentDescriptorsCount)->write($contentDescriptorsWriter->toString());
 }
示例#7
0
 /**
  * Writes the frame raw data without the header.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->writeUInt8($this->_encoding)->write($this->_language);
     switch ($this->_encoding) {
         case self::UTF16LE:
             $writer->writeString16($this->_description, HausDesign_Io_Writer::LITTLE_ENDIAN_ORDER, 1)->writeString16($this->_text, HausDesign_Io_Writer::LITTLE_ENDIAN_ORDER);
             break;
         case self::UTF16:
             // break intentionally omitted
         // break intentionally omitted
         case self::UTF16BE:
             $writer->writeString16($this->_description, null, 1)->writeString16($this->_text);
             break;
         default:
             $writer->writeString8($this->_description, 1)->writeString8($this->_text);
             break;
     }
 }
示例#8
0
 /**
  * Writes the header data.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     /* ID3v2.3.0 ExtendedHeader */
     if ($this->getOption('version', 4) < 4) {
         $writer->writeUInt32BE($this->_size)->writeUInt16BE($this->hasFlag(self::CRC32) ? 0x8000 : 0)->writeUInt32BE($this->_padding);
         if ($this->hasFlag(self::CRC32)) {
             $writer->writeUInt32BE($this->_crc);
         }
     } else {
         $writer->writeUInt32BE($this->_encodeSynchsafe32($this->_size))->writeInt8(1)->writeInt8($this->_flags);
         if ($this->hasFlag(self::UPDATE)) {
             $writer->write("");
         }
         if ($this->hasFlag(self::CRC32)) {
             $writer->writeInt8(5)->writeInt8($this->_crc & 0xf0000000 >> 28 & 0xf)->writeUInt32BE($this->_encodeSynchsafe32($this->_crc));
         }
         if ($this->hasFlag(self::RESTRICTED)) {
             $writer->writeInt8(1)->writeInt8($this->_restrictions);
         }
     }
 }
示例#9
0
 /**
  * Writes the frame raw data without the header.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->writeUInt8($this->_encoding)->write($this->_currency)->writeString8($this->_price, 1)->write($this->_date)->writeString8($this->_contact, 1)->writeUInt8($this->_delivery);
     switch ($this->_encoding) {
         case self::UTF16LE:
             $writer->writeString16($this->_seller, HausDesign_Io_Writer::LITTLE_ENDIAN_ORDER, 1)->writeString16($this->_description, HausDesign_Io_Writer::LITTLE_ENDIAN_ORDER, 1);
             break;
         case self::UTF16:
             // break intentionally omitted
         // break intentionally omitted
         case self::UTF16BE:
             $writer->writeString16($this->_seller, null, 1)->writeString16($this->_description, null, 1);
             break;
         default:
             $writer->writeString8($this->_seller, 1)->writeString8($this->_description, 1);
             break;
     }
     if ($this->_mimeType) {
         $writer->writeString8($this->_mimeType, 1)->write($this->_imageData);
     }
 }
示例#10
0
 /**
  * Writes the frame raw data without the header.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     if ($this->_counter > 4294967295) {
         $writer->writeInt64BE($this->_counter);
         // UInt64
     } else {
         $writer->writeUInt32BE($this->_counter);
     }
 }
示例#11
0
 /**
  * Writes the frame raw data without the header.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->writeUInt8($this->_encoding);
     switch ($this->_encoding) {
         case self::UTF16LE:
             $count = count($this->_text);
             for ($i = 0; $i < $count; $i++) {
                 $writer->writeString16($text, HausDesign_Io_Writer::LITTLE_ENDIAN_ORDER, $i == $count ? null : 1);
             }
             break;
         case self::UTF16:
             // break intentionally omitted
         // break intentionally omitted
         case self::UTF16BE:
             $writer->write(implode("", $this->_text));
             break;
         default:
             $writer->write(implode("", $this->_text));
             break;
     }
 }
示例#12
0
 /**
  * Writes the frame raw data without the header.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->writeUInt8($this->_encoding);
     foreach ($this->_people as $entry) {
         foreach ($entry as $key => $val) {
             switch ($this->_encoding) {
                 case self::UTF16LE:
                     $writer->writeString16($key, HausDesign_Io_Writer::LITTLE_ENDIAN_ORDER, 1)->writeString16($val, HausDesign_Io_Writer::LITTLE_ENDIAN_ORDER, 1);
                     break;
                 case self::UTF16:
                     // break intentionally omitted
                 // break intentionally omitted
                 case self::UTF16BE:
                     $writer->writeString16($key, null, 1)->writeString16($val, null, 1);
                     break;
                 default:
                     $writer->writeString8($key, 1)->writeString8($val, 1);
                     break;
             }
         }
     }
 }
示例#13
0
 /**
  * Writes the object data.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     $writer->writeGuid($this->getIdentifier())->writeInt64LE($this->getSize())->write($this->_data);
 }
示例#14
0
 /**
  * Writes the frame raw data without the header.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->writeUInt8($this->_group)->write($this->_signature);
 }
示例#15
0
 /**
  * Writes the frame raw data without the header.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->writeInt8($this->_interpolation)->writeString8($this->_device, 1);
     foreach ($this->_adjustments as $frequency => $adjustment) {
         $writer->writeUInt16BE($frequency * 2)->writeInt16BE($adjustment * 512);
     }
 }
示例#16
0
 /**
  * Writes the frame raw data without the header.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->writeString8($this->_device, 1);
     foreach ($this->_adjustments as $channel) {
         $writer->writeInt8($channel[self::channelType])->writeInt16BE($channel[self::volumeAdjustment] * 512);
         if (abs($channel[self::peakVolume]) <= 0xff) {
             $writer->writeInt8(8)->writeUInt8($channel[self::peakVolume]);
         } else {
             if (abs($channel[self::peakVolume]) <= 0xffff) {
                 $writer->writeInt8(16)->writeUInt16BE($channel[self::peakVolume]);
             } else {
                 if (abs($channel[self::peakVolume]) <= 0xffffffff) {
                     $writer->writeInt8(32)->writeUInt32BE($channel[self::peakVolume]);
                 } else {
                     $writer->writeInt8(64)->writeInt64BE($channel[self::peakVolume]);
                     // UInt64
                 }
             }
         }
     }
 }
示例#17
0
 /**
  * Writes the frame raw data without the header.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->writeString8($this->_owner, 1)->writeInt8($this->_rating);
     if ($this->_counter > 0xffffffff) {
         $writer->writeInt64BE($this->_counter);
     } else {
         if ($this->_counter > 0) {
             $writer->writeUInt32BE($this->_counter);
         }
     }
 }
示例#18
0
 /**
  * Writes the object data.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     require_once 'HausDesign/Io/StringWriter.php';
     $codecEntriesCount = count($this->_entries);
     $codecEntriesWriter = new HausDesign_Io_StringWriter();
     for ($i = 0; $i < $codecEntriesCount; $i++) {
         $codecEntriesWriter->writeUInt16LE($this->_entries[$i]['type'])->writeUInt16LE(strlen($codecName = iconv($this->getOption('encoding'), 'utf-16le', $this->_entries[$i]['codecName']) . "") / 2)->writeString16($codecName)->writeUInt16LE(strlen($codecDescription = iconv($this->getOption('encoding'), 'utf-16le', $this->_entries[$i]['codecDescription']) . "") / 2)->writeString16($codecDescription)->writeUInt16LE(strlen($this->_entries[$i]['codecInformation']))->write($this->_entries[$i]['codecInformation']);
     }
     $this->setSize(24 + 20 + $codecEntriesWriter->getSize());
     $writer->writeGuid($this->getIdentifier())->writeInt64LE($this->getSize())->writeGuid($this->_reserved)->writeUInt32LE($codecEntriesCount)->write($codecEntriesWriter->toString());
 }
示例#19
0
 /**
  * Writes the object data.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     $this->setSize(24 + 2);
     $writer->writeGuid($this->getIdentifier())->writeInt64LE($this->getSize())->writeUInt8($this->_profile)->writeUInt8($this->_mode);
 }
示例#20
0
 /**
  * Writes the object data.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     require_once 'HausDesign/Io/StringWriter.php';
     $languageIdRecordsCount = count($this->_languages);
     $languageIdRecordsWriter = new HausDesign_Io_StringWriter();
     for ($i = 0; $i < $languageIdRecordsCount; $i++) {
         $languageIdRecordsWriter->writeInt8(strlen($languageId = iconv($this->getOption('encoding'), 'utf-16le', $this->_languages[$i]) . ""))->writeString16($languageId);
     }
     $this->setSize(24 + 2 + $languageIdRecordsWriter->getSize());
     $writer->writeGuid($this->getIdentifier())->writeInt64LE($this->getSize())->writeUInt16LE($languageIdRecordsCount)->write($languageIdRecordsWriter->toString());
 }
示例#21
0
 /**
  * Writes the frame raw data without the header.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->writeString8(substr($this->_target, 0, 4), 4)->writeString8($this->_url, 1)->writeString8($this->_qualifier);
 }
示例#22
0
 /**
  * Writes the frame raw data without the header.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->writeUInt8($this->_format);
     foreach ($this->_events as $timestamp => $type) {
         $writer->writeUInt8($type)->writeUInt32BE($timestamp);
     }
 }
示例#23
0
 /**
  * Returns the current machine endian order.
  *
  * @return integer
  */
 private function _getEndianess()
 {
     if (self::$_endianess === 0) {
         self::$_endianess = $this->_toInt32("") == 1 ? self::LITTLE_ENDIAN_ORDER : self::BIG_ENDIAN_ORDER;
     }
     return self::$_endianess;
 }
示例#24
0
 /**
  * Writes the frame raw data without the header.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->writeString8($this->_owner, 1)->writeUInt8($this->_group)->write($this->_data);
 }
 /**
  * Writes the object data.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     $title = iconv($this->getOption('encoding'), 'utf-16le', $this->_title ? $this->_title . "" : '');
     $author = iconv($this->getOption('encoding'), 'utf-16le', $this->_author ? $this->_author . "" : '');
     $copyright = iconv($this->getOption('encoding'), 'utf-16le', $this->_copyright ? $this->_copyright . "" : '');
     $description = iconv($this->getOption('encoding'), 'utf-16le', $this->_description ? $this->_description . "" : '');
     $rating = iconv($this->getOption('encoding'), 'utf-16le', $this->_rating ? $this->_rating . "" : '');
     require_once 'HausDesign/Io/StringWriter.php';
     $buffer = new HausDesign_Io_StringWriter();
     $buffer->writeUInt16LE(strlen($title))->writeUInt16LE(strlen($author))->writeUInt16LE(strlen($copyright))->writeUInt16LE(strlen($description))->writeUInt16LE(strlen($rating))->writeString16($title)->writeString16($author)->writeString16($copyright)->writeString16($description)->writeString16($rating);
     $this->setSize(24 + $buffer->getSize());
     $writer->writeGuid($this->getIdentifier())->writeInt64LE($this->getSize())->write($buffer->toString());
 }
示例#26
0
 /**
  * Writes the frame raw data without the header.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->write($this->_link);
 }
 /**
  * Writes the object data.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     $streamNumbersCount = count($this->_streamNumbers);
     $this->setSize(24 + 18 + $streamNumbersCount * 2);
     $writer->writeGuid($this->getIdentifier())->writeInt64LE($this->getSize())->writeGuid($this->_exclusionType)->writeUInt16LE($streamNumbersCount);
     for ($i = 0; $i < $streamNumbersCount; $i++) {
         $writer->writeUInt16LE($this->_streamNumbers[$i]);
     }
 }
示例#28
0
 /**
  * Writes the header/footer data without the identifier.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     $writer->writeUInt8(floor($this->_version))->writeUInt8(($this->_version - floor($this->_version)) * 10)->writeUInt8($this->_flags)->writeUInt32BE($this->_encodeSynchsafe32($this->_size));
 }
 /**
  * Writes the object data.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     $this->setSize(24 + 4 + strlen($this->_data));
     $writer->writeGuid($this->getIdentifier())->writeInt64LE($this->getSize())->writeUInt32LE(strlen($this->_data))->write($this->_data);
 }
示例#30
0
 /**
  * Writes the frame data with the header.
  *
  * @param HausDesign_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     /* ID3v2.3.0 Flags; convert from 2.4.0 format */
     if ($this->getOption('version', 4) < 4) {
         $flags = 0;
         if ($this->hasFlag(self::DISCARD_ON_TAGCHANGE)) {
             $flags = $flags | 0x8000;
         }
         if ($this->hasFlag(self::DISCARD_ON_FILECHANGE)) {
             $flags = $flags | 0x4000;
         }
         if ($this->hasFlag(self::READ_ONLY)) {
             $flags = $flags | 0x2000;
         }
         if ($this->hasFlag(self::COMPRESSION)) {
             $flags = $flags | 0x80;
         }
         if ($this->hasFlag(self::ENCRYPTION)) {
             $flags = $flags | 0x40;
         }
         if ($this->hasFlag(self::GROUPING_IDENTITY)) {
             $flags = $flags | 0x20;
         }
     } else {
         $flags = $this->_flags;
     }
     $this->_writeData($buffer = new HausDesign_Io_StringWriter());
     $data = $buffer->toString();
     $size = $this->_size = strlen($data);
     // ID3v2.4.0 supports frame level unsynchronisation. The corresponding
     // option is set to true when any of the frames use the
     // unsynchronisation scheme. The usage is denoted by
     // HausDesign_Media_Id3_Header flag that is set accordingly upon file write.
     if ($this->getOption('version', 4) >= 4) {
         $data = $this->_encodeUnsynchronisation($data);
         if (($dataLength = strlen($data)) != $size) {
             $size = 4 + $dataLength;
             $flags |= self::DATA_LENGTH_INDICATOR | self::UNSYNCHRONISATION;
             $this->setOption('unsynchronisation', true);
         } else {
             $flags &= ~(self::DATA_LENGTH_INDICATOR | self::UNSYNCHRONISATION);
         }
     }
     $writer->writeString8(substr($this->_identifier, 0, 4), 4, " ")->writeUInt32BE($this->getOption('version', 4) < 4 ? $size : $this->_encodeSynchsafe32($size))->writeUInt16BE($flags);
     if (($flags & self::DATA_LENGTH_INDICATOR) == self::DATA_LENGTH_INDICATOR) {
         $writer->writeUInt32BE($this->getOption('version', 4) < 4 ? $this->_size : $this->_encodeSynchsafe32($this->_size));
     }
     $writer->write($data);
 }