Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: src rx st20 plugin for gstreamer #1026

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 162 additions & 0 deletions ecosystem/gstreamer_plugin/gst_mtl_common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/*
* Copyright (C) 2024 Intel Corporation
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "gst_mtl_common.h"

gboolean gst_mtl_common_parse_input_finfo(const GstVideoFormatInfo* finfo,
enum st_frame_fmt* fmt) {
if (finfo->format == GST_VIDEO_FORMAT_v210) {
*fmt = ST_FRAME_FMT_V210;
} else if (finfo->format == GST_VIDEO_FORMAT_I422_10LE) {
*fmt = ST_FRAME_FMT_YUV422PLANAR10LE;
} else {
return FALSE;
}

return TRUE;
}

gboolean gst_mtl_common_parse_fps_code(gint fps_code, enum st_fps* fps) {
if (!fps) {
GST_ERROR("Invalid fps pointer");
return FALSE;
}

switch (fps_code) {
DawidWesierski4 marked this conversation as resolved.
Show resolved Hide resolved
case GST_MTL_SUPPORTED_FPS_120:
*fps = ST_FPS_P120;
break;
case GST_MTL_SUPPORTED_FPS_119_88:
*fps = ST_FPS_P119_88;
break;
case GST_MTL_SUPPORTED_FPS_100:
*fps = ST_FPS_P100;
break;
case GST_MTL_SUPPORTED_FPS_60:
*fps = ST_FPS_P60;
break;
case GST_MTL_SUPPORTED_FPS_59_94:
*fps = ST_FPS_P59_94;
break;
case GST_MTL_SUPPORTED_FPS_50:
*fps = ST_FPS_P50;
break;
case GST_MTL_SUPPORTED_FPS_30:
*fps = ST_FPS_P30;
break;
case GST_MTL_SUPPORTED_FPS_29_97:
*fps = ST_FPS_P29_97;
break;
case GST_MTL_SUPPORTED_FPS_25:
*fps = ST_FPS_P25;
break;
case GST_MTL_SUPPORTED_FPS_24:
*fps = ST_FPS_P24;
break;
case GST_MTL_SUPPORTED_FPS_23_98:
*fps = ST_FPS_P23_98;
break;
default:
return FALSE;
}

return TRUE;
}

gboolean gst_mtl_common_parse_fps(GstVideoInfo* info, enum st_fps* fps) {
gint fps_div;
if (info->fps_n <= 0 || info->fps_d <= 0) {
return FALSE;
}

fps_div = info->fps_n / info->fps_d;

switch (fps_div) {
case 24:
*fps = ST_FPS_P24;
break;
case 25:
*fps = ST_FPS_P25;
break;
case 30:
*fps = ST_FPS_P30;
break;
case 50:
*fps = ST_FPS_P50;
break;
case 60:
*fps = ST_FPS_P60;
break;
case 120:
*fps = ST_FPS_P120;
break;
default:
return FALSE;
}

return TRUE;
}

/* includes all formats supported by the library for future support */
gboolean gst_mtl_common_parse_pixel_format(const char* format, enum st_frame_fmt* fmt) {
if (!fmt || !format) {
GST_ERROR("%s, invalid input\n", __func__);
return FALSE;
}

if (strcmp(format, "YUV422PLANAR10LE") == 0) {
DawidWesierski4 marked this conversation as resolved.
Show resolved Hide resolved
*fmt = ST_FRAME_FMT_YUV422PLANAR10LE;
} else if (strcmp(format, "v210") == 0) {
*fmt = ST_FRAME_FMT_V210;
} else if (strcmp(format, "Y210") == 0) {
*fmt = ST_FRAME_FMT_Y210;
} else if (strcmp(format, "YUV422PLANAR8") == 0) {
*fmt = ST_FRAME_FMT_YUV422PLANAR8;
} else if (strcmp(format, "UYVY") == 0) {
*fmt = ST_FRAME_FMT_UYVY;
} else if (strcmp(format, "YUV422RFC4175PG2BE10") == 0) {
*fmt = ST_FRAME_FMT_YUV422RFC4175PG2BE10;
} else if (strcmp(format, "YUV422PLANAR12LE") == 0) {
*fmt = ST_FRAME_FMT_YUV422PLANAR12LE;
} else if (strcmp(format, "YUV422RFC4175PG2BE12") == 0) {
*fmt = ST_FRAME_FMT_YUV422RFC4175PG2BE12;
} else if (strcmp(format, "YUV444PLANAR10LE") == 0) {
*fmt = ST_FRAME_FMT_YUV444PLANAR10LE;
} else if (strcmp(format, "YUV444RFC4175PG4BE10") == 0) {
*fmt = ST_FRAME_FMT_YUV444RFC4175PG4BE10;
} else if (strcmp(format, "YUV444PLANAR12LE") == 0) {
*fmt = ST_FRAME_FMT_YUV444PLANAR12LE;
} else if (strcmp(format, "YUV444RFC4175PG2BE12") == 0) {
*fmt = ST_FRAME_FMT_YUV444RFC4175PG2BE12;
} else if (strcmp(format, "YUV420CUSTOM8") == 0) {
*fmt = ST_FRAME_FMT_YUV420CUSTOM8;
} else if (strcmp(format, "YUV422CUSTOM8") == 0) {
*fmt = ST_FRAME_FMT_YUV422CUSTOM8;
} else if (strcmp(format, "YUV420PLANAR8") == 0) {
*fmt = ST_FRAME_FMT_YUV420PLANAR8;
} else if (strcmp(format, "ARGB") == 0) {
*fmt = ST_FRAME_FMT_ARGB;
} else if (strcmp(format, "BGRA") == 0) {
*fmt = ST_FRAME_FMT_BGRA;
} else if (strcmp(format, "RGB8") == 0) {
*fmt = ST_FRAME_FMT_RGB8;
} else if (strcmp(format, "GBRPLANAR10LE") == 0) {
*fmt = ST_FRAME_FMT_GBRPLANAR10LE;
} else if (strcmp(format, "RGBRFC4175PG4BE10") == 0) {
*fmt = ST_FRAME_FMT_RGBRFC4175PG4BE10;
} else if (strcmp(format, "GBRPLANAR12LE") == 0) {
*fmt = ST_FRAME_FMT_GBRPLANAR12LE;
} else if (strcmp(format, "RGBRFC4175PG2BE12") == 0) {
*fmt = ST_FRAME_FMT_RGBRFC4175PG2BE12;
} else {
GST_ERROR("invalid output format %s\n", format);
return FALSE;
}

return TRUE;
}
49 changes: 49 additions & 0 deletions ecosystem/gstreamer_plugin/gst_mtl_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2024 Intel Corporation
*/

