objc2_core_media/generated/
CMTimeRange.rs1use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7use objc2_core_foundation::*;
8
9use crate::*;
10
11#[cfg(feature = "CMTime")]
15#[repr(C)]
16#[derive(Clone, Copy, Debug, PartialEq)]
17pub struct CMTimeRange {
18 pub start: CMTime,
20 pub duration: CMTime,
22}
23
24#[cfg(all(feature = "CMTime", feature = "objc2"))]
25unsafe impl Encode for CMTimeRange {
26 const ENCODING: Encoding = Encoding::Struct("?", &[<CMTime>::ENCODING, <CMTime>::ENCODING]);
27}
28
29#[cfg(all(feature = "CMTime", feature = "objc2"))]
30unsafe impl RefEncode for CMTimeRange {
31 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
32}
33
34extern "C" {
35 #[cfg(feature = "CMTime")]
37 pub static kCMTimeRangeZero: CMTimeRange;
38}
39
40extern "C" {
41 #[cfg(feature = "CMTime")]
43 pub static kCMTimeRangeInvalid: CMTimeRange;
44}
45
46#[cfg(feature = "CMTime")]
47impl CMTimeRange {
48 #[doc(alias = "CMTimeRangeMake")]
54 #[cfg(feature = "CMTime")]
55 #[inline]
56 pub unsafe fn new(start: CMTime, duration: CMTime) -> CMTimeRange {
57 extern "C-unwind" {
58 fn CMTimeRangeMake(start: CMTime, duration: CMTime) -> CMTimeRange;
59 }
60 unsafe { CMTimeRangeMake(start, duration) }
61 }
62
63 #[doc(alias = "CMTimeRangeGetUnion")]
78 #[cfg(feature = "CMTime")]
79 #[inline]
80 pub unsafe fn union(self, other_range: CMTimeRange) -> CMTimeRange {
81 extern "C-unwind" {
82 fn CMTimeRangeGetUnion(range: CMTimeRange, other_range: CMTimeRange) -> CMTimeRange;
83 }
84 unsafe { CMTimeRangeGetUnion(self, other_range) }
85 }
86
87 #[doc(alias = "CMTimeRangeGetIntersection")]
102 #[cfg(feature = "CMTime")]
103 #[inline]
104 pub unsafe fn intersection(self, other_range: CMTimeRange) -> CMTimeRange {
105 extern "C-unwind" {
106 fn CMTimeRangeGetIntersection(
107 range: CMTimeRange,
108 other_range: CMTimeRange,
109 ) -> CMTimeRange;
110 }
111 unsafe { CMTimeRangeGetIntersection(self, other_range) }
112 }
113
114 #[doc(alias = "CMTimeRangeEqual")]
128 #[cfg(feature = "CMTime")]
129 #[inline]
130 pub unsafe fn equal(self, range2: CMTimeRange) -> bool {
131 extern "C-unwind" {
132 fn CMTimeRangeEqual(range1: CMTimeRange, range2: CMTimeRange) -> Boolean;
133 }
134 let ret = unsafe { CMTimeRangeEqual(self, range2) };
135 ret != 0
136 }
137
138 #[doc(alias = "CMTimeRangeContainsTime")]
153 #[cfg(feature = "CMTime")]
154 #[inline]
155 pub unsafe fn contains_time(self, time: CMTime) -> bool {
156 extern "C-unwind" {
157 fn CMTimeRangeContainsTime(range: CMTimeRange, time: CMTime) -> Boolean;
158 }
159 let ret = unsafe { CMTimeRangeContainsTime(self, time) };
160 ret != 0
161 }
162
163 #[doc(alias = "CMTimeRangeContainsTimeRange")]
178 #[cfg(feature = "CMTime")]
179 #[inline]
180 pub unsafe fn contains_time_range(self, other_range: CMTimeRange) -> bool {
181 extern "C-unwind" {
182 fn CMTimeRangeContainsTimeRange(
183 range: CMTimeRange,
184 other_range: CMTimeRange,
185 ) -> Boolean;
186 }
187 let ret = unsafe { CMTimeRangeContainsTimeRange(self, other_range) };
188 ret != 0
189 }
190
191 #[doc(alias = "CMTimeRangeGetEnd")]
202 #[cfg(feature = "CMTime")]
203 #[inline]
204 pub unsafe fn end(self) -> CMTime {
205 extern "C-unwind" {
206 fn CMTimeRangeGetEnd(range: CMTimeRange) -> CMTime;
207 }
208 unsafe { CMTimeRangeGetEnd(self) }
209 }
210}
211
212#[cfg(feature = "CMTime")]
213impl CMTime {
214 #[doc(alias = "CMTimeMapTimeFromRangeToRange")]
226 #[cfg(feature = "CMTime")]
227 #[inline]
228 pub unsafe fn map_time_from_range_to_range(
229 self,
230 from_range: CMTimeRange,
231 to_range: CMTimeRange,
232 ) -> CMTime {
233 extern "C-unwind" {
234 fn CMTimeMapTimeFromRangeToRange(
235 t: CMTime,
236 from_range: CMTimeRange,
237 to_range: CMTimeRange,
238 ) -> CMTime;
239 }
240 unsafe { CMTimeMapTimeFromRangeToRange(self, from_range, to_range) }
241 }
242
243 #[doc(alias = "CMTimeClampToRange")]
253 #[cfg(feature = "CMTime")]
254 #[inline]
255 pub unsafe fn clamp_to_range(self, range: CMTimeRange) -> CMTime {
256 extern "C-unwind" {
257 fn CMTimeClampToRange(time: CMTime, range: CMTimeRange) -> CMTime;
258 }
259 unsafe { CMTimeClampToRange(self, range) }
260 }
261
262 #[doc(alias = "CMTimeMapDurationFromRangeToRange")]
270 #[cfg(feature = "CMTime")]
271 #[inline]
272 pub unsafe fn map_duration_from_range_to_range(
273 self,
274 from_range: CMTimeRange,
275 to_range: CMTimeRange,
276 ) -> CMTime {
277 extern "C-unwind" {
278 fn CMTimeMapDurationFromRangeToRange(
279 dur: CMTime,
280 from_range: CMTimeRange,
281 to_range: CMTimeRange,
282 ) -> CMTime;
283 }
284 unsafe { CMTimeMapDurationFromRangeToRange(self, from_range, to_range) }
285 }
286
287 #[doc(alias = "CMTimeFoldIntoRange")]
294 #[cfg(feature = "CMTime")]
295 #[inline]
296 pub unsafe fn fold_into_range(self, fold_range: CMTimeRange) -> CMTime {
297 extern "C-unwind" {
298 fn CMTimeFoldIntoRange(time: CMTime, fold_range: CMTimeRange) -> CMTime;
299 }
300 unsafe { CMTimeFoldIntoRange(self, fold_range) }
301 }
302}
303
304#[cfg(feature = "CMTime")]
305impl CMTimeRange {
306 #[doc(alias = "CMTimeRangeFromTimeToTime")]
310 #[cfg(feature = "CMTime")]
311 #[inline]
312 pub unsafe fn from_time_to_time(start: CMTime, end: CMTime) -> CMTimeRange {
313 extern "C-unwind" {
314 fn CMTimeRangeFromTimeToTime(start: CMTime, end: CMTime) -> CMTimeRange;
315 }
316 unsafe { CMTimeRangeFromTimeToTime(start, end) }
317 }
318
319 #[doc(alias = "CMTimeRangeCopyAsDictionary")]
325 #[cfg(feature = "CMTime")]
326 #[inline]
327 pub unsafe fn as_dictionary(
328 self,
329 allocator: Option<&CFAllocator>,
330 ) -> Option<CFRetained<CFDictionary>> {
331 extern "C-unwind" {
332 fn CMTimeRangeCopyAsDictionary(
333 range: CMTimeRange,
334 allocator: Option<&CFAllocator>,
335 ) -> Option<NonNull<CFDictionary>>;
336 }
337 let ret = unsafe { CMTimeRangeCopyAsDictionary(self, allocator) };
338 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
339 }
340
341 #[doc(alias = "CMTimeRangeMakeFromDictionary")]
352 #[cfg(feature = "CMTime")]
353 #[inline]
354 pub unsafe fn from_dictionary(dictionary_representation: &CFDictionary) -> CMTimeRange {
355 extern "C-unwind" {
356 fn CMTimeRangeMakeFromDictionary(
357 dictionary_representation: &CFDictionary,
358 ) -> CMTimeRange;
359 }
360 unsafe { CMTimeRangeMakeFromDictionary(dictionary_representation) }
361 }
362}
363
364extern "C" {
365 pub static kCMTimeRangeStartKey: &'static CFString;
369}
370
371extern "C" {
372 pub static kCMTimeRangeDurationKey: &'static CFString;
376}
377
378#[cfg(feature = "CMTime")]
379impl CMTimeRange {
380 #[doc(alias = "CMTimeRangeCopyDescription")]
387 #[cfg(feature = "CMTime")]
388 #[inline]
389 pub unsafe fn description(
390 allocator: Option<&CFAllocator>,
391 range: CMTimeRange,
392 ) -> Option<CFRetained<CFString>> {
393 extern "C-unwind" {
394 fn CMTimeRangeCopyDescription(
395 allocator: Option<&CFAllocator>,
396 range: CMTimeRange,
397 ) -> Option<NonNull<CFString>>;
398 }
399 let ret = unsafe { CMTimeRangeCopyDescription(allocator, range) };
400 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
401 }
402
403 #[doc(alias = "CMTimeRangeShow")]
407 #[cfg(feature = "CMTime")]
408 #[inline]
409 pub unsafe fn show(self) {
410 extern "C-unwind" {
411 fn CMTimeRangeShow(range: CMTimeRange);
412 }
413 unsafe { CMTimeRangeShow(self) }
414 }
415}
416
417#[cfg(feature = "CMTime")]
432#[repr(C)]
433#[derive(Clone, Copy, Debug, PartialEq)]
434pub struct CMTimeMapping {
435 pub source: CMTimeRange,
436 pub target: CMTimeRange,
437}
438
439#[cfg(all(feature = "CMTime", feature = "objc2"))]
440unsafe impl Encode for CMTimeMapping {
441 const ENCODING: Encoding =
442 Encoding::Struct("?", &[<CMTimeRange>::ENCODING, <CMTimeRange>::ENCODING]);
443}
444
445#[cfg(all(feature = "CMTime", feature = "objc2"))]
446unsafe impl RefEncode for CMTimeMapping {
447 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
448}
449
450extern "C" {
451 #[cfg(feature = "CMTime")]
453 pub static kCMTimeMappingInvalid: CMTimeMapping;
454}
455
456#[cfg(feature = "CMTime")]
457impl CMTimeMapping {
458 #[doc(alias = "CMTimeMappingMake")]
464 #[cfg(feature = "CMTime")]
465 #[inline]
466 pub unsafe fn new(source: CMTimeRange, target: CMTimeRange) -> CMTimeMapping {
467 extern "C-unwind" {
468 fn CMTimeMappingMake(source: CMTimeRange, target: CMTimeRange) -> CMTimeMapping;
469 }
470 unsafe { CMTimeMappingMake(source, target) }
471 }
472
473 #[doc(alias = "CMTimeMappingMakeEmpty")]
479 #[cfg(feature = "CMTime")]
480 #[inline]
481 pub unsafe fn empty(target: CMTimeRange) -> CMTimeMapping {
482 extern "C-unwind" {
483 fn CMTimeMappingMakeEmpty(target: CMTimeRange) -> CMTimeMapping;
484 }
485 unsafe { CMTimeMappingMakeEmpty(target) }
486 }
487
488 #[doc(alias = "CMTimeMappingCopyAsDictionary")]
494 #[cfg(feature = "CMTime")]
495 #[inline]
496 pub unsafe fn as_dictionary(
497 self,
498 allocator: Option<&CFAllocator>,
499 ) -> Option<CFRetained<CFDictionary>> {
500 extern "C-unwind" {
501 fn CMTimeMappingCopyAsDictionary(
502 mapping: CMTimeMapping,
503 allocator: Option<&CFAllocator>,
504 ) -> Option<NonNull<CFDictionary>>;
505 }
506 let ret = unsafe { CMTimeMappingCopyAsDictionary(self, allocator) };
507 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
508 }
509
510 #[doc(alias = "CMTimeMappingMakeFromDictionary")]
521 #[cfg(feature = "CMTime")]
522 #[inline]
523 pub unsafe fn from_dictionary(dictionary_representation: &CFDictionary) -> CMTimeMapping {
524 extern "C-unwind" {
525 fn CMTimeMappingMakeFromDictionary(
526 dictionary_representation: &CFDictionary,
527 ) -> CMTimeMapping;
528 }
529 unsafe { CMTimeMappingMakeFromDictionary(dictionary_representation) }
530 }
531}
532
533extern "C" {
534 pub static kCMTimeMappingSourceKey: &'static CFString;
538}
539
540extern "C" {
541 pub static kCMTimeMappingTargetKey: &'static CFString;
545}
546
547#[cfg(feature = "CMTime")]
548impl CMTimeMapping {
549 #[doc(alias = "CMTimeMappingCopyDescription")]
556 #[cfg(feature = "CMTime")]
557 #[inline]
558 pub unsafe fn description(
559 allocator: Option<&CFAllocator>,
560 mapping: CMTimeMapping,
561 ) -> Option<CFRetained<CFString>> {
562 extern "C-unwind" {
563 fn CMTimeMappingCopyDescription(
564 allocator: Option<&CFAllocator>,
565 mapping: CMTimeMapping,
566 ) -> Option<NonNull<CFString>>;
567 }
568 let ret = unsafe { CMTimeMappingCopyDescription(allocator, mapping) };
569 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
570 }
571
572 #[doc(alias = "CMTimeMappingShow")]
576 #[cfg(feature = "CMTime")]
577 #[inline]
578 pub unsafe fn show(self) {
579 extern "C-unwind" {
580 fn CMTimeMappingShow(mapping: CMTimeMapping);
581 }
582 unsafe { CMTimeMappingShow(self) }
583 }
584}
585
586extern "C-unwind" {
587 #[cfg(feature = "CMTime")]
588 #[deprecated = "renamed to `CMTimeRange::new`"]
589 pub fn CMTimeRangeMake(start: CMTime, duration: CMTime) -> CMTimeRange;
590}
591
592extern "C-unwind" {
593 #[cfg(feature = "CMTime")]
594 #[deprecated = "renamed to `CMTimeRange::union`"]
595 pub fn CMTimeRangeGetUnion(range: CMTimeRange, other_range: CMTimeRange) -> CMTimeRange;
596}
597
598extern "C-unwind" {
599 #[cfg(feature = "CMTime")]
600 #[deprecated = "renamed to `CMTimeRange::intersection`"]
601 pub fn CMTimeRangeGetIntersection(range: CMTimeRange, other_range: CMTimeRange) -> CMTimeRange;
602}
603
604#[cfg(feature = "CMTime")]
605#[deprecated = "renamed to `CMTimeRange::equal`"]
606#[inline]
607pub unsafe extern "C-unwind" fn CMTimeRangeEqual(range1: CMTimeRange, range2: CMTimeRange) -> bool {
608 extern "C-unwind" {
609 fn CMTimeRangeEqual(range1: CMTimeRange, range2: CMTimeRange) -> Boolean;
610 }
611 let ret = unsafe { CMTimeRangeEqual(range1, range2) };
612 ret != 0
613}
614
615#[cfg(feature = "CMTime")]
616#[deprecated = "renamed to `CMTimeRange::contains_time`"]
617#[inline]
618pub unsafe extern "C-unwind" fn CMTimeRangeContainsTime(range: CMTimeRange, time: CMTime) -> bool {
619 extern "C-unwind" {
620 fn CMTimeRangeContainsTime(range: CMTimeRange, time: CMTime) -> Boolean;
621 }
622 let ret = unsafe { CMTimeRangeContainsTime(range, time) };
623 ret != 0
624}
625
626#[cfg(feature = "CMTime")]
627#[deprecated = "renamed to `CMTimeRange::contains_time_range`"]
628#[inline]
629pub unsafe extern "C-unwind" fn CMTimeRangeContainsTimeRange(
630 range: CMTimeRange,
631 other_range: CMTimeRange,
632) -> bool {
633 extern "C-unwind" {
634 fn CMTimeRangeContainsTimeRange(range: CMTimeRange, other_range: CMTimeRange) -> Boolean;
635 }
636 let ret = unsafe { CMTimeRangeContainsTimeRange(range, other_range) };
637 ret != 0
638}
639
640extern "C-unwind" {
641 #[cfg(feature = "CMTime")]
642 #[deprecated = "renamed to `CMTimeRange::end`"]
643 pub fn CMTimeRangeGetEnd(range: CMTimeRange) -> CMTime;
644}
645
646extern "C-unwind" {
647 #[cfg(feature = "CMTime")]
648 #[deprecated = "renamed to `CMTime::map_time_from_range_to_range`"]
649 pub fn CMTimeMapTimeFromRangeToRange(
650 t: CMTime,
651 from_range: CMTimeRange,
652 to_range: CMTimeRange,
653 ) -> CMTime;
654}
655
656extern "C-unwind" {
657 #[cfg(feature = "CMTime")]
658 #[deprecated = "renamed to `CMTime::clamp_to_range`"]
659 pub fn CMTimeClampToRange(time: CMTime, range: CMTimeRange) -> CMTime;
660}
661
662extern "C-unwind" {
663 #[cfg(feature = "CMTime")]
664 #[deprecated = "renamed to `CMTime::map_duration_from_range_to_range`"]
665 pub fn CMTimeMapDurationFromRangeToRange(
666 dur: CMTime,
667 from_range: CMTimeRange,
668 to_range: CMTimeRange,
669 ) -> CMTime;
670}
671
672extern "C-unwind" {
673 #[cfg(feature = "CMTime")]
674 #[deprecated = "renamed to `CMTime::fold_into_range`"]
675 pub fn CMTimeFoldIntoRange(time: CMTime, fold_range: CMTimeRange) -> CMTime;
676}
677
678extern "C-unwind" {
679 #[cfg(feature = "CMTime")]
680 #[deprecated = "renamed to `CMTimeRange::from_time_to_time`"]
681 pub fn CMTimeRangeFromTimeToTime(start: CMTime, end: CMTime) -> CMTimeRange;
682}
683
684#[cfg(feature = "CMTime")]
685#[deprecated = "renamed to `CMTimeRange::as_dictionary`"]
686#[inline]
687pub unsafe extern "C-unwind" fn CMTimeRangeCopyAsDictionary(
688 range: CMTimeRange,
689 allocator: Option<&CFAllocator>,
690) -> Option<CFRetained<CFDictionary>> {
691 extern "C-unwind" {
692 fn CMTimeRangeCopyAsDictionary(
693 range: CMTimeRange,
694 allocator: Option<&CFAllocator>,
695 ) -> Option<NonNull<CFDictionary>>;
696 }
697 let ret = unsafe { CMTimeRangeCopyAsDictionary(range, allocator) };
698 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
699}
700
701extern "C-unwind" {
702 #[cfg(feature = "CMTime")]
703 #[deprecated = "renamed to `CMTimeRange::from_dictionary`"]
704 pub fn CMTimeRangeMakeFromDictionary(dictionary_representation: &CFDictionary) -> CMTimeRange;
705}
706
707#[cfg(feature = "CMTime")]
708#[deprecated = "renamed to `CMTimeRange::description`"]
709#[inline]
710pub unsafe extern "C-unwind" fn CMTimeRangeCopyDescription(
711 allocator: Option<&CFAllocator>,
712 range: CMTimeRange,
713) -> Option<CFRetained<CFString>> {
714 extern "C-unwind" {
715 fn CMTimeRangeCopyDescription(
716 allocator: Option<&CFAllocator>,
717 range: CMTimeRange,
718 ) -> Option<NonNull<CFString>>;
719 }
720 let ret = unsafe { CMTimeRangeCopyDescription(allocator, range) };
721 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
722}
723
724extern "C-unwind" {
725 #[cfg(feature = "CMTime")]
726 #[deprecated = "renamed to `CMTimeRange::show`"]
727 pub fn CMTimeRangeShow(range: CMTimeRange);
728}
729
730extern "C-unwind" {
731 #[cfg(feature = "CMTime")]
732 #[deprecated = "renamed to `CMTimeMapping::new`"]
733 pub fn CMTimeMappingMake(source: CMTimeRange, target: CMTimeRange) -> CMTimeMapping;
734}
735
736extern "C-unwind" {
737 #[cfg(feature = "CMTime")]
738 #[deprecated = "renamed to `CMTimeMapping::empty`"]
739 pub fn CMTimeMappingMakeEmpty(target: CMTimeRange) -> CMTimeMapping;
740}
741
742#[cfg(feature = "CMTime")]
743#[deprecated = "renamed to `CMTimeMapping::as_dictionary`"]
744#[inline]
745pub unsafe extern "C-unwind" fn CMTimeMappingCopyAsDictionary(
746 mapping: CMTimeMapping,
747 allocator: Option<&CFAllocator>,
748) -> Option<CFRetained<CFDictionary>> {
749 extern "C-unwind" {
750 fn CMTimeMappingCopyAsDictionary(
751 mapping: CMTimeMapping,
752 allocator: Option<&CFAllocator>,
753 ) -> Option<NonNull<CFDictionary>>;
754 }
755 let ret = unsafe { CMTimeMappingCopyAsDictionary(mapping, allocator) };
756 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
757}
758
759extern "C-unwind" {
760 #[cfg(feature = "CMTime")]
761 #[deprecated = "renamed to `CMTimeMapping::from_dictionary`"]
762 pub fn CMTimeMappingMakeFromDictionary(
763 dictionary_representation: &CFDictionary,
764 ) -> CMTimeMapping;
765}
766
767#[cfg(feature = "CMTime")]
768#[deprecated = "renamed to `CMTimeMapping::description`"]
769#[inline]
770pub unsafe extern "C-unwind" fn CMTimeMappingCopyDescription(
771 allocator: Option<&CFAllocator>,
772 mapping: CMTimeMapping,
773) -> Option<CFRetained<CFString>> {
774 extern "C-unwind" {
775 fn CMTimeMappingCopyDescription(
776 allocator: Option<&CFAllocator>,
777 mapping: CMTimeMapping,
778 ) -> Option<NonNull<CFString>>;
779 }
780 let ret = unsafe { CMTimeMappingCopyDescription(allocator, mapping) };
781 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
782}
783
784extern "C-unwind" {
785 #[cfg(feature = "CMTime")]
786 #[deprecated = "renamed to `CMTimeMapping::show`"]
787 pub fn CMTimeMappingShow(mapping: CMTimeMapping);
788}