VideoWidget.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /// VideoWidget.h
  2. #ifndef __VIDEOWIDGET_H__
  3. #define __VIDEOWIDGET_H__
  4. #include <QtWidgets>
  5. #include <QMutex>
  6. #include "PaintGaze.h"
  7. #include "MediaPlayer.h"
  8. #include "EquirectangularToFovVideo.h"
  9. // Forward declare
  10. class Arff;
  11. class VideoWidget : public QWidget
  12. {
  13. Q_OBJECT
  14. signals:
  15. void SendTime(int time);
  16. ///< emits the time shift from m_qMediaplayer in us.
  17. public slots:
  18. void HandleTime(int time, QObject *pSender);
  19. ///< Handles the signal for changing the position on the video.
  20. void HandleToggleView();
  21. ///< It toggles the displayed video if FOV data are available
  22. private slots:
  23. void HandleTimeChanged(qint64 time);
  24. ///< Takes care of hadling the signal from m_qMediaPlayer and transmits it
  25. ///< as being its own.
  26. public:
  27. VideoWidget(QWidget *parent=0);
  28. ~VideoWidget();
  29. QSize minimumSizeHint() const Q_DECL_OVERRIDE;
  30. void SetCurrentTime(int currentTime);
  31. ///< Sets the time of the video in us.
  32. bool SetMedia(QString pathToFile);
  33. ///< Sets media to the provided local path.
  34. void SetGazePaint(PaintGaze *pPaintGaze);
  35. void Play();
  36. ///< Starts playing video.
  37. void Pause();
  38. ///< Pauses video.
  39. void TogglePlayer();
  40. ///< Toggles the state of the video from stopped to playing.
  41. qint64 Duration();
  42. ///< Returns the video duration in us.
  43. ///< \b Available only after starting playing the video.
  44. void ConvertToFov(Arff *pArff);
  45. ///< By calling this function we signal that the video should be converted
  46. ///< from 360 degrees equirectangular to field of view.
  47. protected:
  48. void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
  49. ///< Called on update(), repaint() and then passes painter to surface in order to paint.
  50. void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
  51. ///< Update area on resize.
  52. private:
  53. MediaPlayer m_mediaPlayer;
  54. PaintGaze *m_pPaintGaze; // pointer to gaze painter
  55. EquirectangularToFovVideo *m_pEqToFov;
  56. qint64 m_previousTime;
  57. bool m_isPaused; // used for correcting time offset when pausing
  58. QMutex m_mutex; // mutex for updating QMediaPlayer time
  59. bool m_toggled; // toggle the diplayed frame
  60. };
  61. #endif /*__MEDIAPLAYER_H__*/