diff --git a/assets/sunshine.conf b/assets/sunshine.conf index 7d406b64..e5e47887 100644 --- a/assets/sunshine.conf +++ b/assets/sunshine.conf @@ -15,7 +15,12 @@ unique_id = 03904e64-51da-4fb3-9afd-a9f7ff70fea4 file_devices = devices.xml # How long to wait in milliseconds for data from moonlight before shutting down the stream -ping_timeout = 2000 +ping_timeout = 2000 + +# How much error correcting packets must be send for every video max_b_frames +# This is just some random number, don't know the optimal value +# The higher fec_percentage, the lower space for the actual data to send per frame there is +fec_percentage = 25 ############################################### # FFmpeg software encoding parameters diff --git a/sunshine/config.cpp b/sunshine/config.cpp index cae13bae..e4b9f486 100644 --- a/sunshine/config.cpp +++ b/sunshine/config.cpp @@ -28,7 +28,8 @@ video_t video { }; stream_t stream { - 2s // ping_timeout + 2s, // ping_timeout + 13 // fecPercentage }; nvhttp_t nvhttp { @@ -136,6 +137,8 @@ void parse_file(const char *file) { if(to > 0) { stream.ping_timeout = std::chrono::milliseconds(to); } + + int_f(vars, "fec_percentage", stream.fec_percentage); } diff --git a/sunshine/config.h b/sunshine/config.h index e51ce41b..ad82e5d5 100644 --- a/sunshine/config.h +++ b/sunshine/config.h @@ -20,6 +20,8 @@ struct video_t { struct stream_t { std::chrono::milliseconds ping_timeout; + + int fec_percentage; }; struct nvhttp_t { diff --git a/sunshine/stream.cpp b/sunshine/stream.cpp index 116c3d80..464639f2 100644 --- a/sunshine/stream.cpp +++ b/sunshine/stream.cpp @@ -627,7 +627,7 @@ void videoThread(video::idr_event_t idr_events) { auto blocksize = config.packetsize + MAX_RTP_HEADER_SIZE; auto payload_blocksize = blocksize - sizeof(video_packet_raw_t); - auto fecpercentage { 25 }; + auto fecPercentage = config::stream.fec_percentage; payload_new = insert(sizeof(video_packet_raw_t), payload_blocksize, payload, [&](void *p, int fecIndex, int end) { @@ -639,7 +639,7 @@ void videoThread(video::idr_event_t idr_events) { video_packet->packet.fecInfo = ( fecIndex << 12 | end << 22 | - fecpercentage << 4 + fecPercentage << 4 ); if(fecIndex == 0) { @@ -655,7 +655,7 @@ void videoThread(video::idr_event_t idr_events) { payload = {(char *) payload_new.data(), payload_new.size()}; - auto shards = fec::encode(payload, blocksize, fecpercentage); + auto shards = fec::encode(payload, blocksize, fecPercentage); if(shards.data_shards == 0) { std::cout << "skipping frame..."sv << std::endl; continue; @@ -668,7 +668,7 @@ void videoThread(video::idr_event_t idr_events) { inspect->packet.fecInfo = ( x << 12 | shards.data_shards << 22 | - fecpercentage << 4 + fecPercentage << 4 ); inspect->rtp.sequenceNumber = util::endian::big(lowseq + x);