From 93ec5c2df2e1078bc29894e0ccba0213bfa6451f Mon Sep 17 00:00:00 2001 From: Iwan Timmer Date: Sun, 10 May 2015 18:32:06 +0200 Subject: [PATCH] Make OMX optional --- CMakeLists.txt | 48 +++++++++++++++----------- src/video/fake.c | 66 ++++++++++++++++++++++++++++++++++++ src/{video.c => video/omx.c} | 0 3 files changed, 94 insertions(+), 20 deletions(-) create mode 100644 src/video/fake.c rename src/{video.c => video/omx.c} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1072dd0..c894cec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,30 +3,38 @@ cmake_minimum_required(VERSION 3.2) SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") -aux_source_directory(./common/limelight-common SRC_LIST) -aux_source_directory(./common/limelight-common/OpenAES SRC_LIST) -aux_source_directory(./ilclient SRC_LIST) -aux_source_directory(./h264bitstream SRC_LIST) - aux_source_directory(./src SRC_LIST) +aux_source_directory(./common/limelight-common SRC_LIST) +aux_source_directory(./common/limelight-common/OpenAES SRC_LIST) + include_directories(./common) -include_directories(./ilclient ./h264bitstream) + +find_package(Threads REQUIRED) +find_package(CURL REQUIRED) +find_package(OpenSSL REQUIRED) +find_package(EXPAT REQUIRED) +find_package(ALSA REQUIRED) +find_package(Opus REQUIRED) +find_package(Broadcom) + +find_package(PkgConfig REQUIRED) +pkg_check_modules(EVDEV REQUIRED libevdev) + +if(Broadcom_FOUND) + aux_source_directory(./ilclient SRC_LIST) + aux_source_directory(./h264bitstream SRC_LIST) + + include_directories(./ilclient ./h264bitstream ${BROADCOM_INCLUDE_DIRS}) + target_link_libraries (moonlight PUBLIC ${BROADCOM_LIBRARIES}) + set_property(TARGET moonlight PROPERTY COMPILE_DEFINITIONS ${BROADCOM_DEFINITIONS}) + list(APPEND SRC_LIST ./src/video/omx.c) +else() + list(APPEND SRC_LIST ./src/video/fake.c) +endif() add_executable(moonlight ${SRC_LIST}) set_property(TARGET moonlight PROPERTY C_STANDARD 11) -find_package(Threads) -find_package(CURL) -find_package(OpenSSL) -find_package(EXPAT) -find_package(ALSA) -find_package(Opus) -find_package(Broadcom) - -find_package(PkgConfig REQUIRED) -pkg_check_modules(EVDEV libevdev) - -include_directories(./moonlight-common-c ${OPUS_INCLUDE_DIRS} ${EVDEV_INCLUDE_DIRS} ${BROADCOM_INCLUDE_DIRS}) -target_link_libraries (moonlight PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} ${EXPAT_LIBRARIES} ${EVDEV_LIBRARIES} ${ALSA_LIBRARY} ${OPUS_LIBRARY} ${BROADCOM_LIBRARIES}) -set_property(TARGET moonlight PROPERTY COMPILE_DEFINITIONS ${BROADCOM_DEFINITIONS}) +include_directories(./moonlight-common-c ${OPUS_INCLUDE_DIRS} ${EVDEV_INCLUDE_DIRS}) +target_link_libraries (moonlight PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} ${EXPAT_LIBRARIES} ${EVDEV_LIBRARIES} ${ALSA_LIBRARY} ${OPUS_LIBRARY}) diff --git a/src/video/fake.c b/src/video/fake.c new file mode 100644 index 0000000..19a2d64 --- /dev/null +++ b/src/video/fake.c @@ -0,0 +1,66 @@ +/* + * 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 . + */ + +#include "../video.h" + +#include + +static FILE* fd; +static const char* fileName = "fake.h264"; +static h264_stream_t* stream; + +void decoder_renderer_setup(int width, int height, int redrawRate, void* context, int drFlags) { + printf("decoder_renderer_setup %dx%d %dfps\n", width, height, redrawRate); + fd = fopen(fileName, "w"); + + stream = h264_new(); + if (stream == NULL) { + fprintf(stderr, "Not enough memory\n"); + exit(EXIT_FAILURE); + } +} + +void decoder_renderer_start() { + printf("decoder_renderer_start\n"); +} + +void decoder_renderer_stop() { + printf("decoder_renderer_stop\n"); +} + +void decoder_renderer_release() { + printf("decoder_renderer_release\n"); + fclose(fd); +} + +int decoder_renderer_submit_decode_unit(PDECODE_UNIT decodeUnit) { + while (entry != NULL) { + fwrite(entry->data, entry->length, 1, fd); + entry = entry->next; + } + return DR_OK; +} + +DECODER_RENDERER_CALLBACKS decoder_callbacks = { + .setup = decoder_renderer_setup, + .start = decoder_renderer_start, + .stop = decoder_renderer_stop, + .release = decoder_renderer_release, + .submitDecodeUnit = decoder_renderer_submit_decode_unit, +}; diff --git a/src/video.c b/src/video/omx.c similarity index 100% rename from src/video.c rename to src/video/omx.c