Ejemplo n.º 1
0
//
// Clone - clone my properties to destination atom
//
// this method simplifies duplicating avcC atom properties from
// source to destination file using a single API rather than
// having to copy each property.  This API encapsulates the object
// so the application layer need not concern with each property
// thereby isolating any future changes to atom properties.
//
// ----------------------------------------
// property   description
// ----------------------------------------
//
// 0    configurationVersion
// 1    AVCProfileIndication
// 2    profile_compatibility
// 3    AVCLevelIndication
// 4    reserved
// 5    lengthSizeMinusOne
// 6    reserved
// 7    number of SPS
// 8    SPS entries
// 9    number of PPS
// 10   PPS entries
//
//
void MP4HvcCAtom::Clone(MP4HvcCAtom *dstAtom)
{
#if 1 //cwm
    MP4Property *dstProperty;
    MP4TableProperty *pTable;
    uint16_t i16;
    uint64_t i32;
    uint64_t i64;
    uint8_t *tmp;

    // source pointer Property I16
    MP4Integer16Property *spPI16;
    // source pointer Property Bytes
    MP4BytesProperty *spPB;

    // dest pointer Property I16
    MP4Integer16Property *dpPI16;
    // dest pointer Property Bytes
    MP4BytesProperty *dpPB;


    // start with defaults and reserved fields
    dstAtom->Generate();

    // 0, 4, 6 are now generated from defaults
    // leaving 1, 2, 3, 5, 7, 8, 9, 10 to export

    dstProperty=dstAtom->GetProperty(1);
    ((MP4Integer8Property *)dstProperty)->SetValue(
        0x12);//((MP4Integer8Property *)m_pProperties[1])->GetValue()

    dstProperty=dstAtom->GetProperty(2);
    ((MP4Integer8Property *)dstProperty)->SetValue(
        0x34);//((MP4Integer8Property *)m_pProperties[2])->GetValue()

    dstProperty=dstAtom->GetProperty(3);
    ((MP4Integer8Property *)dstProperty)->SetValue(
        ((MP4Integer8Property *)m_pProperties[3])->GetValue());

    dstProperty=dstAtom->GetProperty(5);
    ((MP4BitfieldProperty *)dstProperty)->SetValue(
        ((MP4BitfieldProperty *)m_pProperties[5])->GetValue());

    //
    // 7 and 8 are related SPS (one set of sequence parameters)
    //
    // first the count bitfield
    //
    dstProperty=dstAtom->GetProperty(7);
    dstProperty->SetReadOnly(false);
    ((MP4BitfieldProperty *)dstProperty)->SetValue(
        ((MP4BitfieldProperty *)m_pProperties[7])->GetValue());
    dstProperty->SetReadOnly(true);

    // next export SPS Length and NAL bytes */

    // first source pointers
    pTable = (MP4TableProperty *) m_pProperties[8];
    spPI16 = (MP4Integer16Property *)pTable->GetProperty(0);
    spPB = (MP4BytesProperty *)pTable->GetProperty(1);

    // now dest pointers
    dstProperty=dstAtom->GetProperty(8);
    pTable = (MP4TableProperty *) dstProperty;
    dpPI16 = (MP4Integer16Property *)pTable->GetProperty(0);
    dpPB = (MP4BytesProperty *)pTable->GetProperty(1);

    // sps length
    i16 = spPI16->GetValue();
    i64 = i16;
    // FIXME - this leaves m_maxNumElements =2
    // but src atom m_maxNumElements is 1
    dpPI16->InsertValue(i64, 0);

    // export byte array
    i32 = i16;
    // copy bytes to local buffer
    tmp = (uint8_t *)MP4Malloc(i32);
    ASSERT(tmp != NULL);
    spPB->CopyValue(tmp, 0);
    // set element count
    dpPB->SetCount(1);
    // copy bytes
    dpPB->SetValue(tmp, i32, 0);
    MP4Free((void *)tmp);

    //
    // 9 and 10 are related PPS (one set of picture parameters)
    //
    // first the integer8 count
    //
    dstProperty=dstAtom->GetProperty(9);
    dstProperty->SetReadOnly(false);
    ((MP4Integer8Property *)dstProperty)->SetValue(
        ((MP4Integer8Property *)m_pProperties[9])->GetValue());
    dstProperty->SetReadOnly(true);

    // next export PPS Length and NAL bytes */

    // first source pointers
    pTable = (MP4TableProperty *) m_pProperties[10];
    spPI16 = (MP4Integer16Property *)pTable->GetProperty(0);
    spPB = (MP4BytesProperty *)pTable->GetProperty(1);

    // now dest pointers
    dstProperty=dstAtom->GetProperty(10);
    pTable = (MP4TableProperty *) dstProperty;
    dpPI16 = (MP4Integer16Property *)pTable->GetProperty(0);
    dpPB = (MP4BytesProperty *)pTable->GetProperty(1);
#if 1//cwm 500
    // pps length
    i16 = spPI16->GetValue();
    i64 = i16;
    dpPI16->InsertValue(i64, 0);

    // export byte array
    i32 = i16;
    // copy bytes to local buffer
    tmp = (uint8_t *)MP4Malloc(i32);
    ASSERT(tmp != NULL);
    spPB->CopyValue(tmp, 0);
    // set element count
    dpPB->SetCount(1);
    // copy bytes
    dpPB->SetValue(tmp, i32, 0);
    MP4Free((void *)tmp);
#endif //cwm 500
#endif //cwm
}
Ejemplo n.º 2
0
MP4Descriptor* MP4File::CreateESD(
    MP4DescriptorProperty* pEsProperty,
    u_int32_t esid,
    u_int8_t objectType,
    u_int8_t streamType,
    u_int32_t bufferSize,
    u_int32_t bitrate,
    u_int8_t* pConfig,
    u_int32_t configLength,
    char* url)
{
    MP4IntegerProperty* pInt;
    MP4StringProperty* pString;
    MP4BytesProperty* pBytes;
    MP4BitfieldProperty* pBits;

    MP4Descriptor* pEsd =
        pEsProperty->AddDescriptor(MP4ESDescrTag);
    pEsd->Generate();

    pEsd->FindProperty("ESID",
                       (MP4Property**)&pInt);
    pInt->SetValue(esid);

    pEsd->FindProperty("decConfigDescr.objectTypeId",
                       (MP4Property**)&pInt);
    pInt->SetValue(objectType);

    pEsd->FindProperty("decConfigDescr.streamType",
                       (MP4Property**)&pInt);
    pInt->SetValue(streamType);

    pEsd->FindProperty("decConfigDescr.bufferSizeDB",
                       (MP4Property**)&pInt);
    pInt->SetValue(bufferSize);

    pEsd->FindProperty("decConfigDescr.maxBitrate",
                       (MP4Property**)&pInt);
    pInt->SetValue(bitrate);

    pEsd->FindProperty("decConfigDescr.avgBitrate",
                       (MP4Property**)&pInt);
    pInt->SetValue(bitrate);

    MP4DescriptorProperty* pConfigDescrProperty;
    pEsd->FindProperty("decConfigDescr.decSpecificInfo",
                       (MP4Property**)&pConfigDescrProperty);

    MP4Descriptor* pConfigDescr =
        pConfigDescrProperty->AddDescriptor(MP4DecSpecificDescrTag);
    pConfigDescr->Generate();

    pConfigDescrProperty->FindProperty("decSpecificInfo[0].info",
                                       (MP4Property**)&pBytes);
    pBytes->SetValue(pConfig, configLength);

    pEsd->FindProperty("slConfigDescr.predefined",
                       (MP4Property**)&pInt);
    // changed 12/5/02 from plugfest to value 0
    pInt->SetValue(0);

    pEsd->FindProperty("slConfig.useAccessUnitEndFlag",
                       (MP4Property **)&pBits);
    pBits->SetValue(1);

    if (url) {
        pEsd->FindProperty("URLFlag",
                           (MP4Property**)&pInt);
        pInt->SetValue(1);

        pEsd->FindProperty("URL",
                           (MP4Property**)&pString);
        pString->SetValue(url);
    }

    return pEsd;
}