Example #1
0
static int cps_get_length(void* data, int64_t* length)
{
    ClipSource* clipSource = (ClipSource*)data;

    if (clipSource->duration >= 0)
    {
        int64_t targetLength;
        if (!msc_get_length(clipSource->targetSource, &targetLength))
        {
            return 0;
        }

        *length = targetLength - clipSource->start;
        *length = (*length > clipSource->duration) ? clipSource->duration : *length;
        *length = (*length < 0) ? 0 : *length;
        return 1;
    }
    else if (clipSource->start > 0)
    {
        int64_t targetLength;
        if (!msc_get_length(clipSource->targetSource, &targetLength))
        {
            return 0;
        }

        *length = targetLength - clipSource->start;
        *length = (*length < 0) ? 0 : *length;
        return 1;
    }

    return msc_get_length(clipSource->targetSource, length);
}
Example #2
0
static int mls_get_length(void* data, int64_t* length)
{
    MultipleMediaSources* multSource = (MultipleMediaSources*)data;
    MediaSourceElement* ele = &multSource->sources;
    int failed = 0;
    int64_t srcLength;
    int64_t minLength = -1;

    while (ele != NULL && ele->source != NULL)
    {
        if (!SOURCE_IS_DISABLED(ele))
        {
            if (!msc_get_length(ele->source, &srcLength))
            {
                failed = 1;
                break;
            }
            minLength = (minLength < 0 || srcLength < minLength) ? srcLength : minLength;
        }

        ele = ele->next;
    }

    if (failed)
    {
        return 0;
    }

    if (multSource->maxLength > 0 && minLength > multSource->maxLength)
    {
        minLength = multSource->maxLength;
    }

    *length = minLength;
    return 1;
}