How can I use webcam as a source of Media with LibVLCSharp - webcam

I want to stream my webcam. How can I do that?
using var libVLC = new LibVLC(enableDebugLogs: true);
using var media = new Media(libVLC, new Uri("HD Webcam"));
using var mp = new MediaPlayer(media);
mp.Play();
Also want to use libVLCharp as audio/video devices as receivers and sources.

Use dshow:// as the media URL, if you're using windows.
As a rule of thumb, try to find the syntax for the VLC command line, and this will give you the way for LibVLCSharp.

Related

Can anyone help me in recording script using recording controller in jmeter?

I have done till creation of proxy sever.Facing some socket broken issue on running the scripts in firefox
When i perform some actions everything is working then some error occurs
also explain what is jmeter tree model and jmeternode is?
Scanner sc = new Scanner(System.in);
// recordingController recordingcontroller=new recordingController("testrecorder",RecordController.class);
// RecordingController rc= (RecordingController) recordingcontroller.buildTestElement();
RecordingController rc = new RecordingController();
GenericController gc = new GenericController();
rc.initialize();
gc.addTestElement(rc);
LoopController loopController = new LoopController();
loopController.setLoops(1);
loopController.setFirst(true);
loopController.setProperty(TestElement.TEST_CLASS, LoopController.class.getName());
loopController.setProperty(TestElement.GUI_CLASS, LoopControlPanel.class.getName());
loopController.initialize();
rc.addTestElement(loopController);
ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setName("Thread-Group");
threadGroup.setSamplerController(loopController);
ProxyControl proxyController = new ProxyControl();
// proxyController.setProperty(TestElement.TEST_CLASS, ProxyControl.class.getName());
// proxyController.setProperty(TestElement.GUI_CLASS, ProxyControlGui.class.getName());
proxyController.setName("Proxy Recorder");
proxyController.setPort(4444);
// threadGroup.setSamplerController(rc);
// proxyController.setSamplerTypeName("SAMPLER_TYPE_JAVA_SAMPLER");
TestPlan testPlan = new TestPlan("My_Test_Plan");
testPlan.addTestElement(threadGroup);
testPlan.addTestElement(proxyController);
JMeterTreeModel jtm = new JMeterTreeModel();
proxyController.setNonGuiTreeModel(jtm);
JMeterTreeNode node = new JMeterTreeNode(proxyController,jtm);
// JMeterTreeNode node=new JMeterTreeNode();
proxyController.setTarget(node);
// proxyController.setCaptureHttpHeaders(true);
// proxyController.setUseKeepAlive(true);
// proxyController.setGroupingMode(4);
proxyController.setCaptureHttpHeaders(true);
proxyController.setProxyPauseHTTPSample("10000");
proxyController.setSamplerFollowRedirects(true);
proxyController.setSslDomains("www.geeksforgeeks.org");
proxyController.startProxy();
I don't think non-GUI proxy recording is something you can achieve with vanilla JMeter, if you have to automate the recording process you will have to go for desktop applications automation solutions like Appium or LDTP
If you need to record a JMeter script using Firefox on a system which doesn't have GUI I can think of following approaches:
Use Proxy2JMX Converter module of Taurus tool
Use BlazeMeter Proxy Recorder (by the way it has nice feature of exporting recorded scenarios in "SmartJMX" mode with automatic detection and correlation of dynamic parameters)

How to set the input audio device for Microsoft.Speech recognizer in VB.Net or C# to any audio device

