summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gst/law/alaw-decode.c73
-rw-r--r--gst/law/alaw-encode.c74
-rw-r--r--gst/law/alaw.c4
-rw-r--r--gst/law/mulaw-decode.c72
-rw-r--r--gst/law/mulaw-encode.c72
-rw-r--r--gst/law/mulaw.c4
6 files changed, 170 insertions, 129 deletions
diff --git a/gst/law/alaw-decode.c b/gst/law/alaw-decode.c
index ac4c6df5c..d7b6f2f2d 100644
--- a/gst/law/alaw-decode.c
+++ b/gst/law/alaw-decode.c
@@ -150,50 +150,61 @@ gst_alaw_dec_getcaps (GstPad * pad)
150{ 150{
151 GstALawDec *alawdec; 151 GstALawDec *alawdec;
152 GstPad *otherpad; 152 GstPad *otherpad;
153 GstCaps *base_caps, *othercaps; 153 GstCaps *othercaps, *result;
154 const GstCaps *templ;
155 gchar *name;
156 gint i;
154 157
155 alawdec = GST_ALAW_DEC (GST_PAD_PARENT (pad)); 158 alawdec = GST_ALAW_DEC (GST_PAD_PARENT (pad));
156 159
157 base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); 160 /* figure out the name of the caps we are going to return */
158
159 if (pad == alawdec->srcpad) { 161 if (pad == alawdec->srcpad) {
162 name = "audio/x-raw-int";
160 otherpad = alawdec->sinkpad; 163 otherpad = alawdec->sinkpad;
161 } else { 164 } else {
165 name = "audio/x-alaw";
162 otherpad = alawdec->srcpad; 166 otherpad = alawdec->srcpad;
163 } 167 }
168 /* get caps from the peer, this can return NULL when there is no peer */
164 othercaps = gst_pad_peer_get_caps (otherpad); 169 othercaps = gst_pad_peer_get_caps (otherpad);
165 if (othercaps) {
166 GstStructure *structure;
167 const GValue *orate, *ochans;
168 const GValue *rate, *chans;
169 GValue irate = { 0 };
170 GValue ichans = { 0 };
171
172 if (gst_caps_is_empty (othercaps) || gst_caps_is_any (othercaps))
173 goto done;
174
175 structure = gst_caps_get_structure (othercaps, 0);
176 orate = gst_structure_get_value (structure, "rate");
177 ochans = gst_structure_get_value (structure, "channels");
178
179 structure = gst_caps_get_structure (base_caps, 0);
180 rate = gst_structure_get_value (structure, "rate");
181 chans = gst_structure_get_value (structure, "channels");
182
183 if (orate) {
184 gst_value_intersect (&irate, orate, rate);
185 gst_structure_set_value (structure, "rate", &irate);
186 }
187 170
188 if (ochans) { 171 /* get the template caps to make sure we return something acceptable */
189 gst_value_intersect (&ichans, ochans, chans); 172 templ = gst_pad_get_pad_template_caps (pad);
190 gst_structure_set_value (structure, "channels", &ichans);
191 }
192 173
193 done: 174 if (othercaps) {
175 /* there was a peer */
176 othercaps = gst_caps_make_writable (othercaps);
177
178 /* go through the caps and remove the fields we don't want */
179 for (i = 0; i < gst_caps_get_size (othercaps); i++) {
180 GstStructure *structure;
181
182 structure = gst_caps_get_structure (othercaps, i);
183
184 /* adjust the name */
185 gst_structure_set_name (structure, name);
186
187 if (pad == alawdec->sinkpad) {
188 /* remove the fields we don't want */
189 gst_structure_remove_fields (structure, "width", "depth", "endianness",
190 "signed", NULL);
191 } else {
192 /* add fixed fields */
193 gst_structure_set (structure, "width", G_TYPE_INT, 16,
194 "depth", G_TYPE_INT, 16,
195 "endianness", G_TYPE_INT, G_BYTE_ORDER,
196 "signed", G_TYPE_BOOLEAN, TRUE, NULL);
197 }
198 }
199 /* filter against the allowed caps of the pad to return our result */
200 result = gst_caps_intersect (othercaps, templ);
194 gst_caps_unref (othercaps); 201 gst_caps_unref (othercaps);
202 } else {
203 /* there was no peer, return the template caps */
204 result = gst_caps_copy (templ);
195 } 205 }
196 return base_caps; 206
207 return result;
197} 208}
198 209
199static void 210static void
diff --git a/gst/law/alaw-encode.c b/gst/law/alaw-encode.c
index b98d8e2e6..2b1b0583a 100644
--- a/gst/law/alaw-encode.c
+++ b/gst/law/alaw-encode.c
@@ -301,51 +301,61 @@ gst_alaw_enc_getcaps (GstPad * pad)
301{ 301{
302 GstALawEnc *alawenc; 302 GstALawEnc *alawenc;
303 GstPad *otherpad; 303 GstPad *otherpad;
304 GstCaps *base_caps, *othercaps; 304 GstCaps *othercaps, *result;
305 const GstCaps *templ;
306 gchar *name;
307 gint i;
305 308
306 alawenc = GST_ALAW_ENC (GST_PAD_PARENT (pad)); 309 alawenc = GST_ALAW_ENC (GST_PAD_PARENT (pad));
307 310
308 /* we can do what our template says */ 311 /* figure out the name of the caps we are going to return */
309 base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
310
311 if (pad == alawenc->srcpad) { 312 if (pad == alawenc->srcpad) {
313 name = "audio/x-alaw";
312 otherpad = alawenc->sinkpad; 314 otherpad = alawenc->sinkpad;
313 } else { 315 } else {
316 name = "audio/x-raw-int";
314 otherpad = alawenc->srcpad; 317 otherpad = alawenc->srcpad;
315 } 318 }
319 /* get caps from the peer, this can return NULL when there is no peer */
316 othercaps = gst_pad_peer_get_caps (otherpad); 320 othercaps = gst_pad_peer_get_caps (otherpad);
317 if (othercaps) {
318 GstStructure *structure;
319 const GValue *orate, *ochans;
320 const GValue *rate, *chans;
321 GValue irate = { 0 };
322 GValue ichans = { 0 };
323
324 if (gst_caps_is_empty (othercaps) || gst_caps_is_any (othercaps))
325 goto done;
326
327 structure = gst_caps_get_structure (othercaps, 0);
328 orate = gst_structure_get_value (structure, "rate");
329 ochans = gst_structure_get_value (structure, "channels");
330
331 structure = gst_caps_get_structure (base_caps, 0);
332 rate = gst_structure_get_value (structure, "rate");
333 chans = gst_structure_get_value (structure, "channels");
334
335 if (orate) {
336 gst_value_intersect (&irate, orate, rate);
337 gst_structure_set_value (structure, "rate", &irate);
338 }
339 321
340 if (ochans) { 322 /* get the template caps to make sure we return something acceptable */
341 gst_value_intersect (&ichans, ochans, chans); 323 templ = gst_pad_get_pad_template_caps (pad);
342 gst_structure_set_value (structure, "channels", &ichans);
343 }
344 324
345 done: 325 if (othercaps) {
326 /* there was a peer */
327 othercaps = gst_caps_make_writable (othercaps);
328
329 /* go through the caps and remove the fields we don't want */
330 for (i = 0; i < gst_caps_get_size (othercaps); i++) {
331 GstStructure *structure;
332
333 structure = gst_caps_get_structure (othercaps, i);
334
335 /* adjust the name */
336 gst_structure_set_name (structure, name);
337
338 if (pad == alawenc->srcpad) {
339 /* remove the fields we don't want */
340 gst_structure_remove_fields (structure, "width", "depth", "endianness",
341 "signed", NULL);
342 } else {
343 /* add fixed fields */
344 gst_structure_set (structure, "width", G_TYPE_INT, 16,
345 "depth", G_TYPE_INT, 16,
346 "endianness", G_TYPE_INT, G_BYTE_ORDER,
347 "signed", G_TYPE_BOOLEAN, TRUE, NULL);
348 }
349 }
350 /* filter against the allowed caps of the pad to return our result */
351 result = gst_caps_intersect (othercaps, templ);
346 gst_caps_unref (othercaps); 352 gst_caps_unref (othercaps);
353 } else {
354 /* there was no peer, return the template caps */
355 result = gst_caps_copy (templ);
347 } 356 }
348 return base_caps; 357
358 return result;
349} 359}
350 360
351static gboolean 361static gboolean
diff --git a/gst/law/alaw.c b/gst/law/alaw.c
index 3525848d9..95ae992dc 100644
--- a/gst/law/alaw.c
+++ b/gst/law/alaw.c
@@ -30,7 +30,7 @@ GstStaticPadTemplate alaw_dec_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
30 "rate = (int) [ 8000, 192000 ], " 30 "rate = (int) [ 8000, 192000 ], "
31 "channels = (int) [ 1, 2 ], " 31 "channels = (int) [ 1, 2 ], "
32 "endianness = (int) BYTE_ORDER, " 32 "endianness = (int) BYTE_ORDER, "
33 "width = (int) 16, " "width = (int) 16, " "signed = (boolean) True") 33 "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) True")
34 ); 34 );
35 35
36GstStaticPadTemplate alaw_dec_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", 36GstStaticPadTemplate alaw_dec_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
@@ -47,7 +47,7 @@ GstStaticPadTemplate alaw_enc_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
47 "rate = (int) [ 8000, 192000 ], " 47 "rate = (int) [ 8000, 192000 ], "
48 "channels = (int) [ 1, 2 ], " 48 "channels = (int) [ 1, 2 ], "
49 "endianness = (int) BYTE_ORDER, " 49 "endianness = (int) BYTE_ORDER, "
50 "width = (int) 16, " "width = (int) 16, " "signed = (boolean) True") 50 "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) True")
51 ); 51 );
52 52
53GstStaticPadTemplate alaw_enc_src_factory = GST_STATIC_PAD_TEMPLATE ("src", 53GstStaticPadTemplate alaw_enc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
diff --git a/gst/law/mulaw-decode.c b/gst/law/mulaw-decode.c
index 831ef0fa8..6d09c1677 100644
--- a/gst/law/mulaw-decode.c
+++ b/gst/law/mulaw-decode.c
@@ -93,50 +93,60 @@ mulawdec_getcaps (GstPad * pad)
93{ 93{
94 GstMuLawDec *mulawdec; 94 GstMuLawDec *mulawdec;
95 GstPad *otherpad; 95 GstPad *otherpad;
96 GstCaps *base_caps, *othercaps; 96 GstCaps *othercaps, *result;
97 const GstCaps *templ;
98 gchar *name;
99 gint i;
97 100
98 mulawdec = GST_MULAWDEC (GST_PAD_PARENT (pad)); 101 mulawdec = GST_MULAWDEC (GST_PAD_PARENT (pad));
99 102
100 base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); 103 /* figure out the name of the caps we are going to return */
101
102 if (pad == mulawdec->srcpad) { 104 if (pad == mulawdec->srcpad) {
105 name = "audio/x-raw-int";
103 otherpad = mulawdec->sinkpad; 106 otherpad = mulawdec->sinkpad;
104 } else { 107 } else {
108 name = "audio/x-mulaw";
105 otherpad = mulawdec->srcpad; 109 otherpad = mulawdec->srcpad;
106 } 110 }
111 /* get caps from the peer, this can return NULL when there is no peer */
107 othercaps = gst_pad_peer_get_caps (otherpad); 112 othercaps = gst_pad_peer_get_caps (otherpad);
108 if (othercaps) {
109 GstStructure *structure;
110 const GValue *orate, *ochans;
111 const GValue *rate, *chans;
112 GValue irate = { 0 };
113 GValue ichans = { 0 };
114
115 if (gst_caps_is_empty (othercaps) || gst_caps_is_any (othercaps))
116 goto done;
117
118 structure = gst_caps_get_structure (othercaps, 0);
119 orate = gst_structure_get_value (structure, "rate");
120 ochans = gst_structure_get_value (structure, "channels");
121
122 structure = gst_caps_get_structure (base_caps, 0);
123 rate = gst_structure_get_value (structure, "rate");
124 chans = gst_structure_get_value (structure, "channels");
125
126 if (orate) {
127 gst_value_intersect (&irate, orate, rate);
128 gst_structure_set_value (structure, "rate", &irate);
129 }
130 113
131 if (ochans) { 114 /* get the template caps to make sure we return something acceptable */
132 gst_value_intersect (&ichans, ochans, chans); 115 templ = gst_pad_get_pad_template_caps (pad);
133 gst_structure_set_value (structure, "channels", &ichans);
134 }
135 116
136 done: 117 if (othercaps) {
118 /* there was a peer */
119 othercaps = gst_caps_make_writable (othercaps);
120
121 /* go through the caps and remove the fields we don't want */
122 for (i = 0; i < gst_caps_get_size (othercaps); i++) {
123 GstStructure *structure;
124
125 structure = gst_caps_get_structure (othercaps, i);
126
127 /* adjust the name */
128 gst_structure_set_name (structure, name);
129
130 if (pad == mulawdec->sinkpad) {
131 /* remove the fields we don't want */
132 gst_structure_remove_fields (structure, "width", "depth", "endianness",
133 "signed", NULL);
134 } else {
135 /* add fixed fields */
136 gst_structure_set (structure, "width", G_TYPE_INT, 16,
137 "depth", G_TYPE_INT, 16,
138 "endianness", G_TYPE_INT, G_BYTE_ORDER,
139 "signed", G_TYPE_BOOLEAN, TRUE, NULL);
140 }
141 }
142 /* filter against the allowed caps of the pad to return our result */
143 result = gst_caps_intersect (othercaps, templ);
137 gst_caps_unref (othercaps); 144 gst_caps_unref (othercaps);
145 } else {
146 /* there was no peer, return the template caps */
147 result = gst_caps_copy (templ);
138 } 148 }
139 return base_caps; 149 return result;
140} 150}
141 151
142GType 152GType
diff --git a/gst/law/mulaw-encode.c b/gst/law/mulaw-encode.c
index 022e96f17..fde922b70 100644
--- a/gst/law/mulaw-encode.c
+++ b/gst/law/mulaw-encode.c
@@ -59,50 +59,60 @@ mulawenc_getcaps (GstPad * pad)
59{ 59{
60 GstMuLawEnc *mulawenc; 60 GstMuLawEnc *mulawenc;
61 GstPad *otherpad; 61 GstPad *otherpad;
62 GstCaps *base_caps, *othercaps; 62 GstCaps *othercaps, *result;
63 const GstCaps *templ;
64 gchar *name;
65 gint i;
63 66
64 mulawenc = GST_MULAWENC (GST_PAD_PARENT (pad)); 67 mulawenc = GST_MULAWENC (GST_PAD_PARENT (pad));
65 68
66 base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); 69 /* figure out the name of the caps we are going to return */
67
68 if (pad == mulawenc->srcpad) { 70 if (pad == mulawenc->srcpad) {
71 name = "audio/x-mulaw";
69 otherpad = mulawenc->sinkpad; 72 otherpad = mulawenc->sinkpad;
70 } else { 73 } else {
74 name = "audio/x-raw-int";
71 otherpad = mulawenc->srcpad; 75 otherpad = mulawenc->srcpad;
72 } 76 }
77 /* get caps from the peer, this can return NULL when there is no peer */
73 othercaps = gst_pad_peer_get_caps (otherpad); 78 othercaps = gst_pad_peer_get_caps (otherpad);
74 if (othercaps) {
75 GstStructure *structure;
76 const GValue *orate, *ochans;
77 const GValue *rate, *chans;
78 GValue irate = { 0 };
79 GValue ichans = { 0 };
80
81 if (gst_caps_is_empty (othercaps) || gst_caps_is_any (othercaps))
82 goto done;
83
84 structure = gst_caps_get_structure (othercaps, 0);
85 orate = gst_structure_get_value (structure, "rate");
86 ochans = gst_structure_get_value (structure, "channels");
87
88 structure = gst_caps_get_structure (base_caps, 0);
89 rate = gst_structure_get_value (structure, "rate");
90 chans = gst_structure_get_value (structure, "channels");
91
92 if (orate) {
93 gst_value_intersect (&irate, orate, rate);
94 gst_structure_set_value (structure, "rate", &irate);
95 }
96 79
97 if (ochans) { 80 /* get the template caps to make sure we return something acceptable */
98 gst_value_intersect (&ichans, ochans, chans); 81 templ = gst_pad_get_pad_template_caps (pad);
99 gst_structure_set_value (structure, "channels", &ichans);
100 }
101 82
102 done: 83 if (othercaps) {
84 /* there was a peer */
85 othercaps = gst_caps_make_writable (othercaps);
86
87 /* go through the caps and remove the fields we don't want */
88 for (i = 0; i < gst_caps_get_size (othercaps); i++) {
89 GstStructure *structure;
90
91 structure = gst_caps_get_structure (othercaps, i);
92
93 /* adjust the name */
94 gst_structure_set_name (structure, name);
95
96 if (pad == mulawenc->srcpad) {
97 /* remove the fields we don't want */
98 gst_structure_remove_fields (structure, "width", "depth", "endianness",
99 "signed", NULL);
100 } else {
101 /* add fixed fields */
102 gst_structure_set (structure, "width", G_TYPE_INT, 16,
103 "depth", G_TYPE_INT, 16,
104 "endianness", G_TYPE_INT, G_BYTE_ORDER,
105 "signed", G_TYPE_BOOLEAN, TRUE, NULL);
106 }
107 }
108 /* filter against the allowed caps of the pad to return our result */
109 result = gst_caps_intersect (othercaps, templ);
103 gst_caps_unref (othercaps); 110 gst_caps_unref (othercaps);
111 } else {
112 /* there was no peer, return the template caps */
113 result = gst_caps_copy (templ);
104 } 114 }
105 return base_caps; 115 return result;
106} 116}
107 117
108static gboolean 118static gboolean
diff --git a/gst/law/mulaw.c b/gst/law/mulaw.c
index 3317e58fa..27a76db81 100644
--- a/gst/law/mulaw.c
+++ b/gst/law/mulaw.c
@@ -29,7 +29,7 @@ GstStaticPadTemplate mulaw_dec_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
29 "rate = (int) [ 8000, 192000 ], " 29 "rate = (int) [ 8000, 192000 ], "
30 "channels = (int) [ 1, 2 ], " 30 "channels = (int) [ 1, 2 ], "
31 "endianness = (int) BYTE_ORDER, " 31 "endianness = (int) BYTE_ORDER, "
32 "width = (int) 16, " "width = (int) 16, " "signed = (boolean) True") 32 "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) True")
33 ); 33 );
34 34
35GstStaticPadTemplate mulaw_dec_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", 35GstStaticPadTemplate mulaw_dec_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
@@ -46,7 +46,7 @@ GstStaticPadTemplate mulaw_enc_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
46 "rate = (int) [ 8000, 192000 ], " 46 "rate = (int) [ 8000, 192000 ], "
47 "channels = (int) [ 1, 2 ], " 47 "channels = (int) [ 1, 2 ], "
48 "endianness = (int) BYTE_ORDER, " 48 "endianness = (int) BYTE_ORDER, "
49 "width = (int) 16, " "width = (int) 16, " "signed = (boolean) True") 49 "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) True")
50 ); 50 );
51 51
52GstStaticPadTemplate mulaw_enc_src_factory = GST_STATIC_PAD_TEMPLATE ("src", 52GstStaticPadTemplate mulaw_enc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",