Skip to content

Commit

Permalink
Merge branch 'main' into gstreamer_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Falron98 authored Jan 31, 2025
2 parents e6e54bb + 12d12b8 commit 378da24
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 53 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/ubuntu_build_with_gtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ env:
# Customize the env if
BUILD_TYPE: Release
DPDK_VERSION: 23.11
TEST_PF_PORT_P: 0000:af:00.0
TEST_PF_PORT_R: 0000:af:00.0
TEST_PORT_P: 0000:af:01.2
TEST_PORT_R: 0000:af:01.3
TEST_PF_PORT_P: "0000:49:00.0"
TEST_PF_PORT_R: "0000:49:00.0"
TEST_PORT_P: "0000:49:01.2"
TEST_PORT_R: "0000:49:01.3"
TEST_DMA_PORT_P: 0000:80:04.0
TEST_DMA_PORT_R: 0000:80:04.1

Expand All @@ -39,7 +39,7 @@ jobs:
changed: ${{ steps.filter.outputs.linux_gtest == 'true' }}
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v2
id: filter
with:
Expand All @@ -57,7 +57,7 @@ jobs:
with:
egress-policy: audit

- name: Checkout IMTL
- name: Checkout MTL
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: Checkout DPDK
Expand All @@ -74,8 +74,7 @@ jobs:
- name: Apply dpdk patches
run: |
cd dpdk
git am ../patches/dpdk/${{ env.DPDK_VERSION }}/*.patch
patch -d "dpdk" -p1 -i <(cat patches/dpdk/${{ env.DPDK_VERSION }}/*.patch)
- name: Build dpdk
run: |
Expand Down Expand Up @@ -135,7 +134,7 @@ jobs:
- name: Run udp ld preload test case
run: |
sudo MUFD_CFG=.github/workflows/upl_gtest.json LD_PRELOAD=/usr/local/lib/x86_64-linux-gnu/libmtl_udp_preload.so ./build/tests/KahawaiUplTest --p_sip 192.168.89.80 --r_sip 192.168.89.81
sudo MUFD_CFG=.github/workflows/upl_gtest.json LD_PRELOAD=/usr/local/lib/x86_64-linux-gnu/libmtl_udp_preload.so ./build/tests/KahawaiUplTest --p_sip 192.168.2.80 --r_sip 192.168.2.81
- name: Run st2110 test case
run: |
Expand All @@ -147,4 +146,4 @@ jobs:
- name: Run st2110 st20p test case with kernel loopback
run: |
./build/tests/KahawaiTest --p_port kernel:lo --r_port kernel:lo --auto_start_stop --gtest_filter=St20p*
./build/tests/KahawaiTest --p_port kernel:lo --r_port kernel:lo --auto_start_stop --gtest_filter=St20p*
14 changes: 7 additions & 7 deletions .github/workflows/upl_gtest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"wake_timeout_us" : "1000",
"interfaces": [
{
"port": "0000:af:01.0",
"ip": "192.168.89.80",
"netmask": "255.255.254.0",
"port": "0000:49:01.0",
"ip": "192.168.2.80",
"netmask": "255.255.255.0"
},
{
"port": "0000:af:01.1",
"ip": "192.168.89.81",
"netmask": "255.255.254.0",
"port": "0000:49:01.1",
"ip": "192.168.2.81",
"netmask": "255.255.255.0"
}
],
]
}
2 changes: 2 additions & 0 deletions ecosystem/gstreamer_plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ The `mtl_st30p_tx` plugin supports the following pad capabilities:
|---------------------|--------|-------------------------------------------------------|-------------------------|---------------|
| tx-samplerate | uint | Sample rate of the audio. | [gst_mtl_supported_audio_sampling](#232-supported-audio-sampling-rates-gst_mtl_supported_audio_sampling) | 0 |
| tx-channels | uint | Number of audio channels. | 1 to 8 | 2 |
| tx-ptime | string | Packetization time for the audio stream. | `1ms`, `125us`, `250us`, `333us`, `4ms`, `80us`, `1.09ms`, `0.14ms`, `0.09ms` | `1.09ms` for 44.1kHz, `1ms` for others |

#### 4.1.2. Example GStreamer Pipeline for Transmission with s16LE format

Expand Down Expand Up @@ -310,6 +311,7 @@ The `mtl_st30p_rx` plugin supports the following pad capabilities:
| rx-channel | uint | Audio channel number. | 0 to G_MAXUINT | 2 |
| rx-sampling | uint | Audio sampling rate. | [gst_mtl_supported_audio_sampling](#232-supported-audio-sampling-rates-gst_mtl_supported_audio_sampling) | 48000 |
| rx-audio-format | string | Audio format type. | `S8`, `S16LE`, `S24LE` | `S16LE` |
| rx-ptime | string | Packetization time for the audio stream. | `1ms`, `125us`, `250us`, `333us`, `4ms`, `80us`, `1.09ms`, `0.14ms`, `0.09ms` | `1.09ms` for 44.1kHz, `1ms` for others |

#### 4.2.2. Preparing Output Path

Expand Down
59 changes: 58 additions & 1 deletion ecosystem/gstreamer_plugin/gst_mtl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,38 @@ gboolean gst_mtl_common_parse_pixel_format(const char* format, enum st_frame_fmt
return TRUE;
}

gboolean gst_mtl_common_parse_ptime(const char* ptime_str, enum st30_ptime* ptime) {
if (!ptime_str || !ptime) {
GST_ERROR("%s, invalid input\n", __func__);
return FALSE;
}

if (strcmp(ptime_str, "1ms") == 0) {
*ptime = ST30_PTIME_1MS;
} else if (strcmp(ptime_str, "125us") == 0) {
*ptime = ST30_PTIME_125US;
} else if (strcmp(ptime_str, "250us") == 0) {
*ptime = ST30_PTIME_250US;
} else if (strcmp(ptime_str, "333us") == 0) {
*ptime = ST30_PTIME_333US;
} else if (strcmp(ptime_str, "4ms") == 0) {
*ptime = ST30_PTIME_4MS;
} else if (strcmp(ptime_str, "80us") == 0) {
*ptime = ST31_PTIME_80US;
} else if (strcmp(ptime_str, "1.09ms") == 0) {
*ptime = ST31_PTIME_1_09MS;
} else if (strcmp(ptime_str, "0.14ms") == 0) {
*ptime = ST31_PTIME_0_14MS;
} else if (strcmp(ptime_str, "0.09ms") == 0) {
*ptime = ST31_PTIME_0_09MS;
} else {
GST_ERROR("invalid packet time %s\n", ptime_str);
return FALSE;
}

return TRUE;
}

gboolean gst_mtl_common_parse_audio_format(const char* format, enum st30_fmt* audio) {
if (!audio || !format) {
GST_ERROR("%s, invalid input\n", __func__);
Expand All @@ -193,7 +225,8 @@ gboolean gst_mtl_common_parse_audio_format(const char* format, enum st30_fmt* au
return TRUE;
}

gboolean gst_mtl_common_parse_sampling(gint sampling, enum st30_sampling* st_sampling) {
gboolean gst_mtl_common_gst_to_st_sampling(gint sampling,
enum st30_sampling* st_sampling) {
if (!st_sampling) {
GST_ERROR("Invalid st_sampling pointer");
return FALSE;
Expand All @@ -210,6 +243,30 @@ gboolean gst_mtl_common_parse_sampling(gint sampling, enum st30_sampling* st_sam
*st_sampling = ST30_SAMPLING_96K;
return TRUE;
default:
GST_ERROR("Unsupported sampling value");
return FALSE;
}
}

gboolean gst_mtl_common_st_to_gst_sampling(enum st30_sampling st_sampling,
gint* gst_sampling) {
if (!gst_sampling) {
GST_ERROR("Invalid gst_sampling pointer");
return FALSE;
}

switch (st_sampling) {
case ST31_SAMPLING_44K:
*gst_sampling = GST_MTL_SUPPORTED_AUDIO_SAMPLING_44_1K;
return TRUE;
case ST30_SAMPLING_48K:
*gst_sampling = GST_MTL_SUPPORTED_AUDIO_SAMPLING_48K;
return TRUE;
case ST30_SAMPLING_96K:
*gst_sampling = GST_MTL_SUPPORTED_AUDIO_SAMPLING_96K;
return TRUE;
default:
GST_ERROR("Unsupported st_sampling value");
return FALSE;
}
}
Expand Down
6 changes: 5 additions & 1 deletion ecosystem/gstreamer_plugin/gst_mtl_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ gboolean gst_mtl_common_parse_fps_code(gint fps_code, enum st_fps* fps);
gboolean gst_mtl_common_parse_pixel_format(const char* format, enum st_frame_fmt* fmt);

gboolean gst_mtl_common_parse_audio_format(const char* format, enum st30_fmt* audio);
gboolean gst_mtl_common_parse_sampling(gint sampling, enum st30_sampling* st_sampling);
gboolean gst_mtl_common_parse_ptime(const char* ptime_str, enum st30_ptime* ptime);
gboolean gst_mtl_common_gst_to_st_sampling(gint sampling,
enum st30_sampling* st_sampling);
gboolean gst_mtl_common_st_to_gst_sampling(enum st30_sampling st_sampling,
gint* gst_sampling);

gboolean gst_mtl_common_parse_dev_arguments(struct mtl_init_params* mtl_init_params,
StDevArgs* devArgs);
Expand Down
48 changes: 38 additions & 10 deletions ecosystem/gstreamer_plugin/gst_mtl_st30p_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ enum {
PROP_ST30P_RX_CHANNEL,
PROP_ST30P_RX_SAMPLING,
PROP_ST30P_RX_AUDIO_FORMAT,
PROP_ST30P_RX_PTIME,
PROP_MAX
};

Expand Down Expand Up @@ -180,6 +181,12 @@ static void gst_mtl_st30p_rx_class_init(Gst_Mtl_St30p_RxClass* klass) {
gobject_class, PROP_ST30P_RX_AUDIO_FORMAT,
g_param_spec_string("rx-audio-format", "Audio format", "Audio format type.", NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property(
gobject_class, PROP_ST30P_RX_PTIME,
g_param_spec_string("rx-ptime", "Packetization time",
"Packetization time for the audio stream", NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}

static gboolean gst_mtl_st30p_rx_start(GstBaseSrc* basesrc) {
Expand All @@ -205,14 +212,25 @@ static gboolean gst_mtl_st30p_rx_start(GstBaseSrc* basesrc) {
ops_rx->name = "st30src";
ops_rx->channel = src->channel;
ops_rx->port.num_port = 1;
ops_rx->ptime = ST30_PTIME_1MS;
ops_rx->flags |= ST30P_RX_FLAG_BLOCK_GET;

if (!gst_mtl_common_parse_sampling(src->sampling, &ops_rx->sampling)) {
if (!gst_mtl_common_gst_to_st_sampling(src->sampling, &ops_rx->sampling)) {
GST_ERROR("Failed to parse ops_rx sampling %d", src->sampling);
return FALSE;
}

if (src->ptime[0] != '\0') {
if (!gst_mtl_common_parse_ptime(src->ptime, &ops_rx->ptime)) {
GST_ERROR("Failed to parse ops_rx ptime %s", src->ptime);
return FALSE;
}
} else {
if (ops_rx->sampling == ST31_SAMPLING_44K)
ops_rx->ptime = ST31_PTIME_1_09MS;
else
ops_rx->ptime = ST30_PTIME_1MS;
}

if (!gst_mtl_common_parse_audio_format(src->audio_format, &ops_rx->fmt)) {
GST_ERROR("Failed to parse ops_rx audio format %s", src->audio_format);
return FALSE;
Expand Down Expand Up @@ -312,6 +330,9 @@ static void gst_mtl_st30p_rx_set_property(GObject* object, guint prop_id,
case PROP_ST30P_RX_AUDIO_FORMAT:
strncpy(self->audio_format, g_value_get_string(value), MTL_PORT_MAX_LEN);
break;
case PROP_ST30P_RX_PTIME:
g_strlcpy(self->ptime, g_value_get_string(value), MTL_PORT_MAX_LEN);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
Expand Down Expand Up @@ -341,6 +362,9 @@ static void gst_mtl_st30p_rx_get_property(GObject* object, guint prop_id, GValue
case PROP_ST30P_RX_AUDIO_FORMAT:
g_value_set_string(value, src->audio_format);
break;
case PROP_ST30P_RX_PTIME:
g_value_set_string(value, src->ptime);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
Expand All @@ -353,25 +377,32 @@ static void gst_mtl_st30p_rx_get_property(GObject* object, guint prop_id, GValue
*/

