public void Open(IReadOnlyList <ushort> ports) { if (contexts.Count > 0) { throw new InvalidOperationException("Bug: please close the transmitter before opening it again"); } denominators = new List <uint>(); for (int d = 0; d < ports.Count; d++) { unsafe { var res = SnvBackend.ScrGetResolution(d); if (res == 0) { throw new Exception("Cannot determine display resolution"); } S2TransmitterContext *tc = (S2TransmitterContext *)Marshal.AllocHGlobal(sizeof(S2TransmitterContext)); if (SnvBackend.S2TransmitterInit(tc, serverAddr.ToString(), ports[d], 0) != 0) { throw new InvalidOperationException("Failed to initialize video stream transmission"); } contexts.Add(d, (IntPtr)tc); } denominators.Add(InitialDenominator); } ctxKeys = contexts.Keys.ToArray(); }
public static unsafe extern int S2TransmitterClose(S2TransmitterContext *tctx);
public static unsafe extern int S2Send(S2TransmitterContext *tctx, S2Frame *frm);
public static unsafe extern int S2TransmitterInit(S2TransmitterContext *tctx, [MarshalAs(UnmanagedType.LPStr)] string addr, ushort port, int flags);