summaryrefslogtreecommitdiff
path: root/sources/custom/Message.cs
blob: 99483a5e8621d16ad509128a4a97c9499e116a07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (C) 2013  Stephan Sundermann <stephansundermann@gmail.com>
// 
// 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.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// 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

namespace Gst {

	using System;
	using System.Runtime.InteropServices;

	partial class Message
	{
		[DllImport ("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_message_parse_error (IntPtr msg, out IntPtr err, out IntPtr debug);

		public void ParseError (out GLib.GException error, out string debug) {

			IntPtr err;
			IntPtr dbg;

			gst_message_parse_error (Handle, out err, out dbg);

			if (dbg != IntPtr.Zero)
				debug = GLib.Marshaller.Utf8PtrToString (dbg);
			else
				debug = null;

			if (err == IntPtr.Zero)
				throw new Exception ();

			error = new GLib.GException (err);
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gst_message_get_stream_status_object(IntPtr raw);

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_message_set_stream_status_object(IntPtr raw, IntPtr value);

		public GLib.Value StreamStatusObject { 
			get {
				IntPtr raw_ret = gst_message_get_stream_status_object(Handle);
				GLib.Value ret = (GLib.Value) Marshal.PtrToStructure (raw_ret, typeof (GLib.Value));
				return ret;
			}
			set {
				IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
				gst_message_set_stream_status_object(Handle, native_value);
				value = (GLib.Value) Marshal.PtrToStructure (native_value, typeof (GLib.Value));
				Marshal.FreeHGlobal (native_value);
			}
		}
	}
}