mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
gst/rtp/: Add mappings for multichannel support. Does not completely just work because the getcaps function does not ...
Original commit message from CVS: * gst/rtp/gstrtpL16depay.c: (gst_rtp_L16_depay_setcaps): * gst/rtp/gstrtpL16pay.c: (gst_rtp_L16_pay_setcaps), (gst_rtp_L16_pay_getcaps): * gst/rtp/gstrtpchannels.c: (check_channels), (gst_rtp_channels_get_by_pos), (gst_rtp_channels_get_by_order), (gst_rtp_channels_create_default): * gst/rtp/gstrtpchannels.h: Add mappings for multichannel support. Does not completely just work because the getcaps function does not yet return the allowed channel mappings. See #556641.
This commit is contained in:
parent
6eb6d5b9ac
commit
09e449609f
5 changed files with 388 additions and 3 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2008-10-28 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||
|
||||
* gst/rtp/gstrtpL16depay.c: (gst_rtp_L16_depay_setcaps):
|
||||
* gst/rtp/gstrtpL16pay.c: (gst_rtp_L16_pay_setcaps),
|
||||
(gst_rtp_L16_pay_getcaps):
|
||||
* gst/rtp/gstrtpchannels.c: (check_channels),
|
||||
(gst_rtp_channels_get_by_pos), (gst_rtp_channels_get_by_order),
|
||||
(gst_rtp_channels_create_default):
|
||||
* gst/rtp/gstrtpchannels.h:
|
||||
Add mappings for multichannel support. Does not completely just work
|
||||
because the getcaps function does not yet return the allowed channel
|
||||
mappings. See #556641.
|
||||
|
||||
2008-10-28 Stefan Kost <ensonic@users.sf.net>
|
||||
|
||||
* gst/goom/Makefile.am:
|
||||
|
|
|
@ -24,7 +24,11 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gst/audio/audio.h>
|
||||
#include <gst/audio/multichannel.h>
|
||||
|
||||
#include "gstrtpL16depay.h"
|
||||
#include "gstrtpchannels.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (rtpL16depay_debug);
|
||||
#define GST_CAT_DEFAULT (rtpL16depay_debug)
|
||||
|
@ -146,6 +150,8 @@ gst_rtp_L16_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
|
|||
gint channels;
|
||||
GstCaps *srccaps;
|
||||
gboolean res;
|
||||
const gchar *channel_order;
|
||||
const GstRTPChannelOrder *order;
|
||||
|
||||
rtpL16depay = GST_RTP_L16_DEPAY (depayload);
|
||||
|
||||
|
@ -163,6 +169,7 @@ gst_rtp_L16_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
|
|||
clock_rate = 44100;
|
||||
break;
|
||||
default:
|
||||
/* no fixed mapping, we need channels and clock-rate */
|
||||
channels = 0;
|
||||
clock_rate = 0;
|
||||
break;
|
||||
|
@ -189,6 +196,25 @@ gst_rtp_L16_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
|
|||
"depth", G_TYPE_INT, 16,
|
||||
"rate", G_TYPE_INT, clock_rate, "channels", G_TYPE_INT, channels, NULL);
|
||||
|
||||
/* add channel positions */
|
||||
channel_order = gst_structure_get_string (structure, "channel-order");
|
||||
|
||||
order = gst_rtp_channels_get_by_order (channels, channel_order);
|
||||
if (order) {
|
||||
gst_audio_set_channel_positions (gst_caps_get_structure (srccaps, 0),
|
||||
order->pos);
|
||||
} else {
|
||||
GstAudioChannelPosition *pos;
|
||||
|
||||
GST_ELEMENT_WARNING (rtpL16depay, STREAM, DECODE,
|
||||
(NULL), ("Unknown channel order '%s' for %d channels",
|
||||
GST_STR_NULL (channel_order), channels));
|
||||
/* create default NONE layout */
|
||||
pos = gst_rtp_channels_create_default (channels);
|
||||
gst_audio_set_channel_positions (gst_caps_get_structure (srccaps, 0), pos);
|
||||
g_free (pos);
|
||||
}
|
||||
|
||||
res = gst_pad_set_caps (depayload->srcpad, srccaps);
|
||||
gst_caps_unref (srccaps);
|
||||
|
||||
|
|
|
@ -23,9 +23,12 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include <gst/audio/audio.h>
|
||||
#include <gst/audio/multichannel.h>
|
||||
#include <gst/rtp/gstrtpbuffer.h>
|
||||
|
||||
#include "gstrtpL16pay.h"
|
||||
#include "gstrtpchannels.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (rtpL16pay_debug);
|
||||
#define GST_CAT_DEFAULT (rtpL16pay_debug)
|
||||
|
@ -173,6 +176,8 @@ gst_rtp_L16_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
|
|||
gint channels, rate;
|
||||
gboolean res;
|
||||
gchar *params;
|
||||
GstAudioChannelPosition *pos;
|
||||
const GstRTPChannelOrder *order;
|
||||
|
||||
rtpL16pay = GST_RTP_L16_PAY (basepayload);
|
||||
|
||||
|
@ -185,13 +190,33 @@ gst_rtp_L16_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
|
|||
if (!gst_structure_get_int (structure, "channels", &channels))
|
||||
goto no_channels;
|
||||
|
||||
/* get the channel order */
|
||||
pos = gst_audio_get_channel_positions (structure);
|
||||
if (pos)
|
||||
order = gst_rtp_channels_get_by_pos (channels, pos);
|
||||
else
|
||||
order = NULL;
|
||||
|
||||
gst_basertppayload_set_options (basepayload, "audio", TRUE, "L16", rate);
|
||||
params = g_strdup_printf ("%d", channels);
|
||||
res = gst_basertppayload_set_outcaps (basepayload,
|
||||
"encoding-params", G_TYPE_STRING, params, "channels", G_TYPE_INT,
|
||||
channels, NULL);
|
||||
|
||||
if (!order && channels > 2) {
|
||||
GST_ELEMENT_WARNING (rtpL16pay, STREAM, DECODE,
|
||||
(NULL), ("Unknown channel order for %d channels", channels));
|
||||
}
|
||||
|
||||
if (order && order->name) {
|
||||
res = gst_basertppayload_set_outcaps (basepayload,
|
||||
"encoding-params", G_TYPE_STRING, params, "channels", G_TYPE_INT,
|
||||
channels, "channel-order", G_TYPE_STRING, order->name, NULL);
|
||||
} else {
|
||||
res = gst_basertppayload_set_outcaps (basepayload,
|
||||
"encoding-params", G_TYPE_STRING, params, "channels", G_TYPE_INT,
|
||||
channels, NULL);
|
||||
}
|
||||
|
||||
g_free (params);
|
||||
g_free (pos);
|
||||
|
||||
rtpL16pay->rate = rate;
|
||||
rtpL16pay->channels = channels;
|
||||
|
|
136
gst/rtp/gstrtpchannels.c
Normal file
136
gst/rtp/gstrtpchannels.c
Normal file
|
@ -0,0 +1,136 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) <2008> Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gstrtpchannels.h"
|
||||
|
||||
/*
|
||||
* RTP channel positions as discussed in RFC 3551 and also RFC 3555
|
||||
*
|
||||
* We can't really represent the described channel positions in GStreamer but we
|
||||
* implement a (very rough) approximation here.
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
check_channels (const GstRTPChannelOrder * order,
|
||||
const GstAudioChannelPosition * pos)
|
||||
{
|
||||
gint i;
|
||||
gboolean res = TRUE;
|
||||
|
||||
for (i = 0; i < order->channels; i++) {
|
||||
if (order->pos[i] != pos[i]) {
|
||||
res = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtp_channels_get_by_pos:
|
||||
* @channels: the amount of channels
|
||||
* @pos: a channel layout
|
||||
*
|
||||
* Return a description of the channel layout.
|
||||
*
|
||||
* Returns: a #GstRTPChannelOrder with the channel information or NULL when @pos
|
||||
* is not a valid layout.
|
||||
*/
|
||||
const GstRTPChannelOrder *
|
||||
gst_rtp_channels_get_by_pos (gint channels, const GstAudioChannelPosition * pos)
|
||||
{
|
||||
gint i;
|
||||
const GstRTPChannelOrder *res = NULL;
|
||||
|
||||
g_return_val_if_fail (pos != NULL, NULL);
|
||||
|
||||
for (i = 0; channel_orders[i].pos; i++) {
|
||||
if (channel_orders[i].channels != channels)
|
||||
continue;
|
||||
|
||||
if (check_channels (&channel_orders[i], pos)) {
|
||||
res = &channel_orders[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtp_channels_create_default:
|
||||
* @channels: the amount of channels
|
||||
* @order: a channel order
|
||||
*
|
||||
* Get the channel order info the @order and @channels.
|
||||
*
|
||||
* Returns: a #GstRTPChannelOrder with the channel information or NULL when
|
||||
* @order is not a know layout for @channels.
|
||||
*/
|
||||
const GstRTPChannelOrder *
|
||||
gst_rtp_channels_get_by_order (gint channels, const gchar * order)
|
||||
{
|
||||
gint i;
|
||||
const GstRTPChannelOrder *res = NULL;
|
||||
|
||||
for (i = 0; channel_orders[i].pos; i++) {
|
||||
if (channel_orders[i].channels != channels)
|
||||
continue;
|
||||
|
||||
/* no name but channels match, continue */
|
||||
if (!channel_orders[i].name || !order) {
|
||||
res = &channel_orders[i];
|
||||
break;
|
||||
}
|
||||
|
||||
/* compare names */
|
||||
if (g_ascii_strcasecmp (channel_orders[i].name, order)) {
|
||||
res = &channel_orders[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtp_channels_create_default:
|
||||
* @channels: the amount of channels
|
||||
*
|
||||
* Create a default none channel mapping for @channels.
|
||||
*
|
||||
* Returns: a #GstAudioChannelPosition with all the channel position info set to
|
||||
* #GST_AUDIO_CHANNEL_POSITION_NONE.
|
||||
*/
|
||||
GstAudioChannelPosition *
|
||||
gst_rtp_channels_create_default (gint channels)
|
||||
{
|
||||
gint i;
|
||||
GstAudioChannelPosition *posn;
|
||||
|
||||
g_return_val_if_fail (channels > 0, NULL);
|
||||
|
||||
posn = g_new (GstAudioChannelPosition, channels);
|
||||
|
||||
for (i = 0; i < channels; i++)
|
||||
posn[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
|
||||
|
||||
return posn;
|
||||
}
|
185
gst/rtp/gstrtpchannels.h
Normal file
185
gst/rtp/gstrtpchannels.h
Normal file
|
@ -0,0 +1,185 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) <2008> Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gst/audio/audio.h>
|
||||
#include <gst/audio/multichannel.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const gchar *name;
|
||||
gint channels;
|
||||
const GstAudioChannelPosition *pos;
|
||||
} GstRTPChannelOrder;
|
||||
|
||||
static const GstAudioChannelPosition pos_4_1[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT
|
||||
};
|
||||
|
||||
static const GstAudioChannelPosition pos_4_2[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
||||
GST_AUDIO_CHANNEL_POSITION_LFE
|
||||
};
|
||||
|
||||
static const GstAudioChannelPosition pos_4_3[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
||||
GST_AUDIO_CHANNEL_POSITION_LFE
|
||||
};
|
||||
|
||||
static const GstAudioChannelPosition pos_5_1[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER
|
||||
};
|
||||
|
||||
static const GstAudioChannelPosition pos_6_1[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
||||
GST_AUDIO_CHANNEL_POSITION_LFE
|
||||
};
|
||||
|
||||
static const GstAudioChannelPosition pos_6_2[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
||||
GST_AUDIO_CHANNEL_POSITION_LFE,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT
|
||||
};
|
||||
|
||||
static const GstAudioChannelPosition pos_8_1[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
||||
GST_AUDIO_CHANNEL_POSITION_LFE,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT
|
||||
};
|
||||
|
||||
static const GstAudioChannelPosition pos_8_2[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
||||
GST_AUDIO_CHANNEL_POSITION_LFE,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT
|
||||
};
|
||||
|
||||
static const GstAudioChannelPosition pos_8_3[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
||||
GST_AUDIO_CHANNEL_POSITION_LFE,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT
|
||||
};
|
||||
|
||||
static const GstAudioChannelPosition pos_def_1[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_NONE
|
||||
};
|
||||
|
||||
static const GstAudioChannelPosition pos_def_2[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT
|
||||
};
|
||||
|
||||
static const GstAudioChannelPosition pos_def_3[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER
|
||||
};
|
||||
|
||||
static const GstAudioChannelPosition pos_def_4[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_LFE
|
||||
};
|
||||
|
||||
static const GstAudioChannelPosition pos_def_5[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT
|
||||
};
|
||||
|
||||
static const GstAudioChannelPosition pos_def_6[] = {
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
||||
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
GST_AUDIO_CHANNEL_POSITION_LFE
|
||||
};
|
||||
|
||||
static const GstRTPChannelOrder channel_orders[] =
|
||||
{
|
||||
/* 4 channels */
|
||||
{ "DV.LRLsRs", 4, pos_4_1 },
|
||||
{ "DV.LRCS", 4, pos_4_2 },
|
||||
{ "DV.LRCWo", 4, pos_4_3 },
|
||||
/* 5 channels */
|
||||
{ "DV.LRLsRsC", 5, pos_5_1 },
|
||||
/* 6 channels */
|
||||
{ "DV.LRLsRsCS", 6, pos_6_1 },
|
||||
{ "DV.LmixRmixTWoQ1Q2", 6, pos_6_2 },
|
||||
/* 8 channels */
|
||||
{ "DV.LRCWoLsRsLmixRmix", 8, pos_8_1 },
|
||||
{ "DV.LRCWoLs1Rs1Ls2Rs2", 8, pos_8_2 },
|
||||
{ "DV.LRCWoLsRsLcRc", 8, pos_8_3 },
|
||||
|
||||
/* default layouts */
|
||||
{ NULL, 1, pos_def_1 },
|
||||
{ NULL, 2, pos_def_2 },
|
||||
{ NULL, 3, pos_def_3 },
|
||||
{ NULL, 4, pos_def_4 },
|
||||
{ NULL, 5, pos_def_5 },
|
||||
{ NULL, 6, pos_def_6 },
|
||||
|
||||
/* terminator, invalid entry */
|
||||
{ NULL, 0, NULL },
|
||||
};
|
||||
|
||||
const GstRTPChannelOrder * gst_rtp_channels_get_by_pos (gint channels,
|
||||
const GstAudioChannelPosition *pos);
|
||||
const GstRTPChannelOrder * gst_rtp_channels_get_by_order (gint channels,
|
||||
const gchar *order);
|
||||
|
||||
GstAudioChannelPosition * gst_rtp_channels_create_default (gint channels);
|
Loading…
Reference in a new issue