~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/maccore/src/CoreMedia/CoreMedia.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
// CoreMedia.cs: Basic definitions for CoreMedia
3
3
//
4
4
// Authors: Mono Team
 
5
//          Marek Safar (marek.safar@gmail.com)
5
6
//
6
7
// Copyright 2010-2011 Novell Inc
7
8
// Copyright 2012 Xamarin Inc
12
13
using MonoMac.ObjCRuntime;
13
14
 
14
15
namespace MonoMac.CoreMedia {
15
 
 
16
 
        [StructLayout(LayoutKind.Sequential)]
17
 
        public struct CMTime {
18
 
                [FlagsAttribute]
19
 
                public enum Flags {
20
 
                        Valid = 1,
21
 
                        HasBeenRounded = 2,
22
 
                        PositiveInfinity = 4,
23
 
                        NegativeInfinity = 8,
24
 
                        Indefinite = 16,
25
 
                        ImpliedValueFlagsMask = 28
26
 
                }
27
 
 
28
 
                public static CMTime Invalid = new CMTime (0);
29
 
                const Flags kIndefinite = Flags.Valid | Flags.Indefinite;
30
 
                public static CMTime Indefinite = new CMTime (kIndefinite);
31
 
                const Flags kPositive = Flags.Valid | Flags.PositiveInfinity;
32
 
                public static CMTime PositiveInfinity = new CMTime (kPositive);
33
 
                const Flags kNegative = Flags.Valid | Flags.NegativeInfinity;
34
 
                public static CMTime NegativeInfinity = new CMTime (kNegative);
35
 
                public static CMTime Zero = new CMTime (Flags.Valid, 1);
36
 
                
37
 
                public const int MaxTimeScale = 0x7fffffff;
38
 
                public long Value;
39
 
                public int TimeScale;
40
 
                public Flags TimeFlags;
41
 
                public long TimeEpoch;
42
 
 
43
 
                CMTime (Flags f)
44
 
                {
45
 
                        Value = 0;
46
 
                        TimeScale = 0;
47
 
                        TimeEpoch = 0;
48
 
                        TimeFlags = f;
49
 
                }
50
 
 
51
 
                CMTime (Flags f, int timescale)
52
 
                {
53
 
                        Value = 0;
54
 
                        TimeScale = timescale;
55
 
                        TimeEpoch = 0;
56
 
                        TimeFlags = f;
57
 
                }
58
 
                       
59
 
                public CMTime (long value, int timescale)
60
 
                {
61
 
                        Value = value;
62
 
                        TimeScale = timescale;
63
 
                        TimeFlags = Flags.Valid;
64
 
                        TimeEpoch = 0;
65
 
                }
66
 
                
67
 
                public CMTime (long value, int timescale, long epoch)
68
 
                {
69
 
                        Value = value;
70
 
                        TimeScale = timescale;
71
 
                        TimeFlags = Flags.Valid;
72
 
                        TimeEpoch = epoch;
73
 
                }
74
 
 
75
 
                public bool IsInvalid {
76
 
                        get {
77
 
                                return (TimeFlags & Flags.Valid) == 0;
78
 
                        }
79
 
                }
80
 
 
81
 
                public bool IsIndefinite {
82
 
                        get {
83
 
                                return (TimeFlags & kIndefinite) == kIndefinite;
84
 
                        }
85
 
                }
86
 
 
87
 
                public bool IsPositiveInfinity {
88
 
                        get {
89
 
                                return (TimeFlags & kPositive) == kPositive;
90
 
                        }
91
 
                }
92
 
 
93
 
                public bool IsNegativeInfinity {
94
 
                        get {
95
 
                                return (TimeFlags & kNegative) == kNegative;
96
 
                        }
97
 
                }
98
 
                
99
 
                [DllImport(Constants.CoreMediaLibrary)]
100
 
                extern static CMTime CMTimeAbsoluteValue (CMTime time);
101
 
                
102
 
                public CMTime AbsoluteValue {
103
 
                        get {
104
 
                                return CMTimeAbsoluteValue (this);
105
 
                        }
106
 
                }
107
 
                
108
 
                [DllImport(Constants.CoreMediaLibrary)]
109
 
                extern static int CMTimeCompare (CMTime time1, CMTime time2);
110
 
                public static int Compare (CMTime time1, CMTime time2)
111
 
                {
112
 
                        return CMTimeCompare (time1, time2);
113
 
                }
114
 
                
115
 
                public static bool operator == (CMTime time1, CMTime time2)
116
 
                {
117
 
                        return Compare (time1,  time2) == 0;
118
 
                }
119
 
                
120
 
                public static bool operator != (CMTime time1, CMTime time2)
121
 
                {
122
 
                        return !(time1 == time2);
123
 
                }
124
 
                
125
 
                public override bool Equals (object obj)
126
 
                {
127
 
                        if (!(obj is CMTime))
128
 
                                return false;
129
 
                        
130
 
                        CMTime other = (CMTime) obj;
131
 
                        return other == this;
132
 
                }
133
 
                
134
 
                public override int GetHashCode ()
135
 
