diff --git a/README.md b/README.md index 38263c96..a12e7d1d 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,12 @@ 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(in float) +(ex: 60.0, 30.0, etc...) # Disclaimer diff --git a/lib/raop.c b/lib/raop.c index 4523a2c4..e85c49b9 100755 --- a/lib/raop.c +++ b/lib/raop.c @@ -31,6 +31,10 @@ #include "raop_rtp_mirror.h" #include "raop_ntp.h" +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 */ raop_callbacks_t callbacks; @@ -340,6 +344,14 @@ 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, unsigned short display_framerate) { + assert(raop); + info_display_width = display_width; + info_display_height = display_height; + info_display_framerate = display_framerate; +} + unsigned short raop_get_port(raop_t *raop) { assert(raop); diff --git a/lib/raop.h b/lib/raop.h index cfd703e1..8bd0241d 100755 --- a/lib/raop.h +++ b/lib/raop.h @@ -5,6 +5,10 @@ #include "stream.h" #include "raop_ntp.h" +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) #else @@ -55,6 +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, 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 104b1c41..e30b28bb 100755 --- a/lib/raop_handlers.h +++ b/lib/raop_handlers.h @@ -31,6 +31,10 @@ 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); + 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); @@ -134,12 +138,12 @@ 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_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 c5a67745..937605f7 100755 --- a/rpiplay.cpp +++ b/rpiplay.cpp @@ -41,14 +41,21 @@ #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_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); + 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); @@ -178,7 +185,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 +195,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 +232,12 @@ 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 == "-z") { + display_framerate = atoi(argv[++i]); } else if (arg == "-f") { if (i == argc - 1) continue; std::string flip_type(argv[++i]); @@ -266,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) != 0) { + if (start_server(server_hw_addr, server_name, debug_log, &video_config, &audio_config, display_width, display_height, display_framerate) != 0) { return 1; } @@ -339,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) { + 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; @@ -384,6 +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); int error; dnssd = dnssd_init(name.c_str(), strlen(name.c_str()), hw_addr.data(), hw_addr.size(), &error);