1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // AVFoundation API is only introduced in Mac OS X > 10.6, and there is only one
6 // build of Chromium, so the (potential) linking with AVFoundation has to happen
7 // in runtime. For this to be clean, an AVFoundationGlue class is defined to try
8 // and load these AVFoundation system libraries. If it succeeds, subsequent
9 // clients can use AVFoundation via the rest of the classes declared in this
12 #ifndef MEDIA_BASE_MAC_AVFOUNDATION_GLUE_H_
13 #define MEDIA_BASE_MAC_AVFOUNDATION_GLUE_H_
16 #import <Foundation/Foundation.h>
17 #endif // defined(__OBJC__)
19 #include "base/basictypes.h"
20 #include "media/base/mac/coremedia_glue.h"
21 #include "media/base/media_export.h"
23 class MEDIA_EXPORT AVFoundationGlue
{
25 // Must be called on the UI thread prior to attempting to use any other
26 // AVFoundation methods.
27 static void InitializeAVFoundation();
29 // This method returns true if the OS version supports AVFoundation and the
30 // AVFoundation bundle could be loaded correctly, or false otherwise.
31 static bool IsAVFoundationSupported();
34 static NSBundle
const* AVFoundationBundle();
36 // Originally coming from AVCaptureDevice.h but in global namespace.
37 static NSString
* AVCaptureDeviceWasConnectedNotification();
38 static NSString
* AVCaptureDeviceWasDisconnectedNotification();
40 // Originally coming from AVMediaFormat.h but in global namespace.
41 static NSString
* AVMediaTypeVideo();
42 static NSString
* AVMediaTypeAudio();
43 static NSString
* AVMediaTypeMuxed();
45 // Originally from AVCaptureSession.h but in global namespace.
46 static NSString
* AVCaptureSessionRuntimeErrorNotification();
47 static NSString
* AVCaptureSessionDidStopRunningNotification();
48 static NSString
* AVCaptureSessionErrorKey();
50 // Originally from AVVideoSettings.h but in global namespace.
51 static NSString
* AVVideoScalingModeKey();
52 static NSString
* AVVideoScalingModeResizeAspectFill();
54 static Class
AVCaptureSessionClass();
55 static Class
AVCaptureVideoDataOutputClass();
56 #endif // defined(__OBJC__)
59 DISALLOW_IMPLICIT_CONSTRUCTORS(AVFoundationGlue
);
64 // Originally AVCaptureDevice and coming from AVCaptureDevice.h
66 @interface CrAVCaptureDevice
: NSObject
68 - (BOOL
)hasMediaType
:(NSString
*)mediaType
;
69 - (NSString
*)uniqueID
;
70 - (NSString
*)localizedName
;
73 - (int32_t)transportType
;
77 // Originally AVCaptureDeviceFormat and coming from AVCaptureDevice.h.
79 @interface CrAVCaptureDeviceFormat
: NSObject
81 - (CoreMediaGlue::CMFormatDescriptionRef
)formatDescription
;
82 - (NSArray
*)videoSupportedFrameRateRanges
;
86 // Originally AVFrameRateRange and coming from AVCaptureDevice.h.
88 @interface CrAVFrameRateRange
: NSObject
90 - (Float64
)maxFrameRate
;
95 @interface CrAVCaptureInput
// Originally from AVCaptureInput.h.
99 @interface CrAVCaptureOutput
// Originally from AVCaptureOutput.h.
102 // Originally AVCaptureSession and coming from AVCaptureSession.h.
104 @interface CrAVCaptureSession
: NSObject
107 - (void)addInput
:(CrAVCaptureInput
*)input
;
108 - (void)removeInput
:(CrAVCaptureInput
*)input
;
109 - (void)addOutput
:(CrAVCaptureOutput
*)output
;
110 - (void)removeOutput
:(CrAVCaptureOutput
*)output
;
112 - (void)startRunning
;
117 // Originally AVCaptureConnection and coming from AVCaptureSession.h.
119 @interface CrAVCaptureConnection
: NSObject
121 - (BOOL
)isVideoMinFrameDurationSupported
;
122 - (void)setVideoMinFrameDuration
:(CoreMediaGlue::CMTime
)minFrameRate
;
123 - (BOOL
)isVideoMaxFrameDurationSupported
;
124 - (void)setVideoMaxFrameDuration
:(CoreMediaGlue::CMTime
)maxFrameRate
;
128 // Originally AVCaptureDeviceInput and coming from AVCaptureInput.h.
130 @interface CrAVCaptureDeviceInput
: CrAVCaptureInput
134 // Originally AVCaptureVideoDataOutputSampleBufferDelegate from
135 // AVCaptureOutput.h.
136 @protocol CrAVCaptureVideoDataOutputSampleBufferDelegate
<NSObject
>
140 - (void)captureOutput
:(CrAVCaptureOutput
*)captureOutput
141 didOutputSampleBuffer
:(CoreMediaGlue::CMSampleBufferRef
)sampleBuffer
142 fromConnection
:(CrAVCaptureConnection
*)connection
;
146 // Originally AVCaptureVideoDataOutput and coming from AVCaptureOutput.h.
148 @interface CrAVCaptureVideoDataOutput
: CrAVCaptureOutput
150 - (oneway
void)release
;
151 - (void)setSampleBufferDelegate
:(id
)sampleBufferDelegate
152 queue
:(dispatch_queue_t
)sampleBufferCallbackQueue
;
154 - (void)setAlwaysDiscardsLateVideoFrames
:(BOOL
)flag
;
155 - (void)setVideoSettings
:(NSDictionary
*)videoSettings
;
156 - (NSDictionary
*)videoSettings
;
157 - (CrAVCaptureConnection
*)connectionWithMediaType
:(NSString
*)mediaType
;
161 // Class to provide access to class methods of AVCaptureDevice.
163 @interface AVCaptureDeviceGlue
: NSObject
167 + (CrAVCaptureDevice
*)deviceWithUniqueID
:(NSString
*)deviceUniqueID
;
171 // Class to provide access to class methods of AVCaptureDeviceInput.
173 @interface AVCaptureDeviceInputGlue
: NSObject
175 + (CrAVCaptureDeviceInput
*)deviceInputWithDevice
:(CrAVCaptureDevice
*)device
176 error
:(NSError
**)outError
;
180 #endif // defined(__OBJC__)
182 #endif // MEDIA_BASE_MAC_AVFOUNDATION_GLUE_H_