mirror of
https://github.com/thinkonmay/sunshine-sdk.git
synced 2026-08-07 06:48:56 +00:00
update rtsp server
This commit is contained in:
parent
ed74034285
commit
d1fbacde41
@ -19,6 +19,9 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
|
||||
endif()
|
||||
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../../package)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../../package)
|
||||
|
||||
# set the module path, used for includes
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
|
||||
@ -6,14 +6,6 @@ install(TARGETS sunshine RUNTIME DESTINATION "." COMPONENT application)
|
||||
# Hardening: include zlib1.dll (loaded via LoadLibrary() in openssl's libcrypto.a)
|
||||
install(FILES "${ZLIB}" DESTINATION "." COMPONENT application)
|
||||
|
||||
# Adding tools
|
||||
install(TARGETS dxgi-info RUNTIME DESTINATION "tools" COMPONENT dxgi)
|
||||
install(TARGETS audio-info RUNTIME DESTINATION "tools" COMPONENT audio)
|
||||
|
||||
# Mandatory tools
|
||||
install(TARGETS ddprobe RUNTIME DESTINATION "tools" COMPONENT application)
|
||||
install(TARGETS sunshinesvc RUNTIME DESTINATION "tools" COMPONENT application)
|
||||
|
||||
# Mandatory scripts
|
||||
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/service/"
|
||||
DESTINATION "scripts"
|
||||
@ -134,16 +126,6 @@ set(CPACK_COMPONENT_ASSETS_DESCRIPTION "Shaders, default box art, and web UI.")
|
||||
set(CPACK_COMPONENT_ASSETS_GROUP "Core")
|
||||
set(CPACK_COMPONENT_ASSETS_REQUIRED true)
|
||||
|
||||
# audio tool
|
||||
set(CPACK_COMPONENT_AUDIO_DISPLAY_NAME "audio-info")
|
||||
set(CPACK_COMPONENT_AUDIO_DESCRIPTION "CLI tool providing information about sound devices.")
|
||||
set(CPACK_COMPONENT_AUDIO_GROUP "Tools")
|
||||
|
||||
# display tool
|
||||
set(CPACK_COMPONENT_DXGI_DISPLAY_NAME "dxgi-info")
|
||||
set(CPACK_COMPONENT_DXGI_DESCRIPTION "CLI tool providing information about graphics cards and displays.")
|
||||
set(CPACK_COMPONENT_DXGI_GROUP "Tools")
|
||||
|
||||
# firewall scripts
|
||||
set(CPACK_COMPONENT_FIREWALL_DISPLAY_NAME "Add Firewall Exclusions")
|
||||
set(CPACK_COMPONENT_FIREWALL_DESCRIPTION "Scripts to enable or disable firewall rules.")
|
||||
|
||||
@ -426,7 +426,7 @@ namespace config {
|
||||
};
|
||||
|
||||
sunshine_t sunshine {
|
||||
2, // min_log_level
|
||||
1, // min_log_level
|
||||
0, // flags
|
||||
{}, // User file
|
||||
{}, // Username
|
||||
|
||||
71
src/rtsp.cpp
71
src/rtsp.cpp
@ -221,7 +221,6 @@ namespace rtsp_stream {
|
||||
class rtsp_server_t {
|
||||
public:
|
||||
~rtsp_server_t() {
|
||||
clear();
|
||||
}
|
||||
|
||||
int
|
||||
@ -285,8 +284,6 @@ namespace rtsp_stream {
|
||||
if (ec) {
|
||||
BOOST_LOG(error) << "Couldn't accept incoming connections: "sv << ec.message();
|
||||
|
||||
// Stop server
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -328,56 +325,6 @@ namespace rtsp_stream {
|
||||
|
||||
safe::event_t<rtsp_stream::launch_session_t> launch_event;
|
||||
|
||||
void
|
||||
clear(bool all = true) {
|
||||
// if a launch event timed out --> Remove it.
|
||||
if (raised_timeout < std::chrono::steady_clock::now()) {
|
||||
auto discarded = launch_event.pop(0s);
|
||||
if (discarded) {
|
||||
++_slot_count;
|
||||
}
|
||||
}
|
||||
|
||||
auto lg = _session_slots.lock();
|
||||
|
||||
for (auto &slot : *_session_slots) {
|
||||
if (slot && (all || stream::session::state(*slot) == stream::session::state_e::STOPPING)) {
|
||||
stream::session::stop(*slot);
|
||||
stream::session::join(*slot);
|
||||
|
||||
slot.reset();
|
||||
|
||||
++_slot_count;
|
||||
}
|
||||
}
|
||||
|
||||
if (all && !ios.stopped()) {
|
||||
ios.stop();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
clear(std::shared_ptr<stream::session_t> *session_p) {
|
||||
auto lg = _session_slots.lock();
|
||||
|
||||
session_p->reset();
|
||||
|
||||
++_slot_count;
|
||||
}
|
||||
|
||||
std::shared_ptr<stream::session_t> *
|
||||
accept(std::shared_ptr<stream::session_t> &session) {
|
||||
auto lg = _session_slots.lock();
|
||||
|
||||
for (auto &slot : *_session_slots) {
|
||||
if (!slot) {
|
||||
slot = session;
|
||||
return &slot;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string_view, cmd_func_t> _map_cmd_cb;
|
||||
@ -703,18 +650,9 @@ namespace rtsp_stream {
|
||||
auto iv = util::from_hex<crypto::aes_t>(config::sunshine.password, true);
|
||||
auto session = stream::session::alloc(config, gcm,iv);
|
||||
|
||||
auto slot = server->accept(session);
|
||||
if (!slot) {
|
||||
BOOST_LOG(info) << "Ran out of slots for client from ["sv << ']';
|
||||
|
||||
respond(sock, &option, 503, "Service Unavailable", req->sequenceNumber, {});
|
||||
return;
|
||||
}
|
||||
|
||||
if (stream::session::start(*session, sock.remote_endpoint().address().to_string())) {
|
||||
BOOST_LOG(error) << "Failed to start a streaming session"sv;
|
||||
|
||||
server->clear(slot);
|
||||
respond(sock, &option, 500, "Internal Server Error", req->sequenceNumber, {});
|
||||
return;
|
||||
}
|
||||
@ -757,17 +695,8 @@ namespace rtsp_stream {
|
||||
|
||||
while (!shutdown_event->peek()) {
|
||||
server.iterate(std::min(500ms, config::stream.ping_timeout));
|
||||
|
||||
if (broadcast_shutdown_event->peek()) {
|
||||
server.clear();
|
||||
}
|
||||
else {
|
||||
// cleanup all stopped sessions
|
||||
server.clear(false);
|
||||
}
|
||||
}
|
||||
|
||||
server.clear();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@ -4,36 +4,3 @@ project(sunshine_tools)
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR})
|
||||
|
||||
add_executable(dxgi-info dxgi.cpp)
|
||||
set_target_properties(dxgi-info PROPERTIES CXX_STANDARD 17)
|
||||
target_link_libraries(dxgi-info
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
dxgi
|
||||
${PLATFORM_LIBRARIES})
|
||||
target_compile_options(dxgi-info PRIVATE ${SUNSHINE_COMPILE_OPTIONS})
|
||||
|
||||
add_executable(audio-info audio.cpp)
|
||||
set_target_properties(audio-info PROPERTIES CXX_STANDARD 17)
|
||||
target_link_libraries(audio-info
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
ksuser
|
||||
${PLATFORM_LIBRARIES})
|
||||
target_compile_options(audio-info PRIVATE ${SUNSHINE_COMPILE_OPTIONS})
|
||||
|
||||
add_executable(sunshinesvc sunshinesvc.cpp)
|
||||
set_target_properties(sunshinesvc PROPERTIES CXX_STANDARD 17)
|
||||
target_link_libraries(sunshinesvc
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
wtsapi32
|
||||
${PLATFORM_LIBRARIES})
|
||||
target_compile_options(sunshinesvc PRIVATE ${SUNSHINE_COMPILE_OPTIONS})
|
||||
|
||||
add_executable(ddprobe ddprobe.cpp)
|
||||
set_target_properties(ddprobe PROPERTIES CXX_STANDARD 17)
|
||||
target_link_libraries(ddprobe
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
dxgi
|
||||
d3d11
|
||||
${PLATFORM_LIBRARIES})
|
||||
target_compile_options(ddprobe PRIVATE ${SUNSHINE_COMPILE_OPTIONS})
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user