Ticket #7892: t7892_avchapter_support_v1.diff
File t7892_avchapter_support_v1.diff, 11.1 KB (added by , 14 years ago) |
---|
-
libs/libmythtv/NuppelVideoPlayer.cpp
169 169 transcoding(false), 170 170 hasFullPositionMap(false), limitKeyRepeat(false), 171 171 errorMsg(QString::null), errorType(kError_None), 172 // Chapter stuff 173 jumpchapter(0), 172 174 // Bookmark stuff 173 175 bookmarkseek(0), previewFromBookmark(false), 174 176 // Seek … … 3248 3250 } 3249 3251 3250 3252 3253 void NuppelVideoPlayer::JumpChapter(int direction) 3254 { 3255 if (jumpchapter == 0) 3256 jumpchapter = direction; 3257 } 3258 3251 3259 void NuppelVideoPlayer::SkipCommercials(int direction) 3252 3260 { 3253 3261 if (skipcommercials == 0) … … 3576 3584 } 3577 3585 3578 3586 rewindtime = fftime = 0; 3587 jumpchapter = 0; 3579 3588 skipcommercials = 0; 3580 3589 3581 3590 if (bookmarkseek > 30) … … 3782 3791 RefreshPauseFrame(); 3783 3792 need_change_dvd_track = 0; 3784 3793 } 3794 else if (jumpchapter != 0) 3795 { 3796 DoJumpChapter(jumpchapter); 3797 RefreshPauseFrame(); 3798 jumpchapter = 0; 3799 } 3785 3800 else if (player_ctx->tvchain && player_ctx->tvchain->NeedsToJump()) 3786 3801 { 3787 3802 JumpToProgram(); … … 3844 3859 need_change_dvd_track = 0; 3845 3860 } 3846 3861 3862 if (jumpchapter != 0) 3863 { 3864 QMutexLocker locker(&internalPauseLock); 3865 3866 PauseVideo(true); 3867 DoJumpChapter(jumpchapter); 3868 UnpauseVideo(true); 3869 3870 jumpchapter = 0; 3871 } 3872 3847 3873 if (skipcommercials != 0 && ffrew_skip == 1) 3848 3874 { 3849 3875 QMutexLocker locker(&internalPauseLock); … … 6660 6686 } 6661 6687 } 6662 6688 6689 int NuppelVideoPlayer::GetNumChapters() 6690 { 6691 return GetDecoder()->GetNumChapters(); 6692 } 6693 6694 bool NuppelVideoPlayer::DoJumpChapter(int direction) 6695 { 6696 int desiredFrame; 6697 6698 if (direction == -1) 6699 { 6700 desiredFrame = GetDecoder()->GetPrevChapter(framesPlayed); 6701 } 6702 else 6703 { 6704 desiredFrame = GetDecoder()->GetNextChapter(framesPlayed); 6705 } 6706 6707 if (paused && !editmode) 6708 GetDecoder()->setExactSeeks(true); 6709 if (direction == -1) 6710 GetDecoder()->DoRewind(desiredFrame); 6711 else 6712 GetDecoder()->DoFastForward(desiredFrame); 6713 GetDecoder()->setExactSeeks(exactseeks); 6714 6715 // Note: The video output will be reset by what the the decoder 6716 // does, so we only need to reset the audio, subtitles, etc. 6717 ClearAfterSeek(false); 6718 6719 lastSkipTime = time(NULL); 6720 return true; 6721 } 6722 6663 6723 bool NuppelVideoPlayer::DoSkipCommercials(int direction) 6664 6724 { 6665 6725 if (!hascommbreaktable) -
libs/libmythtv/decoderbase.h
78 78 virtual bool GetFrame(int onlyvideo) = 0; 79 79 NuppelVideoPlayer *GetNVP() { return m_parent; } 80 80 81 virtual int GetNumChapters(void) { return 0; } 82 virtual int GetNextChapter(int framesPlayed) { return framesPlayed; } 83 virtual int GetPrevChapter(int framesPlayed) { return framesPlayed; } 81 84 virtual bool DoRewind(long long desiredFrame, bool doflush = true); 82 85 virtual bool DoFastForward(long long desiredFrame, bool doflush = true); 83 86 -
libs/libmythtv/avformatdecoder.cpp
561 561 return ((lsb - base_ts)&mask); 562 562 } 563 563 564 int AvFormatDecoder::GetNumChapters() 565 { 566 return ic->nb_chapters; 567 } 568 569 int AvFormatDecoder::GetPrevChapter(int framesPlayed) 570 { 571 int framenum; 572 int prevframenum = framesPlayed; 573 int prevchapter = 0; 574 for (int i=0; i < ic->nb_chapters; i++) 575 { 576 int num = ic->chapters[i]->time_base.num; 577 int den = ic->chapters[i]->time_base.den; 578 int64_t start = ic->chapters[i]->start; 579 int64_t end = ic->chapters[i]->end; 580 double total_secs = (double)((long double)start * (long double)num / (long double)den); 581 framenum = (int)(total_secs * fps); 582 if (framenum > (framesPlayed - (int)fps)) 583 { 584 VERBOSE(VB_PLAYBACK, LOC + 585 QString("GetPrevChapter(selected chapter %1 framenum %2)") 586 .arg(prevchapter).arg(prevframenum)); 587 return prevframenum; 588 } 589 prevframenum = framenum; 590 prevchapter = i; 591 } 592 return framenum; 593 } 594 595 int AvFormatDecoder::GetNextChapter(int framesPlayed) 596 { 597 int framenum; 598 for (int i=0; i < ic->nb_chapters; i++) 599 { 600 int num = ic->chapters[i]->time_base.num; 601 int den = ic->chapters[i]->time_base.den; 602 int64_t start = ic->chapters[i]->start; 603 int64_t end = ic->chapters[i]->end; 604 double total_secs = (double)((long double)start * (long double)num / (long double)den); 605 framenum = (int)(total_secs * fps); 606 if (framenum > framesPlayed) 607 { 608 VERBOSE(VB_IMPORTANT, LOC + 609 QString("GetNextChapter(selected chapter %1 framenum %2)") 610 .arg(i).arg(framenum)); 611 return framenum; 612 } 613 } 614 return framesPlayed; 615 } 616 564 617 bool AvFormatDecoder::DoRewind(long long desiredFrame, bool discardFrames) 565 618 { 566 619 VERBOSE(VB_PLAYBACK, LOC + "DoRewind(" … … 1080 1133 QString("Successfully opened decoder for file: " 1081 1134 "\"%1\". novideo(%2)").arg(filename).arg(novideo)); 1082 1135 1136 // Print AVContext chapter information 1137 for (int i=0; i < ic->nb_chapters; i++) 1138 { 1139 int id = ic->chapters[i]->id; 1140 int num = ic->chapters[i]->time_base.num; 1141 int den = ic->chapters[i]->time_base.den; 1142 int64_t start = ic->chapters[i]->start; 1143 int64_t end = ic->chapters[i]->end; 1144 double total_secs = (double)((long double)start * (long double)num / (long double)den); 1145 int hours = (int)total_secs / 60 / 60; 1146 int minutes = ((int)total_secs / 60) - (hours * 60); 1147 double secs = total_secs - (double)((hours * 60 * 60) - (minutes * 60)); 1148 VERBOSE(VB_PLAYBACK, LOC + QString("Chapter %1 found %2:%3:%4") 1149 .arg(QString().sprintf("%02d", i)) 1150 .arg(QString().sprintf("%02d", hours)) 1151 .arg(QString().sprintf("%02d", minutes)) 1152 .arg(QString().sprintf("%02.3f", secs))); 1153 } 1154 1083 1155 // Return true if recording has position map 1084 1156 return recordingHasPositionMap; 1085 1157 } -
libs/libmythtv/tv_play.h
436 436 float StopFFRew(PlayerContext*); 437 437 void ChangeFFRew(PlayerContext*, int direction); 438 438 void SetFFRew(PlayerContext*, int index); 439 int GetNumChapters(PlayerContext*); 440 void DoJumpChapter(PlayerContext*, int direction); 439 441 void DoSkipCommercials(PlayerContext*, int direction); 440 442 void StartProgramEditMode(PlayerContext*); 441 443 -
libs/libmythtv/NuppelVideoPlayer.h
265 265 bool RebuildSeekTable(bool showPercentage = true, StatusCallback cb = NULL, 266 266 void* cbData = NULL); 267 267 268 // Chapter stuff 269 void JumpChapter(int direction); 270 268 271 // Commercial stuff 269 272 void SkipCommercials(int direction); 270 273 int FlagCommercials(bool showPercentage, bool fullSpeed, … … 409 412 void CheckTVChain(); 410 413 void FileChangedCallback(); 411 414 415 // Chapter public stuff 416 int GetNumChapters(); 417 412 418 // DVD public stuff 413 419 void ChangeDVDTrack(bool ffw); 414 420 void ActivateDVDButton(void); … … 486 492 void JumpToNetFrame(long long net) { JumpToFrame(framesPlayed + net); } 487 493 void RefreshPauseFrame(void); 488 494 495 // Private chapter stuff 496 bool DoJumpChapter(int direction); 497 489 498 // Private commercial skipping 490 499 void SkipCommercialsByBlanks(void); 491 500 bool DoSkipCommercials(int direction); … … 596 605 mutable QString errorMsg; ///< Reason why NVP exited with a error 597 606 mutable int errorType; 598 607 608 // Chapter stuff 609 int jumpchapter; 610 599 611 // Bookmark stuff 600 612 long long bookmarkseek; 601 613 bool previewFromBookmark; -
libs/libmythtv/tv_play.cpp
4222 4222 { 4223 4223 if (isDVD) 4224 4224 DVDJumpBack(ctx); 4225 else if (GetNumChapters(ctx) > 0) 4226 DoJumpChapter(ctx, -1); 4225 4227 else 4226 4228 DoSeek(ctx, -ctx->jumptime * 60, tr("Jump Back")); 4227 4229 } … … 4229 4231 { 4230 4232 if (isDVD) 4231 4233 DVDJumpForward(ctx); 4234 else if (GetNumChapters(ctx) > 0) 4235 DoJumpChapter(ctx, 1); 4232 4236 else 4233 4237 DoSeek(ctx, ctx->jumptime * 60, tr("Jump Ahead")); 4234 4238 } … … 6106 6110 ctx->UnlockPlayingInfo(__FILE__, __LINE__); 6107 6111 } 6108 6112 6113 int TV::GetNumChapters(PlayerContext *ctx) 6114 { 6115 int num_chapters; 6116 ctx->LockDeleteNVP(__FILE__, __LINE__); 6117 if (ctx->nvp) 6118 num_chapters = ctx->nvp->GetNumChapters(); 6119 ctx->UnlockDeleteNVP(__FILE__, __LINE__); 6120 6121 return num_chapters; 6122 } 6123 6124 void TV::DoJumpChapter(PlayerContext *ctx, int direction) 6125 { 6126 NormalSpeed(ctx); 6127 StopFFRew(ctx); 6128 6129 ctx->LockDeleteNVP(__FILE__, __LINE__); 6130 bool muted = MuteChannelChange(ctx); 6131 ctx->UnlockDeleteNVP(__FILE__, __LINE__); 6132 6133 struct StatusPosInfo posInfo; 6134 ctx->CalcNVPSliderPosition(posInfo); 6135 6136 bool slidertype = false; 6137 6138 OSD *osd = GetOSDLock(ctx); 6139 if (osd) 6140 { 6141 posInfo.desc = tr("Searching..."); 6142 if (direction < 0) 6143 osd->ShowStatus(posInfo, slidertype, tr("Previous Chapter"), 6); 6144 else 6145 osd->ShowStatus(posInfo, slidertype, tr("Next Chapter"), 6); 6146 SetUpdateOSDPosition(true); 6147 } 6148 ReturnOSDLock(ctx, osd); 6149 6150 ctx->LockDeleteNVP(__FILE__, __LINE__); 6151 if (ctx->nvp) 6152 ctx->nvp->JumpChapter(direction); 6153 ctx->UnlockDeleteNVP(__FILE__, __LINE__); 6154 6155 if (muted) 6156 SetMuteTimer(ctx, kMuteTimeout); 6157 } 6158 6109 6159 void TV::DoSkipCommercials(PlayerContext *ctx, int direction) 6110 6160 { 6111 6161 NormalSpeed(ctx); -
libs/libmythtv/avformatdecoder.h
131 131 132 132 int ScanStreams(bool novideo); 133 133 134 virtual int GetNumChapters(); 135 virtual int GetPrevChapter(int framesPlayed); 136 virtual int GetNextChapter(int framesPlayed); 134 137 virtual bool DoRewind(long long desiredFrame, bool doflush = true); 135 138 virtual bool DoFastForward(long long desiredFrame, bool doflush = true); 136 139