Added fec_percentage as configurable variable

This commit is contained in:
loki 2019-12-11 23:37:20 +01:00
parent e0c1e4ec55
commit c819664e33
4 changed files with 16 additions and 6 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -20,6 +20,8 @@ struct video_t {
struct stream_t {
std::chrono::milliseconds ping_timeout;
int fec_percentage;
};
struct nvhttp_t {

View File

@ -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<uint16_t>(lowseq + x);