kCMTimeInvalid is invalid CMTime, but based on Apple document, there are more invalid CMTime, what are they? What does CMTime "invalid" means? It's overflow, uninitiated or anything else?
https://developer.apple.com/documentation/coremedia/kcmtimeinvalid
All fields are 0, so you can calloc or fill with 0's to make lots of them. Do not test against this using (time == kCMTimeInvalid), there are many CMTimes other than this that are also invalid. Use CMTIME_IS_INVALID(time) instead.
I found some cases when CMTime is invalid:
When flags(CMTimeFlags) kCMTimeFlags_Valid not set.
kCMTimeFlags_Valid Must be set, or the CMTime is considered invalid.
Some operations of CMTimeAdd
+infinity + +infinity == +infinity
-infinity + -infinity == -infinity +infinity + -infinity == invalid -infinity + +infinity == invalid
There are five possible states:
From the documentation you posted, it says:
Use CMTIME_IS_INVALID(time) instead.
From CMTime.h
, it looks like CMTIME_IS_INVALID
is defined as:
#define CMTIME_IS_INVALID(time) (! CMTIME_IS_VALID(time))
And CMTIME_IS_VALID
is defined as:
#define CMTIME_IS_VALID(time) ((Boolean)(((time).flags & kCMTimeFlags_Valid) != 0))
So it looks like the only thing that determines if a CMTime
is valid or not is whether the kCMTimeFlags_Valid
flag is set.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.