diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/camera/camera2/ICameraDeviceUser.h | 6 | ||||
| -rw-r--r-- | include/media/IResourceManagerService.h | 2 | ||||
| -rw-r--r-- | include/media/stagefright/AudioSource.h | 5 | ||||
| -rw-r--r-- | include/media/stagefright/MediaCodec.h | 5 | ||||
| -rw-r--r-- | include/media/stagefright/MediaSync.h | 9 | ||||
| -rw-r--r-- | include/media/stagefright/VideoFrameScheduler.h | 103 | 
6 files changed, 124 insertions, 6 deletions
diff --git a/include/camera/camera2/ICameraDeviceUser.h b/include/camera/camera2/ICameraDeviceUser.h index b3dd140..a7bf8ab 100644 --- a/include/camera/camera2/ICameraDeviceUser.h +++ b/include/camera/camera2/ICameraDeviceUser.h @@ -138,6 +138,12 @@ public:       * Preallocate buffers for a given output stream asynchronously.       */      virtual status_t        prepare(int streamId) = 0; + +    /** +     * Free all unused buffers for a given output stream. +     */ +    virtual status_t        tearDown(int streamId) = 0; +  };  // ---------------------------------------------------------------------------- diff --git a/include/media/IResourceManagerService.h b/include/media/IResourceManagerService.h index 067392c..1e4f6de 100644 --- a/include/media/IResourceManagerService.h +++ b/include/media/IResourceManagerService.h @@ -43,7 +43,7 @@ public:              const sp<IResourceManagerClient> client,              const Vector<MediaResource> &resources) = 0; -    virtual void removeResource(int64_t clientId) = 0; +    virtual void removeResource(int pid, int64_t clientId) = 0;      virtual bool reclaimResource(              int callingPid, diff --git a/include/media/stagefright/AudioSource.h b/include/media/stagefright/AudioSource.h index 50cf371..3074910 100644 --- a/include/media/stagefright/AudioSource.h +++ b/include/media/stagefright/AudioSource.h @@ -37,7 +37,8 @@ struct AudioSource : public MediaSource, public MediaBufferObserver {              audio_source_t inputSource,              const String16 &opPackageName,              uint32_t sampleRate, -            uint32_t channels = 1); +            uint32_t channels, +            uint32_t outSampleRate = 0);      status_t initCheck() const; @@ -78,11 +79,13 @@ private:      status_t mInitCheck;      bool mStarted;      int32_t mSampleRate; +    int32_t mOutSampleRate;      bool mTrackMaxAmplitude;      int64_t mStartTimeUs;      int16_t mMaxAmplitude;      int64_t mPrevSampleTimeUs; +    int64_t mFirstSampleTimeUs;      int64_t mInitialReadTimeUs;      int64_t mNumFramesReceived;      int64_t mNumClientOwnedBuffers; diff --git a/include/media/stagefright/MediaCodec.h b/include/media/stagefright/MediaCodec.h index 09cbe8f..b621b9c 100644 --- a/include/media/stagefright/MediaCodec.h +++ b/include/media/stagefright/MediaCodec.h @@ -260,18 +260,18 @@ private:          virtual void binderDied(const wp<IBinder>& /*who*/);          void addResource( -                int pid,                  int64_t clientId,                  const sp<IResourceManagerClient> client,                  const Vector<MediaResource> &resources);          void removeResource(int64_t clientId); -        bool reclaimResource(int callingPid, const Vector<MediaResource> &resources); +        bool reclaimResource(const Vector<MediaResource> &resources);      private:          Mutex mLock;          sp<IResourceManagerService> mService; +        int mPid;      };      State mState; @@ -299,6 +299,7 @@ private:      bool mIsVideo;      int32_t mVideoWidth;      int32_t mVideoHeight; +    int32_t mRotationDegrees;      // initial create parameters      AString mInitName; diff --git a/include/media/stagefright/MediaSync.h b/include/media/stagefright/MediaSync.h index 1eef211..ef8cb23 100644 --- a/include/media/stagefright/MediaSync.h +++ b/include/media/stagefright/MediaSync.h @@ -37,6 +37,7 @@ class GraphicBuffer;  class IGraphicBufferConsumer;  class IGraphicBufferProducer;  struct MediaClock; +struct VideoFrameScheduler;  // MediaSync manages media playback and its synchronization to a media clock  // source. It can be also used for video-only playback. @@ -103,6 +104,9 @@ public:      // MediaClock::getMediaTime() and MediaClock::getRealTimeFor().      sp<const MediaClock> getMediaClock(); +    // Flush mediasync +    void flush(); +      // Set the video frame rate hint - this is used by the video FrameScheduler      status_t setVideoFrameRateHint(float rate); @@ -134,8 +138,6 @@ private:          kWhatDrainVideo = 'dVid',      }; -    static const int MAX_OUTSTANDING_BUFFERS = 2; -      // This is a thin wrapper class that lets us listen to      // IConsumerListener::onFrameAvailable from mInput.      class InputListener : public BnConsumerListener, @@ -194,6 +196,8 @@ private:      sp<IGraphicBufferConsumer> mInput;      sp<IGraphicBufferProducer> mOutput;      int mUsageFlagsFromOutput; +    uint32_t mMaxAcquiredBufferCount; // max acquired buffer count +    bool mReturnPendingInputFrame;    // set while we are pending before acquiring an input frame      sp<AudioTrack> mAudioTrack;      uint32_t mNativeSampleRateInHz; @@ -202,6 +206,7 @@ private:      int64_t mNextBufferItemMediaUs;      List<BufferItem> mBufferItems; +    sp<VideoFrameScheduler> mFrameScheduler;      // Keep track of buffers received from |mInput|. This is needed because      // it's possible the consumer of |mOutput| could return a different diff --git a/include/media/stagefright/VideoFrameScheduler.h b/include/media/stagefright/VideoFrameScheduler.h new file mode 100644 index 0000000..9d97dfd --- /dev/null +++ b/include/media/stagefright/VideoFrameScheduler.h @@ -0,0 +1,103 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + *     http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef VIDEO_FRAME_SCHEDULER_H_ +#define VIDEO_FRAME_SCHEDULER_H_ + +#include <utils/RefBase.h> +#include <utils/Timers.h> + +#include <media/stagefright/foundation/ABase.h> + +namespace android { + +class ISurfaceComposer; + +struct VideoFrameScheduler : public RefBase { +    VideoFrameScheduler(); + +    // (re)initialize scheduler +    void init(float videoFps = -1); +    // use in case of video render-time discontinuity, e.g. seek +    void restart(); +    // get adjusted nanotime for a video frame render at renderTime +    nsecs_t schedule(nsecs_t renderTime); + +    // returns the vsync period for the main display +    nsecs_t getVsyncPeriod(); + +    // returns the current frames-per-second, or 0.f if not primed +    float getFrameRate(); + +    void release(); + +    static const size_t kHistorySize = 8; + +protected: +    virtual ~VideoFrameScheduler(); + +private: +    struct PLL { +        PLL(); + +        // reset PLL to new PLL +        void reset(float fps = -1); +        // keep current estimate, but restart phase +        void restart(); +        // returns period or 0 if not yet primed +        nsecs_t addSample(nsecs_t time); +        nsecs_t getPeriod() const; + +    private: +        nsecs_t mPeriod; +        nsecs_t mPhase; + +        bool    mPrimed;        // have an estimate for the period +        size_t  mSamplesUsedForPriming; + +        nsecs_t mLastTime;      // last input time +        nsecs_t mRefitAt;       // next input time to fit at + +        size_t  mNumSamples;    // can go past kHistorySize +        nsecs_t mTimes[kHistorySize]; + +        void test(); +        // returns whether fit was successful +        bool fit(nsecs_t phase, nsecs_t period, size_t numSamples, +                int64_t *a, int64_t *b, int64_t *err); +        void prime(size_t numSamples); +    }; + +    void updateVsync(); + +    nsecs_t mVsyncTime;        // vsync timing from display +    nsecs_t mVsyncPeriod; +    nsecs_t mVsyncRefreshAt;   // next time to refresh timing info + +    nsecs_t mLastVsyncTime;    // estimated vsync time for last frame +    nsecs_t mTimeCorrection;   // running adjustment + +    PLL mPll;                  // PLL for video frame rate based on render time + +    sp<ISurfaceComposer> mComposer; + +    DISALLOW_EVIL_CONSTRUCTORS(VideoFrameScheduler); +}; + +}  // namespace android + +#endif  // VIDEO_FRAME_SCHEDULER_H_ +  | 
