Skip to content

Commit

Permalink
Few fixes + audio playback (#667)
Browse files Browse the repository at this point in the history
* QT 6

* document audio

* QT 6

* experiment - add audio

* experiment - add audio

* fix ip check

* fix ip check

* fix ip check

* fix ip check

* update gst location

* update gst version

* update gst version

* back to 1,20.5

* alaw

* lgstalaw

* exp autoaudiosrc

* exp autoaudiosrc

* alaw and audio

* register plugins

* weird

* fix

* add gstautoetect

* weird

* weird

* so no alaw
  • Loading branch information
Consti10 authored Feb 28, 2024
1 parent 1cf1255 commit 9f44f12
Show file tree
Hide file tree
Showing 21 changed files with 153 additions and 283 deletions.
6 changes: 0 additions & 6 deletions QOpenHD.pro
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,6 @@ DISTFILES += \
android/res/values/libs.xml \
android/res/values/styles.xml \
android/src/QOpenHDActivity.java \
android/src/SurfaceTextureListener.java \
android/src/org/freedesktop/gstreamer/androidmedia/GstAhcCallback.java \
android/src/org/freedesktop/gstreamer/androidmedia/GstAhsCallback.java \
android/src/org/freedesktop/gstreamer/androidmedia/GstAmcOnFrameAvailableListener.java \
android/src/org/openhd/IsConnected.java \
android/src/org/openhd/LiveVideoPlayerWrapper.java \
qml/qtquickcontrols2.conf \
qml/ui/qmldir \

Expand Down
2 changes: 1 addition & 1 deletion android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<manifest package="com.openhd.openhd" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="v16" android:versionCode="16" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33"/>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31"/>

<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
Expand Down
173 changes: 0 additions & 173 deletions android/src/org/openhd/IsConnected.java

This file was deleted.

49 changes: 0 additions & 49 deletions android/src/org/openhd/LiveVideoPlayerWrapper.java

This file was deleted.

3 changes: 0 additions & 3 deletions android/src/org/openhd/QOpenHDActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import android.widget.RelativeLayout;
// Custom video surface end

import org.openhd.IsConnected;

public class QOpenHDActivity extends QtActivity {
private static QOpenHDActivity _instance = null;

Expand All @@ -39,7 +37,6 @@ public static void jniOnLoad() {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
IsConnected.m_stored_context= this;

// Init surface
/*surfaceView = new SurfaceView(this);
Expand Down
19 changes: 10 additions & 9 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
#include <QFontDatabase>
#if defined(__android__)
#include <QtAndroid>
const QVector<QString> permissions({"android.permission.INTERNET",
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.ACCESS_NETWORK_STATE",
"android.permission.ACCESS_FINE_LOCATION"});
#endif

#include "telemetry/models/fcmavlinksystem.h"
Expand Down Expand Up @@ -48,13 +43,13 @@ const QVector<QString> permissions({"android.permission.INTERNET",
#ifdef QOPENHD_ENABLE_GSTREAMER_QMLGLSINK
#include "videostreaming/gstreamer/gst_helper.hpp"
#include "videostreaming/gstreamer/gstqmlglsinkstream.h"
#include "videostreaming/gstreamer/gstrtpaudioplayer.h"
#endif //QOPENHD_ENABLE_GSTREAMER_QMLGLSINK
#ifdef QOPENHD_ENABLE_VIDEO_VIA_ANDROID
#include <videostreaming/android/qandroidmediaplayer.h>
#include <videostreaming/android/qsurfacetexture.h>
#endif
#include "videostreaming/vscommon/QOpenHDVideoHelper.hpp"
#include "videostreaming/vscommon/audio_playback.h"
// Video end

#include "util/qrenderstats.h"
Expand Down Expand Up @@ -183,6 +178,11 @@ static void write_platform_context_properties(QQmlApplicationEngine& engine){

static void android_check_permissions(){
#if defined(__android__)
const QVector<QString> permissions({"android.permission.INTERNET",
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.ACCESS_NETWORK_STATE",
"android.permission.ACCESS_FINE_LOCATION"});
qDebug()<<"Android request permissions";
for(const QString &permission : permissions) {
auto result = QtAndroid::checkPermission(permission);
Expand Down Expand Up @@ -354,6 +354,8 @@ int main(int argc, char *argv[]) {
auto adsbVehicleManager = ADSBVehicleManager::instance();
engine.rootContext()->setContextProperty("AdsbVehicleManager", adsbVehicleManager);
adsbVehicleManager->onStarted();
// video - a bit special
engine.rootContext()->setContextProperty("_decodingStatistics",&DecodingStatistcs::instance());

// And then the main part
engine.rootContext()->setContextProperty("_mavlinkTelemetry", &MavlinkTelemetry::instance());
Expand Down Expand Up @@ -397,11 +399,9 @@ int main(int argc, char *argv[]) {
#else
engine.rootContext()->setContextProperty("QOPENHD_ENABLE_VIDEO_VIA_ANDROID", QVariant(false));
#endif
//GstRtpAudioPlayer::instance().start_playing();
platform_start_audio_streaming_if_enabled();
// Platform - dependend video end -----------------------------------------------------------------

engine.rootContext()->setContextProperty("_decodingStatistics",&DecodingStatistcs::instance());

// This allows to use the defines as strings in qml
engine.rootContext()->setContextProperty("QOPENHD_GIT_VERSION",
#ifdef QOPENHD_GIT_VERSION
Expand Down Expand Up @@ -443,5 +443,6 @@ int main(int argc, char *argv[]) {
// Terminating needs a bit of special care due to the singleton usage and threads
qDebug()<<"Terminating";
MavlinkTelemetry::instance().terminate();
platform_audio_terminate();
return retval;
}
5 changes: 1 addition & 4 deletions app/telemetry/MavlinkTelemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,8 @@ void MavlinkTelemetry::change_telemetry_connection_mode(int mavlink_connection_m
m_connection_mode=mavlink_connection_mode;
}

bool MavlinkTelemetry::change_manual_tcp_ip(QString ip)
void MavlinkTelemetry::change_manual_tcp_ip(QString ip)
{
if(!QOpenHD::instance().is_valid_ip(ip)){
return false;
}
threadsafe_set_manual_tcp_ip(ip.toStdString());
}

Expand Down
2 changes: 1 addition & 1 deletion app/telemetry/MavlinkTelemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class MavlinkTelemetry : public QObject
Q_INVOKABLE void re_apply_rates();
// Change the conenction mode
Q_INVOKABLE void change_telemetry_connection_mode(int mode);
Q_INVOKABLE bool change_manual_tcp_ip(QString ip);
Q_INVOKABLE void change_manual_tcp_ip(QString ip);
public:
// A couple of stats exposed as QT properties
L_RO_PROP(int,telemetry_pps_in,set_telemetry_pps_in,-1)
Expand Down
7 changes: 6 additions & 1 deletion app/telemetry/settings/documentedparam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,12 @@ static std::vector<std::shared_ptr<XParam>> get_parameters_list(){
append_only_documented(ret,"RC_UPDATE_HZ",
"Specify the update rate of RC over wifibroadcast. A higher update rate gives lower RC latency, but takes more bandwidth away from the downlink."
"No effect if joy rc is disabled.");

}
{
append_int(ret,"AUDIO_ENABLE",
ImprovedIntSetting::createEnumEnableDisable(),
"enables / disables audio streaming from air to ground. In development. Enabling automatically restarts the air unit !"
);
}
return ret;
}
Expand Down
2 changes: 0 additions & 2 deletions app/telemetry/telemetry.pri
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
INCLUDEPATH += $$PWD

#INCLUDEPATH += $$PWD/../../lib/mavlink-headers

SOURCES += \
$$PWD/action/impl/cmdsender.cpp \
$$PWD/action/fcaction.cpp \
Expand Down
12 changes: 4 additions & 8 deletions app/util/qopenhd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QDebug>
#include <qapplication.h>
#include <QTimer>
#include <QHostAddress>

#include<iostream>
#include <sys/stat.h>
Expand Down Expand Up @@ -308,14 +309,9 @@ void QOpenHD::sysctl_openhd(int task)

bool QOpenHD::is_valid_ip(QString ip)
{
#ifdef __windows__
//TODO fix windows
return true;
#else
// TODO
return true;

#endif
QHostAddress addr;
bool valid=addr.setAddress(ip);
return valid;
}

bool QOpenHD::is_platform_rpi()
Expand Down
Loading

0 comments on commit 9f44f12

Please sign in to comment.