Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3725d7b authored by Lajos Molnar's avatar Lajos Molnar
Browse files

stagefright: MediaSync: use VideoFrameScheduler

Move VideoFrameScheduler to libstagefright as part of this change.

Bug: 22234976
Change-Id: Ib23fb52399cb700a1dcf789e8486b94a3edf9d95
parent bc24bb8a
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -37,6 +37,7 @@ class GraphicBuffer;
class IGraphicBufferConsumer;
class IGraphicBufferConsumer;
class IGraphicBufferProducer;
class IGraphicBufferProducer;
struct MediaClock;
struct MediaClock;
struct VideoFrameScheduler;


// MediaSync manages media playback and its synchronization to a media clock
// MediaSync manages media playback and its synchronization to a media clock
// source. It can be also used for video-only playback.
// source. It can be also used for video-only playback.
@@ -132,10 +133,9 @@ protected:
private:
private:
    enum {
    enum {
        kWhatDrainVideo          = 'dVid',
        kWhatDrainVideo          = 'dVid',
        kWhatCheckFrameAvailable = 'cFrA',
    };
    };


    static const int MAX_OUTSTANDING_BUFFERS = 2;

    // This is a thin wrapper class that lets us listen to
    // This is a thin wrapper class that lets us listen to
    // IConsumerListener::onFrameAvailable from mInput.
    // IConsumerListener::onFrameAvailable from mInput.
    class InputListener : public BnConsumerListener,
    class InputListener : public BnConsumerListener,
@@ -194,6 +194,7 @@ private:
    sp<IGraphicBufferConsumer> mInput;
    sp<IGraphicBufferConsumer> mInput;
    sp<IGraphicBufferProducer> mOutput;
    sp<IGraphicBufferProducer> mOutput;
    int mUsageFlagsFromOutput;
    int mUsageFlagsFromOutput;
    uint32_t mMaxAcquiredBufferCount; // max acquired buffer count


    sp<AudioTrack> mAudioTrack;
    sp<AudioTrack> mAudioTrack;
    uint32_t mNativeSampleRateInHz;
    uint32_t mNativeSampleRateInHz;
@@ -202,6 +203,7 @@ private:


    int64_t mNextBufferItemMediaUs;
    int64_t mNextBufferItemMediaUs;
    List<BufferItem> mBufferItems;
    List<BufferItem> mBufferItems;
    sp<VideoFrameScheduler> mFrameScheduler;


    // Keep track of buffers received from |mInput|. This is needed because
    // Keep track of buffers received from |mInput|. This is needed because
    // it's possible the consumer of |mOutput| could return a different
    // it's possible the consumer of |mOutput| could return a different
@@ -242,8 +244,9 @@ private:
    // onBufferReleasedByOutput releases a buffer back to the input.
    // onBufferReleasedByOutput releases a buffer back to the input.
    void onFrameAvailableFromInput();
    void onFrameAvailableFromInput();


    // Send |bufferItem| to the output for rendering.
    // Send |bufferItem| to the output for rendering. If this is not the only
    void renderOneBufferItem_l(const BufferItem &bufferItem);
    // buffer sent for rendering, check for any dropped frames in |checkInUs| us.
    void renderOneBufferItem_l(const BufferItem &bufferItem, int64_t checkInUs);


    // This implements the onBufferReleased callback from IProducerListener.
    // This implements the onBufferReleased callback from IProducerListener.
    // It gets called from an OutputListener.
    // It gets called from an OutputListener.
+5 −1
Original line number Original line Diff line number Diff line
@@ -39,6 +39,9 @@ struct VideoFrameScheduler : public RefBase {
    // returns the vsync period for the main display
    // returns the vsync period for the main display
    nsecs_t getVsyncPeriod();
    nsecs_t getVsyncPeriod();


    // returns the current frames-per-second, or 0.f if not primed
    float getFrameRate();

    void release();
    void release();


    static const size_t kHistorySize = 8;
    static const size_t kHistorySize = 8;
@@ -54,8 +57,9 @@ private:
        void reset(float fps = -1);
        void reset(float fps = -1);
        // keep current estimate, but restart phase
        // keep current estimate, but restart phase
        void restart();
        void restart();
        // returns period
        // returns period or 0 if not yet primed
        nsecs_t addSample(nsecs_t time);
        nsecs_t addSample(nsecs_t time);
        nsecs_t getPeriod() const;


    private:
    private:
        nsecs_t mPeriod;
        nsecs_t mPeriod;
+0 −1
Original line number Original line Diff line number Diff line
@@ -21,7 +21,6 @@ LOCAL_SRC_FILES:= \
    StagefrightPlayer.cpp       \
    StagefrightPlayer.cpp       \
    StagefrightRecorder.cpp     \
    StagefrightRecorder.cpp     \
    TestPlayerStub.cpp          \
    TestPlayerStub.cpp          \
    VideoFrameScheduler.cpp     \


LOCAL_SHARED_LIBRARIES :=       \
LOCAL_SHARED_LIBRARIES :=       \
    libbinder                   \
    libbinder                   \
+1 −2
Original line number Original line Diff line number Diff line
@@ -29,8 +29,7 @@
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/Utils.h>
#include <media/stagefright/Utils.h>

#include <media/stagefright/VideoFrameScheduler.h>
#include <VideoFrameScheduler.h>


#include <inttypes.h>
#include <inttypes.h>


+1 −0
Original line number Original line Diff line number Diff line
@@ -64,6 +64,7 @@ LOCAL_SRC_FILES:= \
        TimedEventQueue.cpp               \
        TimedEventQueue.cpp               \
        Utils.cpp                         \
        Utils.cpp                         \
        VBRISeeker.cpp                    \
        VBRISeeker.cpp                    \
        VideoFrameScheduler.cpp           \
        WAVExtractor.cpp                  \
        WAVExtractor.cpp                  \
        WVMExtractor.cpp                  \
        WVMExtractor.cpp                  \
        XINGSeeker.cpp                    \
        XINGSeeker.cpp                    \
Loading