Ticket #2426: embed_playback_part2.4.diff
File embed_playback_part2.4.diff, 17.8 KB (added by , 18 years ago) |
---|
-
libs/libmythtv/tv_play.h
38 38 typedef QMap<QString,QString> InfoMap; 39 39 typedef QMap<QString,InfoMap> DDValueMap; 40 40 typedef QMap<QString,DDValueMap> DDKeyMap; 41 typedef ProgramInfo * (*RUNPLAYBACKBOX)(void *); 41 42 43 42 44 class VBIMode 43 45 { 44 46 public: … … 68 70 enum scheduleEditTypes { 69 71 kScheduleProgramGuide = 0, 70 72 kScheduleProgramFinder, 71 kScheduledRecording 73 kScheduledRecording, 74 kPlaybackBox, 72 75 }; 73 76 74 77 class MPUBLIC TV : public QObject … … 112 115 // Recording commands 113 116 int PlayFromRecorder(int recordernum); 114 117 int Playback(ProgramInfo *rcinfo); 118 119 // Various commands 115 120 void setLastProgram(ProgramInfo *rcinfo); 116 121 ProgramInfo *getLastProgram(void) { return lastProgram; } 117 122 void setInPlayList(bool setting) { inPlaylist = setting; } 118 123 void setUnderNetworkControl(bool setting) { underNetworkControl = setting; } 124 bool IsSameProgram(ProgramInfo *p); 119 125 120 // Various commands121 126 void ShowNoRecorderDialog(void); 122 127 void FinishRecording(void); 123 128 void AskAllowRecording(const QStringList&, int, bool); … … 173 178 static void InitKeys(void); 174 179 static bool StartTV(ProgramInfo *tvrec = NULL, bool startInGuide = false, 175 180 bool inPlaylist = false, bool initByNetworkCommand = false); 176 181 static void SetEmbedPbbFunc(RUNPLAYBACKBOX lptr); 177 182 178 183 void SetIgnoreKeys(bool ignore) { ignoreKeys = ignore; } 179 184 … … 194 199 static void *EPGMenuHandler(void *param); 195 200 static void *FinderMenuHandler(void *param); 196 201 static void *ScheduleMenuHandler(void *param); 202 static void *RecordedShowMenuHandler(void *param); 197 203 198 204 void RunTV(void); 199 205 static void *EventThread(void *param); 200 206 201 207 bool eventFilter(QObject *o, QEvent *e); 208 static QStringList lastProgramStringList; 209 static RUNPLAYBACKBOX RunPlaybackBoxPtr; 202 210 203 211 private: 204 212 bool RequestNextRecorder(bool showDialogs); … … 297 305 void SetAutoCommercialSkip(enum commSkipMode skipMode = CommSkipOff); 298 306 void SetManualZoom(bool zoomON = false); 299 307 300 void DoDisplayJumpMenu(void);301 308 void SetJumpToProgram(QString progKey = "", int progIndex = 0); 302 309 303 310 bool ClearOSD(void); … … 325 332 void ToggleActiveWindow(void); 326 333 void SwapPIP(void); 327 334 void SwapPIPSoon(void) { needToSwapPIP = true; } 328 void DisplayJumpMenuSoon(void) { needToJumpMenu = true; }329 335 330 336 void ToggleAutoExpire(void); 331 337 … … 426 432 427 433 bool ignoreKeys; 428 434 bool needToSwapPIP; 429 bool needToJumpMenu;430 435 QMap<QString,ProgramList> progLists; 431 436 432 437 mutable QMutex chanEditMapLock; ///< Lock for chanEditMap and ddMap -
libs/libmythtv/tv_play.cpp
61 61 * \brief stores last program info. maintains info so long as 62 62 * mythfrontend is active 63 63 */ 64 static QStringListlastProgramStringList = QStringList();64 QStringList TV::lastProgramStringList = QStringList(); 65 65 66 66 /* 67 * \brief function pointer for RunPlaybackBox in playbackbox.cpp 68 */ 69 RUNPLAYBACKBOX TV::RunPlaybackBoxPtr = NULL; 70 71 /* 67 72 \brief returns true if the recording completed when exiting. 68 73 */ 69 74 bool TV::StartTV (ProgramInfo *tvrec, bool startInGuide, … … 130 135 ProgramInfo *tmpProgram = tv->getLastProgram(); 131 136 ProgramInfo *nextProgram = new ProgramInfo(*tmpProgram); 132 137 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); 134 143 135 144 if (curProgram) 136 145 delete curProgram; … … 179 188 180 189 return playCompleted; 181 190 } 182 191 192 void TV::SetEmbedPbbFunc(RUNPLAYBACKBOX lptr) 193 { 194 RunPlaybackBoxPtr = lptr; 195 } 196 183 197 void TV::InitKeys(void) 184 198 { 185 199 REG_KEY("TV Frontend", "PAGEUP", "Page Up", "3"); … … 415 429 queuedTranscode(false), getRecorderPlaybackInfo(false), 416 430 adjustingPicture(kAdjustingPicture_None), 417 431 adjustingPictureAttribute(kPictureAttribute_None), 418 ignoreKeys(false), needToSwapPIP(false), needToJumpMenu(false),432 ignoreKeys(false), needToSwapPIP(false), 419 433 // Channel Editing 420 434 chanEditMapLock(true), ddMapSourceId(0), ddMapLoaderRunning(false), 421 435 // Sleep Timer … … 1935 1949 SwapPIP(); 1936 1950 needToSwapPIP = false; 1937 1951 } 1938 1939 if (needToJumpMenu)1940 {1941 DoDisplayJumpMenu();1942 needToJumpMenu = false;1943 }1944 1952 } 1945 1953 1946 1954 if (!IsErrored() && (GetState() != kState_None)) … … 2685 2693 jumpToProgram = true; 2686 2694 } 2687 2695 else if (action == "JUMPREC") 2688 DisplayJumpMenuSoon(); 2696 { 2697 if (RunPlaybackBoxPtr) 2698 EditSchedule(kPlaybackBox); 2699 } 2689 2700 else if (action == "SIGNALMON") 2690 2701 { 2691 2702 if ((GetState() == kState_WatchingLiveTV) && activerecorder) … … 4940 4951 pbinfoLock.unlock(); 4941 4952 4942 4953 bool changeChannel = false; 4954 ProgramInfo *nextProgram = NULL; 4943 4955 4944 4956 if (StateIsLiveTV(GetState())) 4945 4957 { … … 4969 4981 RunProgramFind(true, false); 4970 4982 break; 4971 4983 case kScheduledRecording: 4984 { 4972 4985 pbinfoLock.lock(); 4973 4986 ScheduledRecording record; 4974 4987 record.loadByProgram(playbackinfo); 4975 4988 record.exec(); 4976 4989 pbinfoLock.unlock(); 4977 4990 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 } 4978 5004 } 4979 5005 4980 5006 if (!stayPaused) … … 5020 5046 return NULL; 5021 5047 } 5022 5048 5049 void *TV::RecordedShowMenuHandler(void *param) 5050 { 5051 TV *obj = (TV *)param; 5052 obj->doEditSchedule(kPlaybackBox); 5053 5054 return NULL; 5055 } 5056 5023 5057 void TV::EditSchedule(int editType) 5024 5058 { 5025 5059 if (menurunning == true) … … 5042 5076 case kScheduledRecording: 5043 5077 pthread_create(&tid, &attr, TV::ScheduleMenuHandler, this); 5044 5078 break; 5079 case kPlaybackBox: 5080 pthread_create(&tid, &attr, TV::RecordedShowMenuHandler, this); 5081 break; 5045 5082 } 5046 5083 } 5047 5084 … … 6337 6374 jumpToProgram = true; 6338 6375 } 6339 6376 else if (action == "JUMPREC") 6340 DisplayJumpMenuSoon(); 6377 { 6378 if (RunPlaybackBoxPtr) 6379 EditSchedule(kPlaybackBox); 6380 } 6341 6381 else if (action.left(8) == "JUMPPROG") 6342 6382 { 6343 6383 SetJumpToProgram(action.section(" ",1,-2), … … 6368 6408 } 6369 6409 } 6370 6410 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 titles6380 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 else6411 {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 else6420 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 6443 6411 void TV::ShowOSDTreeMenu(void) 6444 6412 { 6445 6413 BuildOSDTreeMenu(); … … 7409 7377 lastProgram = NULL; 7410 7378 } 7411 7379 7380 bool TV::IsSameProgram(ProgramInfo *rcinfo) 7381 { 7382 if (rcinfo && playbackinfo) 7383 return playbackinfo->IsSameProgram(*rcinfo); 7384 7385 return false; 7386 } 7387 7412 7388 /* vim: set expandtab tabstop=4 shiftwidth=4: */ -
programs/mythfrontend/playbackbox.cpp
16 16 #include <qfileinfo.h> 17 17 #include <qsqldatabase.h> 18 18 #include <qmap.h> 19 #include <qwaitcondition.h> 19 20 20 21 #include <cmath> 21 22 #include <unistd.h> … … 50 51 51 52 #define USE_PREV_GEN_THREAD 52 53 54 QWaitCondition pbbIsVisibleCond; 55 53 56 static int comp_programid(ProgramInfo *a, ProgramInfo *b) 54 57 { 55 58 if (a->programid == b->programid) … … 185 188 return (a->startts.date() > b->startts.date() ? 1 : -1); 186 189 } 187 190 191 192 ProgramInfo *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 188 212 PlaybackBox::PlaybackBox(BoxType ltype, MythMainWindow *parent, 189 const char *name )213 const char *name, TV *player) 190 214 : MythDialog(parent, name), 191 215 // Settings 192 216 type(ltype), … … 248 272 previewPixmapEnabled(false), previewPixmap(NULL), 249 273 previewSuspend(false), previewChanid(""), 250 274 // Network Control Variables 251 underNetworkControl(false) 275 underNetworkControl(false), 276 m_player(NULL) 252 277 { 253 278 formatShortDate = gContext->GetSetting("ShortDateFormat", "M/d"); 254 279 formatLongDate = gContext->GetSetting("DateFormat", "ddd MMMM d"); … … 263 288 groupnameAsAllProg = gContext->GetNumSetting("DispRecGroupAsAllProg", 0); 264 289 arrowAccel = gContext->GetNumSetting("UseArrowAccels", 1); 265 290 inTitle = gContext->GetNumSetting("PlaybackBoxStartInTitle", 0); 266 previewVideoEnabled =gContext->GetNumSetting("PlaybackPreview"); 291 if (!player) 292 previewVideoEnabled =gContext->GetNumSetting("PlaybackPreview"); 267 293 previewPixmapEnabled=gContext->GetNumSetting("GeneratePreviewPixmaps"); 268 294 previewFromBookmark= gContext->GetNumSetting("PreviewFromBookmark"); 269 295 drawTransPixmap = gContext->LoadScalePixmap("trans-backup.png"); … … 283 309 titleList << ""; 284 310 playList.clear(); 285 311 312 if (player) 313 m_player = player; 314 286 315 // recording group stuff 287 316 recGroupType.clear(); 288 317 recGroupType[recGroup] = (displayCat) ? "category" : "recgroup"; … … 369 398 gContext->removeListener(this); 370 399 gContext->removeCurrentLocation(); 371 400 372 killPlayerSafe(); 401 if (!m_player) 402 killPlayerSafe(); 373 403 374 404 if (previewVideoRefreshTimer) 375 405 { … … 566 596 567 597 void PlaybackBox::exitWin() 568 598 { 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 570 609 accept(); 571 610 } 572 611 … … 1247 1286 if (playList.grep(tempInfo->MakeUniqueKey()).count()) 1248 1287 ltype->EnableForcedFont(cnt, "tagged"); 1249 1288 1250 if (tempInfo->availableStatus != asAvailable) 1289 if (tempInfo->availableStatus != asAvailable || 1290 (m_player && m_player->IsSameProgram(tempInfo)) && tempInfo->recstatus != rsRecording) 1251 1291 ltype->EnableForcedFont(cnt, "inactive"); 1252 1292 } 1253 1293 } … … 2080 2120 if (!curitem) 2081 2121 return; 2082 2122 2123 if (m_player && m_player->IsSameProgram(curitem)) 2124 exitWin(); 2125 2083 2126 if (curitem && curitem->availableStatus != asAvailable) 2084 2127 showAvailablePopup(curitem); 2085 2128 else 2086 2129 play(curitem); 2130 2131 if (m_player) 2132 { 2133 pbbIsVisibleCond.wakeAll(); 2134 accept(); 2135 } 2087 2136 } 2088 2137 2089 2138 void PlaybackBox::stopSelected() … … 2212 2261 popup->addButton(tr("Playlist options"), this, 2213 2262 SLOT(showPlaylistPopup())); 2214 2263 } 2215 else 2264 else if (!m_player) 2216 2265 { 2217 2266 if (inTitle) 2218 2267 { … … 2255 2304 if (!rec) 2256 2305 return false; 2257 2306 2307 if (m_player) 2308 return true; 2309 2258 2310 if (fileExists(rec) == false) 2259 2311 { 2260 2312 QString msg = … … 2913 2965 2914 2966 initPopup(popup, program, "", ""); 2915 2967 2916 QButton *playButton ;2968 QButton *playButton = new QButton(); 2917 2969 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 } 2923 2978 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 } 2930 2988 2931 2989 if (program->recstatus == rsRecording) 2932 2990 popup->addButton(tr("Stop Recording"), this, SLOT(askStop())); … … 2942 3000 popup->addButton(tr("Recording Options"), this, SLOT(showRecordingPopup())); 2943 3001 popup->addButton(tr("Job Options"), this, SLOT(showJobPopup())); 2944 3002 2945 popup->addButton(tr("Delete"), this, SLOT(askDelete())); 3003 if (!(m_player && m_player->IsSameProgram(curitem))) 3004 popup->addButton(tr("Delete"), this, SLOT(askDelete())); 2946 3005 2947 3006 popup->ShowPopup(this, SLOT(doCancel())); 2948 3007 -
programs/mythfrontend/main.cpp
614 614 REG_JUMP("Previously Recorded", "", "", startPrevious); 615 615 616 616 TV::InitKeys(); 617 618 TV::SetEmbedPbbFunc(PlaybackBox::RunPlaybackBox); 617 619 } 618 620 619 621 int internal_media_init() -
programs/mythfrontend/playbackbox.h
13 13 #include "xmlparse.h" 14 14 #include "programinfo.h" 15 15 #include "jobqueue.h" 16 #include "tv_play.h" 16 17 17 18 #include <qvaluelist.h> 18 19 #include <pthread.h> … … 98 99 } killStateType; 99 100 100 101 101 PlaybackBox(BoxType ltype, MythMainWindow *parent, const char *name = 0 );102 PlaybackBox(BoxType ltype, MythMainWindow *parent, const char *name = 0, TV *player = NULL); 102 103 ~PlaybackBox(void); 103 104 104 105 void customEvent(QCustomEvent *e); 105 106 static ProgramInfo *RunPlaybackBox(void *player); 107 108 106 109 protected slots: 107 110 void timeout(void); 108 111 … … 246 249 void stop(ProgramInfo *); 247 250 void remove(ProgramInfo *); 248 251 void showActions(ProgramInfo *); 252 ProgramInfo *getSelected(void){ return curitem; } 253 249 254 250 255 void togglePlayListItem(ProgramInfo *pginfo); 251 256 void randomizePlayList(void); … … 451 456 mutable QMutex ncLock; 452 457 QValueList<QString> networkControlCommands; 453 458 bool underNetworkControl; 459 460 TV *m_player; 454 461 }; 455 462 456 463 #endif