Ticket #2426: embed_playback_part2.4.diff

File embed_playback_part2.4.diff, 17.8 KB (added by skamithi, 6 years ago)

temp workaround till pin support is added for the JUMPPREV/(jump to last watched show) option. if the recording groups of the current program and next program are not the same, clear the lastProgram variable.

  • libs/libmythtv/tv_play.h

     
    3838typedef QMap<QString,QString>    InfoMap; 
    3939typedef QMap<QString,InfoMap>    DDValueMap; 
    4040typedef QMap<QString,DDValueMap> DDKeyMap; 
     41typedef ProgramInfo * (*RUNPLAYBACKBOX)(void *); 
    4142 
     43 
    4244class VBIMode 
    4345{ 
    4446  public: 
     
    6870enum scheduleEditTypes { 
    6971    kScheduleProgramGuide = 0, 
    7072    kScheduleProgramFinder, 
    71     kScheduledRecording 
     73    kScheduledRecording, 
     74    kPlaybackBox, 
    7275}; 
    7376 
    7477class MPUBLIC TV : public QObject 
     
    112115    // Recording commands 
    113116    int  PlayFromRecorder(int recordernum); 
    114117    int  Playback(ProgramInfo *rcinfo); 
     118 
     119    // Various commands 
    115120    void setLastProgram(ProgramInfo *rcinfo);  
    116121    ProgramInfo *getLastProgram(void) { return lastProgram; } 
    117122    void setInPlayList(bool setting) { inPlaylist = setting; } 
    118123    void setUnderNetworkControl(bool setting) { underNetworkControl = setting; } 
     124    bool IsSameProgram(ProgramInfo *p); 
    119125 
    120     // Various commands 
    121126    void ShowNoRecorderDialog(void); 
    122127    void FinishRecording(void); 
    123128    void AskAllowRecording(const QStringList&, int, bool); 
     
    173178    static void InitKeys(void); 
    174179    static bool StartTV(ProgramInfo *tvrec = NULL, bool startInGuide = false, 
    175180                        bool inPlaylist = false, bool initByNetworkCommand = false); 
    176          
     181    static void SetEmbedPbbFunc(RUNPLAYBACKBOX lptr); 
    177182 
    178183    void SetIgnoreKeys(bool ignore) { ignoreKeys = ignore; } 
    179184 
     
    194199    static void *EPGMenuHandler(void *param); 
    195200    static void *FinderMenuHandler(void *param); 
    196201    static void *ScheduleMenuHandler(void *param); 
     202    static void *RecordedShowMenuHandler(void *param); 
    197203 
    198204    void RunTV(void); 
    199205    static void *EventThread(void *param); 
    200206 
    201207    bool eventFilter(QObject *o, QEvent *e); 
     208    static QStringList lastProgramStringList; 
     209    static RUNPLAYBACKBOX RunPlaybackBoxPtr; 
    202210 
    203211  private: 
    204212    bool RequestNextRecorder(bool showDialogs); 
     
    297305    void SetAutoCommercialSkip(enum commSkipMode skipMode = CommSkipOff); 
    298306    void SetManualZoom(bool zoomON = false); 
    299307 
    300     void DoDisplayJumpMenu(void); 
    301308    void SetJumpToProgram(QString progKey = "", int progIndex = 0); 
    302309  
    303310    bool ClearOSD(void); 
     
    325332    void ToggleActiveWindow(void); 
    326333    void SwapPIP(void); 
    327334    void SwapPIPSoon(void) { needToSwapPIP = true; } 
    328     void DisplayJumpMenuSoon(void) { needToJumpMenu = true; } 
    329335 
    330336    void ToggleAutoExpire(void); 
    331337 
     
    426432 
    427433    bool ignoreKeys; 
    428434    bool needToSwapPIP; 
    429     bool needToJumpMenu; 
    430435    QMap<QString,ProgramList> progLists; 
    431436 
    432437    mutable QMutex chanEditMapLock; ///< Lock for chanEditMap and ddMap 
  • libs/libmythtv/tv_play.cpp

     
    6161 * \brief stores last program info. maintains info so long as 
    6262 * mythfrontend is active 
    6363 */ 
    64 static QStringList lastProgramStringList = QStringList(); 
     64QStringList TV::lastProgramStringList = QStringList(); 
    6565 
    6666/* 
     67 * \brief function pointer for RunPlaybackBox in playbackbox.cpp 
     68 */ 
     69RUNPLAYBACKBOX TV::RunPlaybackBoxPtr = NULL; 
     70 
     71/* 
    6772 \brief returns true if the recording completed when exiting. 
    6873 */ 
    6974bool TV::StartTV (ProgramInfo *tvrec, bool startInGuide,  
     
    130135            ProgramInfo *tmpProgram  = tv->getLastProgram(); 
    131136            ProgramInfo *nextProgram = new ProgramInfo(*tmpProgram); 
    132137 
    133             tv->setLastProgram(curProgram); 
     138            //Temp workaround until Pin support for password protected last show is implemented. 
     139            if (curProgram->recgroup == nextProgram->recgroup) 
     140                tv->setLastProgram(curProgram); 
     141            else 
     142                tv->setLastProgram(NULL); 
    134143 
    135144            if (curProgram) 
    136145                delete curProgram; 
     
    179188 
    180189    return playCompleted; 
    181190} 
    182          
     191        
     192void TV::SetEmbedPbbFunc(RUNPLAYBACKBOX lptr) 
     193{ 
     194    RunPlaybackBoxPtr = lptr; 
     195} 
     196 
    183197void TV::InitKeys(void) 
    184198{ 
    185199    REG_KEY("TV Frontend", "PAGEUP", "Page Up", "3"); 
     
    415429      queuedTranscode(false), getRecorderPlaybackInfo(false), 
    416430      adjustingPicture(kAdjustingPicture_None), 
    417431      adjustingPictureAttribute(kPictureAttribute_None), 
    418       ignoreKeys(false), needToSwapPIP(false), needToJumpMenu(false), 
     432      ignoreKeys(false), needToSwapPIP(false), 
    419433      // Channel Editing 
    420434      chanEditMapLock(true), ddMapSourceId(0), ddMapLoaderRunning(false), 
    421435      // Sleep Timer 
     
    19351949            SwapPIP(); 
    19361950            needToSwapPIP = false; 
    19371951        } 
    1938  
    1939         if (needToJumpMenu) 
    1940         { 
    1941             DoDisplayJumpMenu(); 
    1942             needToJumpMenu = false; 
    1943         } 
    19441952    } 
    19451953   
    19461954    if (!IsErrored() && (GetState() != kState_None)) 
     
    26852693            jumpToProgram = true; 
    26862694        } 
    26872695        else if (action == "JUMPREC") 
    2688             DisplayJumpMenuSoon(); 
     2696        { 
     2697            if (RunPlaybackBoxPtr) 
     2698                EditSchedule(kPlaybackBox); 
     2699        } 
    26892700        else if (action == "SIGNALMON") 
    26902701        { 
    26912702            if ((GetState() == kState_WatchingLiveTV) && activerecorder) 
     
    49404951    pbinfoLock.unlock(); 
    49414952 
    49424953    bool changeChannel = false; 
     4954    ProgramInfo *nextProgram = NULL; 
    49434955 
    49444956    if (StateIsLiveTV(GetState())) 
    49454957    { 
     
    49694981                    RunProgramFind(true, false); 
    49704982                    break; 
    49714983            case kScheduledRecording: 
     4984            { 
    49724985                    pbinfoLock.lock(); 
    49734986                    ScheduledRecording record; 
    49744987                    record.loadByProgram(playbackinfo); 
    49754988                    record.exec(); 
    49764989                    pbinfoLock.unlock(); 
    49774990                    break; 
     4991            } 
     4992            case kPlaybackBox: 
     4993            { 
     4994                    nextProgram = RunPlaybackBoxPtr((void *)this); 
     4995                    if (nextProgram) 
     4996                    { 
     4997                        setLastProgram(nextProgram); 
     4998                        jumpToProgram = true; 
     4999                        exitPlayer = true; 
     5000                        delete nextProgram; 
     5001                    } 
     5002                    break; 
     5003            } 
    49785004        } 
    49795005 
    49805006        if (!stayPaused) 
     
    50205046    return NULL; 
    50215047} 
    50225048 
     5049void *TV::RecordedShowMenuHandler(void *param) 
     5050{ 
     5051    TV *obj = (TV *)param; 
     5052    obj->doEditSchedule(kPlaybackBox); 
     5053 
     5054    return NULL; 
     5055} 
     5056 
    50235057void TV::EditSchedule(int editType) 
    50245058{ 
    50255059    if (menurunning == true) 
     
    50425076        case kScheduledRecording: 
    50435077                pthread_create(&tid, &attr, TV::ScheduleMenuHandler, this); 
    50445078                break; 
     5079        case kPlaybackBox: 
     5080                pthread_create(&tid, &attr, TV::RecordedShowMenuHandler, this); 
     5081                break; 
    50455082    } 
    50465083} 
    50475084 
     
    63376374            jumpToProgram = true; 
    63386375        } 
    63396376        else if (action == "JUMPREC") 
    6340             DisplayJumpMenuSoon(); 
     6377        { 
     6378            if (RunPlaybackBoxPtr) 
     6379                EditSchedule(kPlaybackBox); 
     6380        } 
    63416381        else if (action.left(8) == "JUMPPROG") 
    63426382        { 
    63436383            SetJumpToProgram(action.section(" ",1,-2), 
     
    63686408    } 
    63696409} 
    63706410 
    6371 void TV::DoDisplayJumpMenu(void) 
    6372 { 
    6373     if (treeMenu) 
    6374         delete treeMenu; 
    6375  
    6376     treeMenu = new OSDGenericTree(NULL, "treeMenu"); 
    6377     OSDGenericTree *item, *subitem; 
    6378  
    6379     // Build jumpMenu of recorded program titles 
    6380     ProgramInfo *p; 
    6381     progLists.clear(); 
    6382     vector<ProgramInfo *> *infoList; 
    6383     infoList = RemoteGetRecordedList(false); 
    6384  
    6385     bool LiveTVInAllPrograms = gContext->GetNumSetting("LiveTVInAllPrograms",0); 
    6386  
    6387     if (infoList) 
    6388     { 
    6389         pbinfoLock.lock(); 
    6390         vector<ProgramInfo *>::iterator i = infoList->begin(); 
    6391         for ( ; i != infoList->end(); i++) 
    6392         { 
    6393             p = *i; 
    6394             //if (p->recgroup != "LiveTV" || LiveTVInAllPrograms) 
    6395             if (p->recgroup == playbackinfo->recgroup) 
    6396                 progLists[p->title].prepend(p); 
    6397         } 
    6398         pbinfoLock.unlock(); 
    6399  
    6400         QMap<QString,ProgramList>::Iterator Iprog; 
    6401         for (Iprog = progLists.begin(); Iprog != progLists.end(); Iprog++) 
    6402         { 
    6403             ProgramList plist = Iprog.data(); 
    6404             int progIndex = plist.count(); 
    6405             if (progIndex == 1) 
    6406             { 
    6407                 item = new OSDGenericTree(treeMenu, tr(Iprog.key()), 
    6408                     QString("JUMPPROG %1 0").arg(Iprog.key())); 
    6409             }  
    6410             else  
    6411             { 
    6412                 item = new OSDGenericTree(treeMenu, tr(Iprog.key())); 
    6413                 for (int i = 0; i < progIndex; i++) 
    6414                 { 
    6415                     p = plist.at(i); 
    6416                     if (p->subtitle != "") 
    6417                         subitem = new OSDGenericTree(item, tr(p->subtitle),  
    6418                             QString("JUMPPROG %1 %2").arg(Iprog.key()).arg(i)); 
    6419                     else  
    6420                         subitem = new OSDGenericTree(item, tr(p->title),  
    6421                             QString("JUMPPROG %1 %2").arg(Iprog.key()).arg(i)); 
    6422                 } 
    6423             } 
    6424         } 
    6425     }  
    6426  
    6427     if (GetOSD()) 
    6428     { 
    6429         ClearOSD(); 
    6430  
    6431         OSDListTreeType *tree = GetOSD()->ShowTreeMenu("menu", treeMenu); 
    6432         if (tree) 
    6433         { 
    6434             connect(tree, SIGNAL(itemSelected(OSDListTreeType *,OSDGenericTree *)),  
    6435                     this, SLOT(TreeMenuSelected(OSDListTreeType *, OSDGenericTree *))); 
    6436  
    6437             connect(tree, SIGNAL(itemEntered(OSDListTreeType *, OSDGenericTree *)), 
    6438                     this, SLOT(TreeMenuEntered(OSDListTreeType *, OSDGenericTree *))); 
    6439         } 
    6440     }  
    6441 } 
    6442  
    64436411void TV::ShowOSDTreeMenu(void) 
    64446412{ 
    64456413    BuildOSDTreeMenu(); 
     
    74097377        lastProgram = NULL; 
    74107378} 
    74117379 
     7380bool TV::IsSameProgram(ProgramInfo *rcinfo) 
     7381{ 
     7382    if (rcinfo && playbackinfo) 
     7383        return playbackinfo->IsSameProgram(*rcinfo); 
     7384 
     7385    return false; 
     7386} 
     7387 
    74127388/* vim: set expandtab tabstop=4 shiftwidth=4: */ 
  • programs/mythfrontend/playbackbox.cpp

     
    1616#include <qfileinfo.h> 
    1717#include <qsqldatabase.h> 
    1818#include <qmap.h> 
     19#include <qwaitcondition.h> 
    1920 
    2021#include <cmath> 
    2122#include <unistd.h> 
     
    5051 
    5152#define USE_PREV_GEN_THREAD 
    5253 
     54QWaitCondition pbbIsVisibleCond; 
     55 
    5356static int comp_programid(ProgramInfo *a, ProgramInfo *b) 
    5457{ 
    5558    if (a->programid == b->programid) 
     
    185188        return (a->startts.date() > b->startts.date() ? 1 : -1); 
    186189} 
    187190 
     191 
     192ProgramInfo *PlaybackBox::RunPlaybackBox(void * player) 
     193{ 
     194    ProgramInfo *nextProgram = NULL; 
     195    qApp->lock(); 
     196 
     197    PlaybackBox *pbb = new PlaybackBox(PlaybackBox::Play, 
     198            gContext->GetMainWindow(), "tvplayselect", (TV *)player); 
     199    pbb->Show(); 
     200 
     201    qApp->unlock(); 
     202    pbbIsVisibleCond.wait(); 
     203 
     204    if (pbb->getSelected()) 
     205        nextProgram = new ProgramInfo(*pbb->getSelected()); 
     206    
     207    delete pbb; 
     208     
     209    return nextProgram; 
     210} 
     211 
    188212PlaybackBox::PlaybackBox(BoxType ltype, MythMainWindow *parent,  
    189                          const char *name) 
     213                         const char *name, TV *player) 
    190214    : MythDialog(parent, name), 
    191215      // Settings 
    192216      type(ltype), 
     
    248272      previewPixmapEnabled(false),      previewPixmap(NULL), 
    249273      previewSuspend(false),            previewChanid(""), 
    250274      // Network Control Variables 
    251       underNetworkControl(false) 
     275      underNetworkControl(false), 
     276      m_player(NULL) 
    252277{ 
    253278    formatShortDate    = gContext->GetSetting("ShortDateFormat", "M/d"); 
    254279    formatLongDate     = gContext->GetSetting("DateFormat", "ddd MMMM d"); 
     
    263288    groupnameAsAllProg = gContext->GetNumSetting("DispRecGroupAsAllProg", 0); 
    264289    arrowAccel         = gContext->GetNumSetting("UseArrowAccels", 1); 
    265290    inTitle            = gContext->GetNumSetting("PlaybackBoxStartInTitle", 0); 
    266     previewVideoEnabled =gContext->GetNumSetting("PlaybackPreview"); 
     291    if (!player) 
     292        previewVideoEnabled =gContext->GetNumSetting("PlaybackPreview"); 
    267293    previewPixmapEnabled=gContext->GetNumSetting("GeneratePreviewPixmaps"); 
    268294    previewFromBookmark= gContext->GetNumSetting("PreviewFromBookmark"); 
    269295    drawTransPixmap    = gContext->LoadScalePixmap("trans-backup.png"); 
     
    283309    titleList << ""; 
    284310    playList.clear(); 
    285311 
     312    if (player) 
     313        m_player = player; 
     314 
    286315    // recording group stuff 
    287316    recGroupType.clear(); 
    288317    recGroupType[recGroup] = (displayCat) ? "category" : "recgroup"; 
     
    369398    gContext->removeListener(this); 
    370399    gContext->removeCurrentLocation(); 
    371400 
    372     killPlayerSafe(); 
     401    if (!m_player) 
     402        killPlayerSafe(); 
    373403 
    374404    if (previewVideoRefreshTimer) 
    375405    { 
     
    566596 
    567597void PlaybackBox::exitWin() 
    568598{ 
    569     killPlayerSafe(); 
     599    if (m_player) 
     600    { 
     601        if (curitem) 
     602            delete curitem; 
     603        curitem = NULL; 
     604        pbbIsVisibleCond.wakeAll(); 
     605    } 
     606    else 
     607        killPlayerSafe(); 
     608 
    570609    accept(); 
    571610} 
    572611 
     
    12471286                if (playList.grep(tempInfo->MakeUniqueKey()).count()) 
    12481287                    ltype->EnableForcedFont(cnt, "tagged"); 
    12491288 
    1250                 if (tempInfo->availableStatus != asAvailable) 
     1289                if (tempInfo->availableStatus != asAvailable ||  
     1290                        (m_player && m_player->IsSameProgram(tempInfo)) && tempInfo->recstatus != rsRecording) 
    12511291                    ltype->EnableForcedFont(cnt, "inactive"); 
    12521292            } 
    12531293        }  
     
    20802120    if (!curitem) 
    20812121        return; 
    20822122 
     2123    if (m_player && m_player->IsSameProgram(curitem)) 
     2124        exitWin(); 
     2125 
    20832126    if (curitem && curitem->availableStatus != asAvailable) 
    20842127        showAvailablePopup(curitem); 
    20852128    else 
    20862129        play(curitem); 
     2130 
     2131    if (m_player) 
     2132    { 
     2133        pbbIsVisibleCond.wakeAll(); 
     2134        accept(); 
     2135    } 
    20872136} 
    20882137 
    20892138void PlaybackBox::stopSelected() 
     
    22122261        popup->addButton(tr("Playlist options"), this, 
    22132262                         SLOT(showPlaylistPopup())); 
    22142263    } 
    2215     else 
     2264    else if (!m_player) 
    22162265    { 
    22172266        if (inTitle) 
    22182267        { 
     
    22552304    if (!rec) 
    22562305        return false; 
    22572306 
     2307    if (m_player) 
     2308        return true; 
     2309             
    22582310    if (fileExists(rec) == false) 
    22592311    { 
    22602312        QString msg =  
     
    29132965 
    29142966    initPopup(popup, program, "", ""); 
    29152967 
    2916     QButton *playButton; 
     2968    QButton *playButton = new QButton(); 
    29172969 
    2918     if (curitem->programflags & FL_BOOKMARK) 
    2919         playButton = popup->addButton(tr("Play from..."), this, 
    2920                                       SLOT(showPlayFromPopup())); 
    2921     else 
    2922         playButton = popup->addButton(tr("Play"), this, SLOT(doPlay())); 
     2970    if (!(m_player && m_player->IsSameProgram(curitem))) 
     2971    { 
     2972        if (curitem->programflags & FL_BOOKMARK) 
     2973            popup->addButton(tr("Play from..."), this, 
     2974                                        SLOT(showPlayFromPopup())); 
     2975        else 
     2976            popup->addButton(tr("Play"), this, SLOT(doPlay())); 
     2977    } 
    29232978 
    2924     if (playList.grep(curitem->MakeUniqueKey()).count()) 
    2925         popup->addButton(tr("Remove from Playlist"), this, 
    2926                          SLOT(togglePlayListItem())); 
    2927     else 
    2928         popup->addButton(tr("Add to Playlist"), this, 
    2929                          SLOT(togglePlayListItem())); 
     2979    if (!m_player) 
     2980    { 
     2981        if (playList.grep(curitem->MakeUniqueKey()).count()) 
     2982            popup->addButton(tr("Remove from Playlist"), this, 
     2983                            SLOT(togglePlayListItem())); 
     2984        else 
     2985            popup->addButton(tr("Add to Playlist"), this, 
     2986                            SLOT(togglePlayListItem())); 
     2987    } 
    29302988 
    29312989    if (program->recstatus == rsRecording) 
    29322990        popup->addButton(tr("Stop Recording"), this, SLOT(askStop())); 
     
    29423000    popup->addButton(tr("Recording Options"), this, SLOT(showRecordingPopup())); 
    29433001    popup->addButton(tr("Job Options"), this, SLOT(showJobPopup())); 
    29443002 
    2945     popup->addButton(tr("Delete"), this, SLOT(askDelete())); 
     3003    if (!(m_player && m_player->IsSameProgram(curitem))) 
     3004        popup->addButton(tr("Delete"), this, SLOT(askDelete())); 
    29463005 
    29473006    popup->ShowPopup(this, SLOT(doCancel())); 
    29483007 
  • programs/mythfrontend/main.cpp

     
    614614    REG_JUMP("Previously Recorded", "", "", startPrevious); 
    615615 
    616616    TV::InitKeys(); 
     617 
     618    TV::SetEmbedPbbFunc(PlaybackBox::RunPlaybackBox); 
    617619} 
    618620 
    619621int internal_media_init()  
  • programs/mythfrontend/playbackbox.h

     
    1313#include "xmlparse.h" 
    1414#include "programinfo.h" 
    1515#include "jobqueue.h" 
     16#include "tv_play.h" 
    1617 
    1718#include <qvaluelist.h> 
    1819#include <pthread.h> 
     
    9899    } killStateType; 
    99100      
    100101 
    101     PlaybackBox(BoxType ltype, MythMainWindow *parent, const char *name = 0); 
     102    PlaybackBox(BoxType ltype, MythMainWindow *parent, const char *name = 0, TV *player = NULL); 
    102103   ~PlaybackBox(void); 
    103104    
    104105    void customEvent(QCustomEvent *e); 
    105    
     106    static ProgramInfo *RunPlaybackBox(void *player); 
     107     
     108     
    106109  protected slots: 
    107110    void timeout(void); 
    108111 
     
    246249    void stop(ProgramInfo *); 
    247250    void remove(ProgramInfo *); 
    248251    void showActions(ProgramInfo *); 
     252    ProgramInfo *getSelected(void){ return curitem; } 
     253         
    249254 
    250255    void togglePlayListItem(ProgramInfo *pginfo); 
    251256    void randomizePlayList(void); 
     
    451456    mutable QMutex      ncLock; 
    452457    QValueList<QString> networkControlCommands; 
    453458    bool                underNetworkControl; 
     459     
     460    TV                  *m_player; 
    454461}; 
    455462 
    456463#endif