Ticket #4568: ticket_4568.diff

File ticket_4568.diff, 21.0 KB (added by skamithi, 13 years ago)
  • libs/libmythtv/guidegrid.h

     
    3838    static DBChanList Run(uint           startChanId,
    3939                          const QString &startChanNum,
    4040                          bool           thread = false,
    41                           TV            *player = NULL,
    42                           bool           allowsecondaryepg = true);
     41                          TV            *player = NULL);
    4342
    4443    DBChanList GetSelection(void) const;
    4544
     
    8584  protected:
    8685    GuideGrid(MythMainWindow *parent,
    8786              uint chanid = 0, QString channum = "",
    88               TV *player = NULL, bool allowsecondaryepg = true,
     87              TV *player = NULL,
    8988              const char *name = "GuideGrid");
    9089   ~GuideGrid();
    9190
  • libs/libmythtv/tv_play.h

     
    4343typedef QMap<QString,InfoMap>    DDValueMap;
    4444typedef QMap<QString,DDValueMap> DDKeyMap;
    4545typedef ProgramInfo * (*RUNPLAYBACKBOX)(void *);
     46typedef void (*RUNVIEWSCHEDULED) (void *);
    4647
    47 
    4848class VBIMode
    4949{
    5050  public:
     
    7575    kScheduleProgramGuide = 0,
    7676    kScheduleProgramFinder,
    7777    kScheduledRecording,
    78     kPlaybackBox,
     78    kViewSchedule,
     79    kPlaybackBox
    7980};
    8081
    8182typedef enum
     
    197198    /// true if dialog is either videoplayexit, playexit or askdelete dialog
    198199    bool IsVideoExitDialog(void);
    199200    /// true if NVP is near the end
    200     bool IsNearEnd(void) { return isnearend; }
     201    bool IsNearEnd(void) const { return isnearend; }
     202    /// true if tv player is paused
     203    bool IsPaused(void) const { return paused; }
    201204
    202205    // Other queries
    203206    int GetLastRecorderNum(void) const;
     
    239242  protected:
    240243    void doEditSchedule(int editType = kScheduleProgramGuide);
    241244    static void *RecordedShowMenuHandler(void *param);
     245    static void *ViewScheduledMenuHandler(void *param);
     246    void VideoThemeCheck(QString str, bool stayPaused = false);
    242247
    243248    void RunTV(void);
    244249    static void *EventThread(void *param);
     
    247252    bool eventFilter(QObject *o, QEvent *e);
    248253    static QStringList lastProgramStringList;
    249254    static RUNPLAYBACKBOX RunPlaybackBoxPtr;
     255    static RUNVIEWSCHEDULED RunViewScheduledPtr;
    250256
    251257  private:
    252258    bool RequestNextRecorder(bool showDialogs);
  • libs/libmythtv/guidegrid.cpp

     
    4040    uint           chanid,
    4141    const QString &channum,
    4242    bool           thread,
    43     TV            *player,
    44     bool           allowsecondaryepg)
     43    TV            *player)
    4544{
    4645    DBChanList channel_changed;
    4746
     
    5251
    5352    GuideGrid *gg = new GuideGrid(gContext->GetMainWindow(),
    5453                                  chanid, channum,
    55                                   player, allowsecondaryepg, "guidegrid");
     54                                  player, "guidegrid");
    5655
    5756    gg->Show();
    5857
     
    9190
    9291GuideGrid::GuideGrid(MythMainWindow *parent,
    9392                     uint chanid, QString channum,
    94                      TV *player, bool allowsecondaryepg,
    95                      const char *name)
     93                     TV *player, const char *name)
    9694         : MythDialog(parent, name)
    9795{
    9896    desiredDisplayChans = DISPLAY_CHANS = 6;
     
    123121    theme = new XMLParse();
    124122    theme->SetWMult(wmult);
    125123    theme->SetHMult(hmult);
    126     if (m_player && m_player->IsRunning() && allowsecondaryepg)
     124    if (m_player && m_player->IsRunning() && !m_player->IsPaused())
    127125        theme->LoadTheme(xmldata, "programguide-video");
    128126    else
    129127        theme->LoadTheme(xmldata, "programguide");
    130128
    131129    LoadWindow(xmldata);
    132130
    133     if (m_player && m_player->IsRunning() && !allowsecondaryepg)
     131    if (m_player && m_player->IsRunning() && m_player->IsPaused())
    134132        videoRect = QRect(0, 0, 1, 1);
    135133
    136134    showFavorites = gContext->GetNumSetting("EPGShowFavorites", 0);
     
    202200
    203201    int dNum = gContext->GetNumSetting("chanPerPage", 8);
    204202
    205     if (m_player && m_player->IsRunning() && allowsecondaryepg)
     203    if (m_player && m_player->IsRunning() && !m_player->IsPaused())
    206204        dNum = dNum * 2 / 3 + 1;
    207205
    208206    desiredDisplayChans = DISPLAY_CHANS = dNum;
  • libs/libmythtv/tv_play.cpp

     
    7878 */
    7979RUNPLAYBACKBOX TV::RunPlaybackBoxPtr = NULL;
    8080
     81/**\ brief function pointer for RunViewScheduled in viewscheduled.cpp
     82 */
     83RUNVIEWSCHEDULED TV::RunViewScheduledPtr = NULL;
     84
    8185/*
    8286 \brief returns true if the recording completed when exiting.
    8387 */
     
    262266    QString name(string);
    263267    if (name == "playbackbox")
    264268        RunPlaybackBoxPtr = (RUNPLAYBACKBOX)lptr;
     269    else if (name == "viewscheduled")
     270        RunViewScheduledPtr = (RUNVIEWSCHEDULED)lptr;
    265271}
    266272
    267273void TV::InitKeys(void)
     
    406412    REG_KEY("TV Playback", "PLAY", "Play", "Ctrl+P");
    407413    REG_KEY("TV Playback", "JUMPPREV", "Jump to previously played recording", "");
    408414    REG_KEY("TV Playback", "JUMPREC", "Display menu of recorded programs to jump to", "");
     415    REG_KEY("TV Playback", "VIEWSCHEDULED", "Display scheduled recording list", "");
    409416    REG_KEY("TV Playback", "SIGNALMON", "Monitor Signal Quality", "F7");
    410417    REG_KEY("TV Playback", "JUMPTODVDROOTMENU", "Jump to the DVD Root Menu", "");
    411418    REG_KEY("TV Playback", "EXITSHOWNOPROMPTS","Exit Show without any prompts", "");
     
    31513158                jumpToProgram = true;
    31523159            }
    31533160        }
     3161        else if (action == "VIEWSCHEDULED")
     3162            EmbedWithNewThread(kViewSchedule);
    31543163        else if (action == "JUMPREC")
    31553164        {
    31563165            if (gContext->GetNumSetting("JumpToProgramOSD", 1)
     
    56755684        nvp->DrawUnusedRects(sync);
    56765685}
    56775686
     5687void *TV::ViewScheduledMenuHandler(void *param)
     5688{
     5689    TV *obj = (TV *)param;
     5690    obj->doEditSchedule(kViewSchedule);
     5691    return NULL;
     5692}
     5693
    56785694void *TV::RecordedShowMenuHandler(void *param)
    56795695{
    56805696    TV *obj = (TV *)param;
    56815697    obj->doEditSchedule(kPlaybackBox);
    5682 
    56835698    return NULL;
    56845699}
    56855700
     5701/**
     5702 * \brief Used by EditSchedule(). Unpauses embedded tv based on whether theme
     5703    exists and/or if knob to continued playback is enabled
     5704 */
     5705void TV::VideoThemeCheck(QString str, bool stayPaused)
     5706{   
     5707    // see if embedded window is allowed
     5708    bool allowembed = false;
     5709    if (gContext->GetNumSetting("ContinueEmbeddedTVPlay", 0) ||
     5710        StateIsLiveTV(GetState()))
     5711    {
     5712        allowembed = (nvp && nvp->getVideoOutput() &&
     5713                nvp->getVideoOutput()->AllowEmbedding());
     5714    }
     5715
     5716    long long margin = (long long)(nvp->GetFrameRate() *
     5717                        nvp->GetAudioStretchFactor());
     5718    margin = margin * 5;
     5719    QDomElement xmldata;
     5720    XMLParse *theme = new XMLParse();
     5721    if (allowembed && theme->LoadTheme(xmldata, str) &&
     5722        !nvp->IsNearEnd(margin) && !stayPaused)
     5723    {
     5724        DoPause(false);
     5725    }
     5726
     5727    if (theme)
     5728        delete theme;
     5729}
     5730
    56865731void TV::doEditSchedule(int editType)
    56875732{
    56885733    if (!playbackinfo)
     
    57145759    DBChanList changeChannel;
    57155760    ProgramInfo *nextProgram = NULL;
    57165761
    5717     if (StateIsLiveTV(GetState()))
     5762    bool stayPaused = paused;
     5763    if (!paused)
     5764        DoPause(false);
     5765
     5766    switch (editType)
    57185767    {
    5719         switch (editType)
     5768        default:
     5769        case kScheduleProgramGuide:
     5770            VideoThemeCheck("programguide-video", stayPaused);
     5771            GuideGrid::Run(chanid, channum, false, this);
     5772            break;
     5773        case kScheduleProgramFinder:
     5774            RunProgramFind(true, false);
     5775            break;
     5776        case kScheduledRecording:
    57205777        {
    5721             default:
    5722             case kScheduleProgramGuide:
    5723             {
    5724                 // See if we can provide a channel preview in EPG
    5725                 bool allowsecondary = true;
    5726                 if (nvp && nvp->getVideoOutput())
    5727                     allowsecondary = nvp->getVideoOutput()->AllowPreviewEPG();
    5728 
    5729                 // Start up EPG
    5730                 changeChannel = GuideGrid::Run(
    5731                     chanid, channum, false, this, allowsecondary);
    5732 
    5733                 break;
    5734             }
    5735             case kPlaybackBox:
    5736             {
    5737                 bool stayPaused = false;
    5738                 QDomElement pbbxmldata;
    5739                 XMLParse    *theme = new XMLParse();
    5740                 if (!theme->LoadTheme(pbbxmldata, "playback-video"))
    5741                 {
    5742                     stayPaused = paused;
    5743                     if (!paused)
    5744                         DoPause(false);
    5745                 }
    5746                 if (theme)
    5747                     delete theme;
    5748                 nextProgram = RunPlaybackBoxPtr((void *)this);
    5749                 if (nextProgram)
    5750                 {
    5751                     setLastProgram(nextProgram);
    5752                     jumpToProgram = true;
    5753                     exitPlayer = true;
    5754                     delete nextProgram;
    5755                 }
    5756                 if (paused && !stayPaused)
    5757                     DoPause(false);
    5758                 break;
    5759             }
     5778            QMutexLocker locker(&pbinfoLock);
     5779            ScheduledRecording *record = new ScheduledRecording();
     5780            record->loadByProgram(playbackinfo);
     5781            record->exec();
     5782            record->deleteLater();
     5783            break;
    57605784        }
    5761         if (IsEmbedding())
    5762             StopEmbeddingOutput();
    5763     }
    5764     else
    5765     {
    5766         bool stayPaused = paused;
    5767         if (!paused)
    5768             DoPause();
    5769 
    5770         switch (editType)
     5785        case kViewSchedule:
    57715786        {
    5772             default:
    5773             case kScheduleProgramGuide:
    5774                 GuideGrid::Run(chanid, channum, false);
    5775                 break;
    5776             case kScheduleProgramFinder:
    5777                 RunProgramFind(true, false);
    5778                 break;
    5779             case kScheduledRecording:
    5780             {
    5781                 QMutexLocker locker(&pbinfoLock);
    5782                 ScheduledRecording *record = new ScheduledRecording();
    5783                 record->loadByProgram(playbackinfo);
    5784                 record->exec();
    5785                 record->deleteLater();
    5786                 break;
    5787             }
    5788             case kPlaybackBox:
    5789             {
    5790                 long long margin =
    5791                     (long long)(nvp->GetFrameRate() * nvp->GetAudioStretchFactor());
    5792                 // keep video paused if only 5 seconds left in recording
    5793                 margin = margin * 5;
    5794                 QDomElement pbbxmldata;
    5795                 XMLParse *theme = new XMLParse();
    5796                 if (theme->LoadTheme(pbbxmldata, "playback-video"))
    5797                 {
    5798                     if (!stayPaused && paused && !nvp->IsNearEnd(margin))
    5799                     {
    5800                         DoPause(false);
    5801                         stayPaused = true;
    5802                     }
    5803                 }
    5804                 if (theme)
    5805                     delete theme;
    5806                 nextProgram = RunPlaybackBoxPtr((void *)this);
    5807                 if (IsEmbedding())
    5808                     StopEmbeddingOutput();
    5809                 if (nextProgram)
    5810                 {
    5811                     setLastProgram(nextProgram);
    5812                     jumpToProgram = true;
    5813                     exitPlayer = true;
    5814                     delete nextProgram;
    5815                 }
    5816                 break;
    5817             }
     5787            VideoThemeCheck("conflict-video", stayPaused);
     5788            RunViewScheduledPtr((void *)this);
     5789            break;
    58185790        }
    5819 
    5820         if (!stayPaused)
    5821             DoPause();
     5791        case kPlaybackBox:
     5792        {
     5793            VideoThemeCheck("playback-video", stayPaused);
     5794            nextProgram = RunPlaybackBoxPtr((void *)this);
     5795        }
    58225796    }
    58235797
     5798    if (!stayPaused && paused)
     5799        DoPause(false);
     5800
     5801    if (IsEmbedding())
     5802        StopEmbeddingOutput();
     5803
     5804    if (nextProgram)
     5805    {
     5806        setLastProgram(nextProgram);
     5807        jumpToProgram = true;
     5808        exitPlayer = true;
     5809        delete nextProgram;
     5810    }
    58245811    // Resize the window back to the MythTV Player size
    58255812    if (!using_gui_size_for_tv)
    58265813    {
     
    58455832 */
    58465833void TV::EmbedWithNewThread(int editType)
    58475834{
    5848     (void) editType;
    5849 
    58505835    if (menurunning != true)
    58515836    {
    58525837        menurunning = true;
     
    58555840        pthread_attr_init(&attr);
    58565841        pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
    58575842
    5858         pthread_create(&tid, &attr, TV::RecordedShowMenuHandler, this);
     5843        switch (editType)
     5844        {
     5845            case kViewSchedule:
     5846                pthread_create(&tid, &attr, TV::ViewScheduledMenuHandler, this);
     5847                break;
     5848            case kPlaybackBox:
     5849                pthread_create(&tid, &attr, TV::RecordedShowMenuHandler, this);
     5850                break;
     5851        }
     5852
    58595853        pthread_attr_destroy(&attr);
    58605854
    58615855        return;
     
    72287222            jumpToProgram = true;
    72297223        }
    72307224    }
     7225    else if (action == "VIEWSCHEDULED")
     7226        EmbedWithNewThread(kViewSchedule);
    72317227    else if (action == "JUMPREC")
    72327228    {
    72337229        if (gContext->GetNumSetting("JumpToProgramOSD", 1)
     
    76707666
    76717667    item = new OSDGenericTree(treeMenu, tr("Schedule Recordings"));
    76727668    subitem = new OSDGenericTree(item, tr("Program Guide"), "GUIDE");
     7669    subitem = new OSDGenericTree(item, tr("Upcoming Recordings"),
     7670                                "VIEWSCHEDULED");
    76737671    subitem = new OSDGenericTree(item, tr("Program Finder"), "FINDER");
    76747672    subitem = new OSDGenericTree(item, tr("Edit Recording Schedule"),
    76757673                                 "SCHEDULE");
  • libs/libmythtv/videooutbase.h

     
    115115    int         GetPictureAttribute(PictureAttribute) const;
    116116    virtual void InitPictureAttributes(void);
    117117
    118     bool AllowPreviewEPG(void) { return allowpreviewepg; }
     118    bool AllowEmbedding(void) { return allowpreviewepg; }
    119119
    120120    /// \brief Returns true iff Motion Compensation acceleration is available.
    121121    virtual bool hasMCAcceleration(void) const { return false; }
  • programs/mythfrontend/playbackbox.cpp

     
    348348    // theme stuff
    349349    theme->SetWMult(wmult);
    350350    theme->SetHMult(hmult);
    351     if (m_player && theme->LoadTheme(xmldata,"playback-video"))
     351    if (m_player && !m_player->IsPaused() &&
     352        theme->LoadTheme(xmldata,"playback-video"))
    352353    {
    353354        playbackVideoContainer = true;
    354355        previewPixmapEnabled = false;
  • programs/mythfrontend/viewscheduled.h

     
    99#include "xmlparse.h"
    1010#include "programinfo.h"
    1111
     12class TV;
     13class Timer;
    1214
    1315class ViewScheduled : public MythDialog
    1416{
    1517    Q_OBJECT
    1618  public:
    17     ViewScheduled(MythMainWindow *parent, const char *name = 0);
     19    ViewScheduled(MythMainWindow *parent, const char *name = 0,
     20                    TV *player = NULL);
    1821    ~ViewScheduled();
     22    static void * RunViewScheduled(void *player);
    1923
    2024  protected slots:
    2125    void edit();
     
    2832    void cursorUp(bool page = false);
    2933    void pageDown() { cursorDown(true); }
    3034    void pageUp() { cursorUp(true); }
     35    void timeout(void);
    3136
    3237  protected:
    3338    void paintEvent(QPaintEvent *);
     
    4954
    5055    void LoadWindow(QDomElement &);
    5156    void parseContainer(QDomElement &);
     57    void EmbedTVWindow(void);
    5258    XMLParse *theme;
    5359    QDomElement xmldata;
    5460
     
    6672    QRect showLevelRect;
    6773    QRect recStatusRect;
    6874    QRect fullRect;
     75    QRect tvRect;
    6976
    7077    int listsize;
    7178
     
    8592    QMap<int, int> inputref;
    8693    int maxinput;
    8794    int curinput;
     95
     96    TV *m_player;
     97    QTimer *timer;
    8898};
    8999
    90100#endif
  • programs/mythfrontend/globalsettings.cpp

     
    19071907    return gc;
    19081908}
    19091909
     1910static HostCheckBox *ContinueEmbeddedTVPlay()
     1911{
     1912    HostCheckBox *gc = new HostCheckBox("ContinueEmbeddedTVPlay");
     1913    gc->setLabel(QObject::tr("Continue Playback When Embedded"));
     1914    gc->setValue(false);
     1915    gc->setHelpText(QObject::tr(
     1916                    "This option, continues TV playback, when the TV window "
     1917                    "is embedded in the upcoming program list or recorded "
     1918                    "list. The default is to pause the recorded show when "
     1919                    "embedded"));
     1920    return gc;
     1921}
     1922
    19101923static HostCheckBox *AutomaticSetWatched()
    19111924{
    19121925    HostCheckBox *gc = new HostCheckBox("AutomaticSetWatched");
     
    44104423    column2->addChild(ClearSavedPosition());
    44114424    column2->addChild(AltClearSavedPosition());
    44124425    column2->addChild(JumpToProgramOSD());
     4426    column2->addChild(ContinueEmbeddedTVPlay());
    44134427    column2->addChild(AutomaticSetWatched());
    44144428    columns->addChild(column2);
    44154429
  • programs/mythfrontend/main.cpp

     
    802802    TV::InitKeys();
    803803
    804804    TV::SetFuncPtr("playbackbox", (void *)PlaybackBox::RunPlaybackBox);
     805    TV::SetFuncPtr("viewscheduled", (void *)ViewScheduled::RunViewScheduled);
    805806}
    806807
    807808
  • programs/mythfrontend/viewscheduled.cpp

     
    1818#include "scheduledrecording.h"
    1919#include "customedit.h"
    2020#include "proglist.h"
    21 #include "tv.h"
     21#include "tv_play.h"
    2222
    2323#include "exitcodes.h"
    2424#include "dialogbox.h"
    2525#include "mythcontext.h"
    2626#include "remoteutil.h"
    2727
    28 ViewScheduled::ViewScheduled(MythMainWindow *parent, const char *name)
     28QWaitCondition vsbIsVisibleCond;
     29
     30void *ViewScheduled::RunViewScheduled(void *player)
     31{
     32    qApp->lock();
     33
     34    ViewScheduled *vsb = new ViewScheduled(gContext->GetMainWindow(),
     35                            "view scheduled", (TV*)player);
     36    vsb->Show();
     37    qApp->unlock();
     38    vsbIsVisibleCond.wait();
     39    delete vsb;
     40
     41    return NULL;
     42}
     43
     44ViewScheduled::ViewScheduled(MythMainWindow *parent, const char *name,
     45                            TV* player)
    2946             : MythDialog(parent, name)
    3047{
    3148    dateformat = gContext->GetSetting("ShortDateFormat", "M/d");
     
    4057    showLevelRect = QRect(0, 0, 0, 0);
    4158    recStatusRect = QRect(0, 0, 0, 0);
    4259
     60    m_player = player;
    4361    theme = new XMLParse();
    4462    theme->SetWMult(wmult);
    4563    theme->SetHMult(hmult);
    46     theme->LoadTheme(xmldata, "conflict");
     64    if (m_player && m_player->IsRunning() && !m_player->IsPaused())
     65    {
     66        if (!theme->LoadTheme(xmldata, "conflict-video"))
     67            theme->LoadTheme(xmldata, "conflict");
     68    }
     69    else
     70        theme->LoadTheme(xmldata, "conflict");
    4771    LoadWindow(xmldata);
    4872
     73    if (m_player)
     74    {
     75        timer = new QTimer(this);
     76        connect(timer, SIGNAL(timeout()), this, SLOT(timeout()));
     77        timer->start(500);
     78        EmbedTVWindow();
     79    }
     80
    4981    LayerSet *container = theme->GetSet("selector");
    5082    if (container)
    5183    {
     
    84116    gContext->SaveSetting("ViewSchedShowLevel", !showAll);
    85117    gContext->removeListener(this);
    86118    gContext->removeCurrentLocation();
     119
     120    if (timer)
     121    {
     122        timer->deleteLater();
     123        timer = NULL;
     124    }
     125
    87126    delete theme;
    88127}
    89128
     129void ViewScheduled::timeout(void)
     130{
     131    if (m_player)
     132        EmbedTVWindow();
     133}
     134
    90135void ViewScheduled::keyPressEvent(QKeyEvent *e)
    91136{
    92137    if (inEvent)
     
    116161            else if (action == "DETAILS")
    117162                details();
    118163            else if (action == "ESCAPE" || action == "LEFT")
     164            {
     165                vsbIsVisibleCond.wakeAll();
    119166                done(MythDialog::Accepted);
     167            }
    120168            else if (action == "UP")
    121169                cursorUp();
    122170            else if (action == "DOWN")
     
    196244        showLevelRect = area;
    197245    if (name.lower() == "status_info")
    198246        recStatusRect = area;
     247    if (name.lower() == "tv_video")
     248        tvRect = area;
    199249}
    200250
    201251void ViewScheduled::updateBackground(void)
     
    736786    }
    737787    curinput = 0;
    738788}
     789
     790void ViewScheduled::EmbedTVWindow(void)
     791{
     792    if (m_player)
     793    {
     794        m_player->EmbedOutput(this->winId(), tvRect.x(), tvRect.y(),
     795                            tvRect.width(), tvRect.height());
     796    }
     797}
     798