Skip to content
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

Added screen resolution and framerate support #191

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions lib/raop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions lib/raop.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 9 additions & 5 deletions lib/raop_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
26 changes: 20 additions & 6 deletions rpiplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char> 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);

Expand Down Expand Up @@ -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<char> server_hw_addr = DEFAULT_HW_ADDRESS;
bool debug_log = DEFAULT_DEBUG_LOG;
Expand All @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -339,7 +352,7 @@ extern "C" void log_callback(void *cls, int level, const char *msg) {
}

int start_server(std::vector<char> 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;
Expand Down Expand Up @@ -384,6 +397,7 @@ int start_server(std::vector<char> 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);
Expand Down