Hi.
※I am using deepl.
I am building a windows form app with C# (Visual Studio 2019) + Gstreamer (Ver 1.24.1) + GstSharp (1.18.0).
I need some help on how to use AppSink.
About “appSink = pipeline.GetByName(“sink”) as AppSink;” in the following program,
When I run it, appSink is null.
I guess the cast must be failing, but I can’t figure out why.
The plugin seems to be loaded.
Environment variables have also been set.
Path:C:\gstreamer\1.0\msvc_x86_64\bin
GST_PLUGIN_PATH:C:\gstreamer\1.0\msvc_x86_64\lib\gstreamer-1.0
If you know anything about it, could you please let me know?
I look forward to hearing from you.
public partial class Form1 : Form
{
private Pipeline pipeline;
private Gst.App.AppSink appSink;
private VideoOverlayAdapter overlayAdapter;
private bool pipelineInitialized = false;
public Form1()
{
InitializeComponent();
InitGStreamer();
InitializePipeline();
}
private void InitGStreamer()
{
Gst.Application.Init();
}
private void InitializePipeline()
{
if (!Gst.Application.InitCheck())
{
MessageBox.Show("Failed to initialize GStreamer.");
return;
}
pipeline = new Pipeline();
var source = ElementFactory.Make("udpsrc", "source");
if (source == null)
{
MessageBox.Show("Failed to create source.");
return;
}
var queue = ElementFactory.Make("queue", "queue");
var jitterBuffer = ElementFactory.Make("rtpjitterbuffer", "jitter-buffer");
var depayloader = ElementFactory.Make("rtph264depay", "depayloader");
var decoder = ElementFactory.Make("avdec_h264", "decoder");
var converter = ElementFactory.Make("videoconvert", "converter");
var sink = ElementFactory.Make("appsink", "sink");
if (queue == null || jitterBuffer == null || depayloader == null || decoder == null || converter == null || sink == null)
{
MessageBox.Show("Failed to create one or more elements.");
return;
}
pipeline.Add(source, queue, jitterBuffer, depayloader, decoder, converter, sink);
if (!Element.Link(source, queue, jitterBuffer, depayloader, decoder, converter, sink))
{
MessageBox.Show("Failed to link elements.");
return;
}
appSink = pipeline.GetByName("sink") as AppSink;
var caps = Caps.FromString("application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264,payload=(int)96");
source["caps"] = caps;
source["port"] = 50007;
//appSink.EmitSignals = true;
//appSink.Sync = false;
//appSink.NewSample += AppSink_NewSample;
pipelineInitialized = true;
}
}
C:\Users\KY2017>gst-inspect-1.0 app
Plugin Details:
Name app
Description Elements used to communicate with applications
Filename C:\gstreamer\1.0\msvc_x86_64\lib\gstreamer-1.0\gstapp.dll
Version 1.24.1
License LGPL
Source module gst-plugins-base
Documentation app
Source release date 2024-03-21
Binary package GStreamer Base Plug-ins source release
Origin URL Unknown package origin
appsink: AppSink
appsrc: AppSrc
2 features:
±- 2 elements
C:\Users\KY2017>