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.
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.
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.
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.