コード例 #1
0
ファイル: clip_source.c プロジェクト: UIKit0/bbc-ingex
static int cps_get_available_length(void* data, int64_t* length)
{
    ClipSource* clipSource = (ClipSource*)data;

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

        *length = targetAvailableLength - clipSource->start;
        *length = (*length > clipSource->duration) ? clipSource->duration : *length;
        *length = (*length < 0) ? 0 : *length;

        return 1;
    }
    else if (clipSource->start > 0)
    {
        int64_t targetAvailableLength;
        if (!msc_get_available_length(clipSource->targetSource, &targetAvailableLength))
        {
            return 0;
        }

        *length = targetAvailableLength - clipSource->start;
        *length = (*length < 0) ? 0 : *length;

        return 1;
    }

    return msc_get_available_length(clipSource->targetSource, length);
}
コード例 #2
0
ファイル: multiple_sources.c プロジェクト: dluobo/ingex
static int mls_get_available_length(void* data, int64_t* length)
{
    MultipleMediaSources* multSource = (MultipleMediaSources*)data;
    MediaSourceElement* ele = &multSource->sources;
    int64_t srcLength;
    int64_t minSrcLength = -1;

    while (ele != NULL && ele->source != NULL)
    {
        if (!SOURCE_IS_DISABLED(ele))
        {
            if (!msc_get_available_length(ele->source, &srcLength))
            {
                minSrcLength = -1;
                break;
            }
            if (minSrcLength == -1 || srcLength < minSrcLength)
            {
                minSrcLength = srcLength;
            }
        }

        ele = ele->next;
    }

    if (minSrcLength == -1)
    {
        return 0;
    }

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

    *length = minSrcLength;
    return 1;
}