As I understand it, the installation expects that MediaDataInRealTime - YES means that the encoder is waiting for real-time data transmission, for example, cameras, etc. In this case, you will constantly feed the encoder with data, isReadyForMoreMediaData will tell you if it can feed data to the encoder. If isReadyForMoreMediaData is NO, you will have to drop the current pattern and wait until the next pattern appears, and check isReadyForMoreMediaData again for whether it is YES.
On the other hand, if you expect that MediaDataInRealTime is NO, it means that the encoder does not use the source in real time, but an autonomous data stream, for example, AVAssetReader. In this case, since you can control the flow rate yourself, so there is no NO on isReadyForMoreMediaData, you can hold the input and encoder and wait until isReadyForMoreMediaData turns into YES (for example, use an infinite loop to sleep and wait for the isReadyForMoreMediaData to change, etc.) .
The purpose of this, I believe, is that for the internal mechanism, you can try to alternate the timestamp of audio and video as even as possible, so players, decoders, do not need to pre-sample a large amount of data for playback. This is a compromise between the integrity of the data of the final data source and the experience of reproduction. Although, I suppose, you can use expectsMediaDataInRealTime for YES all the time, but it is better to discard early samples in the case of isReadyForMoreMediaData == NO.
source share