Call encoder.on_done in a function

pull/65/head
Andri Yngvason 2022-06-05 15:50:43 +00:00
parent d4258a0aab
commit 9285594e9d
6 changed files with 14 additions and 8 deletions

View File

@ -90,3 +90,6 @@ int encoder_push(struct encoder* self, struct nvnc_fb* fb,
struct rcbuf* encoder_pull(struct encoder* self, uint64_t* pts);
void encoder_request_key_frame(struct encoder* self);
void encoder_finish_frame(struct encoder* self, struct rcbuf* result,
uint64_t pts);

View File

@ -141,3 +141,10 @@ void encoder_request_key_frame(struct encoder* self)
if (self->impl->request_key_frame)
return self->impl->request_key_frame(self);
}
void encoder_finish_frame(struct encoder* self, struct rcbuf* result,
uint64_t pts)
{
if (self->on_done)
self->on_done(self, result, pts);
}

View File

@ -76,8 +76,7 @@ static void open_h264_handle_packet(const void* data, size_t size, uint64_t pts,
vec_append(&self->pending, data, size);
self->pts = pts;
if (self->parent.on_done)
self->parent.on_done(&self->parent, NULL, NVNC_NO_PTS);
encoder_finish_frame(&self->parent, NULL, NVNC_NO_PTS);
}
static int open_h264_init_pending(struct open_h264* self)

View File

@ -173,8 +173,7 @@ static void raw_encoder_on_done(void* obj)
aml_unref(self->work);
self->work = NULL;
if (self->encoder.on_done)
self->encoder.on_done(&self->encoder, result, pts);
encoder_finish_frame(&self->encoder, result, pts);
rcbuf_unref(result);
}

View File

@ -519,8 +519,7 @@ static void on_tight_finished(void* obj)
self->encoder.n_rects = self->n_rects;
if (self->encoder.on_done)
self->encoder.on_done(&self->encoder, result, self->pts);
encoder_finish_frame(&self->encoder, result, self->pts);
self->pts = NVNC_NO_PTS;
rcbuf_unref(result);

View File

@ -375,8 +375,7 @@ static void zrle_encoder_on_done(void* obj)
aml_unref(self->work);
self->work = NULL;
if (self->encoder.on_done)
self->encoder.on_done(&self->encoder, result, pts);
encoder_finish_frame(&self->encoder, result, pts);
rcbuf_unref(result);
}