[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: add the player SMPTE timer

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Fri Oct 22 08:04:37 UTC 2021



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
a1033178 by Fatih Uzunoglu at 2021-10-22T07:50:31+00:00
qt: add the player SMPTE timer

- - - - -
326759fa by Fatih Uzunoglu at 2021-10-22T07:50:31+00:00
qml: add high resolution time widget

- - - - -
457dcf4f by Fatih Uzunoglu at 2021-10-22T07:50:31+00:00
qt: remove unnecessary macro usage in player_controller.hpp

- - - - -


8 changed files:

- modules/gui/qt/Makefile.am
- modules/gui/qt/player/control_list_model.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/player/qml/ControlbarControls.qml
- + modules/gui/qt/player/qml/controlbarcontrols/HighResolutionTimeWidget.qml
- modules/gui/qt/vlc.qrc


Changes:

=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -791,6 +791,7 @@ libqt_plugin_la_QML = \
 	gui/qt/player/qml/TopBar.qml \
 	gui/qt/player/qml/TrackInfo.qml \
 	gui/qt/player/qml/ButtonsLayout.qml \
+	gui/qt/player/qml/controlbarcontrols/HighResolutionTimeWidget.qml \
 	gui/qt/player/qml/controlbarcontrols/ArtworkInfoWidget.qml \
 	gui/qt/player/qml/controlbarcontrols/AspectRatioWidget.qml \
 	gui/qt/player/qml/controlbarcontrols/AtoBButton.qml \


=====================================
modules/gui/qt/player/control_list_model.hpp
=====================================
@@ -65,6 +65,7 @@ public:
         PLAYER_SWITCH_BUTTON,
         ARTWORK_INFO,
         PLAYBACK_SPEED_BUTTON,
+        HIGH_RESOLUTION_TIME_WIDGET,
 
         SPLITTER = 0x20,
         VOLUME,


=====================================
modules/gui/qt/player/player_controller.cpp
=====================================
@@ -58,6 +58,8 @@ using TitleListPtr = vlc_shared_data_ptr_type(vlc_player_title_list,
 
 PlayerControllerPrivate::~PlayerControllerPrivate()
 {
+    assert(m_smpteTimerRequestCount == 0);
+
     vlc_player_locker locker{m_player}; //this also locks the player
     vlc_player_vout_RemoveListener( m_player, m_player_vout_listener );
     vlc_player_aout_RemoveListener( m_player, m_player_aout_listener );
@@ -949,6 +951,22 @@ static void on_player_timer_discontinuity(vlc_tick_t system_date, void *data)
     });
 }
 
+static void on_player_timer_smpte_update(const struct vlc_player_timer_smpte_timecode *tc,
+                                         void *data)
+{
+    PlayerControllerPrivate* that = static_cast<PlayerControllerPrivate *>(data);
+
+    that->callAsync([that, tc_copy = *tc](){
+        that->m_highResolutionTime = QString::asprintf("%02u:%02u:%02u%c%02u",
+                                                       tc_copy.hours,
+                                                       tc_copy.minutes,
+                                                       tc_copy.seconds,
+                                                       tc_copy.drop_frame ? '.' : ':',
+                                                       tc_copy.frames);
+        emit that->q_func()->highResolutionTimeChanged(that->m_highResolutionTime);
+    });
+}
+
 } //extern "C"
 
 static const struct vlc_player_cbs player_cbs = {
@@ -1009,6 +1027,10 @@ static const vlc_player_timer_cbs player_timer_cbs = []{
     return cbs;
 }();
 
+static const struct vlc_player_timer_smpte_cbs player_timer_smpte_cbs = {
+    on_player_timer_smpte_update
+};
+
 PlayerControllerPrivate::PlayerControllerPrivate(PlayerController *playercontroller, qt_intf_t *p_intf)
     : q_ptr(playercontroller)
     , p_intf(p_intf)
@@ -1050,6 +1072,24 @@ PlayerControllerPrivate::PlayerControllerPrivate(PlayerController *playercontrol
     m_volume = vlc_player_aout_GetVolume( m_player );
 }
 
+void PlayerControllerPrivate::addSMPTETimer()
+{
+    assert( !m_player_timer_smpte );
+
+    vlc_player_locker lock{ m_player };
+    m_player_timer_smpte = vlc_player_AddSmpteTimer( m_player, &player_timer_smpte_cbs, this );
+    assert( m_player_timer_smpte );
+}
+
+void PlayerControllerPrivate::removeSMPTETimer()
+{
+    assert( m_player_timer_smpte );
+
+    vlc_player_locker lock{ m_player };
+    vlc_player_RemoveTimer( m_player, m_player_timer_smpte );
+    m_player_timer_smpte = nullptr;
+}
+
 PlayerController::PlayerController( qt_intf_t *_p_intf )
     : QObject(NULL)
     , d_ptr( new PlayerControllerPrivate(this, _p_intf) )
@@ -1698,6 +1738,27 @@ void PlayerController::toggleVisualization()
     }
 }
 
