Skip to content

Commit

Permalink
Add: gstreamer add src plugin for st30p audio (#1028)
Browse files Browse the repository at this point in the history
Add simple gstreamer plugin for st30p audio,
Create a simple design where we create
the session in the _start function, and
the recive and processing is in _create function.
  • Loading branch information
DawidWesierski4 authored Jan 7, 2025
1 parent 12098ba commit dfba8c9
Show file tree
Hide file tree
Showing 5 changed files with 799 additions and 1 deletion.
43 changes: 43 additions & 0 deletions ecosystem/gstreamer_plugin/gst_mtl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,46 @@ gboolean gst_mtl_common_parse_pixel_format(const char* format, enum st_frame_fmt

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__);
return FALSE;
}

if (strcmp(format, "PCM8") == 0) {
*audio = ST30_FMT_PCM8;
} else if (strcmp(format, "PCM16") == 0) {
*audio = ST30_FMT_PCM16;
} else if (strcmp(format, "PCM24") == 0) {
*audio = ST30_FMT_PCM24;
} else if (strcmp(format, "AM824") == 0) {
*audio = ST31_FMT_AM824;
} else {
GST_ERROR("%s, invalid audio format %s\n", __func__, format);
return FALSE;
}

return TRUE;
}

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

switch (sampling) {
case GST_MTL_SUPPORTED_AUDIO_SAMPLING_44_1K:
*st_sampling = ST31_SAMPLING_44K;
return TRUE;
case GST_MTL_SUPPORTED_AUDIO_SAMPLING_48K:
*st_sampling = ST30_SAMPLING_48K;
return TRUE;
case GST_MTL_SUPPORTED_AUDIO_SAMPLING_96K:
*st_sampling = ST30_SAMPLING_96K;
return TRUE;
default:
return FALSE;
}
}
14 changes: 14 additions & 0 deletions ecosystem/gstreamer_plugin/gst_mtl_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
#define __GST_MTL_COMMON_H__

#include <arpa/inet.h>
#include <gst/audio/audio-info.h>
#include <gst/audio/audio.h>
#include <gst/gst.h>
#include <gst/video/video.h>
#include <mtl/mtl_api.h>
#include <mtl/st30_pipeline_api.h>
#include <mtl/st_pipeline_api.h>

#define NS_PER_MS (1000 * 1000)

enum gst_mtl_supported_fps {
GST_MTL_SUPPORTED_FPS_23_98 = 2398,
GST_MTL_SUPPORTED_FPS_24 = 24,
Expand All @@ -25,6 +30,12 @@ enum gst_mtl_supported_fps {
GST_MTL_SUPPORTED_FPS_120 = 120
};

enum gst_mtl_supported_audio_sampling {
GST_MTL_SUPPORTED_AUDIO_SAMPLING_44_1K = 44100,
GST_MTL_SUPPORTED_AUDIO_SAMPLING_48K = 48000,
GST_MTL_SUPPORTED_AUDIO_SAMPLING_96K = 96000
};

typedef struct StDevArgs {
gchar port[MTL_PORT_MAX_LEN];
gchar local_ip_string[MTL_PORT_MAX_LEN];
Expand All @@ -46,4 +57,7 @@ gboolean gst_mtl_common_parse_fps(GstVideoInfo* info, enum st_fps* fps);
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);

#endif /* __GST_MTL_COMMON_H__ */
Loading

0 comments on commit dfba8c9

Please sign in to comment.