                {
136
 
                        return Value.GetHashCode () ^ TimeScale.GetHashCode () ^ TimeFlags.GetHashCode () ^ TimeEpoch.GetHashCode ();
137
 
                }
138
 
                
139
 
                [DllImport(Constants.CoreMediaLibrary)]
140
 
                extern static CMTime CMTimeAdd (CMTime addend1, CMTime addend2);
141
 
                public static CMTime Add (CMTime time1, CMTime time2)
142
 
                {
143
 
                        return CMTimeAdd (time1, time2);
144
 
                }
145
 
                
146
 
                [DllImport(Constants.CoreMediaLibrary)]
147
 
                extern static CMTime CMTimeSubtract (CMTime minuend, CMTime subtraend);
148
 
                public static CMTime Subtract (CMTime minuend, CMTime subtraend)
149
 
                {
150
 
                        return CMTimeSubtract (minuend, subtraend);
151
 
                }
152
 
                
153
 
                [DllImport(Constants.CoreMediaLibrary)]
154
 
                extern static CMTime CMTimeMultiply (CMTime time, int multiplier);
155
 
                public static CMTime Multiply (CMTime time, int multiplier)
156
 
                {
157
 
                        return CMTimeMultiply (time, multiplier);
158
 
                }
159
 
                
160
 
                [DllImport(Constants.CoreMediaLibrary)]
161
 
                extern static CMTime CMTimeMultiplyByFloat64 (CMTime time, double multiplier);
162
 
                public static CMTime Multiply (CMTime time, double multiplier)
163
 
                {
164
 
                        return CMTimeMultiplyByFloat64 (time, multiplier);
165
 
                }
166
 
                
167
 
                public static CMTime operator + (CMTime time1, CMTime time2)
168
 
                {
169
 
                        return Add (time1, time2);
170
 
                }
171
 
                
172
 
                public static CMTime operator - (CMTime minuend, CMTime subtraend)
173
 
                {
174
 
                        return Subtract (minuend, subtraend);
175
 
                }
176
 
                
177
 
                public static CMTime operator * (CMTime time, int multiplier)
178
 
                {
179
 
                        return Multiply (time, multiplier);
180
 
                }
181
 
                
182
 
                public static CMTime operator * (CMTime time, double multiplier)
183
 
                {
184
 
                        return Multiply (time, multiplier);
185
 
                }
186
 
                
187
 
                [DllImport(Constants.CoreMediaLibrary)]
188
 
                extern static CMTime CMTimeConvertScale (CMTime time, int newScale, CMTimeRoundingMethod method);
189
 
                public CMTime ConvertScale (int newScale, CMTimeRoundingMethod method)
190
 
                {
191
 
                        return CMTimeConvertScale (this, newScale, method);
192
 
                }
193
 
                
194
 
                [DllImport(Constants.CoreMediaLibrary)]
195
 
                extern static double CMTimeGetSeconds (CMTime time);
196
 
                public double Seconds {
197
 
                        get {
198
 
                                return CMTimeGetSeconds (this);
199
 
                        }
200
 
                }
201
 
                
202
 
                [DllImport(Constants.CoreMediaLibrary)]
203
 
                extern static CMTime CMTimeMakeWithSeconds (double seconds, int preferredTimeScale);
204
 
                public static CMTime FromSeconds (double seconds, int preferredTimeScale)
205
 
                {
206
 
                        return CMTimeMakeWithSeconds (seconds, preferredTimeScale);
207
 
                }
208
 
                
209
 
                [DllImport(Constants.CoreMediaLibrary)]
210
 
                extern static CMTime CMTimeMaximum (CMTime time1, CMTime time2);
211
 
                public static CMTime GetMaximum (CMTime time1, CMTime time2)
212
 
                {
213
 
                        return CMTimeMaximum (time1, time2);
214
 
                }
215
 
                
216
 
                [DllImport(Constants.CoreMediaLibrary)]
217
 
                extern static CMTime CMTimeMinimum (CMTime time1, CMTime time2);
218
 
                public static CMTime GetMinimum (CMTime time1, CMTime time2)
219
 
                {
220
 
                        return CMTimeMinimum (time1, time2);
221
 
                }
222
 
                
223
 
                public readonly static NSString ValueKey;
224
 
                public readonly static NSString ScaleKey;
225
 
                public readonly static NSString EpochKey;
226
 
                public readonly static NSString FlagsKey;
227
 
                
228
 
                static CMTime ()
229
 
                {
230
 
                        var lib = Dlfcn.dlopen (Constants.CoreMediaLibrary, 0);
231
 
                        if (lib != IntPtr.Zero) {
232
 
                                try {
233
 
                                        ValueKey  = Dlfcn.GetStringConstant (lib, "kCMTimeValueKey");
234
 
                                        ScaleKey  = Dlfcn.GetStringConstant (lib, "kCMTimeScaleKey");
235
 
                                        EpochKey  = Dlfcn.GetStringConstant (lib, "kCMTimeEpochKey");
236
 
                                        FlagsKey  = Dlfcn.GetStringConstant (lib, "kCMTimeFlagsKey");
237
 
                                } finally {
238
 
                                        Dlfcn.dlclose (lib);
239
 
                                }
240
 
                        }
241
 
                }
242
 
                
243
 
