summaryrefslogtreecommitdiff
path: root/gstreamer-sharp/Bin.custom
blob: 8b0911bdc34afcfe0314210da65743087ae0c879 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
[DllImport ("gstreamer-0.10.dll") ]
static extern bool gst_bin_add (IntPtr raw, IntPtr element);

[DllImport ("libgobject-2.0-0.dll") ]
static extern IntPtr g_object_ref (IntPtr raw);

public bool Add (Gst.Element element) {
  bool raw_ret = gst_bin_add (Handle, element == null ? IntPtr.Zero : element.Handle);
  if (raw_ret) {
    // Incrmenting the refcount of the element.
    g_object_ref (element.Handle);
  }
  bool ret = raw_ret;
  return ret;
}

public bool Add (params Element[] elements) {
  if (elements == null) {
    return false;
  }

  foreach (Element element in elements) {
    if (element == null || !Add (element)) {
      return false;
    }
  }

  return true;
}

public bool Remove (params Element[] elements) {
  if (elements == null) {
    return false;
  }

  foreach (Element element in elements) {
    if (element == null || !Remove (element)) {
      return false;
    }
  }

  return true;
}

public Gst.Element GetByInterface (System.Type type) {
  if (!type.IsSubclassOf (typeof (GLib.GInterfaceAdapter)))
    return null;

  GLib.GType t = (GLib.GType) type;

  return GetByInterface (t);
}

[DllImport ("gstreamer-0.10.dll") ]
static extern IntPtr gst_bin_iterate_elements (IntPtr bin);
[DllImport ("gstreamer-0.10.dll") ]
static extern IntPtr gst_bin_iterate_recurse (IntPtr bin);
[DllImport ("gstreamer-0.10.dll") ]
static extern IntPtr gst_bin_iterate_sinks (IntPtr bin);
[DllImport ("gstreamer-0.10.dll") ]
static extern IntPtr gst_bin_iterate_sorted (IntPtr bin);
[DllImport ("gstreamer-0.10.dll") ]
static extern IntPtr gst_bin_iterate_sources (IntPtr bin);
[DllImport ("gstreamer-0.10.dll") ]
static extern IntPtr gst_bin_iterate_all_by_interface (IntPtr bin, IntPtr gtype);

public IEnumerable Elements {
  get {
    return new Enumerable (gst_bin_iterate_elements (Handle));
  }
}

public IEnumerable ElementsRecurse {
  get {
    return new Enumerable (gst_bin_iterate_recurse (Handle));
  }
}

public IEnumerable ElementsSorted {
  get {
    return new Enumerable (gst_bin_iterate_sorted (Handle));
  }
}

public IEnumerable SinkElements {
  get {
    return new Enumerable (gst_bin_iterate_sinks (Handle));
  }
}

public IEnumerable SourceElements {
  get {
    return new Enumerable (gst_bin_iterate_sources (Handle));
  }
}

public IEnumerable GetAllByInterface (GLib.GType type) {
  return new Enumerable (gst_bin_iterate_all_by_interface (Handle, type.Val));
}

public IEnumerable GetAllByInterface (System.Type type) {
  if (!type.IsSubclassOf (typeof (GLib.GInterfaceAdapter)))
    return null;

  GLib.GType t = (GLib.GType) type;

  return GetAllByInterface (t);
}