]> git.sesse.net Git - nageru/blobdiff - main.cpp
Import a bunch of http/mux code from Nageru.
[nageru] / main.cpp
index d916f44819841b105a80dfba6e3b5b2bf7d2d6e6..e8c0dc4ac1fe7e6769dea0b98377b29729c137b1 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -20,6 +20,7 @@ extern "C" {
 #include "defs.h"
 #include "mainwindow.h"
 #include "ffmpeg_raii.h"
+#include "httpd.h"
 #include "player.h"
 #include "post_to_main_thread.h"
 #include "ui_mainwindow.h"
@@ -39,15 +40,40 @@ string filename_for_frame(unsigned stream_idx, int64_t pts)
 
 mutex frame_mu;
 vector<int64_t> frames[MAX_STREAMS];
+QGLWidget *global_share_widget;
+HTTPD *global_httpd;
 
 int record_thread_func();
 
 int main(int argc, char **argv)
 {
-       av_register_all();
        avformat_network_init();
+       global_httpd = new HTTPD;
+       global_httpd->start(DEFAULT_HTTPD_PORT);
+
+       QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
+
+       QSurfaceFormat fmt;
+       fmt.setDepthBufferSize(0);
+       fmt.setStencilBufferSize(0);
+       fmt.setProfile(QSurfaceFormat::CoreProfile);
+       fmt.setMajorVersion(3);
+       fmt.setMinorVersion(1);
+
+       // Turn off vsync, since Qt generally gives us at most frame rate
+       // (display frequency) / (number of QGLWidgets active).
+       fmt.setSwapInterval(0);
+
+       QSurfaceFormat::setDefaultFormat(fmt);
+
+       QGLFormat::setDefaultFormat(QGLFormat::fromSurfaceFormat(fmt));
 
        QApplication app(argc, argv);
+       global_share_widget = new QGLWidget();
+       if (!global_share_widget->isValid()) {
+               fprintf(stderr, "Failed to initialize OpenGL. Futatabi needs at least OpenGL 3.1 to function properly.\n");
+               exit(1);
+       }
        MainWindow mainWindow;
        mainWindow.show();