Exemple #1
0
 void ReadEntry(MP4File& file, uint32_t index) {
     // Each table has a size, followed by the length field
     // first, read the length
     m_pProperties[0]->Read(file, index);
     MP4IntegerProperty *pIntProp = (MP4IntegerProperty *)m_pProperties[0];
     // set the size in the bytes property
     MP4BytesProperty *pBytesProp = (MP4BytesProperty *)m_pProperties[1];
     pBytesProp->SetValueSize(pIntProp->GetValue(index), index);
     // And read the bytes
     m_pProperties[1]->Read(file, index);
 };
Exemple #2
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
}
Exemple #3
0
void MP4HvcCAtom::Generate()
{
    MP4Atom::Generate();
	
#if 0 //cwm 322
	uint8_t *out_buf = NULL;
	uint32_t out_size = 0;
	if(NULL != m_File.m_pPsData)
	{
		mov_write_hvcc_tag(m_File.m_pPsData, m_File.m_ui32PsDataSize, &out_buf, &out_size);
	    m_pProperties[0]->SetReadOnly(false);
	    ((MP4BytesProperty*)m_pProperties[0])->
	    SetValue(out_buf, out_size);
	    m_pProperties[0]->SetReadOnly(true);
		m_File.m_ui32PsDataSize = 0;
		free(m_File.m_pPsData);
	}
#else //cwm 322

	((MP4Integer8Property*)m_pProperties[0])->SetValue(1);

	#if 0 //cwm 351
	((MP4Integer8Property*)m_pProperties[0])->SetValue(1);

    m_pProperties[4]->SetReadOnly(false);
    ((MP4BitfieldProperty*)m_pProperties[4])->SetValue(0x3f);
    m_pProperties[4]->SetReadOnly(true);

    m_pProperties[6]->SetReadOnly(false);
    ((MP4BitfieldProperty*)m_pProperties[6])->SetValue(0x7);
    m_pProperties[6]->SetReadOnly(true);
	#endif //cwm 351
	#if 0 //cwm 389
	const uint8_t buffer[4] = {0x12, 0x34, 0x56, 0x78};
	
    MP4BytesProperty *pUnit;
	if(this->FindProperty("hvcC.sequenceEntries.sequenceParameterSetNALUnit",
                                    (MP4Property **)&pUnit) == false)
	{
		PrintInfo("hvcC.sequenceEntries.sequenceParameterSetNALUnit failed");
	}
    pUnit->AddValue(buffer, sizeof(buffer));
	#endif //cwm 389
	#if 0 //cwm_add 336
	uint8_t *out_buf = NULL;
	uint32_t out_size = 0;
	if(NULL != m_File.m_pPsData)
	{
		mov_write_hvcc_tag(m_File.m_pPsData, m_File.m_ui32PsDataSize, &out_buf, &out_size);
	    m_pProperties[0]->SetReadOnly(false);
	    ((MP4BytesProperty*)m_pProperties[0])->
	    SetValue(out_buf, out_size);
	    m_pProperties[0]->SetReadOnly(true);
		m_File.m_ui32PsDataSize = 0;
		free(m_File.m_pPsData);
	}

	#endif //cwm_add 336
	
#endif //cwm 322

}
Exemple #4
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;
}