// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. #if DESKTOP_APP using System; using System.Runtime.InteropServices; namespace SharpDX.MediaFoundation { public static partial class MediaFactory { /// ///

Enumerates a list of audio or video capture devices.

///
///

Pointer to an attribute store that contains search criteria. To create the attribute store, call . Set one or more of the following attributes on the attribute store:

ValueMeaning

Specifies whether to enumerate audio or video devices. (Required.)

For audio capture devices, specifies the device role. (Optional.)

For video capture devices, specifies the device category. (Optional.)

?

///

Receives an array of interface references. Each reference represents an activation object for a media source. The function allocates the memory for the array. The caller must release the references in the array and call CoTaskMemFree to free the memory for the array.

///

Receives the number of elements in the pppSourceActivate array. If no capture devices match the search criteria, this parameter receives the value 0.

///

If this function succeeds, it returns . Otherwise, it returns an error code.

/// ///

Each returned reference represents a capture device, and can be used to create a media source for that device. You can also use the reference to query for attributes that describe the device. The following attributes might be set:

AttributeDescription
The display name of the device.
The major type and subtype GUIDs that describe the device's output format.
The type of capture device (audio or video).
The audio endpoint ID string. (Audio devices only.)
The device category. (Video devices only.)
Whether a device is a hardware or software device. (Video devices only.)
The symbolic link for the device driver. (Video devices only.)

?

To create a media source from an reference, call the method.

///
/// /// dd388503 /// HRESULT MFEnumDeviceSources([In] IMFAttributes* pAttributes,[Out, Buffer] IMFActivate*** pppSourceActivate,[Out] unsigned int* pcSourceActivate) /// MFEnumDeviceSources public static Activate[] EnumDeviceSources(MediaAttributes attributesRef) { IntPtr devicePtr; int devicesCount; EnumDeviceSources(attributesRef, out devicePtr, out devicesCount); var result = new Activate[devicesCount]; unsafe { var address = (void**)devicePtr; for (var i = 0; i < devicesCount; i++) result[i] = new Activate(new IntPtr(address[i])); } return result; } /// /// Gets a list of Microsoft Media Foundation transforms (MFTs) that match specified search criteria. This function extends the function. /// /// A GUID that specifies the category of MFTs to enumerate. For a list of MFT categories, see . /// The bitwise OR of zero or more flags from the enumeration. /// A pointer to an structure that specifies an input media type to match.This parameter can be NULL. If NULL, all input types are matched. /// A pointer to an structure that specifies an output media type to match.This parameter can be NULL. If NULL, all output types are matched. /// Returns an array of objects. Each object represents an activation object for an MFT that matches the search criteria. The function allocates the memory for the array. The caller must release the pointers and call the Dispose for each element in the array. /// dd388652 /// HRESULT MFTEnumEx([In] GUID guidCategory,[In] unsigned int Flags,[In, Optional] const MFT_REGISTER_TYPE_INFO* pInputType,[In, Optional] const MFT_REGISTER_TYPE_INFO* pOutputType,[Out, Buffer] IMFActivate*** pppMFTActivate,[Out] unsigned int* pnumMFTActivate) /// MFTEnumEx public static Activate[] FindTransform(Guid guidCategory, TransformEnumFlag enumFlags, TRegisterTypeInformation? inputTypeRef = null, TRegisterTypeInformation? outputTypeRef = null) { IntPtr pActivatesArr; int pNumActivates; TEnumEx(guidCategory, (int)enumFlags, inputTypeRef, outputTypeRef, out pActivatesArr, out pNumActivates); var activates = new Activate[pNumActivates]; unsafe { var ptr = (IntPtr*)(pActivatesArr); for (int i = 0; i < pNumActivates; i++) { activates[i] = new Activate(ptr[i]); } } Marshal.FreeCoTaskMem(pActivatesArr); return activates; } /// ///

Applies to: desktop apps | Metro style apps

Copies an image or image plane from one buffer to another.

///
///

Pointer to the start of the first row of pixels in the destination buffer.

///

Stride of the destination buffer, in bytes.

///

Pointer to the start of the first row of pixels in the source image.

///

Stride of the source image, in bytes.

///

Width of the image, in bytes.

///

Number of rows of pixels to copy.

///

If this function succeeds, it returns . Otherwise, it returns an error code.

/// ///

This function copies a single plane of the image. For planar YUV formats, you must call the function once for each plane. In this case, pDest and pSrc must point to the start of each plane.

This function is optimized if the MMX, SSE, or SSE2 instruction sets are available on the processor. The function performs a non-temporal store (the data is written to memory directly without polluting the cache).

Note??Prior to Windows?7, this function was exported from evr.dll. Starting in Windows?7, this function is exported from mfplat.dll, and evr.dll exports a stub function that calls into mfplat.dll. For more information, see Library Changes in Windows?7.

///
/// /// bb970554 /// HRESULT MFCopyImage([Out, Buffer] unsigned char* pDest,[In] int lDestStride,[In, Buffer] const unsigned char* pSrc,[In] int lSrcStride,[In] unsigned int dwWidthInBytes,[In] unsigned int dwLines) /// MFCopyImage public static void CopyImage(IntPtr destRef, int lDestStride, IntPtr srcRef, int lSrcStride, int dwWidthInBytes, int dwLines) { unsafe { SharpDX.Result __result__; __result__ = MFCopyImage_(destRef.ToPointer(), lDestStride, srcRef.ToPointer(), lSrcStride, dwWidthInBytes, dwLines); __result__.CheckError(); } } } } #endif