                [DllImport(Constants.CoreMediaLibrary)]
244
 
                extern static IntPtr CMTimeCopyAsDictionary (CMTime time, IntPtr allocator);
245
 
                public IntPtr AsDictionary {
246
 
                        get {
247
 
                                return CMTimeCopyAsDictionary (this, IntPtr.Zero);
248
 
                        }
249
 
                }
250
 
                
251
 
                [DllImport(Constants.CoreMediaLibrary)]
252
 
                extern static IntPtr CMTimeCopyDescription (IntPtr allocator, CMTime time);
253
 
                public string Description {
254
 
                        get {
255
 
                                return NSString.FromHandle (CMTimeCopyDescription (IntPtr.Zero, this)).ToString ();
256
 
                        }
257
 
                }
258
 
                
259
 
                public override string ToString ()
260
 
                {
261
 
                        return Description;
262
 
                }
263
 
                
264
 
                [DllImport(Constants.CoreMediaLibrary)]
265
 
                extern static CMTime CMTimeMakeFromDictionary (IntPtr dict);
266
 
                public static CMTime FromDictionary (IntPtr dict)
267
 
                {
268
 
                        return CMTimeMakeFromDictionary (dict);
269
 
                }
270
 
                
271
 
                // Should we also bind CMTimeShow?
272
 
        }
273
16
        
274
17
        public enum CMMediaType : uint
275
18
        {
280
23
                ClosedCaption = 1668047728, // 'clcp'
281
24
                Subtitle      = 1935832172, // 'sbtl'
282
25
                TimeCode      = 1953325924, // 'tmcd'
 
26
//              [Obsolete ("Use Metadata instead")]
283
27
                TimedMetadata = 1953326452, // 'tmet'
284
 
        }
285
 
        
 
28
                Metadata      = TimedMetadata,
 
29
        }
 
30
 
 
31
        public enum CMClosedCaptionFormatType : uint
 
32
        {
 
33
                CEA608  = 0x63363038, // 'c608',
 
34
                CEA708  = 0x63373038, // 'c708',
 
35
                ATSC    = 0x61746363, // 'atcc'
 
36
        }
 
37
 
 
38
        public enum CMMuxedStreamType : uint
 
39
        {
 
40
                MPEG1System             = 0x6D703173, // 'mp1s',
 
41
                MPEG2Transport  = 0x6D703274, // 'mp2t',
 
42
                MPEG2Program    = 0x6D703270, // 'mp2p',
 
43
                DV                              = 0x64762020, // 'dv  '
 
44
        }
 
45
 
 
46
        public enum CMSubtitleFormatType : uint
 
47
        {
 
48
                Text3G  = 0x74783367, // 'tx3g'
 
49
                WebVTT  = 0x77767474, // 'wvtt'
 
50
        }
 
51
 
 
52
        public enum CMMetadataFormatType : uint
 
53
        {
 
54
                ICY   = 0x69637920, // 'icy '
 
55
                ID3   = 0x69643320, // 'id3 '
 
56
                Boxed = 0x6d656278, // 'mebx'
 
57
        }
 
58
 
 
59
        public enum CMTimeCodeFormatType : uint
 
60
        {
 
61
                TimeCode32      = 0x746D6364, // 'tmcd',
 
62
                TimeCode64      = 0x74633634, // 'tc64',
 
63
                Counter32       = 0x636E3332, // 'cn32',
 
64
                Counter64       = 0x636E3634, // 'cn64'
 
65
        }
 
66
 
286
67
        public enum CMTimeRoundingMethod 
287
68
        {
288
69
                RoundHalfAwayFromZero = 1,
295
76
        }
296
77
        
297
78
        [StructLayout(LayoutKind.Sequential)]
298
 
        struct CMSampleTimingInfo
 
79
        public struct CMSampleTimingInfo
299
80
        {
300
81
                public CMTime Duration;
301
82
                public CMTime PresentationTimeStamp;
310
91
 
311
92
        [StructLayout(LayoutKind.Sequential)]
312
93
        public struct CMTimeMapping {
313
 
                public CMTime Source;
314
 
                public CMTime Target;
 
94
                public CMTimeRange Source;
 
95
                public CMTimeRange Target;
 
96
        }
 
97
 
 
98
        [StructLayout(LayoutKind.Sequential)]
 
99
        public struct CMTimeScale
 
100
        {
 
101
                public static readonly CMTimeScale MaxValue = new CMTimeScale (0x7fffffff);
 
102
 
 
103
                public int Value;
 
104
 
 
105
                public CMTimeScale (int value)
 
106
                {
 
107
                        if (value < 0 || value > 0x7fffffff)
 
108
                                throw new ArgumentOutOfRangeException ("value");
 
109
 
 
110
                        this.Value = value;
 
111
                }
315
112
        }
316
113
 
317
114
        public enum CMVideoCodecType