diff options
Diffstat (limited to 'include/media/stagefright')
-rw-r--r-- | include/media/stagefright/AudioPlayer.h | 6 | ||||
-rw-r--r-- | include/media/stagefright/MediaSync.h | 56 | ||||
-rw-r--r-- | include/media/stagefright/Utils.h | 9 |
3 files changed, 55 insertions, 16 deletions
diff --git a/include/media/stagefright/AudioPlayer.h b/include/media/stagefright/AudioPlayer.h index 98c4fa7..e0cd965 100644 --- a/include/media/stagefright/AudioPlayer.h +++ b/include/media/stagefright/AudioPlayer.h @@ -25,9 +25,10 @@ namespace android { -class MediaSource; +struct AudioPlaybackRate; class AudioTrack; struct AwesomePlayer; +class MediaSource; class AudioPlayer : public TimeSource { public: @@ -73,7 +74,8 @@ public: bool isSeeking(); bool reachedEOS(status_t *finalStatus); - status_t setPlaybackRatePermille(int32_t ratePermille); + status_t setPlaybackRate(const AudioPlaybackRate &rate); + status_t getPlaybackRate(AudioPlaybackRate *rate /* nonnull */); void notifyAudioEOS(); diff --git a/include/media/stagefright/MediaSync.h b/include/media/stagefright/MediaSync.h index e071b65..a349986 100644 --- a/include/media/stagefright/MediaSync.h +++ b/include/media/stagefright/MediaSync.h @@ -20,6 +20,8 @@ #include <gui/IConsumerListener.h> #include <gui/IProducerListener.h> +#include <media/AudioResamplerPublic.h> +#include <media/AVSyncSettings.h> #include <media/stagefright/foundation/AHandler.h> #include <utils/Condition.h> @@ -77,10 +79,7 @@ public: // Called when audio track is used as media clock source. It should be // called before updateQueuedAudioData(). - // |nativeSampleRateInHz| is the sample rate of audio data fed into audio - // track. It's the same number used to create AudioTrack. - status_t configureAudioTrack( - const sp<AudioTrack> &audioTrack, uint32_t nativeSampleRateInHz); + status_t configureAudioTrack(const sp<AudioTrack> &audioTrack); // Create a surface for client to render video frames. This is the surface // on which the client should render video frames. Those video frames will @@ -99,21 +98,31 @@ public: // Set the consumer name of the input queue. void setName(const AString &name); - // Set the playback in a desired speed. - // This method can be called any time. - // |rate| is the ratio between desired speed and the normal one, and should - // be non-negative. The meaning of rate values: - // 1.0 -- normal playback - // 0.0 -- stop or pause - // larger than 1.0 -- faster than normal speed - // between 0.0 and 1.0 -- slower than normal speed - status_t setPlaybackRate(float rate); - // Get the media clock used by the MediaSync so that the client can obtain // corresponding media time or real time via // MediaClock::getMediaTime() and MediaClock::getRealTimeFor(). sp<const MediaClock> getMediaClock(); + // Set the video frame rate hint - this is used by the video FrameScheduler + status_t setVideoFrameRateHint(float rate); + + // Get the video frame rate measurement from the FrameScheduler + // returns -1 if there is no measurement + float getVideoFrameRate(); + + // Set the sync settings parameters. + status_t setSyncSettings(const AVSyncSettings &syncSettings); + + // Gets the sync settings parameters. + void getSyncSettings(AVSyncSettings *syncSettings /* nonnull */); + + // Sets the playback rate using playback settings. + // This method can be called any time. + status_t setPlaybackSettings(const AudioPlaybackRate &rate); + + // Gets the playback rate (playback settings parameters). + void getPlaybackSettings(AudioPlaybackRate *rate /* nonnull */); + // Get the play time for pending audio frames in audio sink. status_t getPlayTimeForPendingAudioFrames(int64_t *outTimeUs); @@ -201,6 +210,9 @@ private: sp<ALooper> mLooper; float mPlaybackRate; + AudioPlaybackRate mPlaybackSettings; + AVSyncSettings mSyncSettings; + sp<MediaClock> mMediaClock; MediaSync(); @@ -239,6 +251,22 @@ private: // up. This must be called with mMutex locked. void onAbandoned_l(bool isInput); + // Set the playback in a desired speed. + // This method can be called any time. + // |rate| is the ratio between desired speed and the normal one, and should + // be non-negative. The meaning of rate values: + // 1.0 -- normal playback + // 0.0 -- stop or pause + // larger than 1.0 -- faster than normal speed + // between 0.0 and 1.0 -- slower than normal speed + void updatePlaybackRate_l(float rate); + + // apply new sync settings + void resync_l(); + + // apply playback settings only - without resyncing or updating playback rate + status_t setPlaybackSettings_l(const AudioPlaybackRate &rate); + // helper. bool isPlaying() { return mPlaybackRate != 0.0; } diff --git a/include/media/stagefright/Utils.h b/include/media/stagefright/Utils.h index 0ce1603..5e9d7d4 100644 --- a/include/media/stagefright/Utils.h +++ b/include/media/stagefright/Utils.h @@ -76,6 +76,15 @@ struct HLSTime { bool operator <(const HLSTime &t0, const HLSTime &t1); +// read and write various object to/from AMessage + +void writeToAMessage(sp<AMessage> msg, const AudioPlaybackRate &rate); +void readFromAMessage(const sp<AMessage> &msg, AudioPlaybackRate *rate /* nonnull */); + +void writeToAMessage(sp<AMessage> msg, const AVSyncSettings &sync, float videoFpsHint); +void readFromAMessage( + const sp<AMessage> &msg, AVSyncSettings *sync /* nonnull */, float *videoFps /* nonnull */); + } // namespace android #endif // UTILS_H_ |