I want to use the Microsoft.Speech namespace in VB.NET to create a telephony application. I need to be able to set the recognizer input to any audio device installed on the system. Microsoft has the recognizer.SetInputToDefaultAudioDevice() method, but I need something like .SetInputToAudioDeviceID. How can I choose another wave audio input from the list of devices installed on my system? In SAPI, I would use MMSystem and SpVoice:
Set MMSysAudioIn1 = New SpMMAudioIn
MMSysAudioIn1.DeviceId = WindowsAudioDeviceID 'set audio input to audio device Id
MMSysAudioIn1.Format.Type = SAFT11kHz8BitMono 'set wave format, change to 8kHz, 16bit mono for other devices
Dim fmt As New SpeechAudioFormatInfo(1000, AudioBitsPerSample.Eight, AudioChannel.Mono)
Recognizer.SetInputToAudioStream(MMSysAudioIN1, fmt)
How do I do this with Microsoft.Speech?
MORE INFO: I want to take any wave input device in the Windows list of wave drivers and us that as input to speech recognition. Specifically, I may have a Dialogic card with wave input reported by TAPI as deviceID 1-4. In SAPI, I can use the SpMMAudioIn class to create a stream and set which device ID is associated with that stream. You can see some of that code above. Can I directly set Recognizer1.SetInputToAudioStream by the device ID of the device like I can in SAPI? Or do I have to create code that reads bytes and uses buffers, etc. Do I have to create a MemoryStream Object? I can't find any example code anywhere. What do I have to check in .NET to get access to ISpeechMMSysAudio/spMMAudioIn in case something like this would work? But hopefully, there is a way to use MemoryStream or something like it that takes a device ID and lets me pass that stream to the recognizer.
NOTE 2: I added "imports Speechlib" to the VB project and then tried to run the following code. It gives the error listed in the comments below about not being able to set the audio stream to a COM object.
Dim sre As New SpeechRecognitionEngine
Dim fmt As New SpeechAudioFormatInfo(8000, AudioBitsPerSample.Sixteen, AudioChannel.Mono)
Dim audiosource As ISpeechMMSysAudio
audiosource = New SpMMAudioIn
audiosource.DeviceId = WindowsAudioDeviceID 'set audio input to audio device Id
' audiosource.Format.Type = SpeechAudioFormatType.SAFT11kHz16BitMono
sre.SetInputToAudioStream(audiosource, fmt) <----- Invalid Cast with COM here
It also appears the SpeechAudioFormatType does not support 8kHz formats. This just gets more and more complicated.
You would use SpeechRecognitionEngine.SetInputToAudioStream. Note that if you're having problems with streaming input, you may need to wrap the stream, as illustrated here.

Check if there a usb/AC connection

I'm developing an universal windows phone application which checks if there a connection via usb or AC charging.
I used this code:
var deviceInfo = await DeviceInformation.FindAllAsync(Battery.GetDeviceSelector());
var aggBattery = Battery.AggregateBattery;
var report = aggBattery.GetReport();
report.Status.ToString();
It works well for some devices.
There are few devices (devices which got upgraded from WP8 to WP10) that takes them 30 seconds to detect the "charging mode".
I want to know if there a way to detect a usb connection?
To detect USB device, we can use a DeviceWatcher object to detect when the device is added to or removed from the system.
For Windows 10 Universal app, here is a good sample: Device enumeration sample
or get the battery level?
The Battery class does not provide method to get the battery level.
As a workaround, we can use BatteryReport.RemainingCapacityInMilliwattHours to get the remaining power capacity of the battery, in milliwatt-hours. Also we can use BatteryReport.FullChargeCapacityInMilliwattHours to get the fully-charged energy capacity of the battery. Then we can use BatteryReport.RemainingCapacityInMilliwattHours/BatteryReport.FullChargeCapacityInMilliwattHours to get the battery level.
For example:
var deviceInfo = await DeviceInformation.FindAllAsync(Battery.GetDeviceSelector());
var aggBattery = Battery.AggregateBattery;
var report = aggBattery.GetReport().RemainingCapacityInMilliwattHours;
var report3 = aggBattery.GetReport().FullChargeCapacityInMilliwattHours;
MyText.Text = (report / (double)report3).ToString();

How to record video using canon edsdk and java?

I want record video by using canon edsdk, in documentation i found that we can record video using version above that 2.11. i want use this using java code.Please le me know if any one have answer of this question.
Yes you can record video using EDSDK, refer to Section 6.4 in the EDSDK Manual (the one that comes with the latest v 2.13.20)
e.g. C++ example from that page for starting/stopping video:
EdsUInt32 record_start = 4; // Begin movie shooting
err = EdsSetPropertyData(cameraRef, kEdsPropID_Record, 0, sizeof(record_start), &record_start);
EdsUInt32 record_stop = 0; // End movie shooting
err = EdsSetPropertyData(cameraRef, kEdsPropID_Record, 0, sizeof(record_stop), &record_stop);
If you want to use Java, please look into some of the Java wrappers flying around, e.g. https://github.com/kritzikratzi/edsdk4j . I am not sure if these are up to date and reflect all the necessary commands.

AIR sqlite asynchronous database connection?

function openDatabase():void
{
var dbFile:File = File.applicationStorageDirectory.resolvePath("database.db");
connection = new SQLConnection();
connection.addEventListener(SQLEvent.OPEN, onOpen);
connection.openAsync(dbFile, "create");
}
i used this code in AIR to create connection and it's working but where is the database file??
where is the applicationStorageDirectory??
It's platform dependent (Mac, Windows, etc.). If you print out the value of "File.applicationStorageDirectory.nativePath", it will give you the fully-specified path on the filesystem of your current platform.