2013-10-13 20:26:50 +00:00
|
|
|
// Copyright (C) 2013 Stephan Sundermann <stephansundermann@gmail.com>
|
|
|
|
//
|
2014-05-28 11:29:36 +00:00
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2.1 of the License, or (at your option) any later version.
|
2013-10-13 20:26:50 +00:00
|
|
|
//
|
2014-05-28 11:29:36 +00:00
|
|
|
// This library is distributed in the hope that it will be useful,
|
2013-10-13 20:26:50 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2014-05-28 11:29:36 +00:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
2013-10-13 20:26:50 +00:00
|
|
|
//
|
2014-05-28 11:29:36 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
// 02110-1301 USA
|
2013-10-13 20:26:50 +00:00
|
|
|
|
2021-09-30 11:02:26 +00:00
|
|
|
namespace Gst.Base {
|
2013-10-13 20:26:50 +00:00
|
|
|
using System;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
2021-09-30 11:02:26 +00:00
|
|
|
public partial class Adapter {
|
2019-10-24 14:00:17 +00:00
|
|
|
[DllImport("gstbase-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
2013-10-13 20:26:50 +00:00
|
|
|
static extern void gst_adapter_copy(IntPtr raw, out IntPtr dest, int offset, int size);
|
|
|
|
|
|
|
|
public byte[] Copy(int offset, int size) {
|
|
|
|
|
2021-09-30 11:02:26 +00:00
|
|
|
IntPtr mem = Marshal.AllocHGlobal(size);
|
2013-10-13 20:26:50 +00:00
|
|
|
|
|
|
|
gst_adapter_copy(Handle, out mem, offset, size);
|
|
|
|
|
|
|
|
byte[] bytes = new byte[size];
|
2021-09-30 11:02:26 +00:00
|
|
|
Marshal.Copy(mem, bytes, 0, size);
|
2013-10-13 20:26:50 +00:00
|
|
|
|
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
2019-10-24 14:00:17 +00:00
|
|
|
[DllImport("gstbase-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
2013-10-13 20:26:50 +00:00
|
|
|
static extern IntPtr gst_adapter_map(IntPtr raw, out int size);
|
|
|
|
|
|
|
|
public byte[] Map() {
|
|
|
|
int size;
|
|
|
|
|
2021-09-30 11:02:26 +00:00
|
|
|
IntPtr mem = gst_adapter_map(Handle, out size);
|
2013-10-13 20:26:50 +00:00
|
|
|
byte[] ret = new byte[size];
|
2021-09-30 11:02:26 +00:00
|
|
|
Marshal.Copy(mem, ret, 0, size);
|
2013-10-13 20:26:50 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
2021-09-30 11:02:26 +00:00
|
|
|
}
|