Last active
December 15, 2015 16:12
-
-
Save RLovelett/e5ee7f173877bb8475dc to your computer and use it in GitHub Desktop.
Allow `withUnsafePointer` to not mark `struct` function as `mutating`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension AVCodec { | |
mutating func profileName(profile: Int32) -> String? { | |
let result = withUnsafePointer(&self) { (codecPointer) in | |
return av_get_profile_name(codecPointer, profile) | |
} | |
return String.fromCString(result) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See: https://ffmpeg.org/doxygen/2.8/libavcodec_2avcodec_8h_source.html#l03472 | |
typedef struct AVCodec { | |
// ... | |
} AVCodec; | |
// See: https://ffmpeg.org/doxygen/2.8/libavcodec_2utils_8c_source.html#l03260 | |
const char *av_get_profile_name(const AVCodec *codec, int profile) | |
{ | |
const AVProfile *p; | |
if (profile == FF_PROFILE_UNKNOWN || !codec->profiles) | |
return NULL; | |
for (p = codec->profiles; p->profile != FF_PROFILE_UNKNOWN; p++) | |
if (p->profile == profile) | |
return p->name; | |
return NULL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment