temp
This commit is contained in:
parent
4c66e3c37a
commit
7e9690e621
@ -67,22 +67,18 @@ static void on_mqtt_message_received(const std::string &topic, const std::string
|
|||||||
StreamType type = (streamType == 0) ? StreamType::MAIN : StreamType::SUB;
|
StreamType type = (streamType == 0) ? StreamType::MAIN : StreamType::SUB;
|
||||||
auto channels = data.value("channels", std::vector<int>{});
|
auto channels = data.value("channels", std::vector<int>{});
|
||||||
|
|
||||||
nlohmann::json resp_data = nlohmann::json::array();
|
|
||||||
|
|
||||||
for (int ch : channels)
|
for (int ch : channels)
|
||||||
{
|
{
|
||||||
if (ch < 0 || ch >= static_cast<int>(g_app_config.cameras.size()))
|
if (ch < 0 || ch >= static_cast<int>(g_app_config.cameras.size()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Camera &cam = g_app_config.cameras[ch];
|
Camera &cam = g_app_config.cameras[ch];
|
||||||
bool op_result = false;
|
|
||||||
|
|
||||||
if (switch_val == 0)
|
if (switch_val == 0)
|
||||||
{
|
{
|
||||||
if (!RTMPManager::is_streaming(cam.name, type))
|
if (!RTMPManager::is_streaming(cam.name, type))
|
||||||
{
|
{
|
||||||
RTMPManager::start_camera(cam, type, seqNo);
|
RTMPManager::start_camera(cam, type, seqNo);
|
||||||
op_result = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -90,25 +86,9 @@ static void on_mqtt_message_received(const std::string &topic, const std::string
|
|||||||
if (RTMPManager::is_streaming(cam.name, type))
|
if (RTMPManager::is_streaming(cam.name, type))
|
||||||
{
|
{
|
||||||
RTMPManager::stop_camera(cam.name, type, seqNo);
|
RTMPManager::stop_camera(cam.name, type, seqNo);
|
||||||
op_result = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json ch_resp;
|
|
||||||
ch_resp["loc"] = ch;
|
|
||||||
ch_resp["url"] = op_result ? RTMPManager::get_stream_url(cam.name, type) : "";
|
|
||||||
ch_resp["result"] = op_result ? 0 : 1;
|
|
||||||
ch_resp["reason"] = op_result ? "" : "already in requested state";
|
|
||||||
|
|
||||||
resp_data.push_back(ch_resp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json reply;
|
|
||||||
reply["type"] = "response";
|
|
||||||
reply["seqNo"] = seqNo;
|
|
||||||
reply["data"] = resp_data;
|
|
||||||
|
|
||||||
mqtt_client->publish(topic, reply.dump());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user