Multiple video backend in single executable

This commit is contained in:
Iwan Timmer
2015-05-14 14:36:58 +02:00
parent 5982631e07
commit c052190c2f
10 changed files with 95 additions and 21 deletions

View File

@@ -4,12 +4,15 @@ cmake_minimum_required(VERSION 3.1)
SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
aux_source_directory(./src SRC_LIST)
list(APPEND SRC_LIST ./src/video/fake.c)
aux_source_directory(./common/limelight-common SRC_LIST)
aux_source_directory(./common/limelight-common/OpenAES SRC_LIST)
include_directories(./common)
set(MOONLIGHT_DEFINITIONS)
find_package(Threads REQUIRED)
find_package(CURL REQUIRED)
find_package(OpenSSL REQUIRED)
@@ -28,10 +31,12 @@ if(BROADCOM_FOUND)
aux_source_directory(./ilclient SRC_LIST)
aux_source_directory(./h264bitstream SRC_LIST)
list(APPEND SRC_LIST ./src/video/omx.c)
elseif(FREESCALE_FOUND)
list(APPEND MOONLIGHT_DEFINITIONS HAVE_OMX)
endif()
if(FREESCALE_FOUND)
list(APPEND SRC_LIST ./src/video/imx.c)
else()
list(APPEND SRC_LIST ./src/video/fake.c)
list(APPEND MOONLIGHT_DEFINITIONS HAVE_IMX)
endif()
add_executable(moonlight ${SRC_LIST})
@@ -40,14 +45,17 @@ set_property(TARGET moonlight PROPERTY C_STANDARD 11)
if(BROADCOM_FOUND)
include_directories(./ilclient ./h264bitstream ${BROADCOM_INCLUDE_DIRS})
target_link_libraries (moonlight PUBLIC ${BROADCOM_LIBRARIES})
set_property(TARGET moonlight PROPERTY COMPILE_DEFINITIONS ${BROADCOM_DEFINITIONS})
elseif(FREESCALE_FOUND)
list(APPEND MOONLIGHT_DEFINITIONS ${BROADCOM_DEFINITIONS})
endif()
if(FREESCALE_FOUND)
include_directories(${FREESCALE_INCLUDE_DIRS})
target_link_libraries (moonlight PUBLIC ${FREESCALE_LIBRARIES})
endif()
set_property(TARGET moonlight PROPERTY COMPILE_DEFINITIONS ${MOONLIGHT_DEFINITIONS})
include_directories(./moonlight-common-c ${OPUS_INCLUDE_DIRS} ${EVDEV_INCLUDE_DIRS} ${AVAHI_INCLUDE_DIRS} ${UDEV_INCLUDE_DIRS})
target_link_libraries (moonlight PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} ${EXPAT_LIBRARIES} ${EVDEV_LIBRARIES} ${ALSA_LIBRARY} ${OPUS_LIBRARY} ${AVAHI_LIBRARIES} ${UDEV_LIBRARIES})
target_link_libraries (moonlight PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} ${EXPAT_LIBRARIES} ${EVDEV_LIBRARIES} ${ALSA_LIBRARY} ${OPUS_LIBRARY} ${AVAHI_LIBRARIES} ${UDEV_LIBRARIES} ${CMAKE_DL_LIBS})
include(${CMAKE_ROOT}/Modules/GNUInstallDirs.cmake)
install(TARGETS moonlight DESTINATION ${CMAKE_INSTALL_BINDIR})

View File

@@ -47,12 +47,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ctype.h>
#include <assert.h>
#include "interface/vcos/vcos.h"
#include "interface/vcos/vcos_logging.h"
#include "interface/vmcs_host/vchost.h"
#include <interface/vcos/vcos.h>
#include <interface/vcos/vcos_logging.h>
#include <interface/vmcs_host/vchost.h>
#include "IL/OMX_Broadcom.h"
#include "ilclient.h"
#include <IL/OMX_Broadcom.h>
#include <ilclient.h>
#define VCOS_LOG_CATEGORY (&ilclient_log_category)

View File

