Video record function added
[mardrone] / mardrone / dronelib / video.h
index 3469cf0..526bb8b 100644 (file)
@@ -23,23 +23,7 @@ void vp_stages_YUV420P_to_ARGB32(void *cfg, vp_api_picture_t *picture, uint8_t *
 
 
 class VideoThread;
-
-class DroneVideo:public QGraphicsWidget
-{
-    Q_OBJECT
-public:
-    DroneVideo();
-    void paint(QPainter *painter,const QStyleOptionGraphicsItem *option,
-                    QWidget *widget);
-    QRectF boundingRect() const;
-
-private:
-    QHostAddress droneHost;  // Ip address of the drone
-    VideoThread *videoThread;
-    QImage *image;
-    int depth;
-    bool initialized;
-};
+class DroneVideo;
 
 class VideoThread:public QThread {
     Q_OBJECT
@@ -50,9 +34,19 @@ public:
     void run();
     void sendVideoPort(QString cmd);
     void decodeTransform(QByteArray &videoData);
+    unsigned int getFrameSeq();
+    bool getVideoRec();
+    bool getVideoPlay();
+    QString getVideoFileName();
+    void setVideoFileName(QString name);
 
+signals:
+    void frameSeqChanged();
 public slots:
     void videoDataReady();
+    void setVideoRec(bool rec);
+
+    void setVideoPlay(bool play);
     void timer();
 
 
@@ -64,6 +58,11 @@ private:
     int pictureWidth;
     int pictureHeight;
     bool luma_only;
+    bool videoRec;
+    bool videoPlay;
+    QFile *videoFile;
+    QString videoFileName;
+    unsigned int frameSeq;
     unsigned int num_picture_decoded;
     QHostAddress droneHost;  // Ip address of the drone
     QTimer *stateTimer;
@@ -73,4 +72,47 @@ private:
 
 };
 
+class DroneVideo:public QGraphicsWidget
+{
+    Q_OBJECT
+public:
+
+    DroneVideo();
+    void paint(QPainter *painter,const QStyleOptionGraphicsItem *option,
+                    QWidget *widget);
+    QRectF boundingRect() const;
+    Q_PROPERTY(QImage* idleImage READ idleImage WRITE setIdleImage )
+    Q_PROPERTY(bool recVideo READ recVideo WRITE setRecVideo )
+    Q_PROPERTY(bool playVideo READ playVideo WRITE setPlayVideo )
+    Q_PROPERTY(QString videoFileName READ videoFileName WRITE setVideoFileName NOTIFY frameSeqChanged)
+    Q_PROPERTY(unsigned int  frameSeq READ frameSeq NOTIFY frameSeqChanged)
+
+
+    QImage* idleImage(); void setIdleImage(QImage *);
+    void setRecVideo(bool val_) { if(videoThread) videoThread->setVideoRec(val_);};
+    bool recVideo() {return videoThread ? videoThread->getVideoRec():false;};
+
+    void setPlayVideo(bool val_) { if(videoThread) videoThread->setVideoPlay(val_);};
+    bool playVideo() {return videoThread ? videoThread->getVideoPlay():false;};
+
+    int  frameSeq() {return videoThread ? videoThread->getFrameSeq():0;};
+
+    QString videoFileName() const { return videoThread ? videoThread->getVideoFileName():"";};
+    void setVideoFileName(const QString &name_) {if(videoThread) videoThread->setVideoFileName(name_);}
+signals:
+    void frameSeqChanged();
+
+public slots:
+    void frameSeqUpdated();
+private:
+    QHostAddress droneHost;  // Ip address of the drone
+
+    VideoThread *videoThread;
+    QImage *image;
+    QImage *m_idleImage;
+    int depth;
+    bool initialized;
+};
+
+
 #endif // VIDEO_H