mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-02-22 12:40:11 +00:00
Remove redundant code
This commit is contained in:
parent
cc3cf60015
commit
3d81b0fe7a
@ -190,7 +190,7 @@ struct session_t {
|
|||||||
struct {
|
struct {
|
||||||
int lowseq;
|
int lowseq;
|
||||||
udp::endpoint peer;
|
udp::endpoint peer;
|
||||||
safe::mail_raw_t::event_t<video::idr_t> idr_events;
|
safe::mail_raw_t::event_t<bool> idr_events;
|
||||||
} video;
|
} video;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@ -456,7 +456,7 @@ void controlBroadcastThread(control_server_t *server) {
|
|||||||
<< "firstFrame [" << firstFrame << ']' << std::endl
|
<< "firstFrame [" << firstFrame << ']' << std::endl
|
||||||
<< "lastFrame [" << lastFrame << ']';
|
<< "lastFrame [" << lastFrame << ']';
|
||||||
|
|
||||||
session->video.idr_events->raise(std::make_pair(firstFrame, lastFrame));
|
session->video.idr_events->raise(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
server->map(packetTypes[IDX_INPUT_DATA], [&](session_t *session, const std::string_view &payload) {
|
server->map(packetTypes[IDX_INPUT_DATA], [&](session_t *session, const std::string_view &payload) {
|
||||||
@ -1023,7 +1023,7 @@ std::shared_ptr<session_t> alloc(config_t &config, crypto::aes_t &gcm_key, crypt
|
|||||||
session->gcm_key = gcm_key;
|
session->gcm_key = gcm_key;
|
||||||
session->iv = iv;
|
session->iv = iv;
|
||||||
|
|
||||||
session->video.idr_events = mail->event<video::idr_t>(mail::idr);
|
session->video.idr_events = mail->event<bool>(mail::idr);
|
||||||
session->video.lowseq = 0;
|
session->video.lowseq = 0;
|
||||||
|
|
||||||
session->audio.sequenceNumber = 0;
|
session->audio.sequenceNumber = 0;
|
||||||
|
@ -353,12 +353,11 @@ struct sync_session_ctx_t {
|
|||||||
safe::signal_t *join_event;
|
safe::signal_t *join_event;
|
||||||
safe::mail_raw_t::event_t<bool> shutdown_event;
|
safe::mail_raw_t::event_t<bool> shutdown_event;
|
||||||
safe::mail_raw_t::queue_t<packet_t> packets;
|
safe::mail_raw_t::queue_t<packet_t> packets;
|
||||||
safe::mail_raw_t::event_t<idr_t> idr_events;
|
safe::mail_raw_t::event_t<bool> idr_events;
|
||||||
safe::mail_raw_t::event_t<input::touch_port_t> touch_port_events;
|
safe::mail_raw_t::event_t<input::touch_port_t> touch_port_events;
|
||||||
|
|
||||||
config_t config;
|
config_t config;
|
||||||
int frame_nr;
|
int frame_nr;
|
||||||
int key_frame_nr;
|
|
||||||
void *channel_data;
|
void *channel_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -986,7 +985,7 @@ std::optional<session_t> make_session(const encoder_t &encoder, const config_t &
|
|||||||
}
|
}
|
||||||
|
|
||||||
void encode_run(
|
void encode_run(
|
||||||
int &frame_nr, int &key_frame_nr, // Store progress of the frame number
|
int &frame_nr, // Store progress of the frame number
|
||||||
safe::mail_t mail,
|
safe::mail_t mail,
|
||||||
img_event_t images,
|
img_event_t images,
|
||||||
config_t config,
|
config_t config,
|
||||||
@ -1009,7 +1008,7 @@ void encode_run(
|
|||||||
|
|
||||||
auto shutdown_event = mail->event<bool>(mail::shutdown);
|
auto shutdown_event = mail->event<bool>(mail::shutdown);
|
||||||
auto packets = mail::man->queue<packet_t>(mail::video_packets);
|
auto packets = mail::man->queue<packet_t>(mail::video_packets);
|
||||||
auto idr_events = mail->event<idr_t>(mail::idr);
|
auto idr_events = mail->event<bool>(mail::idr);
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
if(shutdown_event->peek() || reinit_event.peek() || !images->running()) {
|
if(shutdown_event->peek() || reinit_event.peek() || !images->running()) {
|
||||||
@ -1020,12 +1019,7 @@ void encode_run(
|
|||||||
frame->pict_type = AV_PICTURE_TYPE_I;
|
frame->pict_type = AV_PICTURE_TYPE_I;
|
||||||
frame->key_frame = 1;
|
frame->key_frame = 1;
|
||||||
|
|
||||||
auto event = idr_events->pop();
|
idr_events->pop();
|
||||||
if(!event) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
key_frame_nr = frame_nr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::this_thread::sleep_until(next_frame);
|
std::this_thread::sleep_until(next_frame);
|
||||||
@ -1201,15 +1195,7 @@ encode_e encode_run_sync(std::vector<std::unique_ptr<sync_session_ctx_t>> &synce
|
|||||||
frame->pict_type = AV_PICTURE_TYPE_I;
|
frame->pict_type = AV_PICTURE_TYPE_I;
|
||||||
frame->key_frame = 1;
|
frame->key_frame = 1;
|
||||||
|
|
||||||
auto event = ctx->idr_events->pop();
|
ctx->idr_events->pop();
|
||||||
auto end = event->second;
|
|
||||||
|
|
||||||
ctx->frame_nr = end;
|
|
||||||
ctx->key_frame_nr = end + ctx->config.framerate;
|
|
||||||
}
|
|
||||||
else if(ctx->frame_nr == ctx->key_frame_nr) {
|
|
||||||
frame->pict_type = AV_PICTURE_TYPE_I;
|
|
||||||
frame->key_frame = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(img_tmp) {
|
if(img_tmp) {
|
||||||
@ -1306,8 +1292,7 @@ void capture_async(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int frame_nr = 1;
|
int frame_nr = 1;
|
||||||
int key_frame_nr = 1;
|
|
||||||
|
|
||||||
auto touch_port_event = mail->event<input::touch_port_t>(mail::touch_port);
|
auto touch_port_event = mail->event<input::touch_port_t>(mail::touch_port);
|
||||||
|
|
||||||
@ -1345,7 +1330,7 @@ void capture_async(
|
|||||||
touch_port_event->raise(make_port(display.get(), config));
|
touch_port_event->raise(make_port(display.get(), config));
|
||||||
|
|
||||||
encode_run(
|
encode_run(
|
||||||
frame_nr, key_frame_nr,
|
frame_nr,
|
||||||
mail, images,
|
mail, images,
|
||||||
config, display->width, display->height,
|
config, display->width, display->height,
|
||||||
hwdevice.get(),
|
hwdevice.get(),
|
||||||
@ -1359,9 +1344,9 @@ void capture(
|
|||||||
config_t config,
|
config_t config,
|
||||||
void *channel_data) {
|
void *channel_data) {
|
||||||
|
|
||||||
auto idr_events = mail->event<idr_t>(mail::idr);
|
auto idr_events = mail->event<bool>(mail::idr);
|
||||||
|
|
||||||
idr_events->raise(std::make_pair(0, 1));
|
idr_events->raise(true);
|
||||||
if(encoders.front().flags & SYSTEM_MEMORY) {
|
if(encoders.front().flags & SYSTEM_MEMORY) {
|
||||||
capture_async(std::move(mail), config, channel_data);
|
capture_async(std::move(mail), config, channel_data);
|
||||||
}
|
}
|
||||||
@ -1376,7 +1361,6 @@ void capture(
|
|||||||
mail->event<input::touch_port_t>(mail::touch_port),
|
mail->event<input::touch_port_t>(mail::touch_port),
|
||||||
config,
|
config,
|
||||||
1,
|
1,
|
||||||
1,
|
|
||||||
channel_data,
|
channel_data,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -57,7 +57,6 @@ struct packet_raw_t : public AVPacket {
|
|||||||
};
|
};
|
||||||
|
|
||||||
using packet_t = std::unique_ptr<packet_raw_t>;
|
using packet_t = std::unique_ptr<packet_raw_t>;
|
||||||
using idr_t = std::pair<int64_t, int64_t>;
|
|
||||||
|
|
||||||
struct config_t {
|
struct config_t {
|
||||||
int width;
|
int width;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user