bool
PictureAspectRatioBox::set( MP4FileHandle file, uint16_t trackIndex, const Item& item )
{
    MP4Atom* coding;
    if( findCoding( file, trackIndex, coding ))
        throw new MP4Exception( "supported coding not found" );

    MP4Atom* pasp;
    if( findPictureAspectRatioBox( file, *coding, pasp ))
        throw new MP4Exception( "pasp-box not found" );

    MP4Integer16Property* hSpacing;
    MP4Integer16Property* vSpacing;

    if( pasp->FindProperty( "pasp.hSpacing", (MP4Property**)&hSpacing ))
        hSpacing->SetValue( item.hSpacing );

    if( pasp->FindProperty( "pasp.vSpacing", (MP4Property**)&vSpacing ))
        vSpacing->SetValue( item.vSpacing );

    return false;
}
Example #2
0
void MP4File::CreateIsmaODUpdateCommandFromFileForFile(
    MP4TrackId odTrackId,
    MP4TrackId audioTrackId,
    MP4TrackId videoTrackId,
    u_int8_t** ppBytes,
    u_int64_t* pNumBytes)
{
    MP4Descriptor* pCommand = CreateODCommand(MP4ODUpdateODCommandTag);
    pCommand->Generate();

    for (u_int8_t i = 0; i < 2; i++) {
        MP4TrackId trackId;
        u_int16_t odId;

        if (i == 0) {
            trackId = audioTrackId;
            odId = 10;
        } else {
            trackId = videoTrackId;
            odId = 20;
        }

        if (trackId == MP4_INVALID_TRACK_ID) {
            continue;
        }

        MP4DescriptorProperty* pOdDescrProperty =
            (MP4DescriptorProperty*)(pCommand->GetProperty(0));

        pOdDescrProperty->SetTags(MP4FileODescrTag);

        MP4Descriptor* pOd =
            pOdDescrProperty->AddDescriptor(MP4FileODescrTag);

        pOd->Generate();

        MP4BitfieldProperty* pOdIdProperty = NULL;
        pOd->FindProperty("objectDescriptorId",
                          (MP4Property**)&pOdIdProperty);
        pOdIdProperty->SetValue(odId);

        MP4DescriptorProperty* pEsIdsDescriptorProperty = NULL;
        pOd->FindProperty("esIds",
                          (MP4Property**)&pEsIdsDescriptorProperty);
        ASSERT(pEsIdsDescriptorProperty);

        pEsIdsDescriptorProperty->SetTags(MP4ESIDRefDescrTag);

        MP4Descriptor *pRefDescriptor =
            pEsIdsDescriptorProperty->AddDescriptor(MP4ESIDRefDescrTag);
        pRefDescriptor->Generate();

        MP4Integer16Property* pRefIndexProperty = NULL;
        pRefDescriptor->FindProperty("refIndex",
                                     (MP4Property**)&pRefIndexProperty);
        ASSERT(pRefIndexProperty);

        u_int32_t mpodIndex = FindTrackReference(
                                  MakeTrackName(odTrackId, "tref.mpod"), trackId);
        ASSERT(mpodIndex != 0);

        pRefIndexProperty->SetValue(mpodIndex);
    }

    pCommand->WriteToMemory(this, ppBytes, pNumBytes);

    delete pCommand;
}