File indexing completed on 2024-04-28 04:21:28

0001 // SPDX-FileCopyrightText: 2021 Jesper K. Pedersen <jesper.pedersen@kdab.com>
0002 // SPDX-FileCopyrightText: 2022-2023 Johannes Zarl-Zierl <johannes@zarl-zierl.at>
0003 // SPDX-FileCopyrightText: 2022 Tobias Leupold <tl@stonemx.de>
0004 //
0005 // SPDX-License-Identifier: GPL-2.0-or-later
0006 
0007 #pragma once
0008 
0009 #include "VideoDisplay.h"
0010 #include <vlc/vlc.h>
0011 
0012 class QTimer;
0013 
0014 namespace Viewer
0015 {
0016 /**
0017  * @brief The VLCDisplay class
0018  *
0019  * \note To ensure proper cleanup, you need to stop playback before deleting the VLCDisplay!
0020  * The VLCDisplay is not in the position to do this, since it is not the main widget of the
0021  * window and therefore does not receive a QCloseEvent (where the window handle is still valid).
0022  * There is no way to call releaseVLC safely from the destructor otherwise.
0023  */
0024 class VLCDisplay : public Viewer::VideoDisplay
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     VLCDisplay(QWidget *parent);
0030     ~VLCDisplay();
0031     bool isPaused() const override;
0032     bool isPlaying() const override;
0033     QImage screenShoot() override;
0034     void relativeSeek(int msec) override;
0035     void restart() override;
0036 
0037 public Q_SLOTS:
0038     void updateInterface();
0039     void changeVolume(int newVolume);
0040     void setPosition(int newPosition);
0041 
0042     void playPause() override;
0043     void stop() final override;
0044     void rotate(const DB::ImageInfoPtr &info) override;
0045 
0046 protected:
0047     bool setImageImpl(DB::ImageInfoPtr info, bool forward) override;
0048 
0049 private:
0050     void releaseVLC();
0051     void setupVLC();
0052 
0053     QWidget *m_videoWidget = nullptr;
0054     class VideoToolBar *m_videoToolBar = nullptr;
0055     QTimer *m_poller = nullptr;
0056     libvlc_instance_t *m_vlcInstance = nullptr;
0057     libvlc_media_player_t *m_player = nullptr;
0058     libvlc_media_t *m_media = nullptr;
0059 };
0060 
0061 } // namespace Viewer