Using an Encoder's Activation Objects
For converting media files into ASF format, you can use Windows Media encoders. To use these encoders, they must be registered with the system.
For information about encoder registration, see Instantiating an Encoder MFT.
Using an Encoder's Activation Objects
As an alternative to using an encoder's IMFTransform interface (described in Creating an Encoder by Using CoCreateInstance), you can create an instance of the activation object for the encoder. Activation objects facilitates encoder creation and Media Foundation provides the following two functions for this approach:
- MFCreateWMAEncoderActivate for instantiating the Windows Media audio encoder.
- MFCreateWMVEncoderActivate for instantiating the Windows Media video encoder.
Both these functions require that you create the target media type and set the encoding properties before calling these functions. If your application is using Pipeline Layer ASF Components to encode a file to ASF format, and have already created and configured the ASF Media Sinks, you can get this set of information from the ASF media sink.
MFCreateWMAEncoderActivate and MFCreateWMVEncoderActivate set the output type of the encoder to the media type specified by the application.
Note If you are using MFCreateWMAEncoderActivate and MFCreateWMVEncoderActivate you can activate the encoder by calling IMFActivate::ActivateObject but you cannot change the input and the output media types of the encoder nor can you change any of the encoding properties.
For more information about creating Media Foundation objects by using activation objects, see Activation Objects.
To get the target media type from the ASF media sink
- Get a pointer to the IMFASFContentInfo pointer of the ASF media sink by calling IMFMediaSink::QueryInterface on the ASF media sink and passing IID_IMFASFContentInfo as the interface identifier.
- Get the ASF profile object associated with the ContentInfo object.
- Enumerate the streams in the profile to get the stream's media type.
To get the encoding properties from the ASF media sink
If you have configured the Encoding Properties in the media sink (described in Setting Properties in the File Sink), you can a reference to the sink's property store by calling IMFMediaSink::QueryInterface on the ASF media sink and passing IID_IPropertyStore as the interface identifier.
If you have a pointer to the sink's ContentInfo object, you can call IMFASFContentInfo::GetEncodingConfigurationPropertyStore to get a reference to the media sink's property store.
Make sure that all of encoding properties that are set on the ASF media sink are reflected in the property store passed to MFCreateWMAEncoderActivate and MFCreateWMVEncoderActivate. The encoder is configured automatically based on the settings specified by the application.
While creating the transform node in the encoding topology, you can set the object type as an IMFActivate pointer received in these two calls. When the topology is resolved, the Media Session uses the activation object to create an instance of the encoder MFT.
Encoder Enumeration in Windows 7 and Later
For applications that are running on Windows 7, in addition to MFTEnum you can enumerate the encoder MFTs by calling MFTEnumEx. This function returns a pointer to the activation object of the encoder MFT. The structure of the function is very similar to MFTEnum described above except MFTEnumExreturns an array of IMFActivate pointers for the encoder MFTs that match the search criteria.
Related topics