From 9ede9cbad8657da0c2fca86a16019ee60c9ee08f Mon Sep 17 00:00:00 2001 From: seungjunProgramming Date: Fri, 4 Dec 2020 17:26:31 +0900 Subject: [PATCH 1/5] added -x -y for display height, width --- lib/raop.c | 10 ++++++++++ lib/raop.h | 4 ++++ lib/raop_handlers.h | 11 +++++++---- rpiplay.cpp | 23 +++++++++++++++++------ 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/lib/raop.c b/lib/raop.c index 4523a2c4..c3bf0cb9 100755 --- a/lib/raop.c +++ b/lib/raop.c @@ -31,6 +31,9 @@ #include "raop_rtp_mirror.h" #include "raop_ntp.h" +unsigned int info_display_width = 1920; +unsigned int info_display_height = 1080; + struct raop_s { /* Callbacks for audio and video */ raop_callbacks_t callbacks; @@ -340,6 +343,13 @@ raop_set_port(raop_t *raop, unsigned short port) { raop->port = port; } +void +raop_set_display(raop_t *raop, unsigned short display_width, unsigned short display_height) { + assert(raop); + info_display_width = display_width; + info_display_height = display_height; +} + unsigned short raop_get_port(raop_t *raop) { assert(raop); diff --git a/lib/raop.h b/lib/raop.h index cfd703e1..ee422b7e 100755 --- a/lib/raop.h +++ b/lib/raop.h @@ -5,6 +5,9 @@ #include "stream.h" #include "raop_ntp.h" +extern unsigned int info_display_width; +extern unsigned int info_display_height; + #if defined (WIN32) && defined(DLL_EXPORT) # define RAOP_API __declspec(dllexport) #else @@ -55,6 +58,7 @@ RAOP_API raop_t *raop_init(int max_clients, raop_callbacks_t *callbacks); RAOP_API void raop_set_log_level(raop_t *raop, int level); RAOP_API void raop_set_log_callback(raop_t *raop, raop_log_callback_t callback, void *cls); RAOP_API void raop_set_port(raop_t *raop, unsigned short port); +RAOP_API void raop_set_display(raop_t *raop, unsigned short display_width, unsigned short display_height); RAOP_API unsigned short raop_get_port(raop_t *raop); RAOP_API void *raop_get_callback_cls(raop_t *raop); RAOP_API int raop_start(raop_t *raop, unsigned short *port); diff --git a/lib/raop_handlers.h b/lib/raop_handlers.h index 104b1c41..a5cf6554 100755 --- a/lib/raop_handlers.h +++ b/lib/raop_handlers.h @@ -31,6 +31,9 @@ raop_handler_info(raop_conn_t *conn, { assert(conn->raop->dnssd); + printf("Display width reported as: %d\n", info_display_width); + printf("Display height reported as: %d\n", info_display_height); + int airplay_txt_len = 0; const char *airplay_txt = dnssd_get_airplay_txt(conn->raop->dnssd, &airplay_txt_len); @@ -134,10 +137,10 @@ raop_handler_info(raop_conn_t *conn, plist_t displays_0_uuid_node = plist_new_string("e0ff8a27-6738-3d56-8a16-cc53aacee925"); plist_t displays_0_width_physical_node = plist_new_uint(0); plist_t displays_0_height_physical_node = plist_new_uint(0); - plist_t displays_0_width_node = plist_new_uint(1920); - plist_t displays_0_height_node = plist_new_uint(1080); - plist_t displays_0_width_pixels_node = plist_new_uint(1920); - plist_t displays_0_height_pixels_node = plist_new_uint(1080); + plist_t displays_0_width_node = plist_new_uint(info_display_width); + plist_t displays_0_height_node = plist_new_uint(info_display_height); + plist_t displays_0_width_pixels_node = plist_new_uint(info_display_width); + plist_t displays_0_height_pixels_node = plist_new_uint(info_display_height); plist_t displays_0_rotation_node = plist_new_bool(0); plist_t displays_0_refresh_rate_node = plist_new_real(1.0 / 60.0); plist_t displays_0_overscanned_node = plist_new_bool(1); diff --git a/rpiplay.cpp b/rpiplay.cpp index c5a67745..2fea14a6 100755 --- a/rpiplay.cpp +++ b/rpiplay.cpp @@ -41,14 +41,20 @@ #define DEFAULT_LOW_LATENCY false #define DEFAULT_DEBUG_LOG false #define DEFAULT_ROTATE 0 +#define DEFAULT_DISPLAY_WIDTH 1920 +#define DEFAULT_DISPLAY_HEIGHT 1080 #define DEFAULT_FLIP FLIP_NONE #define DEFAULT_HW_ADDRESS { (char) 0x48, (char) 0x5d, (char) 0x60, (char) 0x7c, (char) 0xee, (char) 0x22 } int start_server(std::vector hw_addr, std::string name, bool debug_log, - video_renderer_config_t const *video_config, audio_renderer_config_t const *audio_config); + video_renderer_config_t const *video_config, audio_renderer_config_t const *audio_config, int display_width, int display_height); int stop_server(); +int display_width = 1920; +int display_height = 1080; + + typedef video_renderer_t *(*video_init_func_t)(logger_t *logger, video_renderer_config_t const *config); typedef audio_renderer_t *(*audio_init_func_t)(logger_t *logger, video_renderer_t *video_renderer, audio_renderer_config_t const *config); @@ -178,7 +184,7 @@ void print_info(char *name) { int main(int argc, char *argv[]) { init_signals(); - + std::string server_name = DEFAULT_NAME; std::vector server_hw_addr = DEFAULT_HW_ADDRESS; bool debug_log = DEFAULT_DEBUG_LOG; @@ -188,11 +194,11 @@ int main(int argc, char *argv[]) { video_config.low_latency = DEFAULT_LOW_LATENCY; video_config.rotation = DEFAULT_ROTATE; video_config.flip = DEFAULT_FLIP; - + audio_renderer_config_t audio_config; audio_config.device = DEFAULT_AUDIO_DEVICE; audio_config.low_latency = DEFAULT_LOW_LATENCY; - + // Default to the best available renderer video_init_func = video_renderers[0].init_func; audio_init_func = audio_renderers[0].init_func; @@ -225,6 +231,10 @@ int main(int argc, char *argv[]) { audio_config.low_latency = !audio_config.low_latency; } else if (arg == "-r") { video_config.rotation = atoi(argv[++i]); + } else if (arg == "-x") { + display_width = atoi(argv[++i]); + } else if (arg == "-y") { + display_height = atoi(argv[++i]); } else if (arg == "-f") { if (i == argc - 1) continue; std::string flip_type(argv[++i]); @@ -266,7 +276,7 @@ int main(int argc, char *argv[]) { parse_hw_addr(mac_address, server_hw_addr); } - if (start_server(server_hw_addr, server_name, debug_log, &video_config, &audio_config) != 0) { + if (start_server(server_hw_addr, server_name, debug_log, &video_config, &audio_config, display_width, display_height) != 0) { return 1; } @@ -339,7 +349,7 @@ extern "C" void log_callback(void *cls, int level, const char *msg) { } int start_server(std::vector hw_addr, std::string name, bool debug_log, - video_renderer_config_t const *video_config, audio_renderer_config_t const *audio_config) { + video_renderer_config_t const *video_config, audio_renderer_config_t const *audio_config, int display_width, int display_height) { raop_callbacks_t raop_cbs; memset(&raop_cbs, 0, sizeof(raop_cbs)); raop_cbs.conn_init = conn_init; @@ -384,6 +394,7 @@ int start_server(std::vector hw_addr, std::string name, bool debug_log, unsigned short port = 0; raop_start(raop, &port); raop_set_port(raop, port); + raop_set_display(raop, display_width, display_height); int error; dnssd = dnssd_init(name.c_str(), strlen(name.c_str()), hw_addr.data(), hw_addr.size(), &error); From b3660a6a8dc4cc22259cae3d6c8e2784fdb725cf Mon Sep 17 00:00:00 2001 From: seungjunProgramming Date: Fri, 4 Dec 2020 17:29:36 +0900 Subject: [PATCH 2/5] added #define to add support for framerate --- README.md | 5 +++++ lib/raop_handlers.h | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4931af3a..59a082ec 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,11 @@ At the moment, these options are implemented: **-v/-h**: Displays short help and version information. +**-x**: Set display width + +**-y**: Set display height + +**-z**: Set display framerate(Added #define, adding support for start arg.) # Disclaimer diff --git a/lib/raop_handlers.h b/lib/raop_handlers.h index a5cf6554..614566bb 100755 --- a/lib/raop_handlers.h +++ b/lib/raop_handlers.h @@ -21,6 +21,8 @@ #include #include +#define FRAMERATE 60.0 + typedef void (*raop_handler_t)(raop_conn_t *, http_request_t *, http_response_t *, char **, int *); @@ -142,7 +144,7 @@ raop_handler_info(raop_conn_t *conn, plist_t displays_0_width_pixels_node = plist_new_uint(info_display_width); plist_t displays_0_height_pixels_node = plist_new_uint(info_display_height); plist_t displays_0_rotation_node = plist_new_bool(0); - plist_t displays_0_refresh_rate_node = plist_new_real(1.0 / 60.0); + plist_t displays_0_refresh_rate_node = plist_new_real(1.0 / FRAMERATE); plist_t displays_0_overscanned_node = plist_new_bool(1); plist_t displays_0_features = plist_new_uint(14); From 3e0f32a8c361d9394d3c87d34c04fc92f470ee79 Mon Sep 17 00:00:00 2001 From: seungjunProgramming Date: Sat, 19 Dec 2020 00:38:36 +0900 Subject: [PATCH 3/5] Fully supports -z to change framerate --- lib/raop.c | 4 +++- lib/raop.h | 3 ++- lib/raop_handlers.h | 5 ++--- rpiplay.cpp | 13 ++++++++----- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/raop.c b/lib/raop.c index c3bf0cb9..e85c49b9 100755 --- a/lib/raop.c +++ b/lib/raop.c @@ -33,6 +33,7 @@ unsigned int info_display_width = 1920; unsigned int info_display_height = 1080; +unsigned int info_display_framerate = 60; struct raop_s { /* Callbacks for audio and video */ @@ -344,10 +345,11 @@ raop_set_port(raop_t *raop, unsigned short port) { } void -raop_set_display(raop_t *raop, unsigned short display_width, unsigned short display_height) { +raop_set_display(raop_t *raop, unsigned short display_width, unsigned short display_height, unsigned short display_framerate) { assert(raop); info_display_width = display_width; info_display_height = display_height; + info_display_framerate = display_framerate; } unsigned short diff --git a/lib/raop.h b/lib/raop.h index ee422b7e..8bd0241d 100755 --- a/lib/raop.h +++ b/lib/raop.h @@ -7,6 +7,7 @@ extern unsigned int info_display_width; extern unsigned int info_display_height; +extern unsigned int info_display_framerate; #if defined (WIN32) && defined(DLL_EXPORT) # define RAOP_API __declspec(dllexport) @@ -58,7 +59,7 @@ RAOP_API raop_t *raop_init(int max_clients, raop_callbacks_t *callbacks); RAOP_API void raop_set_log_level(raop_t *raop, int level); RAOP_API void raop_set_log_callback(raop_t *raop, raop_log_callback_t callback, void *cls); RAOP_API void raop_set_port(raop_t *raop, unsigned short port); -RAOP_API void raop_set_display(raop_t *raop, unsigned short display_width, unsigned short display_height); +RAOP_API void raop_set_display(raop_t *raop, unsigned short display_width, unsigned short display_height, unsigned short display_framerate); RAOP_API unsigned short raop_get_port(raop_t *raop); RAOP_API void *raop_get_callback_cls(raop_t *raop); RAOP_API int raop_start(raop_t *raop, unsigned short *port); diff --git a/lib/raop_handlers.h b/lib/raop_handlers.h index 614566bb..e30b28bb 100755 --- a/lib/raop_handlers.h +++ b/lib/raop_handlers.h @@ -21,8 +21,6 @@ #include #include -#define FRAMERATE 60.0 - typedef void (*raop_handler_t)(raop_conn_t *, http_request_t *, http_response_t *, char **, int *); @@ -35,6 +33,7 @@ raop_handler_info(raop_conn_t *conn, printf("Display width reported as: %d\n", info_display_width); printf("Display height reported as: %d\n", info_display_height); + printf("Display framerate reported as: %d\n", info_display_framerate); int airplay_txt_len = 0; const char *airplay_txt = dnssd_get_airplay_txt(conn->raop->dnssd, &airplay_txt_len); @@ -144,7 +143,7 @@ raop_handler_info(raop_conn_t *conn, plist_t displays_0_width_pixels_node = plist_new_uint(info_display_width); plist_t displays_0_height_pixels_node = plist_new_uint(info_display_height); plist_t displays_0_rotation_node = plist_new_bool(0); - plist_t displays_0_refresh_rate_node = plist_new_real(1.0 / FRAMERATE); + plist_t displays_0_refresh_rate_node = plist_new_real(1.0 / info_display_framerate); plist_t displays_0_overscanned_node = plist_new_bool(1); plist_t displays_0_features = plist_new_uint(14); diff --git a/rpiplay.cpp b/rpiplay.cpp index 2fea14a6..be09bdfa 100755 --- a/rpiplay.cpp +++ b/rpiplay.cpp @@ -43,17 +43,18 @@ #define DEFAULT_ROTATE 0 #define DEFAULT_DISPLAY_WIDTH 1920 #define DEFAULT_DISPLAY_HEIGHT 1080 +#define DEFAULT_DISPLAY_FRAMERATE 60.0 #define DEFAULT_FLIP FLIP_NONE #define DEFAULT_HW_ADDRESS { (char) 0x48, (char) 0x5d, (char) 0x60, (char) 0x7c, (char) 0xee, (char) 0x22 } int start_server(std::vector hw_addr, std::string name, bool debug_log, - video_renderer_config_t const *video_config, audio_renderer_config_t const *audio_config, int display_width, int display_height); + video_renderer_config_t const *video_config, audio_renderer_config_t const *audio_config, int display_width, int display_height, float display_framerate); int stop_server(); int display_width = 1920; int display_height = 1080; - +float display_framerate = 60.0; typedef video_renderer_t *(*video_init_func_t)(logger_t *logger, video_renderer_config_t const *config); typedef audio_renderer_t *(*audio_init_func_t)(logger_t *logger, video_renderer_t *video_renderer, audio_renderer_config_t const *config); @@ -235,6 +236,8 @@ int main(int argc, char *argv[]) { display_width = atoi(argv[++i]); } else if (arg == "-y") { display_height = atoi(argv[++i]); + } else if (arg == "-z") { + display_framerate = atoi(argv[++i]); } else if (arg == "-f") { if (i == argc - 1) continue; std::string flip_type(argv[++i]); @@ -276,7 +279,7 @@ int main(int argc, char *argv[]) { parse_hw_addr(mac_address, server_hw_addr); } - if (start_server(server_hw_addr, server_name, debug_log, &video_config, &audio_config, display_width, display_height) != 0) { + if (start_server(server_hw_addr, server_name, debug_log, &video_config, &audio_config, display_width, display_height, display_framerate) != 0) { return 1; } @@ -349,7 +352,7 @@ extern "C" void log_callback(void *cls, int level, const char *msg) { } int start_server(std::vector hw_addr, std::string name, bool debug_log, - video_renderer_config_t const *video_config, audio_renderer_config_t const *audio_config, int display_width, int display_height) { + video_renderer_config_t const *video_config, audio_renderer_config_t const *audio_config, int display_width, int display_height, float display_framerate) { raop_callbacks_t raop_cbs; memset(&raop_cbs, 0, sizeof(raop_cbs)); raop_cbs.conn_init = conn_init; @@ -394,7 +397,7 @@ int start_server(std::vector hw_addr, std::string name, bool debug_log, unsigned short port = 0; raop_start(raop, &port); raop_set_port(raop, port); - raop_set_display(raop, display_width, display_height); + raop_set_display(raop, display_width, display_height, display_framerateß); int error; dnssd = dnssd_init(name.c_str(), strlen(name.c_str()), hw_addr.data(), hw_addr.size(), &error); From 3bf2a676c4d5c03719845733ab1187d307322862 Mon Sep 17 00:00:00 2001 From: seungjunProgramming Date: Sat, 19 Dec 2020 00:42:53 +0900 Subject: [PATCH 4/5] changed README.md to add about float type parm. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 59a082ec..39c2a6e1 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,8 @@ At the moment, these options are implemented: **-y**: Set display height -**-z**: Set display framerate(Added #define, adding support for start arg.) +**-z**: Set display framerate(in float) +(ex: 60.0, 30.0, etc...) # Disclaimer From b192a4bd8863b713d73f351be725ee8a69c978ba Mon Sep 17 00:00:00 2001 From: seungjunProgramming <64799763+seungjunProgramming@users.noreply.github.com> Date: Thu, 29 Jul 2021 02:15:15 +0900 Subject: [PATCH 5/5] Fix typo on rpiplay.cpp --- rpiplay.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpiplay.cpp b/rpiplay.cpp index be09bdfa..937605f7 100755 --- a/rpiplay.cpp +++ b/rpiplay.cpp @@ -397,7 +397,7 @@ int start_server(std::vector hw_addr, std::string name, bool debug_log, unsigned short port = 0; raop_start(raop, &port); raop_set_port(raop, port); - raop_set_display(raop, display_width, display_height, display_framerateß); + raop_set_display(raop, display_width, display_height, display_framerate); int error; dnssd = dnssd_init(name.c_str(), strlen(name.c_str()), hw_addr.data(), hw_addr.size(), &error);