summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-08-20 18:11:27 -0500
committerTimothy Pearson <tpearson@raptorengineering.com>2019-03-17 00:34:02 -0500
commita2d4f91ed24ea8ac78e3af1fd05f30f8cc7766df (patch)
treec0e8c61973b1773ac6d6272546026f3b04e30087
parenta3c2cb3bb2596f6461a317fce9fc87b47c596d2f (diff)
downloadxrdp-proprietary-a2d4f91ed24ea8ac78e3af1fd05f30f8cc7766df.tar.gz
xrdp-proprietary-a2d4f91ed24ea8ac78e3af1fd05f30f8cc7766df.zip
Add rudimentary sound support
-rw-r--r--raptorsmiface/libraptorsmiface.c38
-rw-r--r--raptorsmiface/libraptorsmiface.h6
-rw-r--r--sesman/chansrv/chansrv.c3
-rw-r--r--sesman/chansrv/clipboard.c5
-rw-r--r--sesman/chansrv/sound.c12
5 files changed, 61 insertions, 3 deletions
diff --git a/raptorsmiface/libraptorsmiface.c b/raptorsmiface/libraptorsmiface.c
index 0c172f2e..cec15084 100644
--- a/raptorsmiface/libraptorsmiface.c
+++ b/raptorsmiface/libraptorsmiface.c
@@ -23,7 +23,8 @@
#include "libraptorsmiface.h"
-char *server = "localhost";
+//char *server = "localhost";
+char *server = "freyja.starlink.edu";
char *user = "remotelab";
char *password = "rlpass123"; /* set me first */
char *database = "remotelab_sm";
@@ -349,6 +350,39 @@ char* raptor_sm_get_hostname_for_username(char* username, bool create) {
}
}
+char* raptor_sm_get_hostname_for_display(int display) {
+ MYSQL_RES *res;
+ MYSQL_ROW row;
+ char* query;
+
+ MYSQL *conn = connect_if_needed();
+ if (!conn) {
+ return strdup("SQLERR100");
+ }
+
+ asprintf(&query, "SELECT servername FROM sessions WHERE display='%d'", display);
+ if (mysql_query_internal(conn, query)) {
+ // Server error
+ free(query);
+ mysql_close(conn);
+ return strdup("SQLERR101");
+ }
+ else {
+ free(query);
+ res = mysql_store_result(conn);
+ while ((row = mysql_fetch_row(res)) != NULL) {
+ char* ret = strdup(row[0]);
+ mysql_free_result(res);
+ mysql_close(conn);
+ return ret;
+ }
+ // Nothing in the DB
+ mysql_free_result(res);
+ mysql_close(conn);
+ return strdup("");
+ }
+}
+
char* raptor_sm_get_ip_for_username(char* username, bool create) {
char* hostname = raptor_sm_get_hostname_for_username(username, create);
char err;
@@ -529,7 +563,7 @@ pid_t raptor_sm_run_remote_server(char* username, char *const argv[], char* dbfi
else {
asprintf(&command_string, "ssh root@%s \"su %s -c \'export DISPLAY=:%d && %s\' &> /dev/null & echo \\$!\"", ipaddr, username, display, origstr);
}
-dprint("Running command %s...\n\r", command_string);
+ dprint("Running command %s...\n\r", command_string);
free(origstr);
FILE *fp;
diff --git a/raptorsmiface/libraptorsmiface.h b/raptorsmiface/libraptorsmiface.h
index 232dfe33..d0a12a2c 100644
--- a/raptorsmiface/libraptorsmiface.h
+++ b/raptorsmiface/libraptorsmiface.h
@@ -23,6 +23,9 @@ enum raptor_sm_status {
#define RAPTOR_SM_SERVER_PID_FIELD "server_pid"
#define RAPTOR_SM_WM_PID_FIELD "wm_pid"
+#define RAPTOR_SM_BASE_PULSEAUDIO_PORT 2000
+#define RAPTOR_SM_MANAGEMENT_SERVER_IP_NETRANGE "10.0.0.0/8"
+
char* raptor_sm_get_ip_for_hostname(char* hostname, char* err);
char* raptor_sm_get_hostname_for_username(char* username, bool create);
@@ -39,4 +42,5 @@ int raptor_sm_get_new_unique_display(int mindisplay, int maxdisplay);
bool raptor_sm_sesslimit_reached(char* username);
char raptor_sm_set_session_state(int display, int state);
void raptor_sm_run_remote_desktop(char* username, int display, char* executable);
-void raptor_sm_terminate_server(char* username); \ No newline at end of file
+void raptor_sm_terminate_server(char* username);
+char* raptor_sm_get_hostname_for_display(int display); \ No newline at end of file
diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c
index 7b4bf0b5..35913a8c 100644
--- a/sesman/chansrv/chansrv.c
+++ b/sesman/chansrv/chansrv.c
@@ -222,6 +222,7 @@ g_is_term(void)
{
return g_is_wait_obj_set(g_term_event);
}
+// #define ENABLE_CHANSERV_DEBUG_LOGGING
#if 0
#include <stdio.h>
@@ -229,6 +230,7 @@ g_is_term(void)
#include <stdarg.h>
void dprint(const char *fmt, ...)
{
+#ifdef ENABLE_CHANSERV_DEBUG_LOGGING
va_list argp;
va_start(argp, fmt);
char debug[1024];
@@ -240,6 +242,7 @@ void dprint(const char *fmt, ...)
fclose(fp);
}
va_end(argp);
+#endif
}
#undef LOG
#define LOG(_a, _params) \
diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c
index 5f01f241..3556933a 100644
--- a/sesman/chansrv/clipboard.c
+++ b/sesman/chansrv/clipboard.c
@@ -371,6 +371,11 @@ clipboard_init(void)
{
return 0;
}
+ if (!g_display)
+ {
+ // prevent crash in XInternAtom
+ return 3;
+ }
xfuse_init();
xcommon_init();
diff --git a/sesman/chansrv/sound.c b/sesman/chansrv/sound.c
index e2b6f53b..4bab49aa 100644
--- a/sesman/chansrv/sound.c
+++ b/sesman/chansrv/sound.c
@@ -30,6 +30,8 @@
#include "file_loc.h"
#include "chansrv_common.h"
+#include "libraptorsmiface.h"
+
#if defined(XRDP_OPUS)
#include <opus/opus.h>
static OpusEncoder *g_opus_encoder = 0;
@@ -215,6 +217,16 @@ static int DEFAULT_CC sound_sndsrvr_source_data_in(struct trans *trans);
static int APP_CC sound_start_source_listener();
static int APP_CC sound_start_sink_listener();
+//#if 0
+void dprint(const char *fmt, ...);
+#undef LOG
+#define LOG(_a, _params) \
+{ \
+ dprint _params; \
+ dprint("\n"); \
+}
+//#endif
+
/*****************************************************************************/
static int APP_CC
sound_send_server_output_formats(void)