NuPlayerRenderer.h revision f592671336be0a061799033e47ceeacb648ed3bf
1d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)/* 2d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * Copyright (C) 2010 The Android Open Source Project 3d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * 4d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * Licensed under the Apache License, Version 2.0 (the "License"); 5d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * you may not use this file except in compliance with the License. 6d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * You may obtain a copy of the License at 7d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * 8d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * http://www.apache.org/licenses/LICENSE-2.0 95c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * 10d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * Unless required by applicable law or agreed to in writing, software 11d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * distributed under the License is distributed on an "AS IS" BASIS, 12d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * See the License for the specific language governing permissions and 14d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * limitations under the License. 15d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) */ 16d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 17d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#ifndef NUPLAYER_RENDERER_H_ 18d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 19d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#define NUPLAYER_RENDERER_H_ 20d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 21d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "NuPlayer.h" 22d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 23d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)namespace android { 24d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 25d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)struct ABuffer; 26d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)struct VideoFrameScheduler; 27d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 28d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)struct NuPlayer::Renderer : public AHandler { 29d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) enum Flags { 30d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) FLAG_REAL_TIME = 1, 31d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) FLAG_OFFLOAD_AUDIO = 2, 32d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) }; 33d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) Renderer(const sp<MediaPlayerBase::AudioSink> &sink, 34d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) const sp<AMessage> ¬ify, 35d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) uint32_t flags = 0); 36d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 37d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) static size_t AudioSinkCallback( 38d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) MediaPlayerBase::AudioSink *audioSink, 39d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void *data, size_t size, void *me, 40d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) MediaPlayerBase::AudioSink::cb_event_t event); 41d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 42d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void queueBuffer( 43d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool audio, 44d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) const sp<ABuffer> &buffer, 45d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) const sp<AMessage> ¬ifyConsumed); 46d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 47d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void queueEOS(bool audio, status_t finalResult); 48d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 49d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void flush(bool audio); 50d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 51d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void signalTimeDiscontinuity(); 52d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 53d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void signalAudioSinkChanged(); 54d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 55d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void signalDisableOffloadAudio(); 56d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 57d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void pause(); 58d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void resume(); 59d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 60d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void setVideoFrameRate(float fps); 61d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 62d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Following setters and getters are protected by mTimeLock. 63d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) status_t getCurrentPosition(int64_t *mediaUs); 64d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) status_t getCurrentPosition( 65d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int64_t *mediaUs, int64_t nowUs, bool allowPastQueuedVideo = false); 66d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void setHasMedia(bool audio); 67d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void setAudioFirstAnchorTime(int64_t mediaUs); 68d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void setAudioFirstAnchorTimeIfNeeded(int64_t mediaUs); 69d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void setAnchorTime( 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int64_t mediaUs, int64_t realUs, int64_t numFramesWritten = -1, bool resume = false); 71d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void setVideoLateByUs(int64_t lateUs); 72d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int64_t getVideoLateByUs(); 73d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void setPauseStartedTimeRealUs(int64_t realUs); 745f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 75d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool openAudioSink( 76d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) const sp<AMessage> &format, 77d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool offloadOnly, 78d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool hasVideo, 795f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) uint32_t flags); 80d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void closeAudioSink(); 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 82d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) enum { 83d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatEOS = 'eos ', 845f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) kWhatFlushComplete = 'fluC', 85d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatPosition = 'posi', 865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) kWhatVideoRenderingStart = 'vdrd', 87d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatMediaRenderingStart = 'mdrd', 88d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatAudioOffloadTearDown = 'aOTD', 891320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci kWhatAudioOffloadPauseTimeout = 'aOPT', 901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci }; 911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci enum AudioOffloadTearDownReason { 93d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kDueToError = 0, 94d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kDueToTimeout, 95d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) }; 96d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 97d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)protected: 98d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) virtual ~Renderer(); 99d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 100d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) virtual void onMessageReceived(const sp<AMessage> &msg); 101d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 102d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)private: 103d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) enum { 104d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatDrainAudioQueue = 'draA', 105d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatDrainVideoQueue = 'draV', 106d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatPostDrainVideoQueue = 'pDVQ', 107d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatQueueBuffer = 'queB', 108d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatQueueEOS = 'qEOS', 109d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatFlush = 'flus', 110d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatAudioSinkChanged = 'auSC', 1115c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu kWhatPause = 'paus', 1125c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu kWhatResume = 'resm', 1135c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu kWhatOpenAudioSink = 'opnA', 114d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatCloseAudioSink = 'clsA', 115d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatStopAudioSink = 'stpA', 116d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatDisableOffloadAudio = 'noOA', 117d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) kWhatSetVideoFrameRate = 'sVFR', 118d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) }; 119d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 120d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) struct QueueEntry { 121d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) sp<ABuffer> mBuffer; 122d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) sp<AMessage> mNotifyConsumed; 123d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) size_t mOffset; 124d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) status_t mFinalResult; 125d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int32_t mBufferOrdinal; 126d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) }; 127d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 128d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) static const int64_t kMinPositionUpdateDelayUs; 129d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 130d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) sp<MediaPlayerBase::AudioSink> mAudioSink; 131d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) sp<AMessage> mNotify; 132d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) Mutex mLock; 133d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) uint32_t mFlags; 134d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) List<QueueEntry> mAudioQueue; 135d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) List<QueueEntry> mVideoQueue; 136d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) uint32_t mNumFramesWritten; 137d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) sp<VideoFrameScheduler> mVideoScheduler; 138d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 139d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool mDrainAudioQueuePending; 140d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool mDrainVideoQueuePending; 141d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int32_t mAudioQueueGeneration; 142d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int32_t mVideoQueueGeneration; 143d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 144d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) Mutex mTimeLock; 145d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // |mTimeLock| protects the following 7 member vars that are related to time. 146d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Note: those members are only written on Renderer thread, so reading on Renderer thread 147d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // doesn't need to be protected. Otherwise accessing those members must be protected by 148d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // |mTimeLock|. 1495f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // TODO: move those members to a seperated media clock class. 150d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int64_t mAudioFirstAnchorTimeMediaUs; 151d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int64_t mAnchorTimeMediaUs; 152d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int64_t mAnchorTimeRealUs; 153d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int64_t mAnchorNumFramesWritten; 154d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int64_t mAnchorMaxMediaUs; 1555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int64_t mVideoLateByUs; 1565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool mHasAudio; 1575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool mHasVideo; 1585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int64_t mPauseStartedTimeRealUs; 1595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Mutex mFlushLock; // protects the following 2 member vars. 1615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool mFlushingAudio; 1625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool mFlushingVideo; 1635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool mSyncQueues; 1655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool mPaused; 167d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool mVideoSampleReceived; 168d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool mVideoRenderingStarted; 169d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int32_t mVideoRenderingStartGeneration; 170d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int32_t mAudioRenderingStartGeneration; 171d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 172d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int64_t mLastPositionUpdateUs; 173d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 174d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int32_t mAudioOffloadPauseTimeoutGeneration; 175d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool mAudioOffloadTornDown; 176d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) audio_offload_info_t mCurrentOffloadInfo; 177d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 178d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int32_t mTotalBuffersQueued; 179d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int32_t mLastAudioBufferDrained; 180d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 181d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 182d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) size_t fillAudioBuffer(void *buffer, size_t size); 183d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 184d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool onDrainAudioQueue(); 185d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int64_t getPendingAudioPlayoutDurationUs(int64_t nowUs); 186d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int64_t getPlayedOutAudioDurationUs(int64_t nowUs); 187d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void postDrainAudioQueue_l(int64_t delayUs = 0); 188d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 189d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void onNewAudioMediaTime(int64_t mediaTimeUs); 190d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) int64_t getRealTimeUs(int64_t mediaTimeUs, int64_t nowUs); 191d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 192d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void onDrainVideoQueue(); 193d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void postDrainVideoQueue(); 194d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 195d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void prepareForMediaRenderingStart(); 196d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void notifyIfMediaRenderingStarted(); 197d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 198d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void onQueueBuffer(const sp<AMessage> &msg); 199d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void onQueueEOS(const sp<AMessage> &msg); 200d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void onFlush(const sp<AMessage> &msg); 201d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void onAudioSinkChanged(); 202d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void onDisableOffloadAudio(); 203d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void onPause(); 204d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void onResume(); 205d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void onSetVideoFrameRate(float fps); 206d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void onAudioOffloadTearDown(AudioOffloadTearDownReason reason); 207d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool onOpenAudioSink( 208d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) const sp<AMessage> &format, 2094e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) bool offloadOnly, 2101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci bool hasVideo, 211d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) uint32_t flags); 212d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void onCloseAudioSink(); 2131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2144e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) void notifyEOS(bool audio, status_t finalResult, int64_t delayUs = 0); 2154e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) void notifyFlushComplete(bool audio); 2164e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) void notifyPosition(); 217d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void notifyVideoLateBy(int64_t lateByUs); 218d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void notifyVideoRenderingStart(); 219d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void notifyAudioOffloadTearDown(); 220d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 221d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void flushQueue(List<QueueEntry> *queue); 222d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool dropBufferWhileFlushing(bool audio, const sp<AMessage> &msg); 223d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void syncQueuesDone_l(); 224d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 225d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool offloadingAudio() const { return (mFlags & FLAG_OFFLOAD_AUDIO) != 0; } 226d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 227d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void startAudioOffloadPauseTimeout(); 228d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void cancelAudioOffloadPauseTimeout(); 229d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 230d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) DISALLOW_EVIL_CONSTRUCTORS(Renderer); 231d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)}; 232d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 233d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)} // namespace android 234d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 2354e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#endif // NUPLAYER_RENDERER_H_ 2364e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)