X-Git-Url: https://git.sesse.net/?p=nageru;a=blobdiff_plain;f=mixer.cpp;h=70175a163c4a2c9a51be1690a9c9c408ac16f81f;hp=4deba02ac52e97554257bbb109684451a3de6ea9;hb=2f4224d7c48b3b22bcb24eb622fe6705fa16375f;hpb=df8ef0e2bcb4b9d5061ad9dd9435d77d761703a0 diff --git a/mixer.cpp b/mixer.cpp index 4deba02..70175a1 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -51,6 +51,10 @@ #include "v210_converter.h" #include "video_encoder.h" +#undef Status +#include +#include "json.pb.h" + class IDeckLink; class QOpenGLContext; @@ -352,6 +356,13 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards) // Must be instantiated after VideoEncoder has initialized global_flags.use_zerocopy. theme.reset(new Theme(global_flags.theme_filename, global_flags.theme_dirs, resource_pool.get(), num_cards)); + httpd.add_endpoint("/channels", bind(&Mixer::get_channels_json, this)); + for (int channel_idx = 2; channel_idx < theme->get_num_channels(); ++channel_idx) { + char url[256]; + snprintf(url, sizeof(url), "/channels/%d/color", channel_idx); + httpd.add_endpoint(url, bind(&Mixer::get_channel_color_http, this, unsigned(channel_idx))); + } + // Start listening for clients only once VideoEncoder has written its header, if any. httpd.start(global_flags.http_port); @@ -1096,6 +1107,24 @@ void Mixer::trim_queue(CaptureCard *card, size_t safe_queue_length) #endif } +pair Mixer::get_channels_json() +{ + Channels ret; + for (int channel_idx = 2; channel_idx < theme->get_num_channels(); ++channel_idx) { + Channel *channel = ret.add_channel(); + channel->set_index(channel_idx); + channel->set_name(theme->get_channel_name(channel_idx)); + channel->set_color(theme->get_channel_color(channel_idx)); + } + string contents; + google::protobuf::util::MessageToJsonString(ret, &contents); // Ignore any errors. + return make_pair(contents, "text/json"); +} + +pair Mixer::get_channel_color_http(unsigned channel_idx) +{ + return make_pair(theme->get_channel_color(channel_idx), "text/plain"); +} Mixer::OutputFrameInfo Mixer::get_one_frame_from_each_card(unsigned master_card_index, bool master_card_is_output, CaptureCard::NewFrame new_frames[MAX_VIDEO_CARDS], bool has_new_frame[MAX_VIDEO_CARDS]) {