nu
This commit is contained in:
parent
875a53f499
commit
d812c6aeab
8 changed files with 2688 additions and 113 deletions
|
|
@ -16,26 +16,43 @@ public:
|
|||
}
|
||||
|
||||
// Get list of active streams
|
||||
void getActiveStreams(std::function<void(bool, const Json::Value&)> callback) {
|
||||
auto request = createRequest(drogon::Get, "/v1/vhosts/default/apps/app/streams");
|
||||
|
||||
getClient()->sendRequest(request, [callback](drogon::ReqResult result, const drogon::HttpResponsePtr& response) {
|
||||
if (result == drogon::ReqResult::Ok && response && response->getStatusCode() == drogon::k200OK) {
|
||||
try {
|
||||
Json::Value json = *response->getJsonObject();
|
||||
// In backend/src/services/OmeClient.h
|
||||
|
||||
void getActiveStreams(std::function<void(bool, const Json::Value&)> callback) {
|
||||
// Try the streams endpoint first
|
||||
auto request = createRequest(drogon::Get, "/v1/vhosts/default/apps/app/streams");
|
||||
|
||||
getClient()->sendRequest(request, [callback](drogon::ReqResult result, const drogon::HttpResponsePtr& response) {
|
||||
if (result == drogon::ReqResult::Ok && response && response->getStatusCode() == drogon::k200OK) {
|
||||
try {
|
||||
Json::Value json = *response->getJsonObject();
|
||||
LOG_DEBUG << "OME streams response: " << json.toStyledString();
|
||||
|
||||
// OME might return the streams in different formats
|
||||
// Sometimes it's {"response": ["stream1", "stream2"]}
|
||||
// Sometimes it's {"response": {"streams": ["stream1", "stream2"]}}
|
||||
if (json.isMember("response")) {
|
||||
callback(true, json);
|
||||
} catch (const std::exception& e) {
|
||||
LOG_ERROR << "Failed to parse OME response: " << e.what();
|
||||
Json::Value empty;
|
||||
callback(false, empty);
|
||||
} else {
|
||||
// Wrap the response if needed
|
||||
Json::Value wrapped;
|
||||
wrapped["response"] = json;
|
||||
callback(true, wrapped);
|
||||
}
|
||||
} else {
|
||||
LOG_ERROR << "Failed to get active streams from OME";
|
||||
} catch (const std::exception& e) {
|
||||
LOG_ERROR << "Failed to parse OME response: " << e.what();
|
||||
Json::Value empty;
|
||||
empty["response"] = Json::arrayValue;
|
||||
callback(false, empty);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
LOG_ERROR << "Failed to get active streams from OME";
|
||||
Json::Value empty;
|
||||
empty["response"] = Json::arrayValue;
|
||||
callback(false, empty);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Get stats for a specific stream
|
||||
void getStreamStats(const std::string& streamKey,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue