Skip to content

Commit

Permalink
Add: gstreamer add plugin for st30p audio
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 committed Dec 23, 2024
1 parent f98c2f6 commit b8c0adb
Show file tree
Hide file tree
Showing 5 changed files with 792 additions and 0 deletions.
44 changes: 44 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,47 @@ 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_mtlst30tx_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;
}
}
15 changes: 15 additions & 0 deletions ecosystem/gstreamer_plugin/gst_mtl_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
#include <arpa/inet.h>
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/audio/audio.h>
#include <gst/audio/audio-info.h>
#include <mtl/mtl_api.h>
#include <mtl/st_pipeline_api.h>
#include <mtl/st30_pipeline_api.h>

#define NS_PER_MS (1000 * 1000)

enum gst_mtl_supported_fps {
GST_MTL_SUPPORTED_FPS_23_98 = 2398,
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,8 @@ 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_mtlst30tx_parse_sampling(gint sampling,
enum st30_sampling* st_sampling);

#endif /* __GST_MTL_COMMON_H__ */
Loading

0 comments on commit b8c0adb

Please sign in to comment.