Creating the ASF File Sink

The ASF file sink is an implementation of IMFMediaSink provided by Media Foundation that an application can use to archive ASF media data to a file. For information about ASF Media Sinks' object model and general usage, see ASF Media Sinks.

There are two ways of creating an instance of the ASF file sink. You can call MFCreateASFMediaSink or MFCreateASFMediaSinkActivate.

If you call MFCreateASFMediaSink, you must specify a byte stream, for the output file, into which the sink will write the ASF content during an encoding session. The specified byte stream must have seekable and writable capabilities otherwise the MFCreateASFMediaSink call fails with the E_FAIL error code. This call creates an in-process file sink object and returns a pointer to the IMFMediaSink interface of the file sink.

If you call MFCreateASFMediaSinkActivate, you must specify the URL of the output file into which the file sink will write media data. In this case, the file sink internally creates the byte stream. The function returns a pointer to the IMFActivate interface of the file sink. To

Consider MFCreateASFMediaSinkActivate instead of MFCreateASFMediaSink, when your encoding topology is designed as follows:

  • The encoding topology is for the protected media path (PMP) and the file sink is used out-of-process.

  • The output node of the topology is created by using the returned pointer to the activate object of the file sink and your application is keeping track of the streams in the file sink by stream numbers.

    Note

    You can activate the file sink by calling IMFActivate::ActivateObject. However you do not need to activate the object explictly. The Media Session keeps track of the activation object and activates the file sink automatically during the encoding session.

     

  • The stream information is configured in the ContentInfo object. Disucssed in the next sub-section.

After creating the ASF file sink it must be configured before building the topology. The file sink needs to know the following information in order to generate the output file.

  • Basic stream information
  • Encoding mode information
  • Metadata

The file sink implements the ASF ContentInfo Object and exposes the IMFASFContentInfo interface so that an application can use it to set information related to the streams and encoding. Depending on the function you called to create the file sink, there are two ways of getting a reference to the IMFASFContentInfo interface.

  • If you call the MFCreateASFMediaSink function, the application must query for IMFASFContentInfo interface by calling IMFMediaSink::QueryInterface on the returned file sink.
  • If you choose to call MFCreateASFMediaSinkActivate, this function expects that you have a fully-configured ContentInfo object prior to the call. To do this, you need to create an empty ContentInfo object by calling MFCreateASFContentInfo and then configure it with all the required information. Pass the configured ContentInfo object to the MFCreateASFMediaSinkActivate to receive a pointer to the sink activate object. You cannot activate the file sink by using the returned activation object and then change any stream or encoding information.

For information about configuring sink streams and specific properties, see the following topics:

ASF Media Sinks

Pipeline Layer ASF Components

ASF Support in Media Foundation