summaryrefslogtreecommitdiff
path: root/testsuite/caps/compatibility.c
blob: 500267dbce0679e598066b17e82550e04897b177 (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
#include <gst/gst.h>

/* these caps all have a non empty intersection */
GstStaticCaps2 sinkcaps = GST_STATIC_CAPS(
  "video/mpeg, "
    "mpegtype=(int)[1,2]"
);

GstStaticCaps2 mp1parsecaps = GST_STATIC_CAPS(
  "video/mpeg, "
    "mpegtype=(int)1"
);

GstStaticCaps2 rawcaps = GST_STATIC_CAPS(
  "video/raw, "
    "fourcc=(fourcc){YV12,YUY2}, "
    "width=(int)[16,4096], "
    "height=(int)[16,4096]"
);

GstStaticCaps2 rawcaps2 = GST_STATIC_CAPS(
  "video/raw, "
    "fourcc=(fourcc)YUY2, "
    "height=(int)[16,256]"
);

GstStaticCaps2 rawcaps3 = GST_STATIC_CAPS(
  "video/raw, "
    "fourcc=(fourcc){YV12,YUY2}, "
    "height=(int)[16,4096]"
);

#if 0
/* these caps aren't used yet */
GstStaticCaps2 rawcaps4 = GST_STATIC_CAPS(
  "video/raw, "
    "fourcc=(fourcc){\"YV12\", \"YUYV\"}, "
    "height=(int)[16,4096]"
);

GstStaticCaps2 rawcaps4 = GST_STATIC_CAPS(
  "video/raw, "
    "fourcc=(fourcc){\"YUYV\", \"YUY2\"}, "
    "height=(int)[16,4096]"
);
#endif

GstStaticCaps2 rawcaps6 = GST_STATIC_CAPS(
  "video/raw, "
    "format=(fourcc)\"I420\"; "
  "video/raw, "
    "format=(fourcc)\"YUYV\""
);

GstStaticCaps2 rawcaps7 = GST_STATIC_CAPS(
  "video/raw, "
    "format=(fourcc)\"I420\"; "
  "video/raw, "
    "format=(fourcc)\"YV12\""
);


int 
main (int argc, char *argv[]) 
{
  gboolean testret;
  gint ret = 0;

  gst_init (&argc, &argv);

  testret = gst_caps2_is_always_compatible (gst_static_caps2_get (&mp1parsecaps),
      gst_static_caps2_get (&rawcaps));
  g_print ("4 <-> 2 == %d (invalid, wrong major type)\n", testret);
  ret = ret + (testret == FALSE) ? 0 : 1;
  
  testret = gst_caps2_is_always_compatible (gst_static_caps2_get (&mp1parsecaps),
      gst_static_caps2_get (&sinkcaps));
  g_print ("4 <-> 1 == %d (valid, subset)\n", testret);
  ret = ret + (testret == TRUE) ? 0 : 1;
  
  testret = gst_caps2_is_always_compatible (gst_static_caps2_get (&sinkcaps),
      gst_static_caps2_get (&mp1parsecaps));
  g_print ("1 <-> 4 == %d (invalid, superset)\n", testret);
  ret = ret + (testret == FALSE) ? 0 : 1;

  testret = gst_caps2_is_always_compatible (gst_static_caps2_get (&rawcaps),
      gst_static_caps2_get (&rawcaps2));
  g_print ("2 <-> 3 == %d (invalid, ranges)\n", testret);
  ret = ret + (testret == FALSE) ? 0 : 1;

  testret = gst_caps2_is_always_compatible (gst_static_caps2_get (&rawcaps),
      gst_static_caps2_get (&rawcaps3));
  g_print ("2 <-> 5 == %d (valid)\n", testret);
  ret = ret + (testret == TRUE) ? 0 : 1;

  testret = gst_caps2_is_always_compatible (gst_static_caps2_get (&rawcaps3),
      gst_static_caps2_get (&rawcaps));
  g_print ("5 <-> 2 == %d (invalid)\n", testret);
  ret = ret + (testret == FALSE) ? 0 : 1;

  testret = gst_caps2_is_always_compatible (gst_static_caps2_get (&rawcaps2),
      gst_static_caps2_get (&rawcaps3));
  g_print ("3 <-> 5 == %d (valid)\n", testret);
  ret = ret + (testret == TRUE) ? 0 : 1;

  testret = gst_caps2_is_always_compatible (gst_static_caps2_get (&rawcaps2),
      gst_static_caps2_get (&rawcaps));
  g_print ("3 <-> 2 == %d (invalid, property missing in source)\n", testret);
  ret = ret + (testret == FALSE) ? 0 : 1;

  testret = gst_caps2_is_always_compatible (gst_static_caps2_get (&rawcaps),
      gst_static_caps2_get (&rawcaps));
  g_print ("2 <-> 2 == %d (valid, same caps)\n", testret);
  ret = ret + (testret == TRUE) ? 0 : 1;

  testret = gst_caps2_is_always_compatible (gst_static_caps2_get (&rawcaps6),
      gst_static_caps2_get (&rawcaps7));
  g_print ("6 <-> 7 == %d (invalid, second caps doesn't fit)\n", testret);
  ret = ret + (testret == FALSE) ? 0 : 1;

  return ret;
}