0.2 version add desktop components multitouch, joystick, multicast
[mardrone] / mardrone / dronelib / video.h
1 #ifndef VIDEO_H
2 #define VIDEO_H
3
4 #include <QGraphicsWidget>
5 #include <QGraphicsItem>
6 #include <QPainter>
7 #include <QUdpSocket>
8 #include <QTcpSocket>
9 #include <QThread>
10 #include <QTimer>
11 #include "dronecontrol.h"
12 #undef _GNU_SOURCE // just get rid of error message double definition
13 #define TARGET_CPU_ARM 1
14 #include <navdata.h>
15 #include <VP_Os/vp_os_malloc.h>
16 #include <VP_Os/vp_os_print.h>
17 extern "C"
18 {
19 #include <VLIB/Stages/vlib_stage_decode.h>
20 void vp_stages_YUV420P_to_RGB565(void *cfg, vp_api_picture_t *picture, uint8_t *dst, uint32_t dst_rbytes);
21 void vp_stages_YUV420P_to_ARGB32(void *cfg, vp_api_picture_t *picture, uint8_t *dst, uint32_t dst_rbytes);
22 }
23
24
25 class VideoThread;
26
27 class DroneVideo:public QGraphicsWidget
28 {
29     Q_OBJECT
30 public:
31     DroneVideo();
32     void paint(QPainter *painter,const QStyleOptionGraphicsItem *option,
33                     QWidget *widget);
34     QRectF boundingRect() const;
35
36 private:
37     QHostAddress droneHost;  // Ip address of the drone
38     VideoThread *videoThread;
39     QImage *image;
40     int depth;
41     bool initialized;
42 };
43
44 class VideoThread:public QThread {
45     Q_OBJECT
46 public:
47     VideoThread(DroneVideo *parentp,QHostAddress host,QImage *_image);
48
49  //   ~DroneThread ();
50     void run();
51     void sendVideoPort(QString cmd);
52     void decodeTransform(QByteArray &videoData);
53
54 public slots:
55     void videoDataReady();
56     void timer();
57
58
59
60 private:
61     QImage *image;
62     video_controller_t controller;
63     vp_api_picture_t picture;
64     int pictureWidth;
65     int pictureHeight;
66     bool luma_only;
67     unsigned int num_picture_decoded;
68     QHostAddress droneHost;  // Ip address of the drone
69     QTimer *stateTimer;
70     volatile bool stopped;
71     DroneVideo *parent;
72     QUdpSocket *videoSock;  // Navigation data receive socket port 5554
73
74 };
75
76 #endif // VIDEO_H