Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finally merging everyting together, thanks @buldo for your windows work #732

Merged
merged 26 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d569209
Using geodesic.h from repo
buldo Nov 30, 2024
2091286
make linux work again ;)
raphaelscholle Dec 1, 2024
0afe727
revert windows gstreamer until it works
raphaelscholle Dec 1, 2024
a6e0bb9
revert more windows stuff for now
raphaelscholle Dec 1, 2024
51832fe
Update MavlinkChoiceElement2.qml
raphaelscholle Dec 1, 2024
d5b66cc
Update MavlinkChoiceElement.qml
raphaelscholle Dec 1, 2024
65baa40
Scheduling hotfix
buldo Dec 1, 2024
91f87ac
windows build
buldo Dec 1, 2024
cd77627
How to
buldo Dec 1, 2024
2e72a60
Update QOpenHD.pro
raphaelscholle Dec 8, 2024
07f00b5
Update gst_video.pri
raphaelscholle Dec 29, 2024
dc7e3e9
Update UDPReceiver.cpp
raphaelscholle Dec 29, 2024
24d42c2
Revert "Update UDPReceiver.cpp"
raphaelscholle Dec 29, 2024
13526f8
Update UDPReceiver.cpp
raphaelscholle Dec 29, 2024
38438a1
Update UDPReceiver.cpp
raphaelscholle Dec 29, 2024
9640d7e
Update UDPReceiver.cpp
raphaelscholle Dec 29, 2024
40640d6
Update UDPReceiver.cpp
raphaelscholle Dec 29, 2024
02889db
Update UDPReceiver.cpp
raphaelscholle Dec 29, 2024
8b7a2d1
Update texturerenderer.cpp
raphaelscholle Dec 29, 2024
527a653
Update avcodec_video.pri
raphaelscholle Dec 29, 2024
290d51e
Update avcodec_video.pri
raphaelscholle Dec 29, 2024
e8b4cbd
Update avcodec_video.pri
raphaelscholle Dec 29, 2024
758e0da
Update avcodec_video.pri
raphaelscholle Dec 29, 2024
8444c40
Update avcodec_video.pri
raphaelscholle Dec 29, 2024
7b31859
Merge branch 'merge_attempt4' into 2.6-evo
raphaelscholle Dec 29, 2024
fcc54c2
Update gst_video.pri
raphaelscholle Dec 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions QOpenHD.pro
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ CONFIG(debug, debug|release) {
} else:CONFIG(release, debug|release) {
DEFINES += QT_NO_DEBUG
CONFIG += installer
CONFIG += force_debug_info
DESTDIR = $${OUT_PWD}/release
DEFINES += QMLJSDEBUGGER
}
Expand Down Expand Up @@ -103,6 +102,12 @@ LinuxBuild {
include(app/videostreaming/gstreamer/gst_video.pri)
}

# gst Qt plugins in windows is hard
WindowsBuild {
# In future is better to use windows decoding and rendering api
include(app/videostreaming/avcodec/avcodec_video.pri)
}

