Ticket #7892: t7892_avchapter_support_v2.diff
File t7892_avchapter_support_v2.diff, 10.9 KB (added by , 14 years ago) |
---|
-
libs/libmythtv/NuppelVideoPlayer.cpp
163 163 transcoding(false), 164 164 hasFullPositionMap(false), limitKeyRepeat(false), 165 165 errorMsg(QString::null), errorType(kError_None), 166 // Chapter stuff 167 jumpchapter(0), 166 168 // Bookmark stuff 167 169 bookmarkseek(0), 168 170 // Seek … … 3163 3165 } 3164 3166 3165 3167 3168 void NuppelVideoPlayer::JumpChapter(int direction) 3169 { 3170 if (jumpchapter == 0) 3171 jumpchapter = direction; 3172 } 3173 3166 3174 void NuppelVideoPlayer::SkipCommercials(int direction) 3167 3175 { 3168 3176 if (skipcommercials == 0) … … 3491 3499 } 3492 3500 3493 3501 rewindtime = fftime = 0; 3502 jumpchapter = 0; 3494 3503 skipcommercials = 0; 3495 3504 3496 3505 if (bookmarkseek > 30) … … 3697 3706 RefreshPauseFrame(); 3698 3707 need_change_dvd_track = 0; 3699 3708 } 3709 else if (jumpchapter != 0) 3710 { 3711 DoJumpChapter(jumpchapter); 3712 RefreshPauseFrame(); 3713 jumpchapter = 0; 3714 } 3700 3715 else if (player_ctx->tvchain && player_ctx->tvchain->NeedsToJump()) 3701 3716 { 3702 3717 JumpToProgram(); … … 3759 3774 need_change_dvd_track = 0; 3760 3775 } 3761 3776 3777 if (jumpchapter != 0) 3778 { 3779 QMutexLocker locker(&internalPauseLock); 3780 3781 PauseVideo(true); 3782 DoJumpChapter(jumpchapter); 3783 UnpauseVideo(true); 3784 3785 jumpchapter = 0; 3786 } 3787 3762 3788 if (skipcommercials != 0 && ffrew_skip == 1) 3763 3789 { 3764 3790 QMutexLocker locker(&internalPauseLock); … … 6539 6565 } 6540 6566 } 6541 6567 6568 int NuppelVideoPlayer::GetNumChapters() 6569 { 6570 return GetDecoder()->GetNumChapters(); 6571 } 6572 6573 bool NuppelVideoPlayer::DoJumpChapter(int direction) 6574 { 6575 int desiredFrame = 0; 6576 6577 if (direction == -1) 6578 { 6579 desiredFrame = GetDecoder()->GetPrevChapter(framesPlayed); 6580 } 6581 else 6582 { 6583 desiredFrame = GetDecoder()->GetNextChapter(framesPlayed); 6584 } 6585 6586 if (paused && !editmode) 6587 GetDecoder()->setExactSeeks(true); 6588 if (direction == -1) 6589 GetDecoder()->DoRewind(desiredFrame); 6590 else 6591 GetDecoder()->DoFastForward(desiredFrame); 6592 GetDecoder()->setExactSeeks(exactseeks); 6593 6594 // Note: The video output will be reset by what the the decoder 6595 // does, so we only need to reset the audio, subtitles, etc. 6596 ClearAfterSeek(false); 6597 6598 lastSkipTime = time(NULL); 6599 return true; 6600 } 6601 6542 6602 bool NuppelVideoPlayer::DoSkipCommercials(int direction) 6543 6603 { 6544 6604 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
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 double total_secs = (double)((long double)start * (long double)num / (long double)den); 599 framenum = (int)(total_secs * fps); 600 if (framenum > (framesPlayed - (int)(2.0 * 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 double total_secs = (double)((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 double total_secs = (double)((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 = 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/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
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); … … 485 491 void JumpToNetFrame(long long net) { JumpToFrame(framesPlayed + net); } 486 492 void RefreshPauseFrame(void); 487 493 494 // Private chapter stuff 495 bool DoJumpChapter(int direction); 496 488 497 // Private commercial skipping 489 498 void SkipCommercialsByBlanks(void); 490 499 bool DoSkipCommercials(int direction); … … 595 604 mutable QString errorMsg; ///< Reason why NVP exited with a error 596 605 mutable int errorType; 597 606 607 // Chapter stuff 608 int jumpchapter; 609 598 610 // Bookmark stuff 599 611 long long bookmarkseek; 600 612 -
libs/libmythtv/tv_play.cpp
4308 4308 { 4309 4309 if (isDVD) 4310 4310 DVDJumpBack(ctx); 4311 else if (GetNumChapters(ctx) > 0) 4312 DoJumpChapter(ctx, -1); 4311 4313 else 4312 4314 DoSeek(ctx, -ctx->jumptime * 60, tr("Jump Back")); 4313 4315 } … … 4315 4317 { 4316 4318 if (isDVD) 4317 4319 DVDJumpForward(ctx); 4320 else if (GetNumChapters(ctx) > 0) 4321 DoJumpChapter(ctx, 1); 4318 4322 else 4319 4323 DoSeek(ctx, ctx->jumptime * 60, tr("Jump Ahead")); 4320 4324 } … … 6198 6202 ctx->UnlockPlayingInfo(__FILE__, __LINE__); 6199 6203 } 6200 6204 6205 int TV::GetNumChapters(PlayerContext *ctx) 6206 { 6207 int num_chapters; 6208 ctx->LockDeleteNVP(__FILE__, __LINE__); 6209 if (ctx->nvp) 6210 num_chapters = ctx->nvp->GetNumChapters(); 6211 ctx->UnlockDeleteNVP(__FILE__, __LINE__); 6212 6213 return num_chapters; 6214 } 6215 6216 void TV::DoJumpChapter(PlayerContext *ctx, int direction) 6217 { 6218 NormalSpeed(ctx); 6219 StopFFRew(ctx); 6220 6221 ctx->LockDeleteNVP(__FILE__, __LINE__); 6222 bool muted = MuteChannelChange(ctx); 6223 ctx->UnlockDeleteNVP(__FILE__, __LINE__); 6224 6225 struct StatusPosInfo posInfo; 6226 ctx->CalcNVPSliderPosition(posInfo); 6227 6228 bool slidertype = false; 6229 6230 OSD *osd = GetOSDLock(ctx); 6231 if (osd) 6232 { 6233 posInfo.desc = tr("Searching..."); 6234 if (direction < 0) 6235 osd->ShowStatus(posInfo, slidertype, tr("Previous Chapter"), 6); 6236 else 6237 osd->ShowStatus(posInfo, slidertype, tr("Next Chapter"), 6); 6238 SetUpdateOSDPosition(true); 6239 } 6240 ReturnOSDLock(ctx, osd); 6241 6242 ctx->LockDeleteNVP(__FILE__, __LINE__); 6243 if (ctx->nvp) 6244 ctx->nvp->JumpChapter(direction); 6245 ctx->UnlockDeleteNVP(__FILE__, __LINE__); 6246 6247 if (muted) 6248 SetMuteTimer(ctx, kMuteTimeout); 6249 } 6250 6201 6251 void TV::DoSkipCommercials(PlayerContext *ctx, int direction) 6202 6252 { 6203 6253 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