/* * Copyright (C) 2014-2026 Amlogic, Inc. All rights reserved. * * All information contained herein is Amlogic confidential. * * This software is provided to you pursuant to Software License Agreement * (SLA) with Amlogic Inc ("Amlogic"). This software may be used * only in accordance with the terms of this agreement. * * Redistribution and use in source and binary forms, with or without * modification is strictly prohibited without prior written permission from * Amlogic. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once #include #include #include #include "InfoChangeListener.h" #include "ParserFactory.h" #include "Presentation.h" class Subtitle : public InfoChangeListener { public: Subtitle(bool isExtSub, int idxSubId, ParserEventNotifier *notifier, bool registeredOnDataCB); ~Subtitle(); void attachDataSource(std::shared_ptr source, std::shared_ptr listener); void dettachDataSource(std::shared_ptr listener); int getTotalSubtitles(); int getSubtitleType(); std::string currentLanguage(); void scheduleStart(); bool resetForSeek(); // InfoChangeListener void onSubtitleChanged(int newTotal) override; void onRenderStartTimestamp(int64_t startPts) override; void onRenderTimeChanged(int64_t renderTimePts) override; void onTypeChanged(int newType) override; void onGetLanguage(std::string &lang) override; // ttx control api int getSubtitleStatus(int type, int cmd); int ttGoHome(); int ttGotoPage(int pageNo, int subPageNo); int ttNextPage(int dir); int ttNextSubPage(int dir); bool onMediaCurrentPresentationTime(int ptsMills); bool setParameter(void *params); void dump(int fd); bool show(); bool hide(); bool setSubTranslationLanguage(const std::string &srcLang, const std::string &dstLang); bool setDvbCountryCode(const std::string &iso3166CountryCode); private: static const int ACTION_SUBTITLE_RECEIVED_SUBTYPE = 1; static const int ACTION_SUBTITLE_RESET_FOR_SEEK = 2; static const int ACTION_SUBTITLE_SET_PARAM = 3; static const int ACTION_SUBTITLE_RESET_MEDIASYNC = 4; static const int ACTION_SUBTITLE_SET_DVB_COUNTRY_CODE = 5; std::shared_ptr mDataSource; int mSubtitleTracks = -1; int mCurrentSubtitleType = -1; int64_t mRenderTimePts = -1; int mPendingAction = -1; bool mIsExtSub = false; int mIdxSubTrack = -1; bool mExitRequested = false; std::string mCurrentLanguage; std::string mDvbCountryCode; std::shared_ptr mPresentation; std::shared_ptr mParser; std::shared_ptr mUserDataAfd; ParserEventNotifier *mParserNotifier = nullptr; std::shared_ptr mThread = nullptr; std::shared_ptr mSubPrams; std::mutex mMutex; std::condition_variable mCv; void run(); };