-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from vignetteapp/camera-config-management
Camera config management
- Loading branch information
Showing
18 changed files
with
2,536 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) The Vignette Authors | ||
// This file is part of SeeShark. | ||
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details. | ||
|
||
namespace SeeShark.Interop.Libc | ||
{ | ||
internal enum FileOpenFlags | ||
{ | ||
O_RDONLY = 0x00, | ||
O_RDWR = 0x02, | ||
O_NONBLOCK = 0x800, | ||
O_SYNC = 0x101000 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) The Vignette Authors | ||
// This file is part of SeeShark. | ||
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace SeeShark.Interop.Libc | ||
{ | ||
internal partial class Ioctl | ||
{ | ||
const int ioc_nrbits = 8; | ||
const int ioc_typebits = 8; | ||
const int ioc_sizebits = 14; | ||
// const int ioc_dirbits = 2; | ||
|
||
// const int ioc_nrmask = (1 << ioc_nrbits) - 1; | ||
// const int ioc_typemask = (1 << ioc_typebits) - 1; | ||
// const int ioc_sizemask = (1 << ioc_sizebits) - 1; | ||
// const int ioc_dirmask = (1 << ioc_dirbits) - 1; | ||
|
||
const int ioc_nrshift = 0; | ||
const int ioc_typeshift = ioc_nrshift + ioc_nrbits; | ||
const int ioc_sizeshift = ioc_typeshift + ioc_typebits; | ||
const int ioc_dirshift = ioc_sizeshift + ioc_sizebits; | ||
|
||
const int ioc_none = 0; | ||
const int ioc_write = 1; | ||
const int ioc_read = 2; | ||
|
||
internal static int IOC(int dir, int type, int nr, int size) | ||
=> dir << ioc_dirshift | type << ioc_typeshift | nr << ioc_nrshift | size << ioc_sizeshift; | ||
|
||
internal static int IO(int type, int nr) => IOC(ioc_none, type, nr, 0); | ||
internal static int IOR(int type, int nr, Type size) => IOC(ioc_read, type, nr, IOC_TYPECHECK(size)); | ||
internal static int IOW(int type, int nr, Type size) => IOC(ioc_write, type, nr, IOC_TYPECHECK(size)); | ||
internal static int IOWR(int type, int nr, Type size) => IOC(ioc_read | ioc_write, type, nr, IOC_TYPECHECK(size)); | ||
internal static int IOC_TYPECHECK(Type t) => Marshal.SizeOf(t); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) The Vignette Authors | ||
// This file is part of SeeShark. | ||
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace SeeShark.Interop.Libc | ||
{ | ||
internal class Libc | ||
{ | ||
private const string libc_library = "libc"; | ||
private const string explain_library = "explain"; | ||
|
||
[DllImport(libc_library, SetLastError = true)] | ||
internal static extern int open([MarshalAs(UnmanagedType.LPStr)] string pathname, FileOpenFlags flags); | ||
|
||
[DllImport(libc_library)] | ||
internal static extern int close(int fd); | ||
|
||
[DllImport(libc_library, SetLastError = true)] | ||
internal static extern int read(int fd, IntPtr buf, int count); | ||
|
||
[DllImport(libc_library, SetLastError = true)] | ||
internal static extern int write(int fd, IntPtr buf, int count); | ||
|
||
#region ioctl | ||
[DllImport(libc_library, SetLastError = true)] | ||
internal static extern int ioctl(int fd, int request, IntPtr argp); | ||
|
||
[DllImport(explain_library, SetLastError = true)] | ||
internal static extern unsafe sbyte* explain_ioctl(int fd, int request, IntPtr argp); | ||
|
||
[DllImport(explain_library, SetLastError = true)] | ||
internal static extern unsafe sbyte* explain_errno_ioctl(int errno, int fd, int request, IntPtr argp); | ||
#endregion | ||
|
||
[DllImport(libc_library, SetLastError = true)] | ||
internal static extern IntPtr mmap(IntPtr addr, int length, MemoryMappedProtections prot, MemoryMappedFlags flags, int fd, int offset); | ||
|
||
[DllImport(libc_library)] | ||
internal static extern int munmap(IntPtr addr, int length); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) The Vignette Authors | ||
// This file is part of SeeShark. | ||
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details. | ||
|
||
using System; | ||
|
||
namespace SeeShark.Interop.Libc | ||
{ | ||
[Flags] | ||
internal enum MemoryMappedFlags | ||
{ | ||
MAP_SHARED = 0x01, | ||
MAP_PRIVATE = 0x02, | ||
MAP_FIXED = 0x10 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) The Vignette Authors | ||
// This file is part of SeeShark. | ||
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details. | ||
|
||
using System; | ||
|
||
namespace SeeShark.Interop.Libc | ||
{ | ||
[Flags] | ||
internal enum MemoryMappedProtections | ||
{ | ||
PROT_NONE = 0x0, | ||
PROT_READ = 0x1, | ||
PROT_WRITE = 0x2, | ||
PROT_EXEC = 0x4 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright (c) The Vignette Authors | ||
// This file is part of SeeShark. | ||
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details. | ||
|
||
using System; | ||
|
||
namespace SeeShark.Interop.Libc | ||
{ | ||
/// <summary> | ||
/// videodev2.h Request Definition | ||
/// </summary> | ||
internal static class RawVideoSettings | ||
{ | ||
public static readonly int VIDIOC_QUERYCAP = Ioctl.IOR('V', 0, typeof(v4l2_capability)); | ||
public static readonly int VIDIOC_ENUM_FMT = Ioctl.IOWR('V', 2, typeof(v4l2_fmtdesc)); | ||
public static readonly int VIDIOC_G_FMT = Ioctl.IOWR('V', 4, typeof(v4l2_format)); | ||
public static readonly int VIDIOC_S_FMT = Ioctl.IOWR('V', 5, typeof(v4l2_format)); | ||
public static readonly int VIDIOC_REQBUFS = Ioctl.IOWR('V', 8, typeof(v4l2_requestbuffers)); | ||
public static readonly int VIDIOC_QUERYBUF = Ioctl.IOWR('V', 9, typeof(v4l2_buffer)); | ||
public static readonly int VIDIOC_OVERLAY = Ioctl.IOW('V', 14, typeof(int)); | ||
public static readonly int VIDIOC_QBUF = Ioctl.IOWR('V', 15, typeof(v4l2_buffer)); | ||
public static readonly int VIDIOC_DQBUF = Ioctl.IOWR('V', 17, typeof(v4l2_buffer)); | ||
public static readonly int VIDIOC_STREAMON = Ioctl.IOW('V', 18, typeof(int)); | ||
public static readonly int VIDIOC_STREAMOFF = Ioctl.IOW('V', 19, typeof(int)); | ||
public static readonly int VIDIOC_G_PARM = Ioctl.IOWR('V', 21, typeof(v4l2_streamparm)); | ||
public static readonly int VIDIOC_S_PARM = Ioctl.IOWR('V', 22, typeof(v4l2_streamparm)); | ||
public static readonly int VIDIOC_G_CTRL = Ioctl.IOWR('V', 27, typeof(v4l2_control)); | ||
public static readonly int VIDIOC_S_CTRL = Ioctl.IOWR('V', 28, typeof(v4l2_control)); | ||
public static readonly int VIDIOC_QUERYCTRL = Ioctl.IOWR('V', 36, typeof(v4l2_queryctrl)); | ||
public static readonly int VIDIOC_G_INPUT = Ioctl.IOR('V', 38, typeof(int)); | ||
public static readonly int VIDIOC_S_INPUT = Ioctl.IOWR('V', 39, typeof(int)); | ||
public static readonly int VIDIOC_G_OUTPUT = Ioctl.IOR('V', 46, typeof(int)); | ||
public static readonly int VIDIOC_S_OUTPUT = Ioctl.IOWR('V', 47, typeof(int)); | ||
public static readonly int VIDIOC_CROPCAP = Ioctl.IOWR('V', 58, typeof(v4l2_cropcap)); | ||
public static readonly int VIDIOC_G_CROP = Ioctl.IOWR('V', 59, typeof(v4l2_crop)); | ||
public static readonly int VIDIOC_S_CROP = Ioctl.IOW('V', 60, typeof(v4l2_crop)); | ||
public static readonly int VIDIOC_TRY_FMT = Ioctl.IOWR('V', 64, typeof(v4l2_format)); | ||
public static readonly int VIDIOC_G_PRIORITY = Ioctl.IOR('V', 67, typeof(uint)); | ||
public static readonly int VIDIOC_S_PRIORITY = Ioctl.IOW('V', 68, typeof(uint)); | ||
public static readonly int VIDIOC_ENUM_FRAMESIZES = Ioctl.IOWR('V', 74, typeof(v4l2_frmsizeenum)); | ||
public static readonly int VIDIOC_ENUM_FRAMEINTERVALS = Ioctl.IOWR('V', 75, typeof(v4l2_frmivalenum)); | ||
public static readonly int VIDIOC_PREPARE_BUF = Ioctl.IOWR('V', 93, typeof(v4l2_buffer)); | ||
|
||
public static void PrintConstants() | ||
{ | ||
Console.WriteLine($" internal enum VideoSettings : int"); | ||
Console.WriteLine($" {{"); | ||
Console.WriteLine($" {nameof(VIDIOC_QUERYCAP)} = {VIDIOC_QUERYCAP},"); | ||
Console.WriteLine($" {nameof(VIDIOC_ENUM_FMT)} = {VIDIOC_ENUM_FMT},"); | ||
Console.WriteLine($" {nameof(VIDIOC_G_FMT)} = {VIDIOC_G_FMT},"); | ||
Console.WriteLine($" {nameof(VIDIOC_S_FMT)} = {VIDIOC_S_FMT},"); | ||
Console.WriteLine($" {nameof(VIDIOC_REQBUFS)} = {VIDIOC_REQBUFS},"); | ||
Console.WriteLine($" {nameof(VIDIOC_QUERYBUF)} = {VIDIOC_QUERYBUF},"); | ||
Console.WriteLine($" {nameof(VIDIOC_OVERLAY)} = {VIDIOC_OVERLAY},"); | ||
Console.WriteLine($" {nameof(VIDIOC_QBUF)} = {VIDIOC_QBUF},"); | ||
Console.WriteLine($" {nameof(VIDIOC_DQBUF)} = {VIDIOC_DQBUF},"); | ||
Console.WriteLine($" {nameof(VIDIOC_STREAMON)} = {VIDIOC_STREAMON},"); | ||
Console.WriteLine($" {nameof(VIDIOC_STREAMOFF)} = {VIDIOC_STREAMOFF},"); | ||
Console.WriteLine($" {nameof(VIDIOC_G_PARM)} = {VIDIOC_G_PARM},"); | ||
Console.WriteLine($" {nameof(VIDIOC_S_PARM)} = {VIDIOC_S_PARM},"); | ||
Console.WriteLine($" {nameof(VIDIOC_G_CTRL)} = {VIDIOC_G_CTRL},"); | ||
Console.WriteLine($" {nameof(VIDIOC_S_CTRL)} = {VIDIOC_S_CTRL},"); | ||
Console.WriteLine($" {nameof(VIDIOC_QUERYCTRL)} = {VIDIOC_QUERYCTRL},"); | ||
Console.WriteLine($" {nameof(VIDIOC_G_INPUT)} = {VIDIOC_G_INPUT},"); | ||
Console.WriteLine($" {nameof(VIDIOC_S_INPUT)} = {VIDIOC_S_INPUT},"); | ||
Console.WriteLine($" {nameof(VIDIOC_G_OUTPUT)} = {VIDIOC_G_OUTPUT},"); | ||
Console.WriteLine($" {nameof(VIDIOC_S_OUTPUT)} = {VIDIOC_S_OUTPUT},"); | ||
Console.WriteLine($" {nameof(VIDIOC_CROPCAP)} = {VIDIOC_CROPCAP},"); | ||
Console.WriteLine($" {nameof(VIDIOC_G_CROP)} = {VIDIOC_G_CROP},"); | ||
Console.WriteLine($" {nameof(VIDIOC_S_CROP)} = {VIDIOC_S_CROP},"); | ||
Console.WriteLine($" {nameof(VIDIOC_TRY_FMT)} = {VIDIOC_TRY_FMT},"); | ||
Console.WriteLine($" {nameof(VIDIOC_G_PRIORITY)} = {VIDIOC_G_PRIORITY},"); | ||
Console.WriteLine($" {nameof(VIDIOC_S_PRIORITY)} = {VIDIOC_S_PRIORITY},"); | ||
Console.WriteLine($" {nameof(VIDIOC_ENUM_FRAMESIZES)} = {VIDIOC_ENUM_FRAMESIZES},"); | ||
Console.WriteLine($" {nameof(VIDIOC_ENUM_FRAMEINTERVALS)} = {VIDIOC_ENUM_FRAMEINTERVALS},"); | ||
Console.WriteLine($" {nameof(VIDIOC_PREPARE_BUF)} = {VIDIOC_PREPARE_BUF},"); | ||
Console.WriteLine($" }}"); | ||
} | ||
} | ||
} |
Oops, something went wrong.