EDIT: I forgot to mention this is working with an axis encoder.
I've recently started using gStreamer-sharp and I can get a video playing with playbin but I need my video to be live, thus a need to set the latency. but I have come across this error:
GST_ELEMENT_PADS gstelement.c:722:gst_element_add_pad:<Source> adding pad 'recv_rtp_src_0_219678342_96'
0:00:11.033000000 13088 05418DA0 INFO basesrc gstbasesrc.c:2519:gst_base_src_loop:<udpsrc1> pausing after gst_pad_push() = not-linked
0:00:11.033000000 13088 05418DA0 WARN basesrc gstbasesrc.c:2582:gst_base_src_loop:<udpsrc1> error: Internal data flow error.
0:00:11.033000000 13088 05418DA0 WARN basesrc gstbasesrc.c:2582:gst_base_src_loop:<udpsrc1> error: streaming task paused, reason not-linked (-1)
0:00:11.214000000 13088 05418DA0 INFO GST_ERROR_SYSTEM gstelement.c:1931:gst_element_message_full:<udpsrc1> posting message: Internal data flow error.
0:00:11.214000000 13088 05418DA0 INFO GST_ERROR_SYSTEM gstelement.c:1954:gst_element_message_full:<udpsrc1> posted error message: Internal data flow error.
Which has lead me to believe it's a problem with the pad's my code is as following:
Gst.Video.VideoSink videoSink;
Pipeline m_Pipeline;
Element m_Source, m_Demux, m_Decoder, m_Space;
private void OnVideoPadAdded(object sender, Gst.PadAddedArgs args)
{
Gst.Element.Link(m_Demux, m_Decoder);
}
private void CreatePipeline()
{
m_Pipeline = new Pipeline("video player");
m_Source = Gst.ElementFactory.Make("rtspsrc", "Source");
m_Source["location"] = #"rtsp://root:root#192.168.8.159:554/axis-media/media.3gp";
m_Demux = Gst.ElementFactory.Make("rtph264depay", "Depay");
m_Decoder = Gst.ElementFactory.Make("ffdec_h264", "Decoder");
m_Space = ElementFactory.Make("ffmpegcolorspace", "Space");
videoSink = Gst.ElementFactory.Make("directdrawsink", "Output") as Gst.Video.VideoSink;
videoSink["force-aspect-ratio"] = true;
m_Pipeline.Add(m_Source, m_Demux, m_Decoder, m_Space, videoSink);
m_Pipeline.SetState(Gst.State.Ready);
m_Source.Link(m_Demux);
m_Demux.PadAdded += new Gst.PadAddedHandler(OnVideoPadAdded);
m_Decoder.Link(m_Space);
m_Space.Link(videoSink);
var overlay = new Gst.Interfaces.XOverlayAdapter(videoSink.Handle);
overlay.XwindowId = (ulong)videoPanel.Handle;
m_Pipeline.SetState(Gst.State.Paused);
m_Pipeline.SetState(State.Playing);
}
Any help is appreciated.
Solution was pretty simple in the end.
Needed to add the handler:
m_Source.PadAdded += new Gst.PadAddedHandler(OnVideoPadAdded);
then handle the sink correctly by getting the static pad in the handler:
Pad sinkpad = m_Demux.GetStaticPad("sink");
args.Pad.Link(sinkpad);
Related
I'm using OmniSharp's C# LSP server to implement a simple parsing/language service for a VS Code plugin. I've managed to get the basics up and running, but I've not been able to figure out how to push diagnostic messages to VS Code (like in this typescript sample).
Does anyone have any sample code/hints that would be of use?
Thanks!
Having spoken with #david-driscoll, it turns out I needed to stash a reference to ILanguageServerFacade in my constructor and use the PublishDiagnostics extension method on TextDocument. Ie:
public class TextDocumentSyncHandler : ITextDocumentSyncHandler
{
private readonly ILanguageServerFacade _facade;
public TextDocumentSyncHandler(ILanguageServerFacade facade)
{
_facade = facade;
}
public Task<Unit> Handle(DidChangeTextDocumentParams request, CancellationToken cancellationToken)
{
// Parse your stuff here
// Diagnostics are sent a document at a time, this example is for demonstration purposes only
var diagnostics = ImmutableArray<Diagnostic>.Empty.ToBuilder();
diagnostics.Add(new Diagnostic()
{
Code = "ErrorCode_001",
Severity = DiagnosticSeverity.Error,
Message = "Something bad happened",
Range = new Range(0, 0, 0, 0),
Source = "XXX",
Tags = new Container<DiagnosticTag>(new DiagnosticTag[] { DiagnosticTag.Unnecessary })
});
_facade.TextDocument.PublishDiagnostics(new PublishDiagnosticsParams()
{
Diagnostics = new Container<Diagnostic>(diagnostics.ToArray()),
Uri = request.TextDocument.Uri,
Version = request.TextDocument.Version
});
return Unit.Task;
}
}
For real code, you would want a centralised array of Diagnostic objects, but this shows the basics of how to get it done.
Thank you David!
Having some issue when applying my terraform plan, and cannot pinpoint what is the problem in it. I tried everything I could think about. Here is my lambda.tf file:
data "archive_file" "projectLeo_listunsubscribe_lambda_code" {
type = "zip"
source_dir = "${path.module}/../src/ProjectLeo.ListUnsubscribe"
output_path = "${path.module}/../src/code-packaged/list-unsubscribe.zip"
}
resource "aws_lambda_function" "projectLeot_list_unsubscribe_lambda" {
filename = "${data.archive_file.projectLeo_listunsubscribe_lambda_code.output_path}"
function_name = "projectLeo-listunsubscribe-lambda"
role = "${aws_iam_role.projectLeo_list_hygiene_role.arn}"
handler = "${var.lambda_list_unsubscribe_function_handler}"
runtime = "dotnetcore2.1"
memory_size = "256"
timeout = 120
publish = true
reserved_concurrent_executions = 1
environment {
variables = {
optout-topic-arn = "${data.aws_sns_topic.projectLeo_optout_topic.arn}"
}
}
}
data "aws_sns_topic" "projectLeo_optout_topic" {
name = "${var.sns_optout_topic_name}"
}
The plan generated looks all fine, ut this error is generated when apply is done:
Error: Error creating Lambda function: ValidationException:
status code: 400, request id: c16dc369-bccd-418d-a2b5-2d0383c66064
on ..\list-unsubscribe\infrastructure\lambda.tf line 9, in resource "aws_lambda_function" "projectLeo_list_unsubscribe_lambda":
9: resource "aws_lambda_function" "projectLeo_list_unsubscribe_lambda" {
That's quite a light log to work with, I tried updating pieces by pieces of the code but always have the same result.
Can anybody help me pinpoint what may be the issue with my code? Thanks!
Finally manage to identify the issue: the environment variables in AWS lambda function doesn't accept hyphen (-). I replaced it by underscore and it went through.
optout-topic-arn became optout_topic_arn
I am trying to render DirectX12 in SwapChainPanel by using SharpDx but creating a SwapChain fails for an unknown reason. Here is a simplified version of what I have:
// select adapter based on some simple scoring mechanism
SelectedAdapter = SelectAdapter();
// create device
using (var defaultDevice = new Device(SelectedAdapter, FeatureLevel.Level_12_0))
Device = defaultDevice.QueryInterface<SharpDX.Direct3D12.Device2>();
// describe swap chain
SwapChainDescription1 swapChainDescription = new SwapChainDescription1
{
AlphaMode = AlphaMode.Ignore,
BufferCount = 2,
Format = Format.R8G8B8A8_UNorm,
Height = (int)(MainSwapChainPanel.RenderSize.Height),
Width = (int)(MainSwapChainPanel.RenderSize.Width),
SampleDescription = new SampleDescription(1, 0),
Scaling = Scaling.Stretch,
Stereo = false,
SwapEffect = SwapEffect.FlipSequential,
Usage = Usage.RenderTargetOutput
};
// create swap chain
using (var factory2 = SelectedAdapter.GetParent<Factory2>())
{
/*--> throws exception:*/
SwapChain1 swapChain1 = new SwapChain1(factory2, Device, ref swapChainDescription);
SwapChain = swapChain1.QueryInterface<SwapChain2>();
}
// tie created swap chain with swap chain panel
using (ISwapChainPanelNative nativeObject = ComObject.As<ISwapChainPanelNative>(MainSwapChainPanel))
nativeObject.SwapChain = SwapChain;
Selection of adapter works as expected (I have 2 adapters + software adapter). I can create a device and I can see that the app in task manager is using that selected adapter.
Creation of the swap chain is based mostly on this documentation here: https://learn.microsoft.com/en-us/windows/uwp/gaming/directx-and-xaml-interop#swapchainpanel-and-gaming
I get factory2 (with all the adapters and other things enumerated). Constructor of SwapChain1 internally is using factory2 to create a swap chain: https://github.com/sharpdx/SharpDX/blob/master/Source/SharpDX.DXGI/SwapChain1.cs#L64
I compared this method with several others examples and tutorials and this is the way it should be done, however, regardless of the Format I choose or adapter, I keep getting this exception:
{SharpDX.SharpDXException: HRESULT: [0x887A0001], Module:
[SharpDX.DXGI], ApiCode: [DXGI_ERROR_INVALID_CALL/InvalidCall],
Message: The application made a call that is invalid. Either the
parameters of the call or the state of some object was incorrect.
Enable the D3D debug layer in order to see details via debug messages.
at SharpDX.Result.CheckError() at
SharpDX.DXGI.Factory2.CreateSwapChainForComposition(IUnknown
deviceRef, SwapChainDescription1& descRef, Output restrictToOutputRef,
SwapChain1 swapChainOut) at SharpDX.DXGI.SwapChain1..ctor(Factory2
factory, ComObject device, SwapChainDescription1& description, Output
restrictToOutput) at UI.MainPage.CreateSwapChain()}
DebugLayer doesn't show any additional info.
The app itself is a regular Windows Universal Blank App (min target version Creators Update 15063). I know I can run Directx12 on my current hardware (C++ hello world works just fine).
Any ideas what is wrong?
This is how I got it working:
try
{
using (var factory4 = new Factory4())
{
SwapChain1 swapChain1 = new SwapChain1(factory4, CommandQueue, ref swapChainDescription);
SwapChain = swapChain1.QueryInterface<SwapChain2>();
}
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
return;
}
using (ISwapChainPanelNative nativeObject = ComObject.As<ISwapChainPanelNative>(MainSwapChainPanel))
nativeObject.SwapChain = SwapChain;
So basically I need Factory4 interface to create temporary SwapChain1 from which I can query SwapChain2, then this SwapChain2 can be attached to SwapChainPanel.
Also, a very important thing to notice here is that even though SwapChain1 constructor signature (and documentation) https://github.com/sharpdx/SharpDX/blob/master/Source/SharpDX.DXGI/SwapChain1.cs#L51 says that 2nd argument should be device - it shouldn't. What you need to pass is a CommandQueue object. I have no idea why.
Also, constructor of SwapChain1 says it needs Factory2, but no, you have to pass Factory4!
Edit: Sorry - now that I've understood the problem a bit better, I think my problem lies elsewhere
I have 2 asynchronus requests.
The first is this:
public void DownloadWebData(Uri apiUrl)
{
WebClient client = new WebClient();
client.DownloadDataCompleted += DownloadDataCompleted;
client.DownloadDataAsync(apiUrl);
}
public void DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
{
string result = System.Text.Encoding.UTF8.GetString (e.Result);
Uri downloadLink = (GetUri(result));
}
Basically it makes a simple url based API request to a remote webserver which returns some basic textual data over http. GetUri() just parses that data to extract an address from the data for an image to download.
I'm then using imageLoader in monotouch.dialog to download the image. All code is in the same class.
Edit: added the imageLoader code (I left the Console lines in because they serve reasonably well as comments).
public void downloadImage (Uri imageUri)
{
var tmp_img = ImageLoader.DefaultRequestImage (imageUri, this);
if (tmp_img != null)
{
adView.Image = tmp_img;
Console.WriteLine ("Image already cached, displaying");
}
else
{
adView.Image = UIImage.FromFile ("Images/downloading.jpg");
Console.WriteLine ("Image not cached. Using placeholder.");
}
}
public void UpdatedImage (System.Uri uri)
{
adView.Image = ImageLoader.DefaultRequestImage(uri, this);
}
You missed to check if e.Result actually contains something. The download might as well have failed and e.Result is null. Add some basic error handling to your code.
if you are using DownloadWebData inside a for loop, it will be better you generate seperate functions for DownloadDataCompleted event.
You can use anonymous function inside DownloadWebData().
client.DownloadDataCompleted +=(s,e)=>{
string result = System.Text.Encoding.UTF8.GetString (e.Result);
Uri downloadLink = (GetUri(result));
};
After realizing I was asking the wrong question, I finally figured it out here:
Hand back control to main UI thread to update UI after asynchronus image download
This is proof of concept project - The goal is to create an application that receive some system wide events and based on some business rules invokes a specific workflow.
The workflows are created separately and the xaml source is stored in a database.
Following is the code that used to invoke the workflow:
public void RaiseEvent(IEvent e, IEventData eventData)
{
var typeName = e.GetType().FullName;
// Query Db for all workflows for the event
var repo = new WorkflowRepository();
var workflows = repo.GetActiveWorkflowsByEvent(typeName);
foreach (var wf in workflows)
{
var condition =
ConditionEvaluator.PrepareCondition(wf.Condition.Expression, eventData);
var okToStart = ConditionEvaluator.Evaluate(condition);
if (okToStart)
{
// Next line is throwing an exeption
object o = XamlServices.Parse(wf.WorkflowDefinition.Expression);
DynamicActivity da = o as DynamicActivity;
WorkflowInvoker.Invoke(da,
new Dictionary<string, object>
{{ "EventData", eventData }});
}
}
We have created very simple workflow that runs without problems on its own. But when xaml is being loaded using XamlService.Parse it throw following exception:
System.Xaml.XamlObjectWriterException was unhandled
Message='No matching constructor found on type 'System.Activities.Activity'.
You can use the Arguments or FactoryMethod directives to construct this type.'
Line number '1' and line position '30'.
Any idea what is wrong?
Thank you.
Not sure what is causing your problem, I have used XamlServices.Load() in the past without any problems, but the easiest way of loading a workflow XAML at runtime is by using the ActivityXamlServices.Load(). See here for an example.
Ok I have solved this by using ActivityXamlServices
So Instead of this line:
object o = XamlServices.Parse(wf.WorkflowDefinition.Expression);
I am using following snippet:
var mStream = new memoryStream(
ASCIIEncoding.Default.GetBytes(wf.WorkflowDefinition.Expression));
object o = ActivityXamlServices.Load(mStream);