Resetting State in AVStream Codecs
To discard the stream data and reset the streaming state, the media streaming pipeline sends MFT_MESSAGE_COMMAND_FLUSH to an MFT. When a HW MFT receives an MFT_MESSAGE_COMMAND_FLUSH, the MFT sends IOCTL_KS_RESET_STATE with a value of KSRESET_BEGIN to the input and output pins. Minidrivers should subscribe to receive reset notification by specifying an AVStrMiniPinReset callback in the Reset member of KSPIN_DISPATCH.
When the driver receives this IOCTL, it should delete all outstanding clone pointers and reset all previous internal states. After the driver has flushed pending IO requests, it receives another IOCTL_KS_RESET_STATE with a value of KSRESET_END.
At this point, the minidriver should be ready to accept new input from the next stream.
Be aware that for reset to work correctly, the minidriver must specify the topology connection between the input and output pins by supplying an array of type KSTOPOLOGY_CONNECTION in the Connections member of the KSFILTER_DESCRIPTOR structure.
A reset IOCTL is also sent in the following scenario. When the driver sets the KSSTREAM_HEADER_OPTIONSF_ENDOFSTREAM flag on a stream header and unlocks the stream pointer, KS flushes the queue, which generates an IOCTL_KS_RESET_STATE call with a value of KSRESET_END into the driver.
In this case, when the driver receives an end request without a preceding begin request, the driver should set KSPIN.ResetState to KSRESET_END. This case applies only to output pins.