I am using DShowNET in a C# project and I have been trying multiple cards. The Card I am trying to access is a GV-800_4A, which is a a capture card normally used by GeoVision CCTV software.
The problem is it is recognized in the device manager as a 'DVR Device' with a different guid than the normal video input devices I have been using and I do NOT know the DShowNET guid, but believe it may relate to this guid.
My question is 'How do I convert the 'Device class guid' seen in devices properties the windows device manager to the Guid used in DirectShow? or are these even equatable?'
GUIDs in device manager
GeoVision GV-800A {4d36e96c-e325-11ce-bfc1-0123456789ab}
AVerMedia {4d36e96c-e325-11ce-bfc1-08002be10318}
Dazzle USB {4d36e96c-e325-11ce-bfc1-08002be10318}
GUID in DShowLib
VideoInputDevice (0x860BB310, 0x5D01,
0x11d0, 0xBD, 0x3B, 0x00, 0xA0, 0xC9,
0x11, 0xCE, 0x86)
EDIT
Basically the end goal is to be able to connect this as a capture filter to a graph to save FilterCatergory.VideoInputDevice, but now this device (GeoVision) does NOT appear on the list of available capture devices, but it IS a capture device just the drivers recognize it as a 'DVR Device'
I use the CLSID by passing it into the DShowNET function for returning an ArrayList of available devices of that type :
DsDev.GetDevicesOfCat(FilterCategory.VideoInputDevice, out m_capDevices)
I need to know the CLSID_[** DVR Device **] or where to get that. I thought it could be derived from the 'Device class guid', but I am getting told this is not possible.
You could use something like this:
const string CAPTURE = "•GeoVision GV-800A";
s_CaptureDevices = BuildDeviceList(FilterCategory.AMKSCapture, CAPTURE);
private static List<DsDevice> BuildDeviceList(Guid category, string name)
{
var list = new List<DsDevice>();
DsDevice[] devices = DsDevice.GetDevicesOfCat(category);
for (int i = 0; i < devices.Length; i++)
{
if (!string.IsNullOrEmpty(devices[i].Name) && devices[i].Name.Equals(name))
{
list.Add(devices[i]);
}
}
return list;
}
Another option would be use GraphEditPlus and add the capture filter to a graph. You can then find out the GUID to create the filter object directly using code like this:
var captureFilter = (IBaseFilter) Activator.CreateInstance(Type.GetTypeFromCLSID(new DsGuid("...guid...")));
Related
Hello Eveyone I am trying to mute/unmute a default mic using AudioDeviceController but it looks like I cannot initialize the variable.
I have since used AudioDeviceModulesManager because you can get an object by device ID.
How do I initilize the Variabale like I do with AudioDeviceModulesManager .
public App()
{
var endpointID = MediaDevice.GetDefaultAudioCaptureId(AudioDeviceRole.Default);
AudioDeviceModulesManager MyController = new AudioDeviceModulesManager(endpointID);
var thing = MyController.FindAll();
var test = thing[0];
}
Thanks for your interesting, derive from official document remake part, To get an instance of this object, retrieve the MediaCapture.AudioDeviceController property.
So we can only get AudioDeviceController instance from MediaCapture class. For more detail please check this Basic photo, video, and audio capture with MediaCapture tutorial.
Is there a way to access a mobile devices properties through C#. The purpose would be to display the device's serial number and iOS version for USB connected like an iPhone.
Using a WMI query like below access is given to the basic info accessible through the Computer Manager like DeviceID or PnpDeviceID. However I have been unable to find a property that gives the device serial number etc.
ManagementObjectSearcher(#"Select * From Win32_USBHub WHERE Description LIKE 'Apple Mobile Device%'")
or
ManagementObjectSearcher(#"Select * From Win32_PnPEntity")
or
ManagementObjectSearcher("#Select * From Win32_USBControllerDevice")
The device property menu I am referring to is in the picture below accessed by right click on a device and then clicking properties.
Placing the code below after lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "Quamotion").ThrowOnError(); you will be able to access values like the serial number or iOS version. This is only a crude example:
string t1;
string t2;
PlistHandle tested1;
PlistHandle tested2;
//Find serial number in plist
lockdown.lockdownd_get_value(lockdownHandle, null, "SerialNumber", out
tested1);
//Find IOS version in plist
lockdown.lockdownd_get_value(lockdownHandle, null, "ProductVersion", out
tested2);
//Get string values from plist
tested1.Api.Plist.plist_get_string_val(tested1, out t1);
tested2.Api.Plist.plist_get_string_val(tested2, out t2);
//Place data in textboxes
serialTXT.Text = t1.Trim();
verTXT.Text = t2.Trim();
If you want to access properties such as the iOS version, your best bet may be to use imobiledevice-net.
You can install the imobiledevice-net NuGet package and then run a command like this:
ReadOnlyCollection<string> udids;
int count = 0;
var idevice = LibiMobileDevice.Instance.iDevice;
var lockdown = LibiMobileDevice.Instance.Lockdown;
var ret = idevice.idevice_get_device_list(out udids, ref count);
if (ret == iDeviceError.NoDevice)
{
// Not actually an error in our case
return;
}
ret.ThrowOnError();
// Get the device name
foreach (var udid in udids)
{
iDeviceHandle deviceHandle;
idevice.idevice_new(out deviceHandle, udid).ThrowOnError();
LockdownClientHandle lockdownHandle;
lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "Quamotion").ThrowOnError();
string deviceName;
lockdown.lockdownd_get_device_name(lockdownHandle, out deviceName).ThrowOnError();
deviceHandle.Dispose();
lockdownHandle.Dispose();
}
The lockdown class will allow you to access other properties, such as the iOS version, as well.
It does come with a dependency on iTunes, though.
I was trying to print to an usb printer using usbmanager, the App can detect the printer device but when i run it doesnt print. there are no errors and all passing data is ok.
Printer : Bixolon SRP 275III
Type: USB
private async void printReciept()
{
UsbManager m_usbManager;
m_usbManager = (UsbManager)Application.Context.GetSystemService(Context.UsbService);
var deviceList = m_usbManager.DeviceList;
IEnumerable<UsbDevice> deviceIterator = deviceList.Values.AsEnumerable();
UsbDevice m_usbdevice = null;
if (deviceIterator.Count() > 0)
{
var device = deviceIterator.ElementAt(0);
m_usbdevice = device;
string ACTION_USB_PERMISSION = "com.android.example.USB_PERMISSION";
var mPermissionIntent = PendingIntent.GetBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);
m_usbManager.RequestPermission(m_usbdevice, mPermissionIntent);
UsbDeviceConnection deviceConnection = null;
try
{
using (var usbInterface = m_usbdevice.GetInterface(0))
{
using (var usbEndpoint = usbInterface.GetEndpoint(0))
{
mEndPoint = usbEndpoint;
deviceConnection = m_usbManager.OpenDevice(m_usbdevice);
byte[] bytesHello = Encoding.UTF8.GetBytes("Hello");
deviceConnection.BulkTransfer(usbEndpoint, bytesHello, bytesHello.Length, 0);
}
}
}
catch
{
}
}
}
You are sending the string to be printed directly to the bulk endpoint, or actually you are doing bulk transfer to the first endpoint found without knowing any of it's characteristics? I think it is a bit more complex than that.
First try to find out whether your printer supports USB printing class or some proprietary implementation. You can do this easily e.g. by connecting the printer to Windows PC and looking from the device manager, usbdeview or some other similar application.
If it supports printing class, read this document and implement your driver based on that (or use the one you may already have in Android). If it only supports proprietary implementation, you need to get the specifications for it or do some reverse engineering.
You may need to learn about PCL which may also be needed.
My question is similar to one here :
Play audio to two different Audiodevices simultaneously with Naudio
But i ask it here again since it has not been answered clearly in the link above.
I also have it at:
Play sound in both speaker and headset wpf
Inspiration from :
Play a sound in a specific device with C#
I am adding source code and adding the NAudio tag here as well.
I have an wpf application and i am using the soundPlayer class to play sound (for eg ringtone). Currently the tone plays either on speakers or on the headset (if its plugged in). I would like the application to play the tone on speaker even when the headsets are plugged in. I know there are ways to do this in android, but couldn't find any in wpf. I would also like an UI for the user to choose the devices in which he would like to hear sound. Any help is appreciated. Thanks !
public void detectDevices()
{
int waveOutDevices = WaveOut.DeviceCount;
switch (waveOutDevices)
{
case 1:
var wave1 = new WaveOut();
wave1.DeviceNumber = 0;
playSound(0);
break;
case 2:
var wave2 = new WaveOut();
wave2.DeviceNumber = 0;
playSound(0);
var wave3 = new WaveOut();
wave3.DeviceNumber = 1;
playSound(1);
break;
}
}
public void playSound(int deviceNumber)
{
disposeWave();// stop previous sounds before starting
waveReader = new NAudio.Wave.WaveFileReader(fileName);
var waveOut = new NAudio.Wave.WaveOut();
waveOut.DeviceNumber = deviceNumber;
output = waveOut;
output.Init(waveReader);
output.Play();
}
public void disposeWave()
{
if (output != null)
{
if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing)
{
output.Stop();
output.Dispose();
output = null;
}
}
if (wave != null)
{
wave.Dispose();
wave = null;
}
}
case eSelector.startIncomingRinging:
fileName = ("Ring.wav");
detectDevices();
I still hear ringtone just in one device (either in headset or speakers) using the code above.
You need two instances of WaveOut, one for each soundcard. And then the simplest way if you are playing from file, is to also have two instances of WaveFileReader. You can't easily synchronize them I'm afraid, you'll just have to start them both playing together and hope for the best.
The wave1, wave2 and wave3 classes in your code above do abosolutely nothing. The audio will be played with the WaveOut device you create in playSound. You seem to have a single class property called output and another called waveReader, when you need two of each.
Hey all i am trying to find the setting to change my video source to "composite" on my webcam. Seems that if i unplug the USB and then plug it back in and fire up the code, its just got a blank screen. But once i change the video source (in another program) and then go back and run my code again, it shows up.
So i need something that will allow me to change that in order for that same thing to happen but within my own app without having to start another program that has that feature to set the webcam.
When i pull the USB cable out then put it back in and i run the source code, the app's picturebox is Black.
The "other program" i use to change the video source (that seems to work to bring up the image):
After i use that "other program" i go back to the source code and run it and this is what i get then:
I am using the C# code called dot Net Webcam Library from here: enter link description here
It seems to use the DirectShow from enter link description here
I have noticed in the source for that it lists different types of video settings (found below in the AXExtend.cs):
public enum PhysicalConnectorType
{
Video_Tuner = 1,
Video_Composite,
Video_SVideo,
Video_RGB,
Video_YRYBY,
Video_SerialDigital,
Video_ParallelDigital,
Video_SCSI,
Video_AUX,
Video_1394,
Video_USB,
Video_VideoDecoder,
Video_VideoEncoder,
Video_SCART,
Video_Black,
Audio_Tuner = 0x1000,
Audio_Line,
Audio_Mic,
Audio_AESDigital,
Audio_SPDIFDigital,
Audio_SCSI,
Audio_AUX,
Audio_1394,
Audio_USB,
Audio_AudioDecoder,
}
But i am unsure of how to call that up in the code here:
Device selectedDevice = device as Device;
imageCapture.Device = selectedDevice as Device;
imageCapture.PerformAutoScale();
imageCapture.Refresh();
imageCapture.Start();
So i am guessing that the "Video_Composite" is what i may need in order to do that?
Any help would be great!!! Thanks!
David
Code update
foreach (Device device in Device.FindDevices())
{
if (device.ToString() == "BackupCamera")
{
Device selectedDevice = device as Device;
IGraphBuilder graphBuilder = new FilterGraph() as IGraphBuilder;
DsDevice device1 = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice)[1]; // <<--- Your Device
Guid baseFilterIdentifier = typeof(IBaseFilter).GUID;
object videoSourceObject;
device1.Mon.BindToObject(null, null, ref baseFilterIdentifier, out videoSourceObject);
IBaseFilter videoSourceBaseFilter = videoSourceObject as IBaseFilter;
graphBuilder.AddFilter(videoSourceBaseFilter, "Source");
ICaptureGraphBuilder2 captureGraphBuilder = new CaptureGraphBuilder2() as ICaptureGraphBuilder2;
captureGraphBuilder.SetFiltergraph(graphBuilder);
object crossbarObject;
captureGraphBuilder.FindInterface(FindDirection.UpstreamOnly, null, videoSourceBaseFilter, typeof(IAMCrossbar).GUID, out crossbarObject);
IAMCrossbar crossbar = crossbarObject as IAMCrossbar;
int inputPinCount, outputPinCount;
crossbar.get_PinCounts(out inputPinCount, out outputPinCount); // <<-- In/Out Pins
// Pin Selection: Physical Input 2 (e.g. Composite) to Capture Pin 0
crossbar.Route(0, 2);
imageCapture.Device = selectedDevice as Device;
imageCapture.PerformAutoScale();
imageCapture.Refresh();
imageCapture.Start();
}
}
Before running the filer graph, you need to obtain the crossbar interface. You typically use ICaptureGraphBuilder2::FindInterface for this. This requires an additional filter and the FindInterface method is useful specifically for this reason:
Supporting Filters. If a capture device uses a Windows Driver Model (WDM) driver, the graph may require certain filters upstream from the WDM Video Capture filter, such as a TV Tuner filter or an Analog Video Crossbar filter. If the pCategory parameter does not equal NULL, this method automatically inserts any required WDM filters into the graph.
Having this done, you will have IAMCrossbar interface, and IAMCrossbar::Route method is how you switch the inputs.
See also: Crossbar filter change current input to Composite
Code snippet:
IGraphBuilder graphBuilder = new FilterGraph() as IGraphBuilder;
DsDevice device = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice)[1]; // <<--- Your Device
Guid baseFilterIdentifier = typeof(IBaseFilter).GUID;
object videoSourceObject;
device.Mon.BindToObject(null, null, ref baseFilterIdentifier, out videoSourceObject);
IBaseFilter videoSourceBaseFilter = videoSourceObject as IBaseFilter;
graphBuilder.AddFilter(videoSourceBaseFilter, "Source");
ICaptureGraphBuilder2 captureGraphBuilder = new CaptureGraphBuilder2() as ICaptureGraphBuilder2;
captureGraphBuilder.SetFiltergraph(graphBuilder);
object crossbarObject;
captureGraphBuilder.FindInterface(FindDirection.UpstreamOnly, null, videoSourceBaseFilter, typeof(IAMCrossbar).GUID, out crossbarObject);
IAMCrossbar crossbar = crossbarObject as IAMCrossbar;
int inputPinCount, outputPinCount;
crossbar.get_PinCounts(out inputPinCount, out outputPinCount); // <<-- In/Out Pins
// Pin Selection: Physical Input 2 (e.g. Composite) to Capture Pin 0
crossbar.Route(0, 2);