Skip to content

Commit

Permalink
fix frame metadata example
Browse files Browse the repository at this point in the history
  • Loading branch information
Yousif-CS committed May 28, 2024
1 parent dc89ae3 commit e2d17f3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Samples~/Scripts/FrameMetadataExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ void Start() {
_subscriber.SetVideoTransform((TransformableVideoFrameInfo info) => {
lock(metadataLock) {
var originalFrameLength = FrameTransformerCoder.DecodeData(info.data, ref metadataOutputArray);
if (originalFrameLength < 0) {
Debug.Log($"Error attempting to decode metadata");
originalFrameLength = info.data.Length;
}
info.SetData(info.data, length: originalFrameLength);
}
});
Expand All @@ -115,8 +119,12 @@ void Start() {
_publisher.SetVideoTransform((TransformableVideoFrameInfo info) => {
lock(metadataLock) {
if (!metadataInputArray.IsCreated) return;
var totalLength = FrameTransformerCoder.EncodeData(info.data, metadataInputArray.ToArray(), ref cache);
info.SetData(data: cache.AsReadOnly(), length: totalLength);
if (metadataInputArray.Length > 0) {
var totalLength = FrameTransformerCoder.EncodeData(info.data, metadataInputArray.ToArray(), ref cache);
info.SetData(data: cache.AsReadOnly(), length: totalLength);
} else {
info.SetData(data: info.data, length: info.data.Length);
}
}
});

Expand Down

0 comments on commit e2d17f3

Please sign in to comment.