#ifndef __GST_MTL_COMMON_H__
#define __GST_MTL_COMMON_H__

#include <arpa/inet.h>
#include <gst/gst.h>
#include <gst/video/video.h>
#include <mtl/mtl_api.h>
#include <mtl/st_pipeline_api.h>

enum gst_mtl_supported_fps {
GST_MTL_SUPPORTED_FPS_23_98 = 2398,
GST_MTL_SUPPORTED_FPS_24 = 24,
GST_MTL_SUPPORTED_FPS_25 = 25,
GST_MTL_SUPPORTED_FPS_29_97 = 2997,
GST_MTL_SUPPORTED_FPS_30 = 30,
GST_MTL_SUPPORTED_FPS_50 = 50,
GST_MTL_SUPPORTED_FPS_59_94 = 5994,
GST_MTL_SUPPORTED_FPS_60 = 60,
GST_MTL_SUPPORTED_FPS_100 = 100,
GST_MTL_SUPPORTED_FPS_119_88 = 11988,
GST_MTL_SUPPORTED_FPS_120 = 120
};

typedef struct StDevArgs {
gchar port[MTL_PORT_MAX_LEN];
gchar local_ip_string[MTL_PORT_MAX_LEN];
gint tx_queues_cnt[MTL_PORT_MAX];
gint rx_queues_cnt[MTL_PORT_MAX];
gchar dma_dev[MTL_PORT_MAX_LEN];
} StDevArgs;

typedef struct SessionPortArgs {
gchar session_ip_string[MTL_PORT_MAX_LEN];
gchar port[MTL_PORT_MAX_LEN];
gint udp_port;
gint payload_type;
} SessionPortArgs;

gboolean gst_mtl_common_parse_input_finfo(const GstVideoFormatInfo* finfo,
enum st_frame_fmt* fmt);
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);

#endif /* __GST_MTL_COMMON_H__ */
Loading
Loading