# All Generic files / files that literally have 0!! dependencies other than qt
SOURCES += \
app/adsb/adsbvehicle.cpp \
Expand All @@ -125,6 +130,7 @@ HEADERS += \
app/common/util_fs.h \
app/common/StringHelper.hpp \
app/common/TimeHelper.hpp \
app/common/SchedulingHelper.hpp \
app/logging/hudlogmessagesmodel.h \
app/logging/loghelper.h \
app/logging/logmessagesmodel.h \
Expand Down Expand Up @@ -234,17 +240,6 @@ JetsonBuild {
WindowsBuild {
# This aparently makes qt use absolute paths, otherwise we get compile issues ?
QMAKE_PROJECT_DEPTH = 0
#include(app/videostreaming/gstreamer/gst_video.pri)
#include(app/videostreaming/avcodec/avcodec_video.pri)
# Path to FFmpeg headers
# INCLUDEPATH += C:/ffmpeg
#INCLUDEPATH += C:/ffmpeg/libavutil/

# Path to FFmpeg libraries
#LIBS += -LC:/ffmpeg/lib

# Link against the required FFmpeg libraries
#LIBS += -lavcodec -lavformat -lavutil -lswscale -lswresample
}

AndroidBuild {
Expand Down
10 changes: 10 additions & 0 deletions README.windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
How to:
1. Create folder `build-libs-windows` in repository root
2. Download and extract `ffmpeg-release-full-shared.7z` into `build-libs-windows` ( from https://www.gyan.dev/ffmpeg/builds/ )
Maybe it will be good idea to fix version and put this version in download script
3. Rename extracted folder to `ffmpeg`. Chech that `ffmpeg` folder contains `bin`, `include`, etc. folders.
4. Trying to use prebuild angle from https://github.com/mmozeiko/build-angle
Download latest release and extract to `build-libs-windows`.
Maybe it better to clone/adjust this build pipeline

5. After build you need to copy `bin` folders content to folder with `.exe`
28 changes: 8 additions & 20 deletions app/common/SchedulingHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,29 @@
#define WIFIBROADCAST_SCHEDULINGHELPER_H

#include <pthread.h>
#include <sys/resource.h>
#include <unistd.h>
#include <string>
#include <iostream>
#include <qdebug.h>
#ifdef __windows__
#include <windows.h>
#endif

namespace SchedulingHelper {

static void printCurrentThreadPriority(const std::string& name) {
int which = PRIO_PROCESS;
id_t pid = (id_t) getpid();
int priority = getpriority(which, pid);
//wifibroadcast::log::get_default()->debug("{} has priority {}",name,priority);
}

static void printCurrentThreadSchedulingPolicy(const std::string& name) {
auto self = pthread_self();
int policy;
sched_param param{};
auto result = pthread_getschedparam(self, &policy, &param);
if (result != 0) {
qDebug()<<"Cannot get thread scheduling policy";
}
//wifibroadcast::log::get_default()->debug("{} has policy {} and priority {}",name,policy,param.sched_priority);
}

// this thread should run as close to realtime as possible
static void setThreadParamsMaxRealtime(pthread_t target) {
int policy = SCHED_FIFO;

// TODO: windows.h contains THREAD_PRIORITY_TIME_CRITICAL but not working
#ifndef __windows__
int policy = SCHED_FIFO;
sched_param param{};
param.sched_priority = sched_get_priority_max(policy);
auto result = pthread_setschedparam(target, policy, &param);
if (result != 0) {
qDebug()<<"cannot set ThreadParamsMaxRealtime";
}
#endif
}

static void setThreadParamsMaxRealtime() {
Expand Down
4 changes: 4 additions & 0 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ static void android_check_permissions(){

int main(int argc, char *argv[]) {

#if defined(__windows__)
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif

QCoreApplication::setOrganizationName("OpenHD");
QCoreApplication::setOrganizationDomain("openhd");
QCoreApplication::setApplicationName("QOpenHD");
Expand Down
2 changes: 1 addition & 1 deletion app/telemetry/tutil/geodesi_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <QtGlobal>

extern "C" {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) || defined(Q_OS_WIN)
#include "lib/geographiclib-c-2.0/src/geodesic.h"
#else
#include "geodesic.h"
Expand Down
3 changes: 1 addition & 2 deletions app/videostreaming/avcodec/avcodec_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ extern "C" {
#include <libavutil/imgutils.h>
#include <libavutil/buffer.h>
#include <libavutil/frame.h>
//
#include "libavutil/frame.h"
#include <libavutil/mem.h>
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_drm.h"
#include "libavutil/pixdesc.h"
Expand Down
12 changes: 12 additions & 0 deletions app/videostreaming/avcodec/avcodec_video.pri
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ LIBS += -LC:/ffmpeg/lib -lavcodec -lavutil -lavformat
# TODO dirty
LIBS += -lGLESv2 -lEGL

win32 {
INCLUDEPATH += $$PWD/../../../build-libs-windows/ffmpeg/include
LIBS += -L$$PWD/../../../build-libs-windows/ffmpeg/lib -lavcodec -lavutil -lavformat

INCLUDEPATH += $$PWD/../../../build-libs-windows/angle-x64/include
LIBS += -L$$PWD/../../../build-libs-windows/angle-x64/bin -lGLESv2 -lEGL

DEFINES += EGL_EGLEXT_PROTOTYPES
DEFINES += GL_GLEXT_PROTOTYPES
# LIBS += -lOpengl32
}

# just using the something something webrtc from stephen was the easiest solution.
#include(../../lib/h264/h264.pri)

Expand Down
22 changes: 14 additions & 8 deletions app/videostreaming/avcodec/color_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@
#include <cstdint>

static uint32_t create_pixel_rgba(uint8_t r,uint8_t g,uint8_t b,uint8_t a){
uint8_t rgba[4];
rgba[0]=r;
rgba[1]=g;
rgba[2]=b;
rgba[3]=a;
uint32_t ret;
memcpy(&ret,rgba,4);
return ret;
#ifdef __windows__
return ((uint32_t)a << 24) | ((uint32_t)b << 16) | ((uint32_t)g << 8) | (uint32_t)r;
#else
uint8_t rgba[4];
rgba[0]=r;
rgba[1]=g;
rgba[2]=b;
rgba[3]=a;
uint32_t ret;
memcpy(&ret,rgba,4);
return ret;
#endif


}

// --------------------------------------------------- from drm-howto ---------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions app/videostreaming/avcodec/gl/gl_shaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ static const GLchar* fragment_shader_source_NV12 =
" texture2D(s_texture_uv,v_texCoord).xy\n"
" );"
" mat3 colorMatrix = mat3(\n"
" 1.1644f, 1.1644f, 1.1644f,\n"
" 0.0f, -0.3917f, 2.0172f,\n"
" 1.5960f, -0.8129f, 0.0f"
" 1.1644, 1.1644, 1.1644,\n"
" 0.0, -0.3917, 2.0172,\n"
" 1.5960, -0.8129, 0.0"
" );\n"
" gl_FragColor = vec4(clamp(YCbCr*colorMatrix,0.0,1.0), 1.0);\n"
"}\n";
Expand Down
12 changes: 9 additions & 3 deletions app/videostreaming/avcodec/gl/gl_videorenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
#include "gl_videorenderer.h"
#include "../color_helper.h"
#include <GL/gl.h>
#include <EGL/eglext.h>
#include <GLES2/gl2ext.h>
#include <chrono>
#include "../avcodec_helper.hpp"
#include <libavutil/error.h>
#include <vector>

static EGLint texgen_attrs[] = {
EGL_DMA_BUF_PLANE0_FD_EXT,
Expand Down Expand Up @@ -34,9 +39,10 @@ static void create_rgba_texture(GLuint& tex_id,uint32_t color_rgba){
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
const int width=1280;
const int height=720;
uint8_t pixels[4*width*height];
fillFrame(pixels,width,height,width*4, color_rgba);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
std::vector<uint8_t> pixels(4*width*height);

fillFrame(pixels.data(), width, height, width*4, color_rgba);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
glBindTexture(GL_TEXTURE_2D,0);
}

Expand Down
7 changes: 6 additions & 1 deletion app/videostreaming/avcodec/gl/glhelp.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef GLHELP_H
#define GLHELP_H

extern "C" {
#include <EGL/egl.h>
#include <EGL/eglext.h>
// Crude hack for QT on the rpi. Fucking hell, how annyoing this QT crap with redefining opengl is !
Expand All @@ -11,12 +12,14 @@

//#include <GLES3/gl32.h>
//#include <GLES3/gl3ext.h>

}
#include <cassert>

/// Some gl extensions that don't seem to be part of raspberry gl.
/// I think you could get these from other places like GLAD or libepoxy.
///

#ifndef __windows__
EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) __attribute__((weak)); // May not be in libEGL symbol table, resolve manually :(
EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
{
Expand Down Expand Up @@ -61,6 +64,8 @@ void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
}
imageTargetTexture2DOES(target, image);
}

#endif
/// END Gl Extensions --------------------------------------------------


Expand Down
Loading
Loading