summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2014-05-09 17:45:12 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2014-09-18 13:37:59 -0400
commit3856338f15d79bdb2ae410079ac26042a4f5f6f8 (patch)
treeed3ca696e18023998f36b08681558107e7baf4bb /gst
parent11cd5652bd027186902b440eb3a11d592bbcf2f1 (diff)
downloadfarstream-3856338f15d79bdb2ae410079ac26042a4f5f6f8.tar.gz
rtpbitrateadapter: Do dynamic getcaps
Diffstat (limited to 'gst')
-rw-r--r--gst/fsrtpconference/fs-rtp-bitrate-adapter.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/gst/fsrtpconference/fs-rtp-bitrate-adapter.c b/gst/fsrtpconference/fs-rtp-bitrate-adapter.c
index b16c8dd2..477ca6fe 100644
--- a/gst/fsrtpconference/fs-rtp-bitrate-adapter.c
+++ b/gst/fsrtpconference/fs-rtp-bitrate-adapter.c
@@ -327,9 +327,11 @@ static GstCaps *
fs_rtp_bitrate_adapter_getcaps (FsRtpBitrateAdapter *self, GstPad *pad,
GstCaps *filter)
{
- GstCaps *caps;
GstPad *otherpad;
GstCaps *peer_caps;
+ GstCaps *result;
+ guint bitrate;
+ guint i;
if (pad == self->srcpad)
otherpad = self->sinkpad;
@@ -338,17 +340,42 @@ fs_rtp_bitrate_adapter_getcaps (FsRtpBitrateAdapter *self, GstPad *pad,
peer_caps = gst_pad_peer_query_caps (otherpad, filter);
+ if (gst_caps_get_size (peer_caps) == 0)
+ return peer_caps;
+
GST_OBJECT_LOCK (self);
- if (self->caps)
- caps = gst_caps_intersect_full (self->caps, peer_caps,
- GST_CAPS_INTERSECT_FIRST);
- else
- caps = gst_caps_intersect (peer_caps,
- gst_pad_get_pad_template_caps (pad));
- gst_caps_unref (peer_caps);
+ bitrate = self->last_bitrate;
GST_OBJECT_UNLOCK (self);
- return caps;
+ if (bitrate == G_MAXUINT)
+ return peer_caps;
+
+ result = gst_caps_new_empty ();
+
+ for (i = 0; i < gst_caps_get_size (peer_caps); i++)
+ {
+ GstStructure *s = gst_caps_get_structure (peer_caps, i);
+
+ if (g_str_has_prefix (gst_structure_get_name (s), "video/"))
+ {
+ GstCaps *rated_caps = caps_from_bitrate (gst_structure_get_name (s),
+ bitrate);
+ GstCaps *copy = gst_caps_copy_nth (peer_caps, i);
+
+ gst_caps_set_features (rated_caps, 0,
+ gst_caps_features_copy (gst_caps_get_features (peer_caps, i)));
+
+ gst_caps_append (result, gst_caps_intersect (rated_caps, copy));
+ gst_caps_unref (copy);
+ gst_caps_unref (rated_caps);
+ }
+ else
+ {
+ gst_caps_append (result, gst_caps_copy_nth (peer_caps, i));
+ }
+ }
+
+ return result;
}
static gboolean