Ejemplo n.º 1
0
 void AFRA::setGlobalEntries(bool newVal) {
   if (newVal) {
     setInt8((getInt8(4) & 0xDF) + 0x20, 4);
   } else {
     setInt8((getInt8(4) & 0xDF), 4);
   }
 }
Ejemplo n.º 2
0
 void AFRA::setLongIDs(bool newVal) {
   if (newVal) {
     setInt8((getInt8(4) & 0x7F) + 0x80, 4);
   } else {
     setInt8((getInt8(4) & 0x7F), 4);
   }
 }
Ejemplo n.º 3
0
 void AFRA::setLongOffsets(bool newVal) {
   if (newVal) {
     setInt8((getInt8(4) & 0xBF) + 0x40, 4);
   } else {
     setInt8((getInt8(4) & 0xBF), 4);
   }
 }
Ejemplo n.º 4
0
 void ABST::setSegmentRunTable(ASRT & newSegment, uint32_t no) {
   uint32_t tempLoc = 29 + getStringLen(29) + 1 + 1;
   for (unsigned int i = 0; i < getServerEntryCount(); i++) {
     tempLoc += getStringLen(tempLoc) + 1;
   }
   tempLoc++;
   for (unsigned int i = 0; i < getQualityEntryCount(); i++) {
     tempLoc += getStringLen(tempLoc) + 1;
   }
   tempLoc += getStringLen(tempLoc) + 1; //DrmData
   tempLoc += getStringLen(tempLoc) + 1; //MetaData
   int countLoc = tempLoc;
   tempLoc++; //skip segmentRuntableCount
   //attempt to reach the wanted position
   unsigned int i;
   for (i = 0; i < getInt8(countLoc) && i < no; ++i) {
     tempLoc += getBoxLen(tempLoc);
   }
   //we are now either at the end, or at the right position
   //let's reserve any unreserved space...
   if (no + 1 > getInt8(countLoc)) {
     int amount = no + 1 - getInt8(countLoc);
     if (!reserve(payloadOffset + tempLoc, 0, amount * 8)) {
       return;
     };
     //set empty erro boxes as contents
     for (int j = 0; j < amount; ++j) {
       memcpy(data + payloadOffset + tempLoc + j * 8, "\000\000\000\010erro", 8);
     }
     setInt8(no + 1, countLoc); //set new count
     tempLoc += (no - i) * 8;
   }
   //now, tempLoc is at position for string number no, and we have at least an erro box reserved.
   setBox(newSegment, tempLoc);
 }
Ejemplo n.º 5
0
 void AFRT::setFragmentRun(afrt_runtable newRun, uint32_t no) {
   int tempLoc = 9;
   for (unsigned int i = 0; i < getQualityEntryCount(); ++i) {
     tempLoc += getStringLen(tempLoc) + 1;
   }
   int countLoc = tempLoc;
   unsigned int count = getInt32(countLoc);
   tempLoc += 4;
   for (unsigned int i = 0; i < no; i++) {
     if (i + 1 > count) {
       setInt32(0, tempLoc);
       setInt64(0, tempLoc + 4);
       setInt32(1, tempLoc + 12);
     }
     if (getInt32(tempLoc + 12) == 0) {
       tempLoc += 17;
     } else {
       tempLoc += 16;
     }
   }
   setInt32(newRun.firstFragment, tempLoc);
   setInt64(newRun.firstTimestamp, tempLoc + 4);
   setInt32(newRun.duration, tempLoc + 12);
   if (newRun.duration == 0) {
     setInt8(newRun.discontinuity, tempLoc + 16);
   }
   if (count < no + 1) {
     setInt32(no + 1, countLoc);
   }
 }
Ejemplo n.º 6
0
 void ABST::setQualityEntry(std::string & newEntry, uint32_t no) {
   int countLoc = 29 + getStringLen(29) + 1 + 1;
   for (unsigned int i = 0; i < getServerEntryCount(); i++) {
     countLoc += getStringLen(countLoc) + 1;
   }
   int tempLoc = countLoc + 1;
   //attempt to reach the wanted position
   unsigned int i;
   for (i = 0; i < getInt8(countLoc) && i < no; ++i) {
     tempLoc += getStringLen(tempLoc) + 1;
   }
   //we are now either at the end, or at the right position
   //let's reserve any unreserved space...
   if (no + 1 > getInt8(countLoc)) {
     int amount = no + 1 - getInt8(countLoc);
     if (!reserve(payloadOffset + tempLoc, 0, amount)) {
       return;
     };
     memset(data + payloadOffset + tempLoc, 0, amount);
     setInt8(no + 1, countLoc); //set new qualityEntryCount
     tempLoc += no - i;
   }
   //now, tempLoc is at position for string number no, and we have at least 1 byte reserved.
   setString(newEntry, tempLoc);
 }
