[vlc-commits] [Git][videolan/vlc][master] Qt: fix mixed usage of Time/Duration
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Wed May 21 10:51:18 UTC 2025
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
56195130 by François Cartegnie at 2025-05-21T10:16:18+00:00
Qt: fix mixed usage of Time/Duration
- - - - -
24 changed files:
- modules/gui/qt/dialogs/extended/extended_panels.cpp
- modules/gui/qt/dialogs/gototime/gototime.cpp
- modules/gui/qt/medialibrary/mlalbum.cpp
- modules/gui/qt/medialibrary/mlalbum.hpp
- modules/gui/qt/medialibrary/mlbookmarkmodel.cpp
- modules/gui/qt/medialibrary/mlfolder.cpp
- modules/gui/qt/medialibrary/mlfolder.hpp
- modules/gui/qt/medialibrary/mlgroup.cpp
- modules/gui/qt/medialibrary/mlgroup.hpp
- modules/gui/qt/medialibrary/mlmedia.hpp
- modules/gui/qt/medialibrary/mlplaylist.cpp
- modules/gui/qt/medialibrary/mlplaylist.hpp
- modules/gui/qt/medialibrary/mlvideo.hpp
- modules/gui/qt/network/networkmediamodel.cpp
- modules/gui/qt/player/delay_estimator.cpp
- modules/gui/qt/player/delay_estimator.hpp
- modules/gui/qt/player/player_controller.cpp
- modules/gui/qt/player/player_controller.hpp
- modules/gui/qt/player/player_controller_p.hpp
- modules/gui/qt/playlist/playlist_model.cpp
- modules/gui/qt/playlist/playlist_model.hpp
- modules/gui/qt/qt.cpp
- modules/gui/qt/util/vlctick.cpp
- modules/gui/qt/util/vlctick.hpp
Changes:
=====================================
modules/gui/qt/dialogs/extended/extended_panels.cpp
=====================================
@@ -1449,19 +1449,19 @@ SyncControls::SyncControls( qt_intf_t *_p_intf, QWidget *_parent )
connect( subSpeedSpin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &SyncControls::adjustSubsSpeed);
connect( subDurationSpin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &SyncControls::adjustSubsDuration);
- connect( THEMIM, &PlayerController::subtitleDelayChanged, [this](vlc_tick_t value) {
+ connect( THEMIM, &PlayerController::subtitleDelayChanged, [this](VLCDuration value) {
b_userAction = false;
- subsSpin->setValue(secf_from_vlc_tick(value));
+ subsSpin->setValue(value.toSecf());
b_userAction = true;
});
- connect( THEMIM, &PlayerController::secondarySubtitleDelayChanged, [this](vlc_tick_t value) {
+ connect( THEMIM, &PlayerController::secondarySubtitleDelayChanged, [this](VLCDuration value) {
b_userAction = false;
- secondarySubsSpin->setValue(secf_from_vlc_tick(value));
+ secondarySubsSpin->setValue(value.toSecf());
b_userAction = true;
});
- connect( THEMIM, &PlayerController::audioDelayChanged, [this](vlc_tick_t value) {
+ connect( THEMIM, &PlayerController::audioDelayChanged, [this](VLCDuration value) {
b_userAction = false;
- AVSpin->setValue(secf_from_vlc_tick(value));
+ AVSpin->setValue(value.toSecf());
b_userAction = true;
});
connect( THEMIM, &PlayerController::subtitleFPSChanged, subSpeedSpin, &QDoubleSpinBox::setValue );
@@ -1494,9 +1494,9 @@ void SyncControls::update()
b_userAction = false;
if( THEMIM->getInput() )
{
- subsSpin->setValue(secf_from_vlc_tick(THEMIM->getSubtitleDelay()));
- secondarySubsSpin->setValue(secf_from_vlc_tick(THEMIM->getSecondarySubtitleDelay()));
- AVSpin->setValue(secf_from_vlc_tick(THEMIM->getAudioDelay()));
+ subsSpin->setValue(THEMIM->getSubtitleDelay().toSecf());
+ secondarySubsSpin->setValue(THEMIM->getSecondarySubtitleDelay().toSecf());
+ AVSpin->setValue(THEMIM->getAudioDelay().toSecf());
subSpeedSpin->setValue(THEMIM->getSubtitleFPS());
subDurationSpin->setValue(m_SubsDelayCfgFactor.getValue());
}
=====================================
modules/gui/qt/dialogs/gototime/gototime.cpp
=====================================
@@ -88,8 +88,8 @@ void GotoTimeDialog::toggleVisible()
reset();
if ( !isVisible() && THEMIM->hasInput() )
{
- vlc_tick_t i_time = THEMIM->getTime();
- timeEdit->setTime( timeEdit->time().addSecs( SEC_FROM_VLC_TICK(i_time) ) );
+ VLCTime time = THEMIM->getTime();
+ timeEdit->setTime( timeEdit->time().addSecs( time.toSeconds() ) );
}
QVLCDialog::toggleVisible();
if(isVisible())
=====================================
modules/gui/qt/medialibrary/mlalbum.cpp
=====================================
@@ -64,7 +64,7 @@ unsigned int MLAlbum::getNbTracks() const
return m_nbTracks;
}
-VLCTick MLAlbum::getDuration() const
+VLCDuration MLAlbum::getDuration() const
{
- return VLCTick::fromMS(m_duration);
+ return VLCDuration::fromMS(m_duration);
}
=====================================
modules/gui/qt/medialibrary/mlalbum.hpp
=====================================
@@ -24,7 +24,7 @@
#include "mlhelper.hpp"
#include "mlqmltypes.hpp"
-class VLCTick;
+class VLCDuration;
class MLAlbum : public MLItem
{
@@ -37,7 +37,7 @@ public:
QString getCover() const;
QString getArtist() const;
unsigned int getNbTracks() const;
- VLCTick getDuration() const;
+ VLCDuration getDuration() const;
private:
QString m_title;
=====================================
modules/gui/qt/medialibrary/mlbookmarkmodel.cpp
=====================================
@@ -66,7 +66,7 @@ QVariant MLBookmarkModel::data( const QModelIndex &index, int role ) const
case BookmarkRoles::NameRole:
return QVariant::fromValue( qfu( bookmark.psz_name ) );
case BookmarkRoles::TimeRole:
- return QVariant::fromValue( VLCTick::fromMS( bookmark.i_time ).formatHMS() );
+ return QVariant::fromValue( VLCDuration::fromMS( bookmark.i_time ).formatHMS() );
case BookmarkRoles::PositionRole:
{
vlc_player_locker lock{ m_player };
@@ -263,7 +263,7 @@ void MLBookmarkModel::add()
if (media)
{
- QString name = qtr("Bookmark at %1").arg(VLCTick::fromMS( time ).formatHMS());
+ QString name = qtr("Bookmark at %1").arg(VLCDuration::fromMS( time ).formatHMS());
vlc_ml_media_update_bookmark(ml, mediaId, time, qtu(name), nullptr);
}
=====================================
modules/gui/qt/medialibrary/mlfolder.cpp
=====================================
@@ -58,9 +58,9 @@ QString MLFolder::getMRL() const
return m_mrl;
}
-VLCTick MLFolder::getDuration() const
+VLCDuration MLFolder::getDuration() const
{
- return VLCTick::fromMS(m_duration);
+ return VLCDuration::fromMS(m_duration);
}
unsigned int MLFolder::getCount() const
=====================================
modules/gui/qt/medialibrary/mlfolder.hpp
=====================================
@@ -24,7 +24,7 @@
// MediaLibrary includes
#include "mlqmltypes.hpp"
-class VLCTick;
+class VLCDuration;
class MLFolder : public MLItem
{
@@ -39,7 +39,7 @@ public: // Interface
QString getMRL() const;
- VLCTick getDuration() const;
+ VLCDuration getDuration() const;
unsigned int getCount() const;
=====================================
modules/gui/qt/medialibrary/mlgroup.cpp
=====================================
@@ -50,9 +50,9 @@ QString MLGroup::getTitle() const
//-------------------------------------------------------------------------------------------------
-VLCTick MLGroup::getDuration() const
+VLCDuration MLGroup::getDuration() const
{
- return VLCTick::fromMS(m_duration);
+ return VLCDuration::fromMS(m_duration);
}
unsigned int MLGroup::getDate() const
=====================================
modules/gui/qt/medialibrary/mlgroup.hpp
=====================================
@@ -28,7 +28,7 @@
// MediaLibrary includes
#include "mlqmltypes.hpp"
-class VLCTick;
+class VLCDuration;
class MLGroup : public MLItem
{
@@ -38,7 +38,7 @@ public:
public: // Interface
QString getTitle() const;
- VLCTick getDuration() const;
+ VLCDuration getDuration() const;
unsigned int getDate() const;
=====================================
modules/gui/qt/medialibrary/mlmedia.hpp
=====================================
@@ -62,7 +62,7 @@ public:
m_fileName = qfu(media->psz_filename);
m_smallThumbnail = getThumbnail(media->thumbnails[VLC_ML_THUMBNAIL_SMALL]);
m_bannerThumbnail = getThumbnail(media->thumbnails[VLC_ML_THUMBNAIL_BANNER]);
- m_duration = VLCTick::fromMS(media->i_duration);
+ m_duration = VLCDuration::fromMS(media->i_duration);
m_progress = media->f_progress;
m_playCount = media->i_playcount;
m_mrl = getMRL();
@@ -73,7 +73,7 @@ public:
QString title() const { return m_title; }
QString fileName() const { return m_fileName; }
- VLCTick duration() const { return m_duration; }
+ VLCDuration duration() const { return m_duration; }
qreal progress() const { return m_progress; }
int playCount() const { return m_playCount; }
QString mrl() const { return m_mrl.toEncoded(); }
@@ -94,7 +94,7 @@ public:
return m_bannerThumbnail.mrl;
}
- VLCTick progressTime() const { return VLCTick::fromMS(m_duration * m_progress); }
+ VLCTime progressTime() const { return m_duration * m_progress; }
Q_INVOKABLE bool valid() const { return getId().id != INVALID_MLITEMID_ID; }
@@ -109,7 +109,7 @@ protected:
QString m_fileName;
MLThumbnail m_smallThumbnail;
MLThumbnail m_bannerThumbnail;
- VLCTick m_duration;
+ VLCDuration m_duration;
qreal m_progress;
int m_playCount;
QUrl m_mrl;
=====================================
modules/gui/qt/medialibrary/mlplaylist.cpp
=====================================
@@ -51,9 +51,9 @@ void MLPlaylist::setName(const QString & name)
//-------------------------------------------------------------------------------------------------
-VLCTick MLPlaylist::getDuration() const
+VLCDuration MLPlaylist::getDuration() const
{
- return VLCTick::fromMS(m_duration);
+ return VLCDuration::fromMS(m_duration);
}
unsigned int MLPlaylist::getCount() const
=====================================
modules/gui/qt/medialibrary/mlplaylist.hpp
=====================================
@@ -26,7 +26,7 @@
// MediaLibrary includes
#include "mlqmltypes.hpp"
-class VLCTick;
+class VLCDuration;
class MLPlaylist : public MLItem
{
@@ -37,7 +37,7 @@ public: // Interface
QString getName() const;
void setName(const QString & name);
- VLCTick getDuration() const;
+ VLCDuration getDuration() const;
unsigned int getCount() const;
=====================================
modules/gui/qt/medialibrary/mlvideo.hpp
=====================================
@@ -33,8 +33,6 @@
#include <functional>
-class VLCTick;
-
class VideoDescription
{
Q_GADGET
=====================================
modules/gui/qt/network/networkmediamodel.cpp
=====================================
@@ -575,8 +575,8 @@ QVariant NetworkMediaModel::data( const QModelIndex& index, int role ) const
{
if (item->media.valid())
{
- const VLCTick duration = item->media.duration();
- return duration <= 0 ? QVariant {} : QVariant::fromValue(duration);
+ const VLCDuration duration = item->media.duration();
+ return !duration.valid() ? QVariant {} : QVariant::fromValue(duration);
}
return {};
=====================================
modules/gui/qt/player/delay_estimator.cpp
=====================================
@@ -29,14 +29,14 @@ DelayEstimator::~DelayEstimator()
}
bool DelayEstimator::isHeardTimeMarked() {
- return (m_heardTime != VLC_TICK_INVALID);
+ return m_heardTime.valid();
}
bool DelayEstimator::isSpottedTimeMarked() {
- return (m_spottedTime != VLC_TICK_INVALID);
+ return m_spottedTime.valid();
}
-/*Q_INVOKABLE*/ VLCTick DelayEstimator::getDelay()
+/*Q_INVOKABLE*/ VLCDuration DelayEstimator::getDelay()
{
return m_delay;
}
@@ -44,7 +44,7 @@ bool DelayEstimator::isSpottedTimeMarked() {
/*Q_INVOKABLE*/ void DelayEstimator::markHeardTime()
{
if (isHeardTimeMarked())
- m_heardTime = VLC_TICK_INVALID;
+ m_heardTime = VLCTime();
else
m_heardTime = vlc_tick_now();
@@ -57,7 +57,7 @@ bool DelayEstimator::isSpottedTimeMarked() {
/*Q_INVOKABLE*/ void DelayEstimator::markSpottedTime()
{
if (isSpottedTimeMarked())
- m_spottedTime = VLC_TICK_INVALID;
+ m_spottedTime = VLCTime();
else
m_spottedTime = vlc_tick_now();
@@ -69,13 +69,13 @@ bool DelayEstimator::isSpottedTimeMarked() {
void DelayEstimator::calculateDelay()
{
- if (m_heardTime != VLC_TICK_INVALID &&
- m_spottedTime != VLC_TICK_INVALID)
+ if (m_heardTime.valid() &&
+ m_spottedTime.valid())
{
m_delay = m_heardTime - m_spottedTime;
emit delayChanged();
- m_heardTime = VLC_TICK_INVALID;
- m_spottedTime = VLC_TICK_INVALID;
+ m_heardTime = VLCTime();
+ m_spottedTime = VLCTime();
emit spottedTimeChanged();
emit heardTimeChanged();
}
@@ -83,9 +83,9 @@ void DelayEstimator::calculateDelay()
/*Q_INVOKABLE*/ void DelayEstimator::reset()
{
- m_heardTime = VLC_TICK_INVALID;
- m_spottedTime = VLC_TICK_INVALID;
- m_delay = VLC_TICK_INVALID;
+ m_heardTime = VLCTime();
+ m_spottedTime = VLCTime();
+ m_delay = VLCDuration();
emit delayChanged();
emit spottedTimeChanged();
emit heardTimeChanged();
=====================================
modules/gui/qt/player/delay_estimator.hpp
=====================================
@@ -25,14 +25,14 @@
#include "qt.hpp"
#include "util/vlctick.hpp"
-class VLCTick;
+class VLCDuration;
class DelayEstimator : public QObject
{
Q_OBJECT
Q_PROPERTY(bool isHeardTimeMarked READ isHeardTimeMarked NOTIFY heardTimeChanged FINAL)
Q_PROPERTY(bool isSpottedTimeMarked READ isSpottedTimeMarked NOTIFY spottedTimeChanged FINAL)
- Q_PROPERTY(VLCTick delay READ getDelay NOTIFY delayChanged FINAL)
+ Q_PROPERTY(VLCDuration delay READ getDelay NOTIFY delayChanged FINAL)
public:
explicit DelayEstimator(QObject* parent = nullptr);
@@ -41,7 +41,7 @@ public:
bool isHeardTimeMarked();
bool isSpottedTimeMarked();
void calculateDelay();
- VLCTick getDelay();
+ VLCDuration getDelay();
Q_INVOKABLE void markHeardTime();
Q_INVOKABLE void markSpottedTime();
@@ -53,9 +53,9 @@ signals:
void delayChanged();
private:
- VLCTick m_heardTime = VLC_TICK_INVALID;
- VLCTick m_spottedTime = VLC_TICK_INVALID;
- VLCTick m_delay = VLC_TICK_INVALID;
+ VLCTime m_heardTime;
+ VLCTime m_spottedTime;
+ VLCDuration m_delay;
};
#endif
=====================================
modules/gui/qt/player/player_controller.cpp
=====================================
@@ -249,11 +249,11 @@ void PlayerControllerPrivate::UpdateSpuOrder(vlc_es_id_t *es_id, enum vlc_vout_o
break;
case VLC_VOUT_ORDER_SECONDARY:
m_secondarySpuEsId.reset(es_id, true);
- if (m_secondarySubtitleDelay != 0)
+ if (m_secondarySubtitleDelay.valid())
{
vlc_player_locker lock{ m_player };
vlc_player_SetEsIdDelay(m_player, es_id,
- m_secondarySubtitleDelay,
+ m_secondarySubtitleDelay.toVLCTick(),
VLC_PLAYER_WHENCE_ABSOLUTE);
}
break;
@@ -268,7 +268,7 @@ int PlayerControllerPrivate::interpolateTime(vlc_tick_t system_now)
if (vlc_player_timer_point_Interpolate(&m_player_time, system_now,
&new_time, &m_position) == VLC_SUCCESS)
{
- m_time = new_time != VLC_TICK_INVALID ? new_time - VLC_TICK_0 : 0;
+ m_time = new_time;
return VLC_SUCCESS;
}
return VLC_EGENERIC;
@@ -354,7 +354,7 @@ static void on_player_state_changed(vlc_player_t *, enum vlc_player_state state,
that->m_position = 0;
that->m_time = 0;
that->m_length = 0;
- emit q->positionUpdated( -1.0, 0 ,0 );
+ emit q->positionUpdated( -1.0, VLCTime() , VLCDuration() );
that->m_rate = 1.0f;
emit q->rateChanged( 1.0f );
that->m_name = "";
@@ -375,11 +375,11 @@ static void on_player_state_changed(vlc_player_t *, enum vlc_player_state state,
that->m_teletextAvailable = false;
emit q->teletextAvailableChanged( false );
that->m_ABLoopState = PlayerController::ABLOOP_STATE_NONE;
- that->m_ABLoopA = VLC_TICK_INVALID;
- that->m_ABLoopB = VLC_TICK_INVALID;
+ that->m_ABLoopA = VLCTime();
+ that->m_ABLoopB = VLCTime();
emit q->ABLoopStateChanged(PlayerController::ABLOOP_STATE_NONE);
- emit q->ABLoopAChanged(VLC_TICK_INVALID);
- emit q->ABLoopBChanged(VLC_TICK_INVALID);
+ emit q->ABLoopAChanged(that->m_ABLoopA);
+ emit q->ABLoopBChanged(that->m_ABLoopB);
that->m_hasVideo = false;
emit q->hasVideoOutputChanged( false );
@@ -742,8 +742,8 @@ static void on_player_atobloop_changed(vlc_player_t *, enum vlc_player_abloop st
PlayerController* q = that->q_func();
switch (state) {
case VLC_PLAYER_ABLOOP_NONE:
- that->m_ABLoopA = VLC_TICK_INVALID;
- that->m_ABLoopB = VLC_TICK_INVALID;
+ that->m_ABLoopA = VLCTime();
+ that->m_ABLoopB = VLCTime();
emit q->ABLoopAChanged(that->m_ABLoopA);
emit q->ABLoopBChanged(that->m_ABLoopB);
break;
@@ -919,9 +919,9 @@ static void on_player_timer_update(const struct vlc_player_timer_point *point,
that->m_player_time = point_copy;
bool lengthOrRateChanged = false;
- if (that->m_length != that->m_player_time.length)
+ if (that->m_length.toVLCTick() != that->m_player_time.length)
{
- that->m_length = that->m_player_time.length;
+ that->m_length = that->m_player_time.length > 0 ? VLCDuration(that->m_player_time.length) : VLCDuration();
emit q->lengthChanged(that->m_length);
lengthOrRateChanged = true;
@@ -949,7 +949,7 @@ static void on_player_timer_update(const struct vlc_player_timer_point *point,
// size.
vlc_tick_t interval =
- that->m_length / that->m_player_time.rate / VLC_TICK_FROM_MS(1);
+ that->m_length.toVLCTick() / that->m_player_time.rate / VLC_TICK_FROM_MS(1);
if (interval < POSITION_MIN_UPDATE_INTERVAL)
interval = POSITION_MIN_UPDATE_INTERVAL;
@@ -1281,13 +1281,13 @@ void PlayerController::normalRate()
}
-void PlayerController::setTime(VLCTick new_time)
+void PlayerController::setTime(VLCTime new_time)
{
Q_D(PlayerController);
vlc_player_locker lock{ d->m_player };
if( !d->isCurrentItemSynced() )
return;
- vlc_player_SetTime( d->m_player, new_time );
+ vlc_player_SetTime( d->m_player, new_time.toVLCTick() );
}
void PlayerController::setPosition(double position)
@@ -1324,14 +1324,14 @@ void PlayerController::jumpBwd()
vlc_player_JumpTime( d->m_player, vlc_tick_from_sec( -i_interval ) );
}
-void PlayerController::jumpToTime(VLCTick i_time)
+void PlayerController::jumpToTime(VLCTime i_time)
{
Q_D(PlayerController);
msg_Dbg( d->p_intf, "jumpToTime");
vlc_player_locker lock{ d->m_player };
if( !d->isCurrentItemSynced() )
return;
- vlc_player_JumpTime( d->m_player, i_time );
+ vlc_player_JumpTime( d->m_player, i_time.toVLCTick() );
}
void PlayerController::jumpToPos( double new_pos )
@@ -1358,41 +1358,41 @@ void PlayerController::frameNext()
//TRACKS
-void PlayerController::setAudioDelay(VLCTick delay)
+void PlayerController::setAudioDelay(VLCDuration delay)
{
Q_D(PlayerController);
vlc_player_locker lock{ d->m_player };
if( !d->isCurrentItemSynced() )
return;
- vlc_player_SetAudioDelay( d->m_player, delay, VLC_PLAYER_WHENCE_ABSOLUTE );
+ vlc_player_SetAudioDelay( d->m_player, delay.toVLCTick(), VLC_PLAYER_WHENCE_ABSOLUTE );
}
-/*Q_INVOKABLE*/void PlayerController::addAudioDelay(VLCTick delay)
+/*Q_INVOKABLE*/void PlayerController::addAudioDelay(VLCDuration delay)
{
Q_D(PlayerController);
vlc_player_locker lock{ d->m_player };
- vlc_player_SetAudioDelay( d->m_player, delay, VLC_PLAYER_WHENCE_RELATIVE );
+ vlc_player_SetAudioDelay( d->m_player, delay.toVLCTick(), VLC_PLAYER_WHENCE_RELATIVE );
emit audioDelayChanged(delay);
}
-void PlayerController::setSubtitleDelay(VLCTick delay)
+void PlayerController::setSubtitleDelay(VLCDuration delay)
{
Q_D(PlayerController);
vlc_player_locker lock{ d->m_player };
if(!d->isCurrentItemSynced() )
return;
- vlc_player_SetSubtitleDelay( d->m_player, delay, VLC_PLAYER_WHENCE_ABSOLUTE );
+ vlc_player_SetSubtitleDelay( d->m_player, delay.toVLCTick(), VLC_PLAYER_WHENCE_ABSOLUTE );
}
-/*Q_INVOKABLE*/void PlayerController::addSubtitleDelay(VLCTick delay)
+/*Q_INVOKABLE*/void PlayerController::addSubtitleDelay(VLCDuration delay)
{
Q_D(PlayerController);
vlc_player_locker lock{ d->m_player };
- vlc_player_SetSubtitleDelay( d->m_player, delay, VLC_PLAYER_WHENCE_RELATIVE);
+ vlc_player_SetSubtitleDelay( d->m_player, delay.toVLCTick(), VLC_PLAYER_WHENCE_RELATIVE);
emit subtitleDelayChanged(delay);
}
-void PlayerController::setSecondarySubtitleDelay(VLCTick delay)
+void PlayerController::setSecondarySubtitleDelay(VLCDuration delay)
{
Q_D(PlayerController);
vlc_player_locker lock{ d->m_player };
@@ -1400,48 +1400,48 @@ void PlayerController::setSecondarySubtitleDelay(VLCTick delay)
return;
if (d->m_secondarySpuEsId.get() != NULL)
vlc_player_SetEsIdDelay(d->m_player, d->m_secondarySpuEsId.get(),
- delay, VLC_PLAYER_WHENCE_ABSOLUTE);
+ delay.toVLCTick(), VLC_PLAYER_WHENCE_ABSOLUTE);
}
-/*Q_INVOKABLE*/void PlayerController::addSecondarySubtitleDelay(VLCTick delay)
+/*Q_INVOKABLE*/void PlayerController::addSecondarySubtitleDelay(VLCDuration delay)
{
Q_D(PlayerController);
vlc_player_locker lock{ d->m_player };
if (d->m_secondarySpuEsId.get() != NULL) {
vlc_player_SetEsIdDelay(d->m_player, d->m_secondarySpuEsId.get(),
- delay, VLC_PLAYER_WHENCE_RELATIVE);
+ delay.toVLCTick(), VLC_PLAYER_WHENCE_RELATIVE);
emit secondarySubtitleDelayChanged(delay);
}
}
int PlayerController::getAudioDelayMS() const
{
- return MS_FROM_VLC_TICK( getAudioDelay() );
+ return getAudioDelay().toMilliseconds();
}
void PlayerController::setAudioDelayMS(int ms)
{
- setAudioDelay( VLC_TICK_FROM_MS(ms) );
+ setAudioDelay( VLCDuration::fromMS(ms) );
}
int PlayerController::getSubtitleDelayMS() const
{
- return MS_FROM_VLC_TICK( getSubtitleDelay() );
+ return getSubtitleDelay().toMilliseconds();
}
void PlayerController::setSubtitleDelayMS(int ms)
{
- setSubtitleDelay( VLC_TICK_FROM_MS(ms) );
+ setSubtitleDelay( VLCDuration::fromMS(ms) );
}
int PlayerController::getSecondarySubtitleDelayMS() const
{
- return MS_FROM_VLC_TICK( getSecondarySubtitleDelay() );
+ return getSecondarySubtitleDelay().toMilliseconds();
}
void PlayerController::setSecondarySubtitleDelayMS(int ms)
{
- setSecondarySubtitleDelay( VLC_TICK_FROM_MS(ms) );
+ setSecondarySubtitleDelay( VLCDuration::fromMS(ms) );
}
void PlayerController::setSubtitleFPS(float fps)
@@ -1759,8 +1759,7 @@ void PlayerController::updatePosition()
// Update position properties
emit positionChanged(d->m_position);
- emit positionUpdated(d->m_position, d->m_time,
- SEC_FROM_VLC_TICK(d->m_length));
+ emit positionUpdated(d->m_position, d->m_time, d->m_length);
}
void PlayerController::updatePositionFromTimer()
@@ -1778,10 +1777,10 @@ void PlayerController::updateTime(vlc_tick_t system_now, bool forceUpdate)
// Update time properties
emit timeChanged(d->m_time);
- if (d->m_time != VLC_TICK_INVALID && d->m_length != VLC_TICK_INVALID)
- d->m_remainingTime = d->m_length - d->m_time;
+ if (d->m_time.valid() && d->m_length.valid() && d->m_time <= VLCTime(d->m_length))
+ d->m_remainingTime = VLCTime(d->m_length) - d->m_time;
else
- d->m_remainingTime = VLC_TICK_INVALID;
+ d->m_remainingTime = VLCDuration();
emit remainingTimeChanged(d->m_remainingTime);
if (system_now != VLC_TICK_INVALID
@@ -1791,7 +1790,7 @@ void PlayerController::updateTime(vlc_tick_t system_now, bool forceUpdate)
// Tell the timer to wait until the next second is reached.
vlc_tick_t next_update_date =
vlc_player_timer_point_GetNextIntervalDate(&d->m_player_time, system_now,
- d->m_time, VLC_TICK_FROM_SEC(1));
+ d->m_time.toVLCTick(), VLC_TICK_FROM_SEC(1));
vlc_tick_t next_update_interval = next_update_date - system_now;
@@ -2127,13 +2126,13 @@ QABSTRACTLIST_GETTER( RendererManager, getRendererManager, m_rendererManager)
PRIMITIVETYPE_GETTER(PlayerController::PlayingState, getPlayingState, m_playing_status)
PRIMITIVETYPE_GETTER(QString, getName, m_name)
-PRIMITIVETYPE_GETTER(VLCTick, getTime, m_time)
-PRIMITIVETYPE_GETTER(VLCTick, getRemainingTime, m_remainingTime)
+PRIMITIVETYPE_GETTER(VLCTime, getTime, m_time)
+PRIMITIVETYPE_GETTER(VLCDuration, getRemainingTime, m_remainingTime)
PRIMITIVETYPE_GETTER(double, getPosition, m_position)
-PRIMITIVETYPE_GETTER(VLCTick, getLength, m_length)
-PRIMITIVETYPE_GETTER(VLCTick, getAudioDelay, m_audioDelay)
-PRIMITIVETYPE_GETTER(VLCTick, getSubtitleDelay, m_subtitleDelay)
-PRIMITIVETYPE_GETTER(VLCTick, getSecondarySubtitleDelay, m_secondarySubtitleDelay)
+PRIMITIVETYPE_GETTER(VLCDuration, getLength, m_length)
+PRIMITIVETYPE_GETTER(VLCDuration, getAudioDelay, m_audioDelay)
+PRIMITIVETYPE_GETTER(VLCDuration, getSubtitleDelay, m_subtitleDelay)
+PRIMITIVETYPE_GETTER(VLCDuration, getSecondarySubtitleDelay, m_secondarySubtitleDelay)
PRIMITIVETYPE_GETTER(bool, isSeekable, m_capabilities & VLC_PLAYER_CAP_SEEK)
PRIMITIVETYPE_GETTER(bool, isRewindable, m_capabilities & VLC_PLAYER_CAP_REWIND)
PRIMITIVETYPE_GETTER(bool, isPausable, m_capabilities & VLC_PLAYER_CAP_PAUSE)
@@ -2156,8 +2155,8 @@ PRIMITIVETYPE_GETTER(bool, hasPrograms, m_hasPrograms)
PRIMITIVETYPE_GETTER(bool, isEncrypted, m_encrypted)
PRIMITIVETYPE_GETTER(bool, isRecording, m_recording)
PRIMITIVETYPE_GETTER(PlayerController::ABLoopState, getABloopState, m_ABLoopState)
-PRIMITIVETYPE_GETTER(VLCTick, getABLoopA, m_ABLoopA)
-PRIMITIVETYPE_GETTER(VLCTick, getABLoopB, m_ABLoopB)
+PRIMITIVETYPE_GETTER(VLCTime, getABLoopA, m_ABLoopA)
+PRIMITIVETYPE_GETTER(VLCTime, getABLoopB, m_ABLoopB)
PRIMITIVETYPE_GETTER(bool, isTeletextEnabled, m_teletextEnabled)
PRIMITIVETYPE_GETTER(bool, isTeletextAvailable, m_teletextAvailable)
PRIMITIVETYPE_GETTER(int, getTeletextPage, m_teletextPage)
=====================================
modules/gui/qt/player/player_controller.hpp
=====================================
@@ -113,10 +113,10 @@ public:
Q_PROPERTY(float rate READ getRate WRITE setRate NOTIFY rateChanged FINAL)
Q_PROPERTY(QUrl url READ getUrl NOTIFY inputChanged FINAL)
- Q_PROPERTY(VLCTick time READ getTime WRITE setTime NOTIFY timeChanged FINAL)
- Q_PROPERTY(VLCTick remainingTime READ getRemainingTime NOTIFY remainingTimeChanged FINAL)
+ Q_PROPERTY(VLCTime time READ getTime WRITE setTime NOTIFY timeChanged FINAL)
+ Q_PROPERTY(VLCTime remainingTime READ getRemainingTime NOTIFY remainingTimeChanged FINAL)
Q_PROPERTY(double position READ getPosition WRITE setPosition NOTIFY positionChanged FINAL)
- Q_PROPERTY(VLCTick length READ getLength NOTIFY lengthChanged FINAL)
+ Q_PROPERTY(VLCDuration length READ getLength NOTIFY lengthChanged FINAL)
Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged FINAL)
Q_PROPERTY(bool rewindable READ isRewindable NOTIFY rewindableChanged FINAL)
@@ -136,9 +136,9 @@ public:
Q_PROPERTY(TrackListModel* audioTracks READ getAudioTracks CONSTANT FINAL)
Q_PROPERTY(TrackListModel* subtitleTracks READ getSubtitleTracks CONSTANT FINAL)
- Q_PROPERTY(VLCTick audioDelay READ getAudioDelay WRITE setAudioDelay NOTIFY audioDelayChanged FINAL)
- Q_PROPERTY(VLCTick subtitleDelay READ getSubtitleDelay WRITE setSubtitleDelay NOTIFY subtitleDelayChanged FINAL)
- Q_PROPERTY(VLCTick secondarySubtitleDelay READ getSecondarySubtitleDelay WRITE setSecondarySubtitleDelay NOTIFY secondarySubtitleDelayChanged FINAL)
+ Q_PROPERTY(VLCDuration audioDelay READ getAudioDelay WRITE setAudioDelay NOTIFY audioDelayChanged FINAL)
+ Q_PROPERTY(VLCDuration subtitleDelay READ getSubtitleDelay WRITE setSubtitleDelay NOTIFY subtitleDelayChanged FINAL)
+ Q_PROPERTY(VLCDuration secondarySubtitleDelay READ getSecondarySubtitleDelay WRITE setSecondarySubtitleDelay NOTIFY secondarySubtitleDelayChanged FINAL)
Q_PROPERTY(int audioDelayMS READ getAudioDelayMS WRITE setAudioDelayMS NOTIFY audioDelayChanged FINAL)
Q_PROPERTY(int subtitleDelayMS READ getSubtitleDelayMS WRITE setSubtitleDelayMS NOTIFY subtitleDelayChanged FINAL)
Q_PROPERTY(int secondarySubtitleDelayMS READ getSecondarySubtitleDelayMS WRITE setSecondarySubtitleDelayMS NOTIFY secondarySubtitleDelayChanged FINAL)
@@ -190,8 +190,8 @@ public:
//misc
Q_PROPERTY(ABLoopState ABloopState READ getABloopState WRITE setABloopState NOTIFY ABLoopStateChanged FINAL)
- Q_PROPERTY(VLCTick ABLoopA READ getABLoopA NOTIFY ABLoopAChanged FINAL)
- Q_PROPERTY(VLCTick ABLoopB READ getABLoopB NOTIFY ABLoopBChanged FINAL)
+ Q_PROPERTY(VLCTime ABLoopA READ getABLoopA NOTIFY ABLoopAChanged FINAL)
+ Q_PROPERTY(VLCTime ABLoopB READ getABLoopB NOTIFY ABLoopBChanged FINAL)
Q_PROPERTY(bool recording READ isRecording WRITE setRecording NOTIFY recordingChanged FINAL)
Q_PROPERTY(RendererManager* rendererManager READ getRendererManager CONSTANT FINAL)
@@ -209,7 +209,7 @@ public slots:
void jumpFwd();
void jumpBwd();
- void jumpToTime( VLCTick i_time );
+ void jumpToTime( VLCTime i_time );
void jumpToPos( double );
void frameNext();
@@ -285,12 +285,12 @@ public slots:
float getBuffering() const;
float getRate() const;
void setRate( float );
- VLCTick getTime() const;
- void setTime(VLCTick);
- VLCTick getRemainingTime() const;
+ VLCTime getTime() const;
+ void setTime(VLCTime);
+ VLCDuration getRemainingTime() const;
double getPosition() const;
void setPosition(double);
- VLCTick getLength() const;
+ VLCDuration getLength() const;
bool isSeekable() const;
bool isRewindable() const;
bool isPausable() const;
@@ -308,15 +308,15 @@ public slots:
TrackListModel* getAudioTracks();
TrackListModel* getSubtitleTracks();
- VLCTick getAudioDelay() const;
- void setAudioDelay( VLCTick );
- Q_INVOKABLE void addAudioDelay( VLCTick );
- VLCTick getSubtitleDelay() const;
- VLCTick getSecondarySubtitleDelay() const;
- void setSubtitleDelay( VLCTick );
- Q_INVOKABLE void addSubtitleDelay( VLCTick );
- void setSecondarySubtitleDelay( VLCTick );
- Q_INVOKABLE void addSecondarySubtitleDelay( VLCTick );
+ VLCDuration getAudioDelay() const;
+ void setAudioDelay( VLCDuration );
+ Q_INVOKABLE void addAudioDelay( VLCDuration );
+ VLCDuration getSubtitleDelay() const;
+ VLCDuration getSecondarySubtitleDelay() const;
+ void setSubtitleDelay( VLCDuration );
+ Q_INVOKABLE void addSubtitleDelay( VLCDuration );
+ void setSecondarySubtitleDelay( VLCDuration );
+ Q_INVOKABLE void addSecondarySubtitleDelay( VLCDuration );
int getAudioDelayMS() const;
void setAudioDelayMS( int );
int getSubtitleDelayMS() const;
@@ -382,8 +382,8 @@ public slots:
void setRecording(bool record);
void setABloopState(ABLoopState);
ABLoopState getABloopState() const;
- VLCTick getABLoopA() const;
- VLCTick getABLoopB() const;
+ VLCTime getABLoopA() const;
+ VLCTime getABLoopB() const;
// High resolution time fed by SMPTE timer
QString highResolutionTime() const;
@@ -409,11 +409,11 @@ signals:
void bufferingChanged( float );
void rateChanged( float );
- void timeChanged( VLCTick );
- void remainingTimeChanged( VLCTick );
+ void timeChanged( VLCTime );
+ void remainingTimeChanged( VLCTime );
void positionChanged( double );
- void lengthChanged( VLCTick );
- void positionUpdated( double , VLCTick, int );
+ void lengthChanged( VLCDuration );
+ void positionUpdated( double , VLCTime, VLCDuration );
void seekRequested( double pos ); //not exposed through Q_PROPERTY
void seekableChanged( bool );
@@ -425,9 +425,9 @@ signals:
void playbackRestoreQueried();
//tracks
- void audioDelayChanged(VLCTick);
- void subtitleDelayChanged(VLCTick);
- void secondarySubtitleDelayChanged(VLCTick);
+ void audioDelayChanged(VLCDuration);
+ void subtitleDelayChanged(VLCDuration);
+ void secondarySubtitleDelayChanged(VLCDuration);
void subtitleFPSChanged(float);
//title/chapters/menu
@@ -462,8 +462,8 @@ signals:
//misc
void recordingChanged( bool );
void ABLoopStateChanged(ABLoopState);
- void ABLoopAChanged(VLCTick);
- void ABLoopBChanged(VLCTick);
+ void ABLoopAChanged(VLCTime);
+ void ABLoopBChanged(VLCTime);
// High resolution time fed by SMPTE timer
void highResolutionTimeChanged(const QString&);
@@ -471,7 +471,7 @@ signals:
// Other signals
// You can resume playback
- void resumePlayback( VLCTick );
+ void resumePlayback( VLCTime );
// Statistics are updated
void statisticsUpdated( const input_stats_t& stats );
void infoChanged( input_item_t* );
=====================================
modules/gui/qt/player/player_controller_p.hpp
=====================================
@@ -95,10 +95,10 @@ public:
float m_buffering = 0.f;
float m_rate = 1.f;
- VLCTick m_time = 0;
- VLCTick m_remainingTime = 0;
+ VLCTime m_time;
+ VLCDuration m_remainingTime;
double m_position = 0.f;
- VLCTick m_length= 0;
+ VLCDuration m_length;
#ifdef QT_HAS_LIBATOMIC
std::atomic<vlc_player_timer_smpte_timecode> m_highResolutionTime;
@@ -122,9 +122,9 @@ public:
vlc_shared_data_ptr_type(vlc_es_id_t, vlc_es_id_Hold, vlc_es_id_Release) m_secondarySpuEsId;
- VLCTick m_audioDelay = 0;
- VLCTick m_subtitleDelay = 0;
- VLCTick m_secondarySubtitleDelay = 0;
+ VLCDuration m_audioDelay;
+ VLCDuration m_subtitleDelay;
+ VLCDuration m_secondarySubtitleDelay;
float m_subtitleFPS = 1.0;
//timer
@@ -180,8 +180,8 @@ public:
//misc
bool m_recording = false;
PlayerController::ABLoopState m_ABLoopState = PlayerController::ABLOOP_STATE_NONE;
- VLCTick m_ABLoopA = VLC_TICK_INVALID;
- VLCTick m_ABLoopB = VLC_TICK_INVALID;
+ VLCTime m_ABLoopA;
+ VLCTime m_ABLoopB;
//others
QString m_artUrl;
=====================================
modules/gui/qt/playlist/playlist_model.cpp
=====================================
@@ -299,11 +299,11 @@ PlaylistListModel::rowCount(const QModelIndex &parent) const
return d->m_items.size();
}
-VLCTick
+VLCDuration
PlaylistListModel::getDuration() const
{
Q_D(const PlaylistListModel);
- return VLCTick(d->m_duration);
+ return VLCDuration(d->m_duration);
}
PlaylistItem
@@ -483,7 +483,7 @@ PlaylistListModel::data(const QModelIndex &index, int role) const
case DurationRole:
{
QVariant var;
- var.setValue(VLCTick(d->m_items[row].getDuration()));
+ var.setValue(d->m_items[row].getDuration());
return var;
}
case ArtistRole:
=====================================
modules/gui/qt/playlist/playlist_model.hpp
=====================================
@@ -39,7 +39,7 @@ class PlaylistListModel : public QAbstractListModel
Q_PROPERTY(Playlist playlist READ getPlaylist WRITE setPlaylist NOTIFY playlistChanged FINAL)
Q_PROPERTY(int currentIndex READ getCurrentIndex NOTIFY currentIndexChanged FINAL)
Q_PROPERTY(int count READ rowCount NOTIFY countChanged FINAL)
- Q_PROPERTY(VLCTick duration READ getDuration NOTIFY countChanged FINAL)
+ Q_PROPERTY(VLCDuration duration READ getDuration NOTIFY countChanged FINAL)
public:
enum Roles
@@ -60,7 +60,7 @@ public:
QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent = {}) const override;
- VLCTick getDuration() const;
+ VLCDuration getDuration() const;
QVariant data(const QModelIndex &index,
int role = Qt::DisplayRole) const override;
=====================================
modules/gui/qt/qt.cpp
=====================================
@@ -750,7 +750,8 @@ static inline void registerMetaTypes()
qRegisterMetaType<ssize_t>();
qRegisterMetaType<vlc_tick_t>();
- qRegisterMetaType<VLCTick>();
+ qRegisterMetaType<VLCTime>();
+ qRegisterMetaType<VLCDuration>();
qRegisterMetaType<SharedInputItem>();
qRegisterMetaType<NetworkTreeItem>();
qRegisterMetaType<Playlist>();
=====================================
modules/gui/qt/util/vlctick.cpp
=====================================
@@ -29,47 +29,50 @@ int64_t roundNearestMultiple(int64_t number, int64_t multiple)
}
-VLCTick::VLCTick()
- : m_ticks(VLC_TICK_INVALID)
+VLCTick::VLCTick(vlc_tick_t base_offset, vlc_tick_t invalid_value)
+ : m_base_offset(base_offset), m_invalid_value(invalid_value), m_ticks(invalid_value)
{
+}
+vlc_tick_t VLCTick::toVLCTick() const
+{
+ return m_ticks;
}
-VLCTick::VLCTick(vlc_tick_t ticks)
- : m_ticks(ticks)
+vlc_tick_t VLCTick::asMilliseconds() const
{
+ return MS_FROM_VLC_TICK(m_ticks - m_base_offset);
}
-VLCTick::operator vlc_tick_t() const
+vlc_tick_t VLCTick::asSeconds() const
{
- return m_ticks;
+ return SEC_FROM_VLC_TICK(m_ticks - m_base_offset);
}
bool VLCTick::valid() const
{
- return m_ticks != VLC_TICK_INVALID;
+ return m_ticks != m_invalid_value;
}
bool VLCTick::isSubSecond() const
{
- return (MS_FROM_VLC_TICK(m_ticks) < 1000);
+ return asMilliseconds() < 1000;
}
bool VLCTick::isSubHour() const
{
- return (SEC_FROM_VLC_TICK(m_ticks) < 3600);
+ return asSeconds() < 3600;
}
QString VLCTick::formatHMS(int formatFlags) const
{
- if (m_ticks == VLC_TICK_INVALID)
+ if (!valid())
return "--:--";
- int64_t t_ms = MS_FROM_VLC_TICK(m_ticks);
if (!isSubSecond() || !(formatFlags & SubSecondFormattedAsMS))
{
//truncate milliseconds toward 0
- int64_t t_sec = t_ms / 1000;
+ int64_t t_sec = asSeconds();
int sec = t_sec % 60;
int min = (t_sec / 60) % 60;
int hour = t_sec / 3600;
@@ -85,15 +88,15 @@ QString VLCTick::formatHMS(int formatFlags) const
.arg(sec, 2, 10, QChar('0'));
}
else
- return qtr("%1 ms").arg(MS_FROM_VLC_TICK(m_ticks));
+ return qtr("%1 ms").arg(asMilliseconds());
}
QString VLCTick::formatLong(int formatFlags) const
{
- if (m_ticks == VLC_TICK_INVALID)
+ if (!valid())
return "--:--";
- int64_t t_ms = MS_FROM_VLC_TICK(m_ticks);
+ int64_t t_ms = asMilliseconds();
if (t_ms >= 60*60*1000)
{
//round to the nearest minute
@@ -127,10 +130,10 @@ QString VLCTick::formatLong(int formatFlags) const
QString VLCTick::formatShort(int formatFlags) const
{
- if (m_ticks == VLC_TICK_INVALID)
+ if (!valid())
return "--:--";
- int64_t t_ms = MS_FROM_VLC_TICK(m_ticks);
+ int64_t t_ms = asMilliseconds();
if (t_ms >= 60*60*1000)
{
//round to the nearest minute
@@ -160,42 +163,100 @@ QString VLCTick::formatShort(int formatFlags) const
return qtr("%1ms").arg(t_ms);
}
-VLCTick VLCTick::scale(float scalar) const
+int VLCTick::toSeconds() const
{
- if (scalar == 0.0f)
- return VLCTick(VLC_TICK_0); // to not decay to VLC_TICK_INVALID
+ return valid() ? asSeconds() : 0;
+}
- return VLCTick(m_ticks * scalar);
+int VLCTick::toMinutes() const
+{
+ return asSeconds() / 60;
}
-int VLCTick::toSeconds() const
+int VLCTick::toHours() const
+{
+ return asSeconds() / 3600;
+}
+
+int VLCTick::toMilliseconds() const
+{
+ return valid() ? asMilliseconds() : 0;
+}
+
+VLCDuration::VLCDuration()
+ : VLCTick::VLCTick(0, 0)
{
- if (m_ticks == VLC_TICK_INVALID)
- return 0;
- int64_t t_sec = SEC_FROM_VLC_TICK(m_ticks);
- return t_sec;
}
-int VLCTick::toMinutes() const
+VLCDuration::VLCDuration(vlc_tick_t t)
+ : VLCTick::VLCTick(0, 0)
{
- if (m_ticks == VLC_TICK_INVALID)
- return 0;
+ m_ticks = t;
+}
- int64_t t_sec = SEC_FROM_VLC_TICK(m_ticks);
- return (t_sec / 60);
+VLCDuration VLCDuration::operator*(double f) const
+{
+ return VLCDuration(m_ticks * f);
}
-int VLCTick::toHours() const
+bool VLCDuration::operator==(const VLCDuration &rhs) const
{
- if (m_ticks == VLC_TICK_INVALID)
- return 0;
+ return m_ticks == rhs.m_ticks;
+}
- int64_t t_sec = SEC_FROM_VLC_TICK(m_ticks);
- return (t_sec / 3600);
+bool VLCDuration::operator>(const VLCDuration &rhs) const
+{
+ return m_ticks > rhs.m_ticks;
+}
+
+double VLCDuration::toSecf() const
+{
+ return secf_from_vlc_tick(m_ticks);
+}
+
+VLCDuration VLCDuration::scale(float scalar) const
+{
+ return VLCDuration(m_ticks * scalar);
+}
+
+VLCDuration VLCDuration::fromMS(int64_t ms)
+{
+ return VLCDuration(VLC_TICK_FROM_MS(ms));
+}
+
+VLCTime::VLCTime()
+ : VLCTick(VLC_TICK_0, VLC_TICK_INVALID)
+{
+}
+
+VLCTime::VLCTime(vlc_tick_t t)
+ : VLCTick(VLC_TICK_0, VLC_TICK_INVALID)
+{
+ m_ticks = t;
+}
+
+VLCTime::VLCTime(VLCDuration d)
+ : VLCTick(VLC_TICK_0, VLC_TICK_INVALID)
+{
+ m_ticks = m_base_offset + d.toVLCTick();
+}
+
+VLCDuration VLCTime::operator-(const VLCTime &rhs) const
+{
+ if(m_ticks >= rhs.m_ticks)
+ return VLCDuration(m_ticks - rhs.m_ticks);
+ return VLCDuration();
+}
+
+bool VLCTime::operator<=(const VLCTime &rhs) const
+{
+ return m_ticks <= rhs.m_ticks;
}
-VLCTick VLCTick::fromMS(int64_t ms)
+VLCTime VLCTime::scale(float scalar) const
{
- return VLCTick(VLC_TICK_FROM_MS(ms));
+ if(!valid())
+ return VLCTime(VLC_TICK_INVALID);
+ return VLCTime(m_base_offset + ((m_ticks - m_base_offset) * scalar));
}
=====================================
modules/gui/qt/util/vlctick.hpp
=====================================
@@ -35,11 +35,6 @@ public:
};
Q_ENUM(FormatFlag)
- VLCTick();
- VLCTick(vlc_tick_t ticks);
-
- operator vlc_tick_t() const;
-
Q_INVOKABLE bool valid() const;
Q_INVOKABLE bool isSubSecond() const;
@@ -79,17 +74,51 @@ public:
*/
Q_INVOKABLE QString formatShort(int formatFlags = SubSecondFormattedAsMS) const;
-
- Q_INVOKABLE VLCTick scale(float) const;
-
+ vlc_tick_t toVLCTick() const;
Q_INVOKABLE int toMinutes() const;
Q_INVOKABLE int toSeconds() const;
Q_INVOKABLE int toHours() const;
+ int toMilliseconds() const;
+
+protected:
+ VLCTick() = delete;
+ VLCTick(vlc_tick_t, vlc_tick_t);
+ vlc_tick_t asMilliseconds() const;
+ vlc_tick_t asSeconds() const;
- static VLCTick fromMS(int64_t ms);
-private:
+ vlc_tick_t m_base_offset;
+ vlc_tick_t m_invalid_value;
vlc_tick_t m_ticks;
};
+class VLCDuration : public VLCTick
+{
+public:
+ VLCDuration();
+ VLCDuration(vlc_tick_t);
+
+ VLCDuration operator*(double) const;
+ bool operator==(const VLCDuration &) const;
+ bool operator>(const VLCDuration &) const;
+
+ double toSecf() const;
+
+ Q_INVOKABLE VLCDuration scale(float) const;
+
+ static VLCDuration fromMS(int64_t ms);
+};
+
+class VLCTime : public VLCTick
+{
+public:
+ VLCTime();
+ VLCTime(vlc_tick_t);
+ VLCTime(VLCDuration);
+ VLCDuration operator-(const VLCTime &rhs) const;
+ bool operator<=(const VLCTime &) const;
+
+ Q_INVOKABLE VLCTime scale(float) const;
+};
+
#endif // VLCTICK_HPP
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/56195130f5972e5cdd1ec721b4a3f66496d5cb3c
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/56195130f5972e5cdd1ec721b4a3f66496d5cb3c
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list