static gboolean gst_mtl_st30p_rx_negotiate(GstBaseSrc* basesrc) {
GstAudioInfo* info;
Gst_Mtl_St30p_Rx* src = GST_MTL_ST30P_RX(basesrc);
struct st30p_rx_ops* ops_rx = &src->ops_rx;
gint ret;
GstAudioInfo* info;
gint sampling;
GstCaps* caps;
gint ret;

info = gst_audio_info_new();

if (!gst_mtl_common_st_to_gst_sampling(ops_rx->sampling, &sampling)) {
GST_ERROR("Failed to convert sampling rate");
gst_audio_info_free(info);
return FALSE;
}

switch (ops_rx->fmt) {
case ST30_FMT_PCM24:
gst_audio_info_set_format(info, GST_AUDIO_FORMAT_S24LE, info->rate, info->channels,
gst_audio_info_set_format(info, GST_AUDIO_FORMAT_S24LE, sampling, ops_rx->channel,
NULL);
break;
case ST30_FMT_PCM16:
gst_audio_info_set_format(info, GST_AUDIO_FORMAT_S16LE, info->rate, info->channels,
gst_audio_info_set_format(info, GST_AUDIO_FORMAT_S16LE, sampling, ops_rx->channel,
NULL);
break;
case ST30_FMT_PCM8:
gst_audio_info_set_format(info, GST_AUDIO_FORMAT_S8, info->rate, info->channels,
gst_audio_info_set_format(info, GST_AUDIO_FORMAT_S8, sampling, ops_rx->channel,
NULL);
break;
default:
Expand All @@ -380,9 +411,6 @@ static gboolean gst_mtl_st30p_rx_negotiate(GstBaseSrc* basesrc) {
return FALSE;
}

info->rate = ops_rx->sampling;
info->channels = ops_rx->channel;

caps = gst_caps_new_simple("audio/x-raw", "format", G_TYPE_STRING,
gst_audio_format_to_string(info->finfo->format), "channels",
G_TYPE_INT, info->channels, "rate", G_TYPE_INT, info->rate,
Expand Down
2 changes: 1 addition & 1 deletion ecosystem/gstreamer_plugin/gst_mtl_st30p_rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct _Gst_Mtl_St30p_Rx {
/* audio (st30p) specific arguments */
guint channel;
guint sampling;
gboolean ptime;
gchar ptime[MTL_PORT_MAX_LEN];
gchar audio_format[MTL_PORT_MAX_LEN];
};

Expand Down
Loading

0 comments on commit 378da24

Please sign in to comment.