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
11 changes: 11 additions & 0 deletions Runtime/Scripts/Internal/TaskYieldInstruction.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions Runtime/Scripts/WebCameraSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ protected override VideoRotation GetVideoRotation()
{
switch (CamTexture.videoRotationAngle)
{
case 0: return VideoRotation._0;
case 90: return VideoRotation._90;
case 180: return VideoRotation._0;
case 180: return VideoRotation._180;
case 270: return VideoRotation._270;
}
return VideoRotation._180;
return VideoRotation._0;
}

public WebCameraSource(WebCamTexture texture, VideoBufferType bufferType = VideoBufferType.Rgba) : base(VideoStreamSource.Texture, bufferType)
Expand Down Expand Up @@ -81,8 +83,13 @@ protected override bool ReadBuffer()
}

CamTexture.GetPixels32(_readBuffer);
MemoryMarshal.Cast<Color32, byte>(_readBuffer)
.CopyTo(_captureBuffer.AsSpan());
// GetPixels32 returns rows bottom-up; WebRTC expects top-down. Flip while copying.
var src = MemoryMarshal.Cast<Color32, byte>(_readBuffer);
var dst = _captureBuffer.AsSpan();
int rowBytes = width * GetStrideForBuffer(_bufferType);
for (int y = 0; y < height; y++)
src.Slice(y * rowBytes, rowBytes)
.CopyTo(dst.Slice((height - 1 - y) * rowBytes, rowBytes));

_requestPending = true;

Expand Down
Loading