Skip to content

Commit 30d466e

Browse files
committed
ignore more non-compliant behavior IT FINALLY WORKS YIPPEE
1 parent 24b8b7f commit 30d466e

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

Uvc.Net/DeviceHandle.cs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,16 @@ public IEnumerable<FormatDescriptor> GetStreamControlFormats()
149149
while (current.HasValue)
150150
{
151151
var cur = current.Value;
152-
var numFrameDescriptors = cur.bNumFrameDescriptors;
153-
if (numFrameDescriptors > 0)
152+
var frameDesc = cur.CreateFrameDescs();
153+
while (frameDesc.HasValue)
154154
{
155-
var frameDesc = cur.CreateFrameDescs();
156-
while (frameDesc.HasValue)
157-
{
158-
result.Add(new FormatDescriptor
159-
{
160-
Width = frameDesc.Value.wWidth,
161-
Height = frameDesc.Value.wHeight
162-
}
163-
);
164-
frameDesc = frameDesc.Value.CreateNext();
165-
}
155+
result.Add(new FormatDescriptor
156+
{
157+
Width = frameDesc.Value.wWidth,
158+
Height = frameDesc.Value.wHeight
159+
}
160+
);
161+
frameDesc = frameDesc.Value.CreateNext();
166162
}
167163
current = current.Value.CreateNext();
168164
}

Uvc.Net/Types.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ public struct Frame
101101
public long TvUsec;
102102
public IntPtr Source;
103103
public byte LibraryOwnsData;
104+
105+
public byte[] GetData()
106+
{
107+
var dataSize = DataBytes.ToInt32();
108+
if (dataSize <= 0) return [];
109+
var buffer = new byte[dataSize];
110+
Marshal.Copy(Data, buffer, 0, dataSize);
111+
return buffer;
112+
}
104113
}
105114

106115
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]

0 commit comments

Comments
 (0)