summaryrefslogtreecommitdiff
path: root/tests/old/testsuite/caps2/caps.c
blob: 333e95d02d0f2c12077e2a2cb0dc14e861d19a76 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

#include <gst/gst.h>


void test1(void)
{
  GstCaps2 *caps;
  GstCaps2 *caps2;

  g_print("type is %d\n", (int)gst_caps2_get_type());

  caps = gst_caps2_new_empty();
  g_assert(caps != NULL);
  gst_caps2_free(caps);

  caps = gst_caps2_new_any();
  g_assert(caps != NULL);
  gst_caps2_free(caps);

  caps = gst_caps2_new_simple("audio/raw",
      "_int", G_TYPE_INT, 100, NULL);
  g_assert(caps != NULL);
  g_assert(gst_caps2_is_empty(caps)==FALSE);
  g_assert(gst_caps2_is_any(caps)==FALSE);
  g_assert(gst_caps2_is_chained(caps)==FALSE);
  g_assert(gst_caps2_is_fixed(caps)==TRUE);
  g_print("%s\n", gst_caps2_to_string(caps));
  gst_caps2_free(caps);

  caps = gst_caps2_new_simple("audio/raw",
      "_double", G_TYPE_DOUBLE, 100.0, NULL);
  g_assert(caps != NULL);
  g_assert(gst_caps2_is_empty(caps)==FALSE);
  g_assert(gst_caps2_is_any(caps)==FALSE);
  g_assert(gst_caps2_is_chained(caps)==FALSE);
  g_assert(gst_caps2_is_fixed(caps)==TRUE);
  g_print("%s\n", gst_caps2_to_string(caps));
  gst_caps2_free(caps);

  caps = gst_caps2_new_simple("audio/raw",
      "_fourcc", GST_TYPE_FOURCC, GST_MAKE_FOURCC('a','b','c','d'), NULL);
  g_assert(caps != NULL);
  g_assert(gst_caps2_is_empty(caps)==FALSE);
  g_assert(gst_caps2_is_any(caps)==FALSE);
  g_assert(gst_caps2_is_chained(caps)==FALSE);
  g_assert(gst_caps2_is_fixed(caps)==TRUE);
  g_print("%s\n", gst_caps2_to_string(caps));
  gst_caps2_free(caps);

  caps = gst_caps2_new_simple("audio/raw",
      "_boolean", G_TYPE_BOOLEAN, TRUE, NULL);
  g_assert(caps != NULL);
  g_assert(gst_caps2_is_empty(caps)==FALSE);
  g_assert(gst_caps2_is_any(caps)==FALSE);
  g_assert(gst_caps2_is_chained(caps)==FALSE);
  g_assert(gst_caps2_is_fixed(caps)==TRUE);
  g_print("%s\n", gst_caps2_to_string(caps));
  gst_caps2_free(caps);

  caps = gst_caps2_new_full(
      gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL),
      gst_structure_new("audio/raw2", "_int", G_TYPE_INT, 100, NULL),
      NULL);
  g_assert(caps != NULL);
  g_assert(gst_caps2_is_empty(caps)==FALSE);
  g_assert(gst_caps2_is_any(caps)==FALSE);
  g_assert(gst_caps2_is_chained(caps)==TRUE);
  g_assert(gst_caps2_is_fixed(caps)==FALSE);
  g_print("%s\n", gst_caps2_to_string(caps));
  gst_caps2_free(caps);

  caps = gst_caps2_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL);
  g_assert(caps != NULL);
  caps2 = gst_caps2_copy(caps);
  g_assert(caps2 != NULL);
  g_assert(gst_caps2_is_empty(caps2)==FALSE);
  g_assert(gst_caps2_is_any(caps2)==FALSE);
  g_assert(gst_caps2_is_chained(caps2)==FALSE);
  g_assert(gst_caps2_is_fixed(caps2)==TRUE);
  g_print("%s\n", gst_caps2_to_string(caps));
  g_print("%s\n", gst_caps2_to_string(caps2));
  gst_caps2_free(caps);
  gst_caps2_free(caps2);

  caps = gst_caps2_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL);
  gst_caps2_append (caps, 
      gst_caps2_new_simple("audio/raw", "_int", G_TYPE_INT, 200, NULL));
  g_assert(caps != NULL);
  g_assert(gst_caps2_is_empty(caps)==FALSE);
  g_assert(gst_caps2_is_any(caps)==FALSE);
  g_assert(gst_caps2_is_chained(caps)==TRUE);
  g_assert(gst_caps2_is_fixed(caps)==FALSE);
  g_print("%s\n", gst_caps2_to_string(caps));
  gst_caps2_free(caps);

  caps = gst_caps2_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL);
  g_assert(caps != NULL);
  gst_caps2_append_cap (caps, 
      gst_structure_new("audio/raw", "_int", G_TYPE_INT, 200, NULL));
  g_assert(gst_caps2_is_empty(caps)==FALSE);
  g_assert(gst_caps2_is_any(caps)==FALSE);
  g_assert(gst_caps2_is_chained(caps)==TRUE);
  g_assert(gst_caps2_is_fixed(caps)==FALSE);
  g_print("%s\n", gst_caps2_to_string(caps));
  gst_caps2_free(caps);
}

void test2(void)
{
  GstCaps2 *caps1;
  GstCaps2 *caps2;
  GstCaps2 *caps;

  caps1 = gst_caps2_new_full(
      gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL),
      gst_structure_new("audio/raw", "_int", G_TYPE_INT, 200, NULL),
      NULL);
  caps2 = gst_caps2_new_full(
      gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL),
      gst_structure_new("audio/raw", "_int", G_TYPE_INT, 300, NULL),
      NULL);
  caps = gst_caps2_intersect(caps1, caps2);
  g_print("%s\n", gst_caps2_to_string(caps));
  gst_caps2_free(caps);
  gst_caps2_free(caps1);
  gst_caps2_free(caps2);

}

int main(int argc, char *argv[])
{
  gst_init(&argc, &argv);

  test1();
  test2();

  return 0;
}