MediaFoundation capture video while previewing - winapi

This says:
A capture device is represented in Media Foundation by a media source object, which exposes the IMFMediaSource interface. In most cases, the application will not use this interface directly, but will use a higher-level API such as the Source Reader to control the capture device.
When I have an IMFMediaSource I can use MFCreateSourceReaderFromMediaSource and create the source reader. However this function fails with MF_E_MULTIPLE_SUBSCRIBERS when I'm also previewing the video I want to capture, which is what I 'd want.
hr = MFCreateSourceReaderFromMediaSource(t.source, 0, &t.rdr); // Fails if I'm previewing, suceeeds when I'm not.
Is there a way to aquire a SourceReader in order to capture video I'm already previewing?
I'm previewing with the Media Session.
Or, if this is not possible, how do I use the IMFMediaSource directly without a source reader? Much like what the embedded Camera application does.
Thanks a lot.

MF_E_MULTIPLE_SUBSCRIBERS part is touched by another question: you cannot have the source managed by Media Session and additionally work with it otherwise.
If you need both you need to either use a tee in that media session and use two legs of the tee to preview and capture.
Alternatively, manage the source yourself and use a custom-developed proxy in the media session to accept data from the source.
Or, if this is not possible, how do I use the IMFMediaSource directly without a source reader? Much like what the embedded Camera application does.
Or just get rid of Media Session, read from media source directly and use the data outside of Media Foundation.
The use pattern is rather straightforward (and repeats what media session or source reader would do on your behalf): create presentation descriptor, set it up, subscrive to events, start, receive samples. This API is fully documented.

Related

Chromecast Receiver: Custom XHR Loader

I am writing a custom receiver for chromecast and was wondering if there is a way we can have our own, custom XHR loader functionality rather then the built in goog.net.XhrIo?
Basically I need to override the functionality of goog.net.XhrIo for all segments/fragments and media files.
I need this to send some beacons back to my servers for analytics.
Thanks!
If you are using the Media Player Library (MPL), then you can use skipRequest() and setResponse() to achieve what you want to do. Note that the Host class provides a number of overrides for updating Segments, Manifest, License and Captions request info.

How to enable support for closed caption tracks on custom chromecast receiver?

I found an example on github for closedcaptions on custom receiver which is about two years old. This example uses sender-receiver communication messageBus to send message to receiver to add a track element to show captions. At that time, chromecast's default media receiver did not support caption track. But as of today, it supports it which can be enabled using chrome.cast.media.Media.editTracksInfo. I tried using editTracksInfo API method to enable captions on my custom receiver which is built using Media Player Library, but it did not work. Can someone please confirm if I still will have to use messageBus to tell my receiver app to create/insert track elements to add captions support to my receiver or can I leverage MPL to automatically do it?
You shouldn't need any custom message; a fully UX compliant receiver sample that supports Closed Captions is available on our GitHub repo. You can use that receiver as the base for your own or you can read through it to see how MPL is utilized to provide closed captions for adaptive media. If you have a simple mp4 + side-loaded vtt file, then MPL doesn't get involved. On the sender side, we now support tracks through the SDK directly; if you want to see a sample of that, take a look at CCL.

Distribute webm/VP8 player without installing directShow filters

I am about to write a C# application that plays webm video files which have VP8 encoded videostreams inside.
Is it possible to do this without having the user to install a DirectShow Filter?
i.e. by providing some DLLs with the distribution?
Is this allowed from a licensing point of view?
A DirectShow filter is operational once it gets added to filter graph. So you don't necessarily need filter COM registration: you can add it there yourself by explicit call. Then you can instantiate it through COM or otherwise.
If you need standard filter registration just to instantiate the filter, you can leverage reg-free COM or simply load the DLL and obtain its factory through exported DllGetClassObject function.
If however you need DirectShow Intelligent Connect to pick up your decoder automatically, you need either full COM registration or you need to update your code to build your graph with explicit filter adding.
Further reading: Using Filters Without Registration.

VB6 code to stream video using bosch ptz ip camera

Can anyone share the code and which ActiveX control did you used to integrate IP camera in vb6?
This is a very wide scoped question. There are various 3rd party controls that can receive and render motion JPEG/H.264 like the DTK video capture control.
Alternatively, you can set up a TCP/HTTP connection to receive the video stream, split it into MIME parts and decode and render each in turn.

switch the cameratype in Windows Phone7

all, as we know, the CameraType property indicates the location of the camera on the device. But when I try to swich the cameratype from Primary to FrontFacing by using the following code, it does not work. After reviewing the MSDN document, I found it was a protected set method. And obviously I have no access permition. Is there any way to do that?
Could any one help me?
Thanks in advance!
camera.CameraType = CameraType.FrontFacing;
It seems like you can't force the camera to a different mode after you initialize it.
Use the constructor of the implementation.
For ex: Constructor of PhotoCamera class
I assume you're trying to create a custom camera app ? or something similar ?
If you just want to capture a picture, use Camera Capture Task instead of this. Otherwise your app will fail certification.
If photo capture is not a core feature of your application, consider using the Camera Capture Task to capture photos instead of using the camera APIs directly. Memory allocated for the Camera Capture Task does not count toward total application memory use. This helps minimize your application’s memory use, which is particularly important when your application runs on a 256-MB device. For more information, see Developing for 256-MB Devices and How to: Use the Camera Capture Task for Windows Phone.

Resources