Ticket #7892: t7892_avchapter_support_v3.diff
File t7892_avchapter_support_v3.diff, 10.9 KB (added by , 16 years ago) |
---|
-
libs/libmythtv/NuppelVideoPlayer.cpp
122 122 transcoding(false), 123 123 hasFullPositionMap(false), limitKeyRepeat(false), 124 124 errorMsg(QString::null), errorType(kError_None), 125 // Chapter stuff 126 jumpchapter(0), 125 127 // Bookmark stuff 126 128 bookmarkseek(0), 127 129 // Seek … … 3125 3127 } 3126 3128 3127 3129 3130 void NuppelVideoPlayer::JumpChapter(int direction) 3131 { 3132 if (jumpchapter == 0) 3133 jumpchapter = direction; 3134 } 3135 3128 3136 void NuppelVideoPlayer::SkipCommercials(int direction) 3129 3137 { 3130 3138 if (skipcommercials == 0) … … 3454 3462 } 3455 3463 3456 3464 rewindtime = fftime = 0; 3465 jumpchapter = 0; 3457 3466 skipcommercials = 0; 3458 3467 3459 3468 if (bookmarkseek > 30) … … 3662 3671 RefreshPauseFrame(); 3663 3672 need_change_dvd_track = 0; 3664 3673 } 3674 else if (jumpchapter != 0) 3675 { 3676 DoJumpChapter(jumpchapter); 3677 RefreshPauseFrame(); 3678 jumpchapter = 0; 3679 } 3665 3680 else if (player_ctx->tvchain && player_ctx->tvchain->NeedsToJump()) 3666 3681 { 3667 3682 JumpToProgram(); … … 3724 3739 need_change_dvd_track = 0; 3725 3740 } 3726 3741 3742 if (jumpchapter != 0) 3743 { 3744 QMutexLocker locker(&internalPauseLock); 3745 3746 PauseVideo(true); 3747 DoJumpChapter(jumpchapter); 3748 UnpauseVideo(true); 3749 3750 jumpchapter = 0; 3751 } 3752 3727 3753 if (skipcommercials != 0 && ffrew_skip == 1) 3728 3754 { 3729 3755 QMutexLocker locker(&internalPauseLock); … … 6580 6606 } 6581 6607 } 6582 6608 6609 int NuppelVideoPlayer::GetNumChapters() 6610 { 6611 return GetDecoder()->GetNumChapters(); 6612 } 6613 6614 bool NuppelVideoPlayer::DoJumpChapter(int direction) 6615 { 6616 int desiredFrame = 0; 6617 6618 if (direction == -1) 6619 { 6620 desiredFrame = GetDecoder()->GetPrevChapter(framesPlayed); 6621 } 6622 else 6623 { 6624 desiredFrame = GetDecoder()->GetNextChapter(framesPlayed); 6625 } 6626 6627 if (paused && !editmode) 6628 GetDecoder()->setExactSeeks(true); 6629 if (direction == -1) 6630 GetDecoder()->DoRewind(desiredFrame); 6631 else 6632 GetDecoder()->DoFastForward(desiredFrame); 6633 GetDecoder()->setExactSeeks(exactseeks); 6634 6635 // Note: The video output will be reset by what the the decoder 6636 // does, so we only need to reset the audio, subtitles, etc. 6637 ClearAfterSeek(false); 6638 6639 lastSkipTime = time(NULL); 6640 return true; 6641 } 6642 6583 6643 bool NuppelVideoPlayer::DoSkipCommercials(int direction) 6584 6644 { 6585 6645 if (!hascommbreaktable) -
libs/libmythtv/avformatdecoder.cpp
580 580 return ((lsb - base_ts)&mask); 581 581 } 582 582 583 int AvFormatDecoder::GetNumChapters() 584 { 585 return ic->nb_chapters; 586 } 587 588 int AvFormatDecoder::GetPrevChapter(int framesPlayed) 589 { 590 int framenum = 0; 591 int prevframenum = framesPlayed; 592 int prevchapter = 0; 593 for (unsigned int i=0; i < ic->nb_chapters; i++) 594 { 595 int num = ic->chapters[i]->time_base.num; 596 int den = ic->chapters[i]->time_base.den; 597 int64_t start = ic->chapters[i]->start; 598 long double total_secs = (long double)start * (long double)num / (long double)den; 599 framenum = (int)(total_secs * fps); 600 if (framenum > (framesPlayed - (int)(3.0f * fps))) 601 { 602 VERBOSE(VB_PLAYBACK, LOC + 603 QString("GetPrevChapter(selected chapter %1 framenum %2)") 604 .arg(prevchapter).arg(prevframenum)); 605 return prevframenum; 606 } 607 prevframenum = framenum; 608 prevchapter = i; 609 } 610 return framenum; 611 } 612 613 int AvFormatDecoder::GetNextChapter(int framesPlayed) 614 { 615 int framenum = 0; 616 for (unsigned int i=0; i < ic->nb_chapters; i++) 617 { 618 int num = ic->chapters[i]->time_base.num; 619 int den = ic->chapters[i]->time_base.den; 620 int64_t start = ic->chapters[i]->start; 621 long double total_secs = (long double)start * (long double)num / (long double)den; 622 framenum = (int)(total_secs * fps); 623 if (framenum > framesPlayed) 624 { 625 VERBOSE(VB_IMPORTANT, LOC + 626 QString("GetNextChapter(selected chapter %1 framenum %2)") 627 .arg(i).arg(framenum)); 628 return framenum; 629 } 630 } 631 return framesPlayed; 632 } 633 583 634 bool AvFormatDecoder::DoRewind(long long desiredFrame, bool discardFrames) 584 635 { 585 636 VERBOSE(VB_PLAYBACK, LOC + "DoRewind(" … … 1100 1151 QString("Successfully opened decoder for file: " 1101 1152 "\"%1\". novideo(%2)").arg(filename).arg(novideo)); 1102 1153 1154 // Print AVChapter information 1155 for (unsigned int i=0; i < ic->nb_chapters; i++) 1156 { 1157 int num = ic->chapters[i]->time_base.num; 1158 int den = ic->chapters[i]->time_base.den; 1159 int64_t start = ic->chapters[i]->start; 1160 long double total_secs = (long double)start * (long double)num / (long double)den; 1161 int hours = (int)total_secs / 60 / 60; 1162 int minutes = ((int)total_secs / 60) - (hours * 60); 1163 double secs = (double)total_secs - (double)(hours * 60 * 60 + minutes * 60); 1164 VERBOSE(VB_PLAYBACK, LOC + QString("Chapter %1 found @ [%2:%3:%4]") 1165 .arg(QString().sprintf("%02d", i)) 1166 .arg(QString().sprintf("%02d", hours)) 1167 .arg(QString().sprintf("%02d", minutes)) 1168 .arg(QString().sprintf("%06.3f", secs))); 1169 } 1170 1103 1171 // Return true if recording has position map 1104 1172 return recordingHasPositionMap; 1105 1173 } -
libs/libmythtv/decoderbase.h
105 105 virtual bool GetFrame(DecodeType) = 0; 106 106 NuppelVideoPlayer *GetNVP() { return m_parent; } 107 107 108 virtual int GetNumChapters(void) { return 0; } 109 virtual int GetNextChapter(int framesPlayed) { return framesPlayed; } 110 virtual int GetPrevChapter(int framesPlayed) { return framesPlayed; } 108 111 virtual bool DoRewind(long long desiredFrame, bool doflush = true); 109 112 virtual bool DoFastForward(long long desiredFrame, bool doflush = true); 110 113 -
libs/libmythtv/tv_play.h
442 442 float StopFFRew(PlayerContext*); 443 443 void ChangeFFRew(PlayerContext*, int direction); 444 444 void SetFFRew(PlayerContext*, int index); 445 int GetNumChapters(PlayerContext*); 446 void DoJumpChapter(PlayerContext*, int direction); 445 447 void DoSkipCommercials(PlayerContext*, int direction); 446 448 void StartProgramEditMode(PlayerContext*); 447 449 -
libs/libmythtv/NuppelVideoPlayer.h
250 250 bool RebuildSeekTable(bool showPercentage = true, StatusCallback cb = NULL, 251 251 void* cbData = NULL); 252 252 253 // Chapter stuff 254 void JumpChapter(int direction); 255 253 256 // Commercial stuff 254 257 void SkipCommercials(int direction); 255 258 int FlagCommercials(bool showPercentage, bool fullSpeed, … … 394 397 void CheckTVChain(); 395 398 void FileChangedCallback(); 396 399 400 // Chapter public stuff 401 int GetNumChapters(); 402 397 403 // DVD public stuff 398 404 void ChangeDVDTrack(bool ffw); 399 405 void ActivateDVDButton(void); … … 470 476 void JumpToNetFrame(long long net) { JumpToFrame(framesPlayed + net); } 471 477 void RefreshPauseFrame(void); 472 478 479 // Private chapter stuff 480 bool DoJumpChapter(int direction); 481 473 482 // Private commercial skipping 474 483 void SkipCommercialsByBlanks(void); 475 484 bool DoSkipCommercials(int direction); … … 580 589 mutable QString errorMsg; ///< Reason why NVP exited with a error 581 590 mutable int errorType; 582 591 592 // Chapter stuff 593 int jumpchapter; 594 583 595 // Bookmark stuff 584 596 long long bookmarkseek; 585 597 -
libs/libmythtv/tv_play.cpp
4302 4302 { 4303 4303 if (isDVD) 4304 4304 DVDJumpBack(ctx); 4305 else if (GetNumChapters(ctx) > 0) 4306 DoJumpChapter(ctx, -1); 4305 4307 else 4306 4308 DoSeek(ctx, -ctx->jumptime * 60, tr("Jump Back")); 4307 4309 } … … 4309 4311 { 4310 4312 if (isDVD) 4311 4313 DVDJumpForward(ctx); 4314 else if (GetNumChapters(ctx) > 0) 4315 DoJumpChapter(ctx, 1); 4312 4316 else 4313 4317 DoSeek(ctx, ctx->jumptime * 60, tr("Jump Ahead")); 4314 4318 } … … 6192 6196 ctx->UnlockPlayingInfo(__FILE__, __LINE__); 6193 6197 } 6194 6198 6199 int TV::GetNumChapters(PlayerContext *ctx) 6200 { 6201 int num_chapters; 6202 ctx->LockDeleteNVP(__FILE__, __LINE__); 6203 if (ctx->nvp) 6204 num_chapters = ctx->nvp->GetNumChapters(); 6205 ctx->UnlockDeleteNVP(__FILE__, __LINE__); 6206 6207 return num_chapters; 6208 } 6209 6210 void TV::DoJumpChapter(PlayerContext *ctx, int direction) 6211 { 6212 NormalSpeed(ctx); 6213 StopFFRew(ctx); 6214 6215 ctx->LockDeleteNVP(__FILE__, __LINE__); 6216 bool muted = MuteChannelChange(ctx); 6217 ctx->UnlockDeleteNVP(__FILE__, __LINE__); 6218 6219 struct StatusPosInfo posInfo; 6220 ctx->CalcNVPSliderPosition(posInfo); 6221 6222 bool slidertype = false; 6223 6224 OSD *osd = GetOSDLock(ctx); 6225 if (osd) 6226 { 6227 posInfo.desc = tr("Searching..."); 6228 if (direction < 0) 6229 osd->ShowStatus(posInfo, slidertype, tr("Previous Chapter"), 3); 6230 else 6231 osd->ShowStatus(posInfo, slidertype, tr("Next Chapter"), 3); 6232 SetUpdateOSDPosition(true); 6233 } 6234 ReturnOSDLock(ctx, osd); 6235 6236 ctx->LockDeleteNVP(__FILE__, __LINE__); 6237 if (ctx->nvp) 6238 ctx->nvp->JumpChapter(direction); 6239 ctx->UnlockDeleteNVP(__FILE__, __LINE__); 6240 6241 if (muted) 6242 SetMuteTimer(ctx, kMuteTimeout); 6243 } 6244 6195 6245 void TV::DoSkipCommercials(PlayerContext *ctx, int direction) 6196 6246 { 6197 6247 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