+void PlayerController::requestAddSMPTETimer()
+{
+    Q_D(PlayerController);
+
+    if ( ++d->m_smpteTimerRequestCount == 1 )
+    {
+        d->addSMPTETimer();
+    }
+}
+
+void PlayerController::requestRemoveSMPTETimer()
+{
+    Q_D(PlayerController);
+
+    assert( d->m_smpteTimerRequestCount > 0 );
+    if ( --d->m_smpteTimerRequestCount == 0 )
+    {
+        d->removeSMPTETimer();
+    }
+}
+
 void PlayerController::setRecording( bool recording )
 {
     Q_D(PlayerController);
@@ -1888,4 +1949,7 @@ PRIMITIVETYPE_GETTER(bool, isTeletextAvailable, m_teletextAvailable)
 PRIMITIVETYPE_GETTER(int, getTeletextPage, m_teletextPage)
 PRIMITIVETYPE_GETTER(bool, getTeletextTransparency, m_teletextTransparent)
 
+// High resolution time fed by SMPTE timer
+PRIMITIVETYPE_GETTER(QString, highResolutionTime, m_highResolutionTime)
+
 #undef PRIMITIVETYPE_GETTER


=====================================
modules/gui/qt/player/player_controller.hpp
=====================================
@@ -186,47 +186,54 @@ public:
     Q_PROPERTY(VLCTick ABLoopB READ getABLoopB NOTIFY ABLoopBChanged FINAL)
     Q_PROPERTY(bool recording READ isRecording WRITE setRecording NOTIFY recordingChanged FINAL)
 
+    // High resolution time fed by SMPTE Timer
+    Q_PROPERTY(QString highResolutionTime READ highResolutionTime NOTIFY highResolutionTimeChanged FINAL)
+
     /* exposed actions */
 public slots:
-    Q_INVOKABLE void reverse();
-    Q_INVOKABLE void slower();
-    Q_INVOKABLE void faster();
-    Q_INVOKABLE void littlefaster();
-    Q_INVOKABLE void littleslower();
-    Q_INVOKABLE void normalRate();
-
-    Q_INVOKABLE void jumpFwd();
-    Q_INVOKABLE void jumpBwd();
-    Q_INVOKABLE void jumpToTime( VLCTick i_time );
-    Q_INVOKABLE void jumpToPos( float );
-    Q_INVOKABLE void frameNext();
+    void reverse();
+    void slower();
+    void faster();
+    void littlefaster();
+    void littleslower();
+    void normalRate();
+
+    void jumpFwd();
+    void jumpBwd();
+    void jumpToTime( VLCTick i_time );
+    void jumpToPos( float );
+    void frameNext();
 
     //title/chapters/menu
-    Q_INVOKABLE void sectionNext();
-    Q_INVOKABLE void sectionPrev();
-    Q_INVOKABLE void sectionMenu();
+    void sectionNext();
+    void sectionPrev();
+    void sectionMenu();
 
-    Q_INVOKABLE void chapterNext();
-    Q_INVOKABLE void chapterPrev();
-    Q_INVOKABLE void titleNext();
-    Q_INVOKABLE void titlePrev();
+    void chapterNext();
+    void chapterPrev();
+    void titleNext();
+    void titlePrev();
 
     //programs
-    Q_INVOKABLE void changeProgram( int );
+    void changeProgram( int );
 
     //vout properties
-    Q_INVOKABLE void toggleFullscreen();
+    void toggleFullscreen();
 
     //aout properties
-    Q_INVOKABLE void setVolumeUp();
-    Q_INVOKABLE void setVolumeDown();
-    Q_INVOKABLE void toggleMuted();
+    void setVolumeUp();
+    void setVolumeDown();
+    void toggleMuted();
 
     //misc
-    Q_INVOKABLE void toggleABloopState();
-    Q_INVOKABLE void snapshot();
-    Q_INVOKABLE void toggleRecord();
-    Q_INVOKABLE void toggleVisualization();
+    void toggleABloopState();
+    void snapshot();
+    void toggleRecord();
+    void toggleVisualization();
+
+    // SMPTE Timer
+    void requestAddSMPTETimer();
+    void requestRemoveSMPTETimer();
 
 public:
     PlayerController( qt_intf_t * );
@@ -361,6 +368,8 @@ public slots:
     VLCTick getABLoopA() const;
     VLCTick getABLoopB() const;
 
+    // High resolution time fed by SMPTE timer
+    QString highResolutionTime() const;
 signals:
     //playback
     void playingStateChanged( PlayingState state );
@@ -425,6 +434,9 @@ signals:
     void ABLoopAChanged(VLCTick);
     void ABLoopBChanged(VLCTick);
 
+    // High resolution time fed by SMPTE timer
+    void highResolutionTimeChanged(const QString&);
+
     // Other signals
 
     // You can resume playback


=====================================
modules/gui/qt/player/player_controller_p.hpp
=====================================
@@ -48,6 +48,10 @@ public:
     void UpdateSpuOrder(vlc_es_id_t *es_id, enum vlc_vout_order spu_order);
     int interpolateTime(vlc_tick_t system_now);
 
+    // SMPTE Timer
+    void addSMPTETimer();
+    void removeSMPTETimer();
+
     ///call function @a fun on object thread
     template <typename Fun>
     void callAsync(Fun&& fun)
@@ -82,6 +86,9 @@ public:
     float           m_position = 0.f;
     VLCTick      m_length= 0;
 
+    QString m_highResolutionTime { "00:00:00:00" };
+    unsigned m_smpteTimerRequestCount = 0;
+
     using InputItemPtr = vlc_shared_data_ptr_type(input_item_t,
                                                   input_item_Hold,
                                                   input_item_Release);


=====================================
modules/gui/qt/player/qml/ControlbarControls.qml
=====================================
@@ -62,7 +62,8 @@ QtObject {
         { id: ControlListModel.WIDGET_SPACER_EXTEND, file: "ExpandingSpacerWidget.qml", label: VLCIcons.space, text: i18n.qtr("Expanding Spacer") },
         { id: ControlListModel.PLAYER_SWITCH_BUTTON, file: "PlayerSwitchButton.qml", label: VLCIcons.fullscreen, text: i18n.qtr("Switch Player") },
         { id: ControlListModel.ARTWORK_INFO, file: "ArtworkInfoWidget.qml", label: VLCIcons.info, text: i18n.qtr("Artwork Info") },
-        { id: ControlListModel.PLAYBACK_SPEED_BUTTON, file: "PlaybackSpeedButton.qml", label: "1x", text: i18n.qtr("Playback Speed") }
+        { id: ControlListModel.PLAYBACK_SPEED_BUTTON, file: "PlaybackSpeedButton.qml", label: "1x", text: i18n.qtr("Playback Speed") },
+        { id: ControlListModel.HIGH_RESOLUTION_TIME_WIDGET, file: "HighResolutionTimeWidget.qml", label: VLCIcons.info, text: i18n.qtr("High Resolution Time") }
     ]
 
     function control(id) {


=====================================
modules/gui/qt/player/qml/controlbarcontrols/HighResolutionTimeWidget.qml
=====================================
@@ -0,0 +1,83 @@
+/*****************************************************************************
+ * Copyright (C) 2021 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+import QtQuick 2.11
+import QtQuick.Controls 2.4
+
+import org.videolan.vlc 0.1
+
+import "qrc:///player/"
+import "qrc:///widgets/" as Widgets
+import "qrc:///style/"
+
+
+Control {
+    id: highResolutionTimeWidget
+
+    property bool paintOnly: false
+    property VLCColors colors: VLCStyle.colors
+
+    padding: VLCStyle.focus_border
+
+    Keys.priority: Keys.AfterItem
+    Keys.onPressed: Navigation.defaultKeyAction(event)
+
+    function _adjustSMPTETimer(add) {
+        if (typeof toolbarEditor !== "undefined") // FIXME: Can't use paintOnly because it is set later
+            return
+
+        if (add === true)
+            player.requestAddSMPTETimer()
+        else if (add === false)
+            player.requestRemoveSMPTETimer()
+    }
+
+    Component.onCompleted: {
+        _adjustSMPTETimer(true)
+    }
+
+    Component.onDestruction: {
+        _adjustSMPTETimer(false)
+    }
+
+    background: Widgets.AnimatedBackground {
+        active: visualFocus
+        activeBorderColor: colors.bgFocus
+    }
+
+    contentItem: Item {
+        implicitHeight: smpteTimecodeMetrics.height
+        implicitWidth: smpteTimecodeMetrics.width
+
+        Widgets.MenuLabel {
+            id: label
+            anchors.fill: parent
+
+            text: paintOnly ? "00:00:00:00" : player.highResolutionTime
+            color: colors.text
+
+            horizontalAlignment: Text.AlignHCenter
+        }
+
+        TextMetrics {
+            id: smpteTimecodeMetrics
+            font: label.font
+            text: "-00:00:00:00-"
+        }
+    }
+}


=====================================
modules/gui/qt/vlc.qrc
=====================================
@@ -346,6 +346,7 @@
         <file alias="PlaybackSpeed.qml">player/qml/PlaybackSpeed.qml</file>
     </qresource>
     <qresource prefix="/player/controlbarcontrols">
+        <file alias="HighResolutionTimeWidget.qml">player/qml/controlbarcontrols/HighResolutionTimeWidget.qml</file>
         <file alias="ArtworkInfoWidget.qml">player/qml/controlbarcontrols/ArtworkInfoWidget.qml</file>
         <file alias="AspectRatioWidget.qml">player/qml/controlbarcontrols/AspectRatioWidget.qml</file>
         <file alias="AtoBButton.qml">player/qml/controlbarcontrols/AtoBButton.qml</file>



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/96166bad04b04bc676aefb1a6909bc31558f93e8...457dcf4fd325a4b14567684876933a4fcb555383

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/96166bad04b04bc676aefb1a6909bc31558f93e8...457dcf4fd325a4b14567684876933a4fcb555383
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list