Exemple #1
0
static int cps_read_frame(void* data, const FrameInfo* frameInfo, MediaSourceListener* listener)
{
    ClipSource* clipSource = (ClipSource*)data;

    if (clipSource->duration >= 0)
    {
        /* check the position is within the clip boundaries */
        int64_t position;
        if (!msc_get_position(clipSource->targetSource, &position))
        {
            return -1;
        }
        if (position < clipSource->start ||
            position >= clipSource->start + clipSource->duration)
        {
            return -1;
        }
    }
    else if (clipSource->start > 0)
    {
        /* check the position is within the clip boundaries */
        int64_t position;
        if (!msc_get_position(clipSource->targetSource, &position))
        {
            return -1;
        }
        if (position < clipSource->start)
        {
            return -1;
        }
    }

    return msc_read_frame(clipSource->targetSource, frameInfo, listener);
}
Exemple #2
0
static int mls_read_frame(void* data, const FrameInfo* frameInfo, MediaSourceListener* listener)
{
    MultipleMediaSources* multSource = (MultipleMediaSources*)data;
    MediaSourceElement* ele = &multSource->sources;
    CollectiveListener collectiveListener;
    int readResult = 0;
    int startStreamId = 0;
    int syncResult;

    /* make sure the sources are in sync */
    if ((syncResult = sync_sources(multSource)) != 0)
    {
        return syncResult;
    }

    memset(&collectiveListener, 0, sizeof(collectiveListener));

    collectiveListener.sourceListener.data = &collectiveListener;
    collectiveListener.sourceListener.accept_frame = mls_accept_frame;
    collectiveListener.sourceListener.allocate_buffer = mls_allocate_buffer;
    collectiveListener.sourceListener.deallocate_buffer = mls_deallocate_buffer;
    collectiveListener.sourceListener.receive_frame = mls_receive_frame;

    collectiveListener.targetListener = listener;

    while (ele != NULL && ele->source != NULL)
    {
        collectiveListener.startStreamId = startStreamId;

        if (!SOURCE_IS_DISABLED(ele))
        {
            readResult = msc_read_frame(ele->source, frameInfo, &collectiveListener.sourceListener);
            if (readResult != 0)
            {
                break;
            }
        }

        startStreamId += ele->numStreams;

        ele = ele->next;
    }

    if (readResult == 0)
    {
        /* update sync position */
        multSource->syncPosition += 1;
    }

    return readResult;
}