]> git.sesse.net Git - nageru/blob - jpeg_frame_view.h
Actually send the MJPEG frames on to the HTTP stream.
[nageru] / jpeg_frame_view.h
1 #ifndef _JPEG_FRAME_VIEW_H
2 #define _JPEG_FRAME_VIEW_H 1
3
4 #include <epoxy/gl.h>
5 #include <QGLWidget>
6
7 #include <stdint.h>
8
9 #include <movit/effect_chain.h>
10 #include <movit/ycbcr_input.h>
11
12 #include <memory>
13
14 std::string filename_for_frame(unsigned stream_idx, int64_t pts);
15
16 struct Frame {
17         std::unique_ptr<uint8_t[]> y, cb, cr;
18         unsigned width, height;
19         unsigned chroma_subsampling_x, chroma_subsampling_y;
20         unsigned pitch_y, pitch_chroma;
21 };
22
23 class JPEGFrameView : public QGLWidget {
24         Q_OBJECT
25
26 public:
27         JPEGFrameView(QWidget *parent);
28
29         void setFrame(unsigned stream_idx, int64_t pts)
30         {
31                 this->stream_idx = stream_idx;
32                 this->pts = pts;
33                 update_frame();
34         }
35
36         unsigned get_stream_idx() const { return stream_idx; }
37
38         void setDecodedFrame(std::shared_ptr<Frame> frame);
39
40 protected:
41         void initializeGL() override;
42         void resizeGL(int width, int height) override;
43         void paintGL() override;
44
45 private:
46         void update_frame();
47
48         unsigned stream_idx;
49         int64_t pts;
50
51         std::unique_ptr<movit::EffectChain> chain;
52         std::shared_ptr<Frame> current_frame;  // So that we hold on to the pixels.
53         movit::YCbCrInput *ycbcr_input;
54         movit::YCbCrFormat ycbcr_format;
55 };
56
57 #endif  // !defined(_JPEG_FRAME_VIEW_H)