Present IMFSample - wpf

I'm working on a WPF project that need to use Media Foundation to capture video from webcam.
Now I can get IMFsample from webcam everytime I want, I had used SLimDX to get IMFMediaBuffer (get it from IMFSample) to IDirect3DSurface9 pointer and set it to back buffer of D3DImage. It's work great on PC but windows Tablet.
This is the error message I got when run on Tablet:
The GPU device instance has been suspended. Use GetDeviceRemovedReason to determine the appropriate action.
So Do you know another way to present IMFSample to UI.
Thanks.

Related

Is it possible on Linux to run a DRM app that takes over the screen while the X server is active?

I have a simple app that launches and then draws a color full-screen using EGL/OpenGL ES. I am using DRM and GBM. It works great if I switch to a framebuffer console and launch from there. However, if I try to run it while the X server is active, the DRM permissions prevent me from doing so. I assume this is because the X server already has "master" control over DRM. Is there any way to override this and have a DRM app take over the screen, then return control to the X server once it completes? This would be preferable to having to switch to a console using ctrl+alt+FX first. I am running Ubuntu 22.
Mesa includes a "drmSetMaster" function in xf86drm.h:
https://github.com/freedesktop/mesa-drm/blob/master/xf86drm.h
However, I just get the same "permission denied" error. When I run as root, I get a "Device or resource busy" error.
What you want to do is to use the KMS API to create a new “DRM plane” (a.k.a. “overlay”) and display your content there. The DRM API does not have a mechanism to “take over the screen”, what it gives you is a way to create new planes and display content on those planes. The display controller will then take care of compositing those planes together and displaying the result. Each display controller has its own way of handling planes, but typically the most complex display controllers will give you the greatest control over how the planes are composed. The best way to get started on this is to look at the source code for the DRM drivers in the kernel. For example, the Intel DRM driver contains a full-featured KMS API implementation. This is a large and complex driver, but it should give you a good idea of what’s possible with the KMS API.

How to enable audio when using VideoCapturePlayer?

I am trying to integrate a live feed in my WPF application using DirectShow device. Both audio and video is working fine in VLC.
I have integrated VideoCapturePlayer from the WPF-MediaKit in a simple application and i am able to see live video feed from the device, but i am unable to get the audio. I am not 100% sure that it is possible to capture both audio and video using the VideoCapturePlayer.
Any help in getting the audio to work will be appreciated.
Probably there's no Audio renderer set up in VideoCapturePlayer. Try to pull up the MediaUriBase.InsertAudioRenderer into the MediaPlayerBase and use it for the VideoCapturePlayer. If you succeed, open a new PR with your code.

C# WinForm RemoteApps

I wrote a WinForm application that will be remotely accessed via RDP. I am having issues with the sound being transmitted to the client.
I am using the following to trigger a Beep. It is working as expected when I launch the app from my development box. However, when I access it via RDP, It is not beeping.
Console.Beep();
I am wondering if there is a better alternative or anybody aware of a workaround.
The solution was to directly play an audio file. I tried Console.Beepand System.Media.SystemSounds.Beep.Play with no luck!
Console.Beep(); // It didn't work.
System.Media.SystemSounds.Beep.Play(); // IT didn't work either
// Playing directly a wave file produced audio.
using (var soundPlayer = new SoundPlayer(#"c:\Windows\Media\ding.wav"))
{
soundPlayer.Play(); // can also use soundPlayer.PlaySync()
}

Silverlight 5 web cam capture: Two capture sources on the same device

I tried to attach the same Video Source Device (the WEB CAM) to two different CaptureSource objects but it looks like that want work.
The system throws an exception: A device attached to the system is not functioning. (Exception from HRESULT: 0x8007001F)
I think the web cam is locked on first CaptureSource.
Does anybody has an idea how to display two images from the same Device but from different capture source? I wanted to use a simple CaptureSource on one side and MediaStremSource with some filtering on the other side to see differences between original and filtered video source.
I wanted to use the plain CaptureSource because it's performance is better than MediaStreamSource. MediaStreamSource loses time when raises OnSample Event which is not happening with CaptureSource.
I know this exception, When you work on debug mode silverlight fails.
Run project by Ctrl+F5. (Release mode)
In addition use ask for permission methods this will display permission window for camera.
It is very capable, just did it myself. However, in experimenting with different cameras and different inputs.... 2 MS LifeCams connected to USB3 = same error. Connecting to USB2 hub to USB2 MB works like a charm. Also, if I run something like ActiveCam and it crashes, may need a reboot. Oh, you will need to use 2 capture sources.... but can still ask permission once.
Also remember not to use DefaultCaptureDevice but:
var dev1 = CaptureDeviceConfiguration.GetAvailableVideoCaptureDevices()[0];
var dev2 = CaptureDeviceConfiguration.GetAvailableVideoCaptureDevices()[1];
With perhaps better naming conventions and logic to check if devices exist etc...

WP7 MediaElement download problems

I'm running into problems on the WP7 with MediaElement downloading a 128kbps mp3 stream from a web service for a music player app that i'm working on. The file downloads correctly when the wp7 is on a wifi connection, but downloading sometimes stops when off of wifi. The problem is that i'm not getting any errors or exceptions when the downloading fails and the MediaElement state is "playing". MediaElement runs right past the downloaded portion of the stream and acts like it is playing, but there is nothing to play since the download stopped. I can somewhat replicate this issue based upon my location and using the 3g instead of wifi, so i believe it is due to a low connection. I don't believe any code needs to be shown in this instance, but i try to post something. I want to know if I have any control over this? Are there any other events I could use to detect when the download has failed? Is there another way I could download a mp3 stream that is more reliable and play it? Is there another player/component I should try?
Thanks in advance
You could always use MediaStreamSource to try to handle the download and implement streaming, to some extent. It is a more "painful" way of doing this since you will have to work with an extra media layer, but it pays off by improving playback stability.
Here is a starter example by Tim Heuer. Take a look specifically at how he takes advantage of a custom implementation of MediaStreamSource. Here is a more complex sample.
If streaming is not a requirement, you could download the file (and store it in the Isolated Storage) and then play from there.

Resources