-
Notifications
You must be signed in to change notification settings - Fork 4
RDKEMW-4433: local server build option #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dwolaver
wants to merge
38
commits into
develop
Choose a base branch
from
feature/RDKEMW-4433_local_server_build_option
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
a07f1aa
First rough draft
dwolaver 4c4f4f9
Cleaned up a bunch.
dwolaver 5f6db0a
added some compile options
dwolaver 50ad1cf
updating app interface to c++ obj
dwolaver 5c1bcc5
Add emit by key name logic
dwolaver d9dddd2
added routing
dwolaver 71d2406
added systemd notify
dwolaver 6ffad2f
silenced repeat keys
dwolaver 912b9d3
Merge branch 'feature/RDKEMW-4433_local_server_build_option' of githu…
dwolaver 0f12922
Added low latency
dwolaver 0b5f26e
increase pipe size. ignore voice key up
dwolaver b074ea3
increase interpacket timeout. print sizes in error message.
dwolaver 6a06eba
Fix timeout packet tag
dwolaver 80571dc
Stop audio when session ends.
dwolaver cceea8a
Changed logs to DEBUG
dwolaver f9c2e63
Merge branch 'develop' into feature/RDKEMW-4433_local_server_build_op…
dwolaver 90098a8
Updated certificate handling
dwolaver 95f7a09
Merge branch 'develop' into feature/RDKEMW-4433_local_server_build_op…
dwolaver 5098e1d
Merge branch 'develop' into feature/RDKEMW-4433_local_server_build_op…
dwolaver 583c1d8
fix compile issues
dwolaver c17769a
remove key write stuff
dwolaver f2b5fb8
fix line endings
dwolaver 73f8d55
fix file mode
dwolaver e977b9f
add newline
dwolaver ecec4a2
fix startup logic
dwolaver cc8fbcd
minor updates
dwolaver cbc5fb0
init fixes
dwolaver 0117363
add cert stuff
dwolaver 745adc6
copilot fixes
dwolaver c2c3477
copilot stuff
dwolaver f565025
more copilot fixes
dwolaver fe22587
more copilot
dwolaver a455a6b
more copilot fixes
dwolaver 4ec676f
more copilot
dwolaver e5d28b2
copilot fixes
dwolaver 1936883
copilot.
dwolaver 7233652
more copilot
dwolaver 63e5381
Merge branch 'develop' into feature/RDKEMW-4433_local_server_build_op…
dwolaver File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| ########################################################################## | ||
| # If not stated otherwise in this file or this component's LICENSE | ||
| # file the following copyright and licenses apply: | ||
| # | ||
| # Copyright 2019 RDK Management | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| ########################################################################## | ||
|
|
||
| add_executable(controlServer ctrlms_main.c) | ||
|
|
||
| include_directories( | ||
| . | ||
| ${CMAKE_SYSROOT}/usr/include/safeclib | ||
| ${CMAKE_SYSROOT}/usr/include/libsafec | ||
| ${CMAKE_SYSROOT}/usr/include/nopoll | ||
| ${CMAKE_SYSROOT}/usr/include | ||
| ) | ||
|
|
||
| target_sources(controlServer PRIVATE | ||
| ctrlms_version.c | ||
| ctrlms_ws.cpp | ||
| ) | ||
|
|
||
| target_compile_options(controlServer PUBLIC -fPIC -rdynamic -Wall -Werror) | ||
|
|
||
| target_link_libraries(controlServer c rdkversion pthread nopoll jansson xr-voice-sdk secure_wrapper systemd ${CMAKE_DL_LIBS}) | ||
|
|
||
| if(AUTH_ENABLED) | ||
| target_compile_definitions(controlServer PRIVATE CTRLMS_WSS_ENABLED) | ||
| target_link_libraries(controlServer ssl crypto RdkCertSelector rdkconfig secure_wrapper) | ||
| endif() | ||
|
|
||
| if(USE_SAFEC) | ||
| find_package(PkgConfig) | ||
| pkg_check_modules(SAFEC REQUIRED libsafec) | ||
| if(SAFEC_FOUND) | ||
| target_link_libraries(controlServer ${SAFEC_LIBRARIES}) | ||
| endif() | ||
| else() | ||
| target_compile_definitions(controlServer PUBLIC SAFEC_DUMMY_API) | ||
| endif() | ||
|
dwolaver marked this conversation as resolved.
|
||
|
|
||
| install(TARGETS controlServer DESTINATION bin) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * If not stated otherwise in this file or this component's license file the | ||
| * following copyright and licenses apply: | ||
| * | ||
| * Copyright 2014 RDK Management | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include <stdint.h> | ||
| #include <stdbool.h> | ||
| #include <jansson.h> | ||
|
|
||
| class ctrlms_app_interface_t | ||
| { | ||
| public: | ||
| virtual ~ctrlms_app_interface_t() {}; | ||
|
|
||
| virtual void ws_connected(void); | ||
| virtual void ws_disconnected(void); | ||
| virtual bool ws_receive_audio(const unsigned char *payload, int payload_size); | ||
| virtual bool ws_receive_json(const json_t *json_obj); | ||
| void ws_send_json(const json_t *json_obj); | ||
| void ws_handle_set(void *handle); | ||
|
|
||
| private: | ||
| void *ws_handle = NULL; | ||
| }; | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| ctrlms_app_interface_t *ctrlms_app_interface_create(void); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| #include <stdlib.h> | ||
| #include <stdio.h> | ||
| #include <string.h> | ||
| #include <errno.h> | ||
| #include <argp.h> | ||
| #include <unistd.h> | ||
| #include <signal.h> | ||
| #include <systemd/sd-daemon.h> | ||
| #include <ctrlm_log.h> | ||
| #include <rdkx_logger.h> | ||
| #include <ctrlms_version.h> | ||
| #include <ctrlms_ws.h> | ||
|
|
||
| #define CTRLMS_VERSION "1.0" | ||
|
|
||
| #define CTRLMS_WS_PORT_INT (9881) | ||
|
|
||
| typedef struct { | ||
| bool silent; | ||
| bool verbose; | ||
| } ctrlms_options_t; | ||
|
|
||
| static bool ctrlms_cmdline_args(int argc, char *argv[]); | ||
| static error_t ctrlms_parse_opt(int key, char *arg, struct argp_state *state); | ||
| static void ctrlms_signal_handler(int signum); | ||
|
|
||
| const char *argp_program_version = "controlServer " CTRLMS_VERSION; | ||
| const char *argp_program_bug_address = "<david_wolaver@cable.comcast.com>"; | ||
|
|
||
| static char doc[] = "controlServer -- a server application"; | ||
|
|
||
| static char args_doc[] = ""; | ||
|
|
||
| static struct argp_option options[] = { | ||
| {"verbose", 'v', 0, 0, "Produce verbose output" }, | ||
| {"quiet", 'q', 0, 0, "Don't produce any output" }, | ||
| { 0 } | ||
| }; | ||
|
|
||
| static struct argp argp = { options, ctrlms_parse_opt, args_doc, doc }; | ||
|
|
||
| static ctrlms_options_t g_ctrlms_opts = { .silent = false, | ||
| .verbose = false | ||
| }; | ||
|
|
||
| void ctrlms_signal_handler(int signum) { | ||
| if(signum == SIGTERM) { | ||
| ctrlms_ws_term(); | ||
| } | ||
|
dwolaver marked this conversation as resolved.
|
||
| } | ||
|
|
||
| int main(int argc, char* argv[]) { | ||
| int result = -1; | ||
| if(signal(SIGTERM, ctrlms_signal_handler) == SIG_ERR) { | ||
| XLOGD_ERROR("ctrlms_main: failed to set SIGTERM handler <%s>", strerror(errno)); | ||
| } | ||
|
|
||
| // Parse command line arguments | ||
| if(!ctrlms_cmdline_args(argc, argv)) { | ||
| return(result); | ||
| } | ||
|
|
||
| xlog_level_t level = XLOG_LEVEL_WARN; | ||
| if(g_ctrlms_opts.silent) { | ||
| level = XLOG_LEVEL_ERROR; | ||
| } else if(g_ctrlms_opts.verbose) { | ||
| level = XLOG_LEVEL_INFO; | ||
| // TODO Add option to allow debug level logging | ||
| //} else if() { | ||
| // level = XLOG_LEVEL_DEBUG; | ||
| } | ||
|
|
||
| if(!ctrlms_init(level)) { | ||
| XLOGD_ERROR("ctrlms_main: init failed"); | ||
| } else { | ||
| // Start listening for connections | ||
| if(!ctrlms_ws_init(CTRLMS_WS_PORT_INT, true)) { | ||
| XLOGD_ERROR("ctrlms_main: ws init failed"); | ||
| } else { | ||
|
dwolaver marked this conversation as resolved.
|
||
| result = 0; | ||
| XLOGD_INFO("Notifying systemd of successful initialization"); | ||
| sd_notifyf(0, "READY=1\nSTATUS=ctrlm-server has successfully initialized\nMAINPID=%lu", (unsigned long)getpid()); | ||
| ctrlms_ws_listen(); | ||
| } | ||
|
dwolaver marked this conversation as resolved.
dwolaver marked this conversation as resolved.
|
||
| XLOGD_INFO("ctrlms_main: main loop ended"); | ||
| } | ||
| ctrlms_term(); | ||
| XLOGD_INFO("ctrlms_main: return"); | ||
|
|
||
| return(result); | ||
| } | ||
|
|
||
| error_t ctrlms_parse_opt(int key, char *arg, struct argp_state *state) { | ||
| // Get the input argument from argp_parse, which we know is a pointer to our arguments structure. | ||
| ctrlms_options_t *arguments = state->input; | ||
|
|
||
| switch(key) { | ||
| case 'q': { | ||
| arguments->silent = true; | ||
| break; | ||
| } | ||
| case 'v': { | ||
| arguments->verbose = true; | ||
| break; | ||
| } | ||
| case ARGP_KEY_ARG: { | ||
| argp_usage(state); | ||
| return(ARGP_ERR_UNKNOWN); | ||
| } | ||
| case ARGP_KEY_END: { | ||
| break; | ||
| } | ||
| default: { | ||
| return(ARGP_ERR_UNKNOWN); | ||
| } | ||
| } | ||
|
|
||
| return(0); | ||
| } | ||
|
|
||
| bool ctrlms_cmdline_args(int argc, char *argv[]) { | ||
| argp_parse(&argp, argc, argv, 0, 0, &g_ctrlms_opts); | ||
|
|
||
| #if 0 | ||
| if() { // Nothing to do | ||
| printf("Invalid options specified. Try 'controlServer --help' or 'controlServer --usage' for more information.\n"); | ||
| return(false); | ||
| } | ||
| #endif | ||
|
|
||
| XLOGD_INFO("verbose <%s>", g_ctrlms_opts.verbose ? "YES" : "NO"); | ||
| XLOGD_INFO("silent <%s>", g_ctrlms_opts.silent ? "YES" : "NO"); | ||
|
|
||
| return(true); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #include <stdlib.h> | ||
| #include <stdio.h> | ||
| #include <string.h> | ||
| #include <ctrlm_log.h> | ||
| #include <rdkx_logger.h> | ||
| #include <rdkversion.h> | ||
| #include <ctrlms_version.h> | ||
|
|
||
|
dwolaver marked this conversation as resolved.
|
||
| typedef struct { | ||
| bool initialized; | ||
| bool is_production; | ||
| } ctrlms_global_t; | ||
|
|
||
| ctrlms_global_t g_ctrlms = { | ||
| .initialized = false, | ||
| .is_production = true | ||
| }; | ||
|
|
||
| bool ctrlms_init(xlog_level_t level) { | ||
| rdk_version_info_t info; | ||
| int ret_val = rdk_version_parse_version(&info); | ||
|
|
||
| if(ret_val != 0) { | ||
| XLOGD_ERROR("parse error <%s>\n", info.parse_error == NULL ? "" : info.parse_error); | ||
|
dwolaver marked this conversation as resolved.
|
||
| rdk_version_object_free(&info); | ||
| return(false); | ||
| } | ||
|
|
||
| g_ctrlms.is_production = info.production_build; | ||
|
|
||
| rdk_version_object_free(&info); | ||
|
|
||
| int rc = xlog_init(XLOG_MODULE_ID, NULL, 0, true, false); | ||
| xlog_level_set_all(level); | ||
|
|
||
| if(rc != 0) { | ||
| XLOGD_ERROR("failed to init xlog"); | ||
| return(false); | ||
| } | ||
|
|
||
| g_ctrlms.initialized = true; | ||
| return(true); | ||
| } | ||
|
|
||
| void ctrlms_term(void) { | ||
| g_ctrlms.initialized = false; | ||
| xlog_term(); | ||
| } | ||
|
|
||
| bool ctrlms_is_initialized(void) { | ||
| return(g_ctrlms.initialized); | ||
| } | ||
|
|
||
| bool ctrlms_is_production(void) { | ||
| return(g_ctrlms.is_production); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * If not stated otherwise in this file or this component's license file the | ||
| * following copyright and licenses apply: | ||
| * | ||
| * Copyright 2014 RDK Management | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #ifndef _CTRLMS_VERSION_H_ | ||
| #define _CTRLMS_VERSION_H_ | ||
|
|
||
| #include <stdint.h> | ||
| #include <stdbool.h> | ||
| #include <rdkx_logger.h> | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| bool ctrlms_init(xlog_level_t level); | ||
| void ctrlms_term(void); | ||
|
|
||
| bool ctrlms_is_initialized(void); | ||
| bool ctrlms_is_production(void); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.