VideoPlayer.h 3.22 KB
#ifndef PLAYER_H
#define PLAYER_H

#include <QWidget>
#include <QMediaPlayer>
#include <QLabel>
#include <QVideoProbe>
#include <QVideoFrame>

#include <armadillo>

#include "VignetteWidget.h"
#include "VideoWidget.h"
#include "PlayerControls.h"
#include "MovieMonitor.h"
#include "Segment.h"

class VideoPlayer: public QWidget
{
  Q_OBJECT

 public:
  VideoPlayer(int nVignettes = 5, QWidget *parent = 0);
  ~VideoPlayer();
  void reset();

  public slots:
  void setPlayer(const QString &fName, const QSize &resolution);
  void setPlayerPosition(qint64 position);
  void positionChanged(qint64 position);
  void stateChanged(QMediaPlayer::State state);
  void positionManuallyChanged(qint64 position);
  void activeHisto(bool dispHisto);
  void currentShot(QList<qint64> positionList);
  void showVignette(bool showed);
  void displaySubtitle(const QString &subtitle);
  void showSegmentation(bool checked, bool annot);
  void viewUtteranceTree(bool checked);
  void setDiarData(const arma::mat &E, const arma::mat &Sigma, const arma::mat &W);
  void getCurrentPattern(const QList<QPair<int, qreal>> &subFeatures);
  void getPatternFirstShot(const QList<QPair<int, qreal>> &subFeatures);
  void getPatternSecondShot(const QList<QPair<int, qreal>> &subFeatures);
  void viewSpeakers(bool checked);
  void getShot(Segment *shot);
  void segmentationRetrieved();
  void getSpokenFrame(qint64 position, const QString &text, const QString &speaker);
  void playSegments(QList<QPair<qint64, qint64>> utterances);
  void setSpeaker(qint64 start, qint64 end, const QString &speaker, VideoFrame::SpeakerSource source);
  void resetSpeaker(qint64 prevStart, qint64 prevEnd, qint64 start, qint64 end, bool sub, VideoFrame::SpeakerSource source);
  void speakersRetrieved(QList<QString> speakers);
  void playSubtitle(QList<int> utter);
  void currentSubtitle(int subIdx);

 signals:
  void positionUpdated(qint64 position);
  void showHisto(bool dispHist);
  void updateVignette(QList<qint64> positionList);
  void playerPaused(bool pause);
  void viewSegmentation(bool checked, bool annot);
  void showUtteranceTree(bool checked);
  void initDiarData(const arma::mat &E, const arma::mat &Sigma, const arma::mat &W);
  void grabCurrentPattern(const QList<QPair<int, qreal>> &subFeatures);
  void grabPatternFirstShot(const QList<QPair<int, qreal>> &subFeatures);
  void grabPatternSecondShot(const QList<QPair<int, qreal>> &subFeatures);
  void showSpeakers(bool checked);
  void grabShot(Segment *shot);
  void grabSpokenFrame(qint64 position, const QString &text, const QString &speaker);
  void segmentationGrabbed();
  void newSpeaker(qint64 start, qint64 end, const QString &speaker, VideoFrame::SpeakerSource source);
  void renewSpeaker(qint64 prevStart, qint64 prevEnd, qint64 start, qint64 end, bool resetSub, VideoFrame::SpeakerSource source);
  void speakersGrabbed(QList<QString> speakers);
  void playSub(QList<int> utter);
  void currSubtitle(int subIdx);
  void releasePos(bool released);

 private:
  QMediaPlayer *m_player;
  QLabel *m_defaultLabel;
  VignetteWidget *m_vignetteWidget;
  VideoWidget *m_videoWidget;
  QLabel *m_subLabel;
  PlayerControls *m_controls;
  MovieMonitor *m_movieMonitor;
  QVideoProbe *m_probe;
  QList<QPair<qint64, qint64>> m_segments;
  int m_segIdx;
};

#endif