Ejemplo n.º 7
0
 ABST::ABST() {
   memcpy(data + 4, "abst", 4);
   setVersion(0);
   setFlags(0);
   setBootstrapinfoVersion(0);
   setProfile(0);
   setLive(1);
   setUpdate(0);
   setTimeScale(1000);
   setCurrentMediaTime(0);
   setSmpteTimeCodeOffset(0);
   std::string empty;
   setMovieIdentifier(empty);
   setInt8(0, 30); //set serverentrycount to 0
   setInt8(0, 31); //set qualityentrycount to 0
   setDrmData(empty);
   setMetaData(empty);
 }
Ejemplo n.º 8
0
 /// Gets the 8 bits integer at the given index.
 /// Attempts to resize the data pointer if the index is out of range.
 /// Returns zero if resizing failed.
 char Box::getInt8(size_t index) {
   index += payloadOffset;
   if (index >= boxedSize()) {
     if (!reserve(index, 0, 1)) {
       return 0;
     }
     setInt8(0, index - payloadOffset);
   }
   return data[index];
 }
Ejemplo n.º 9
0
 void UUID_TrackFragmentReference::setVersion(uint32_t newVersion) {
   setInt8(newVersion, 16);
 }
Ejemplo n.º 10
0
size_t Variant::deserialize(const unsigned char *buffer, size_t size)
{
    if (buffer != NULL && size > 0)
    {
        Variant::Type type = static_cast<Variant::Type>(*buffer);
        ++buffer;

        switch (type)
        {
            case UINT8:
            {
                typedef uint8_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setUint8(static_cast<Type>(*buffer));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case INT8:
            {
                typedef uint8_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setInt8(static_cast<Type>(*buffer));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case UINT16:
            {
                typedef uint16_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setUint16(ntohs(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case INT16:
            {
                typedef int16_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setInt16(ntohs(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case UINT32:
            {
                typedef uint32_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setUint32(ntohl(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case INT32:
            {
                typedef int32_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setInt32(ntohl(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case UINT64:
            {
                typedef uint64_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setUint64(ntohll(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case INT64:
            {
                typedef int64_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setInt64(ntohll(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case FLOAT:
            {
                typedef uint32_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setFloat(ntohf(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case DOUBLE:
            {
                typedef uint64_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setDouble(ntohd(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }
                break;
            }

            case BOOL:
            {
                typedef bool Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setBool(*reinterpret_cast<const Type *>(buffer));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case CHAR:
            {
                typedef char Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setChar(*reinterpret_cast<const Type *>(buffer));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case STRING:
            {
                typedef uint32_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    Type len = ntohl(*reinterpret_cast<const Type *>(buffer));

                    if (len > 0 && len <= ((size - 1) - sizeof(Type)))
                        setString(reinterpret_cast<const char *>(buffer + sizeof(Type)), len);

                    size = sizeof(Type) + 1 + len;
                }

                break;
            }

            case BINARY:
            {
                typedef uint32_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    Type len = ntohl(*reinterpret_cast<const Type *>(buffer));

                    if (len > 0 && len <= ((size - 1) - sizeof(Type)))
                        setBinary(reinterpret_cast<const unsigned char *>(buffer + sizeof(Type)), len);

                    size = sizeof(Type) + 1 + len;
                }

                break;
            }
        }

        return size;
    }

    return 0;
}
Ejemplo n.º 11
0
 void fullBox::setVersion(char newVersion) {
   setInt8(newVersion, 0);
 }
Ejemplo n.º 12
0
 void UUID_TFXD::setVersion(uint32_t newVersion) {
   setInt8(newVersion, 16);
 }
Ejemplo n.º 13
0
 void ASRT::setVersion(char newVersion) {
   setInt8(newVersion, 0);
 }
Ejemplo n.º 14
0
 void ABST::setLive(bool newLive) {
   //live = bit 4 of byte 8.
   setInt8((getInt8(8) & 0xDF) + (newLive ? 0x10 : 0), 8);
 }
Ejemplo n.º 15
0
 void ABST::setProfile(char newProfile) {
   //profile = bit 1 and 2 of byte 8.
   setInt8((getInt8(8) & 0x3F) + ((newProfile & 0x03) << 6), 8);
 }
Ejemplo n.º 16
0
 void UUID_TrackFragmentReference::setFragmentCount(uint32_t newCount) {
   setInt8(newCount, 20);
 }
Ejemplo n.º 17
0
 void SDTP::setVersion(uint32_t newVersion) {
   setInt8(newVersion, 0);
 }
Ejemplo n.º 18
0
 void ABST::setUpdate(bool newUpdate) {
   //update = bit 5 of byte 8.
   setInt8((getInt8(8) & 0xEF) + (newUpdate ? 0x08 : 0), 8);
 }
Ejemplo n.º 19
0
 void SDTP::setValue(uint32_t newValue, size_t index) {
   setInt8(newValue, index);
 }
Ejemplo n.º 20
0
 void AFRA::setVersion(uint32_t newVersion) {
   setInt8(newVersion, 0);
 }