/* * Copyright (C) 2021 Amlogic Corporation. * * 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 __WAYLAND_PLUGIN_H__ #define __WAYLAND_PLUGIN_H__ #include "render_plugin.h" #include "wayland_display.h" #include "Thread.h" #include "Queue.h" class WaylandPlugin : public RenderPlugin, public ATools::Thread { public: WaylandPlugin(int logCatgory); virtual ~WaylandPlugin(); virtual void init(); virtual void release(); void setCallback(void *userData, PluginCallback *callback); virtual int openDisplay(); virtual int openWindow(); virtual int prepareFrame(RenderBuffer *buffer); virtual int displayFrame(RenderBuffer *buffer, int64_t displayTime); virtual int flush(); virtual int pause(); virtual int resume(); virtual int closeDisplay(); virtual int closeWindow(); virtual int getValue(PluginKey key, void *value); virtual int setValue(PluginKey key, void *value); virtual int unexpectReleaseFrame(RenderBuffer *buffer); virtual bool getDisplayVsyncAndPeriod (uint64_t *vsyncTimestamp, uint64_t *vsyncPeriod) override; int getLogCategory() { return mLogCategory; }; void waitTimeoutUs(int64_t timeoutUs); void signalWaitTimeout(); void reportUnderFlow(); //thread func void readyToRun(); virtual bool threadLoop(); //buffer release callback virtual void handleBufferRelease(RenderBuffer *buffer); //buffer had displayed ,but not release virtual void handleFrameDisplayed(RenderBuffer *buffer); //buffer droped callback virtual void handleFrameDropped(RenderBuffer *buffer); void handleMsgNotify(int type, void *detail); static void queueFlushCallback(void *userdata,void *data); private: PluginCallback *mCallback; WaylandDisplay *mDisplay; int mLogCategory; mutable ATools::Mutex mRenderLock; int mFrameWidth; int mFrameHeight; void *mUserData; ATools::Queue *mQueue; bool mPaused; /*immediately output video frame to display*/ bool mImmediatelyOutput; int64_t mLastDisplayTime; bool mUnderFlowDetect; mutable ATools::Mutex mTimeMutex; ATools::Condition mTimeCond; bool mWaiting; }; #endif /*__WAYLAND_PLUGIN_H__*/