diff --git a/src/TrainSidebar.cpp b/src/TrainSidebar.cpp index 88e8d3819..8154a3502 100644 --- a/src/TrainSidebar.cpp +++ b/src/TrainSidebar.cpp @@ -1602,7 +1602,7 @@ void TrainSidebar::FFwd() context->notifySeek(load_msecs); } else displayWorkoutDistance += 1; // jump forward a kilometer in the workout - +// TODO: RLV file to be taken care } void TrainSidebar::Rewind() @@ -1617,6 +1617,7 @@ void TrainSidebar::Rewind() displayWorkoutDistance -=1; // jump back a kilometer if (displayWorkoutDistance < 0) displayWorkoutDistance = 0; } +// TODO: RLV file to be taken care } diff --git a/src/VideoSyncFile.cpp b/src/VideoSyncFile.cpp index c56aeaf70..477898005 100644 --- a/src/VideoSyncFile.cpp +++ b/src/VideoSyncFile.cpp @@ -66,7 +66,6 @@ void VideoSyncFile::parseRLV() Name = ""; Duration = -1; valid = false; // did it parse ok? - rightPoint = leftPoint = 0; format = RLV; // default to rlv until we know Points.clear(); @@ -246,9 +245,7 @@ void VideoSyncFile::parseRLV() // set RLVFile duration Duration = Points.last().secs * 1000.0; // last is the end point in msecs - leftPoint = 0; - rightPoint = 1; - + Distance = Points.last().km; } } diff --git a/src/VideoSyncFile.h b/src/VideoSyncFile.h index d2bef2ff9..bad49da0d 100644 --- a/src/VideoSyncFile.h +++ b/src/VideoSyncFile.h @@ -48,9 +48,9 @@ class VideoSyncFilePoint VideoSyncFilePoint() : km(0), secs(0) {} - double km; // x axis - distance in kilometers + double km; // x axis - distance in km double secs; // t axis - time in seconds - double kph; // speed in kilometers per hour + double kph; // speed in km per hour }; class VideoSyncCourseInfo @@ -90,9 +90,8 @@ class VideoSyncFile Source; // where did this come from long Duration; // Duration of this workout in msecs - bool valid; // did it parse ok? - - int leftPoint, rightPoint; // current points we are between + double Distance; // Distance of this workout in km + bool valid; // did it parse ok? QVector Points; // points in workout diff --git a/src/VideoWindow.cpp b/src/VideoWindow.cpp index 4d82cb55c..bc3e45615 100644 --- a/src/VideoWindow.cpp +++ b/src/VideoWindow.cpp @@ -194,6 +194,8 @@ void VideoWindow::resizeEvent(QResizeEvent * ) void VideoWindow::startPlayback() { + ManualOffset = 0.0; + #ifdef GC_VIDEO_VLC if (!m) return; // ignore if no media selected @@ -227,6 +229,8 @@ void VideoWindow::startPlayback() void VideoWindow::stopPlayback() { + ManualOffset = 0.0; + #ifdef GC_VIDEO_VLC if (!m) return; // ignore if no media selected @@ -248,7 +252,7 @@ void VideoWindow::pausePlayback() if (!m) return; // ignore if no media selected // stop playback & wipe player - libvlc_media_player_pause (mp); + libvlc_media_player_set_pause(mp, true); #endif #ifdef GC_VIDEO_QT5 @@ -265,7 +269,7 @@ void VideoWindow::resumePlayback() if(m_MediaChanged) startPlayback(); else - libvlc_media_player_pause (mp); + libvlc_media_player_set_pause(mp, false); #endif #ifdef GC_VIDEO_QT5 @@ -326,15 +330,17 @@ void VideoWindow::telemetryUpdate(RealtimeData rtd) if(curPosition > VideoSyncFiledataPoints.count()-1 || curPosition < 0) curPosition = 1; + double CurrentDistance = qBound(0.0, rtd.getDistance() + ManualOffset, context->currentVideoSyncFile()->Distance); + // make sure the current position is less than the new distance - while ((VideoSyncFiledataPoints[curPosition].km > rtd.getDistance()) && (curPosition > 1)) + while ((VideoSyncFiledataPoints[curPosition].km > CurrentDistance) && (curPosition > 1)) curPosition--; - while ((VideoSyncFiledataPoints[curPosition].km <= rtd.getDistance()) && (curPosition < VideoSyncFiledataPoints.count()-1)) + while ((VideoSyncFiledataPoints[curPosition].km <= CurrentDistance) && (curPosition < VideoSyncFiledataPoints.count()-1)) curPosition++; // update the rfp - float weighted_average = (VideoSyncFiledataPoints[curPosition].km - VideoSyncFiledataPoints[curPosition-1].km != 0.0)?(rtd.getDistance()-VideoSyncFiledataPoints[curPosition-1].km) / (VideoSyncFiledataPoints[curPosition].km - VideoSyncFiledataPoints[curPosition-1].km):0.0; - rfp.km = rtd.getDistance(); + float weighted_average = (VideoSyncFiledataPoints[curPosition].km - VideoSyncFiledataPoints[curPosition-1].km != 0.0)?(CurrentDistance-VideoSyncFiledataPoints[curPosition-1].km) / (VideoSyncFiledataPoints[curPosition].km - VideoSyncFiledataPoints[curPosition-1].km):0.0; + rfp.km = CurrentDistance; rfp.secs = VideoSyncFiledataPoints[curPosition-1].secs + weighted_average * (VideoSyncFiledataPoints[curPosition].secs - VideoSyncFiledataPoints[curPosition-1].secs); rfp.kph = VideoSyncFiledataPoints[curPosition-1].kph + weighted_average * (VideoSyncFiledataPoints[curPosition].kph - VideoSyncFiledataPoints[curPosition-1].kph); } @@ -396,7 +402,6 @@ void VideoWindow::telemetryUpdate(RealtimeData rtd) void VideoWindow::seekPlayback(long ms) { - #ifdef GC_VIDEO_NONE Q_UNUSED(ms) #endif @@ -404,8 +409,16 @@ void VideoWindow::seekPlayback(long ms) #ifdef GC_VIDEO_VLC if (!m) return; - // seek to ms position in current file - libvlc_media_player_set_time(mp, (libvlc_time_t) ms); + // when we selected a videosync file in traning mode (rlv...) + if (context->currentVideoSyncFile()) + { + ManualOffset += 25.0 * (double) ms / 3600000.0; //we consider 25km/h + } + else + { + // seek to ms position in current file + libvlc_media_player_set_time(mp, (libvlc_time_t) ms); + } #endif #ifdef GC_VIDEO_QT5 diff --git a/src/VideoWindow.h b/src/VideoWindow.h index 08e834701..5ca57808f 100644 --- a/src/VideoWindow.h +++ b/src/VideoWindow.h @@ -181,6 +181,7 @@ class VideoWindow : public GcWindow int curPosition; RideFilePoint rfp; float currentVideoRate; + float ManualOffset; // when seeking video manually // passed from Context * Context *context;