]> git.sesse.net Git - nageru/blob - h264encode.h
Make the locut filter possible to disable.
[nageru] / h264encode.h
1 // Hardware H.264 encoding via VAAPI. Heavily modified based on example
2 // code by Intel. Intel's original copyright and license is reproduced below:
3 //
4 // Copyright (c) 2007-2013 Intel Corporation. All Rights Reserved.
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the
8 // "Software"), to deal in the Software without restriction, including
9 // without limitation the rights to use, copy, modify, merge, publish,
10 // distribute, sub license, and/or sell copies of the Software, and to
11 // permit persons to whom the Software is furnished to do so, subject to
12 // the following conditions:
13 // 
14 // The above copyright notice and this permission notice (including the
15 // next paragraph) shall be included in all copies or substantial portions
16 // of the Software.
17 // 
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 // IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
22 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26 #ifndef _H264ENCODE_H
27 #define _H264ENCODE_H
28
29 #include <epoxy/gl.h>
30 #include <stdint.h>
31 #include <atomic>
32 #include <memory>
33 #include <vector>
34
35 #include "ref_counted_frame.h"
36 #include "ref_counted_gl_sync.h"
37
38 class H264EncoderImpl;
39 class HTTPD;
40 class QSurface;
41
42 // This is just a pimpl, because including anything X11-related in a .h file
43 // tends to trip up Qt. All the real logic is in H264EncoderImpl, defined in the
44 // .cpp file.
45 class H264Encoder {
46 public:
47         H264Encoder(QSurface *surface, int width, int height, HTTPD *httpd);
48         ~H264Encoder();
49
50         void add_audio(int64_t pts, std::vector<float> audio);
51         bool begin_frame(GLuint *y_tex, GLuint *cbcr_tex);
52         void end_frame(RefCountedGLsync fence, int64_t pts, const std::vector<RefCountedFrame> &input_frames);
53         void shutdown();  // Blocking.
54
55 private:
56         std::unique_ptr<H264EncoderImpl> impl;
57 };
58
59 #endif