@@ -40,12 +40,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdlib.h>
#include <string.h>
#include "IL/OMX_Component.h"
#include "interface/vcos/vcos.h"
#include <IL/OMX_Component.h>
#include <interface/vcos/vcos.h>
#include "interface/vmcs_host/vcilcs.h"
#include "interface/vmcs_host/vchost.h"
#include "interface/vmcs_host/vcilcs_common.h"
#include <interface/vmcs_host/vcilcs.h>
#include <interface/vmcs_host/vchost.h>
#include <interface/vmcs_host/vcilcs_common.h>
static int coreInit = 0;
static int nActiveHandles = 0;

View File

@@ -283,7 +283,7 @@ void client_pair(const char *address) {
http_request(url, data);
xml_search(data->memory, data->size, "pairingsecret", &result);
char *signature = NULL;
unsigned char *signature = NULL;
size_t s_len;
if (!sign_it(client_secret_data, 16, &signature, &s_len, privateKey)) {
fprintf(stderr, "Failed to sign data\n");

View File

@@ -64,6 +64,8 @@ static void stream(STREAM_CONFIGURATION* config, const char* address, const char
client_start_app(config, address, appId, sops, localaudio);
video_init();
struct addrinfo hints, *res;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;

54
src/video.c Normal file
View File

@@ -0,0 +1,54 @@
/*
* 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 "video.h"
#include "limelight-common/Limelight.h"
#include <dlfcn.h>
#include <stdlib.h>
DECODER_RENDERER_CALLBACKS *decoder_callbacks;
char* decoder_output_name;
static int decoder_level;
void video_init() {
decoder_callbacks = &decoder_callbacks_fake;
#ifdef HAVE_OMX
if (dlsym(RTLD_DEFAULT, "bcm_host_init") != NULL) {
decoder_callbacks = &decoder_callbacks_omx;
}
#endif
#ifdef HAVE_IMX
if (dlsym(RTLD_DEFAULT, "vpu_Init") != NULL) {
decoder_callbacks = &decoder_callbacks_imx;
}
#endif
}
int video_add_output(int level, char* name, DECODER_RENDERER_CALLBACKS *callbacks) {
if (level > decoder_level) {
decoder_output_name = name;
decoder_level = level;
decoder_callbacks = callbacks;
}
}

View File

@@ -19,4 +19,14 @@
#include "limelight-common/Limelight.h"
extern DECODER_RENDERER_CALLBACKS decoder_callbacks;
extern DECODER_RENDERER_CALLBACKS *decoder_callbacks;
void video_init();
extern DECODER_RENDERER_CALLBACKS decoder_callbacks_fake;
#ifdef HAVE_OMX
extern DECODER_RENDERER_CALLBACKS decoder_callbacks_omx;
#endif
#ifdef HAVE_IMX
extern DECODER_RENDERER_CALLBACKS decoder_callbacks_omx;
#endif

View File

@@ -51,7 +51,7 @@ int decoder_renderer_submit_decode_unit(PDECODE_UNIT decodeUnit) {
return DR_OK;
}
DECODER_RENDERER_CALLBACKS decoder_callbacks = {
DECODER_RENDERER_CALLBACKS decoder_callbacks_fake = {
.setup = decoder_renderer_setup,
.start = decoder_renderer_start,
.stop = decoder_renderer_stop,

View File

@@ -430,7 +430,7 @@ static void decoder_renderer_release() {
vpu_UnInit();
}
DECODER_RENDERER_CALLBACKS decoder_callbacks = {
DECODER_RENDERER_CALLBACKS decoder_callbacks_imx = {
.setup = decoder_renderer_setup,
.start = decoder_renderer_start,
.stop = decoder_renderer_stop,

View File

@@ -229,7 +229,7 @@ static int decoder_renderer_submit_decode_unit(PDECODE_UNIT decodeUnit) {
return DR_OK;
}
DECODER_RENDERER_CALLBACKS decoder_callbacks = {
DECODER_RENDERER_CALLBACKS decoder_callbacks_omx = {
.setup = decoder_renderer_setup,
.start = decoder_renderer_start,
.stop = decoder_renderer_stop,