Platform can be specified as argument

This commit is contained in:
Iwan Timmer
2015-07-12 13:26:05 +02:00
parent 82d1ee1984
commit 2945c13181
4 changed files with 91 additions and 39 deletions

View File

@@ -23,6 +23,7 @@
#include "video.h"
#include "audio.h"
#include "discover.h"
#include "platform.h"
#include "input/evdev.h"
#include "input/udev.h"
@@ -61,7 +62,7 @@ static void applist(const char* address) {
}
}
static void stream(STREAM_CONFIGURATION* config, const char* address, const char* app, bool sops, bool localaudio) {
static void stream(STREAM_CONFIGURATION* config, const char* address, const char* app, bool sops, bool localaudio, enum platform system) {
int appId = client_get_app_id(address, app);
if (appId<0) {
fprintf(stderr, "Can't find app %s\n", app);
@@ -70,13 +71,12 @@ static void stream(STREAM_CONFIGURATION* config, const char* address, const char
client_start_app(config, address, appId, sops, localaudio);
video_init();
evdev_init();
#ifdef HAVE_LIBCEC
cec_init();
#endif /* HAVE_LIBCEC */
LiStartConnection(address, config, &connection_callbacks, decoder_callbacks, &audio_callbacks, NULL, NULL, 0, client_get_server_version());
LiStartConnection(address, config, &connection_callbacks, platform_get_video(system), &audio_callbacks, NULL, NULL, 0, client_get_server_version());
loop_main();
@@ -177,11 +177,13 @@ int main(int argc, char* argv[]) {
{"nosops", no_argument, 0, 'l'},
{"audio", required_argument, 0, 'm'},
{"localaudio", no_argument, 0, 'n'},
{"platform", required_argument, 0, 'o'},
{0, 0, 0, 0},
};
struct input_config inputs[MAX_INPUTS];
int inputsCount = 0;
char* platform = "default";
char* app = "Steam";
char* action = NULL;
char* address = NULL;
@@ -191,7 +193,7 @@ int main(int argc, char* argv[]) {
bool localaudio = false;
bool autoadd = true;
int c;
while ((c = getopt_long_only(argc, argv, "-abc:d:efg:h:i:j:k:lm:n", long_options, &option_index)) != -1) {
while ((c = getopt_long_only(argc, argv, "-abc:d:efg:h:i:j:k:lm:no:", long_options, &option_index)) != -1) {
switch (c) {
case 'a':
config.width = 1280;
@@ -244,6 +246,9 @@ int main(int argc, char* argv[]) {
case 'n':
localaudio = true;
break;
case 'o':
platform = optarg;
break;
case 1:
if (action == NULL)
action = optarg;
@@ -258,7 +263,14 @@ int main(int argc, char* argv[]) {
if (action == NULL || strcmp("help", action) == 0)
help();
else if (strcmp("map", action) == 0) {
enum platform system = platform_check(platform);
if (system != 0) {
fprintf(stderr, "Platform '%s' not found\n", platform);
exit(-1);
}
if (strcmp("map", action) == 0) {
if (address == NULL) {
perror("No filename for mapping");
exit(-1);
@@ -296,7 +308,7 @@ int main(int argc, char* argv[]) {
for (int i=0;i<inputsCount;i++)
evdev_create(inputs[i].path, inputs[i].mapping);
stream(&config, address, app, sops, localaudio);
stream(&config, address, app, sops, localaudio, system);
} else if (strcmp("pair", action) == 0)
client_pair(address);
else if (strcmp("quit", action) == 0) {

70
src/platform.c Normal file
View File

@@ -0,0 +1,70 @@
/*
* This file is part of Moonlight Embedded.
*
* Copyright (C) 2015 Iwan Timmer
*
* Moonlight is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Moonlight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
*/
#define _GNU_SOURCE
#include "platform.h"
#include "video.h"
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
enum platform platform_check(char* name) {
bool std = strcmp(name, "default") == 0;
#ifdef HAVE_SDL
if (std || strcmp(name, "sdl") == 0)
return SDL;
#endif
#ifdef HAVE_IMX
if (std || strcmp(name, "imx") == 0) {
if (dlsym(RTLD_DEFAULT, "vpu_Init") != NULL && video_imx_init())
return IMX;
}
#endif
#ifdef HAVE_OMX
if (std || strcmp(name, "omx") == 0) {
if (dlsym(RTLD_DEFAULT, "bcm_host_init") != NULL)
return OMX;
}
#endif
if (std || strcmp(name, "fake") == 0)
return FAKE;
}
DECODER_RENDERER_CALLBACKS* platform_get_video(enum platform system) {
switch (system) {
#ifdef HAVE_SDL
case SDL:
return &decoder_callbacks_sdl;
#endif
#ifdef HAVE_IMX
case IMX:
return &decoder_callbacks_imx;
#endif
#ifdef HAVE_OMX
case OMX:
return &decoder_callbacks_omx;
#endif
case FAKE:
return &decoder_callbacks_fake;
}
return NULL;
}

View File

@@ -17,33 +17,9 @@
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
*/
#define _GNU_SOURCE
#include "video.h"
#include "limelight-common/Limelight.h"
#include <dlfcn.h>
#include <stdlib.h>
enum platform { SDL, OMX, IMX, FAKE };
DECODER_RENDERER_CALLBACKS *decoder_callbacks;
static int decoder_level;
void video_init() {
#ifdef HAVE_SDL
decoder_callbacks = &decoder_callbacks_sdl;
#else
decoder_callbacks = &decoder_callbacks_fake;
#endif
#ifdef HAVE_IMX
if (dlsym(RTLD_DEFAULT, "vpu_Init") != NULL && video_imx_init()) {
decoder_callbacks = &decoder_callbacks_imx;
}
#endif
#ifdef HAVE_OMX
if (dlsym(RTLD_DEFAULT, "bcm_host_init") != NULL) {
decoder_callbacks = &decoder_callbacks_omx;
}
#endif
}
enum platform platform_check(char*);
DECODER_RENDERER_CALLBACKS* platform_get_video(enum platform system);

View File

@@ -19,12 +19,6 @@
#include "limelight-common/Limelight.h"
#include <stdbool.h>
extern DECODER_RENDERER_CALLBACKS *decoder_callbacks;
void video_init();
extern DECODER_RENDERER_CALLBACKS decoder_callbacks_fake;
#ifdef HAVE_SDL
extern DECODER_RENDERER_CALLBACKS decoder_callbacks_sdl;