Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added cadeaubuild-output/win-x64/native/xmf.dll
Binary file not shown.
40 changes: 28 additions & 12 deletions libxmf/XmfWebM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct xmf_webm
uint32_t frame_rate;
uint64_t frame_count;
uint64_t frame_time;
uint64_t pending_frame_start_time;
uint64_t first_encode_time;
uint64_t last_encode_time;
vpx_codec_pts_t pts;
Expand Down Expand Up @@ -206,21 +207,26 @@ int XmfWebM_EncodeImage(XmfWebM* ctx, vpx_image_t* img, vpx_codec_pts_t start, u
return got_pkts;
}

int XmfWebM_EncodeInternal(XmfWebM* ctx, bool force)
int XmfWebM_EncodePendingFrame(XmfWebM* ctx, bool force)
{
uint32_t ms_per_frame;
uint64_t now;
uint64_t ms_since_last_encode;
uint64_t duration;

ms_per_frame = 1000 / ctx->frame_rate;
ms_since_last_encode = XmfTimeSource_Get(&ctx->ts) - ctx->last_encode_time;
now = XmfTimeSource_Get(&ctx->ts);
ms_since_last_encode = now - ctx->last_encode_time;

if (!force && ms_since_last_encode < ms_per_frame)
return 0;

if (ctx->pts == 0)
ms_since_last_encode = XmfTimeSource_Get(&ctx->ts) - ctx->frame_time;
duration = now - ctx->pending_frame_start_time;

XmfWebM_EncodeImage(ctx, ctx->img, ctx->pts, ms_since_last_encode);
if (XmfWebM_EncodeImage(ctx, ctx->img, ctx->pts, duration) < 0)
return -1;

ctx->pending_frame = false;

return 1;
}
Expand All @@ -234,15 +240,11 @@ int XMF_API XmfWebM_EncodeXRGB(XmfWebM* ctx, const uint8_t* srcData, uint32_t sr
{
uint32_t step[3];

if (!ctx->pending_frame)
if (ctx->pending_frame)
{
ctx->first_encode_time = XmfTimeSource_Get(&ctx->ts);
goto convert_frame;
XmfWebM_EncodePendingFrame(ctx, !srcData);
}
Comment on lines +243 to 246

XmfWebM_EncodeInternal(ctx, !srcData);

convert_frame:
if (!srcData)
return 0;

Expand All @@ -252,7 +254,21 @@ int XMF_API XmfWebM_EncodeXRGB(XmfWebM* ctx, const uint8_t* srcData, uint32_t sr

Xpp_RGBToYCbCr420_8u_P3AC4R(srcData, srcStep, ctx->img->planes, step, width, height);
ctx->frame_time = XmfTimeSource_Get(&ctx->ts);
ctx->pending_frame = true;

if (ctx->frame_count == 0)
{
/* Eagerly emit the first frame so the Gateway receives a frame even on a static recording, preventing a recording policy violation. */
ctx->first_encode_time = ctx->frame_time;
XmfWebM_EncodeImage(ctx, ctx->img, ctx->pts, 1000 / ctx->frame_rate);
ctx->pending_frame = false;
Comment on lines +261 to +263
}
else
{
if (!ctx->pending_frame)
ctx->pending_frame_start_time = ctx->frame_time;

ctx->pending_frame = true;
Comment on lines +267 to +270
}
Comment thread
irvingoujAtDevolution marked this conversation as resolved.

return 1;
}
Expand Down