diff --git a/AppConfig.cpp b/AppConfig.cpp index ef61f26..ea0e73c 100644 --- a/AppConfig.cpp +++ b/AppConfig.cpp @@ -660,6 +660,12 @@ bool applyConfigFile( feed.kind = FeedKind::MxlSdk; } + if (const std::string* label = + jsonString(objectField(*feedObject, "label"))) + { + feed.label = *label; + } + config.feeds[i] = std::move(feed); } diff --git a/AppConfig.hpp b/AppConfig.hpp index 05fc600..870ce57 100644 --- a/AppConfig.hpp +++ b/AppConfig.hpp @@ -35,6 +35,7 @@ struct FeedConfig FeedKind kind = FeedKind::NoSignal; std::string mxlDomain; std::string mxlFlowId; + std::string label; }; struct AppConfig diff --git a/README.md b/README.md index cfcce9a..9455ee7 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,16 @@ Run with an existing feed config: ./build-sdk/mxl_multiviewer --perf --grid 4x4 --config /tmp/feeds_config.json ``` +Each feed object can include an optional `label` field to override the tile UI text: + +```json +{ + "domain": "/tmp/mxl", + "flow": "853a9cda-0f7a-4b48-b2df-b3f628440150", + "label": "Camera 1" +} +``` + Useful probe flags: ```bash diff --git a/config.example.json b/config.example.json index 08e0a2e..b148039 100644 --- a/config.example.json +++ b/config.example.json @@ -7,11 +7,13 @@ "feeds": [ { "domain": "/tmp/mxl", - "flow": "853a9cda-0f7a-4b48-b2df-b3f628440150" + "flow": "853a9cda-0f7a-4b48-b2df-b3f628440150", + "label": "Camera 1" }, { "domain": "/tmp/mxl", - "flow": "fab60e17-f721-4e12-a7dd-312f5f6e502d" + "flow": "fab60e17-f721-4e12-a7dd-312f5f6e502d", + "label": "Camera 2" }, { "kind": "nosignal" diff --git a/main.cpp b/main.cpp index 6c29450..847a3fa 100644 --- a/main.cpp +++ b/main.cpp @@ -464,6 +464,7 @@ static ImU32 tileLabelColor( static void drawTileLabels( const std::vector>& feeds, + const std::vector& feedConfigs, uint32_t gridCols, uint32_t gridRows) { @@ -492,12 +493,20 @@ static void drawTileLabels( feeds[i]->status(); const std::string sourceInfo = feeds[i]->sourceInfo(); + const std::string labelOverride = + i < feedConfigs.size() + ? feedConfigs[i].label + : ""; + const std::string labelText = + !labelOverride.empty() + ? labelOverride + : sourceInfo.empty() + ? feedRuntimeStatusDisplayName(status) + : sourceInfo; const std::string label = std::to_string(i + 1) + ": " + - (sourceInfo.empty() - ? feedRuntimeStatusDisplayName(status) - : sourceInfo); + labelText; const ImVec2 labelMin( tileRect.x0, @@ -716,6 +725,12 @@ int main(int argc, char* argv[]) << " flowId=" << config.feeds[i].mxlFlowId; } + if (!config.feeds[i].label.empty()) + { + std::cout + << " label=\"" << config.feeds[i].label << "\""; + } + std::cout << std::endl; feeds[i] = createFeed( @@ -1809,6 +1824,7 @@ int main(int argc, char* argv[]) drawTileLabels( feeds, + config.feeds, config.gridCols, config.gridRows );