[BackgroundSync] Clean up some tests
[chromium-blink-merge.git] / media / base / mac / avfoundation_glue.h
blobdf54ae0aed96229efafd6a808de9d4f3d6ca3b45
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
10 // file.
12 #ifndef MEDIA_BASE_MAC_AVFOUNDATION_GLUE_H_
13 #define MEDIA_BASE_MAC_AVFOUNDATION_GLUE_H_
15 #if defined(__OBJC__)
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 {
24 public:
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();
33 #if defined(__OBJC__)
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__)
58 private:
59 DISALLOW_IMPLICIT_CONSTRUCTORS(AVFoundationGlue);
62 #if defined(__OBJC__)
64 // Originally AVCaptureDevice and coming from AVCaptureDevice.h
65 MEDIA_EXPORT
66 @interface CrAVCaptureDevice : NSObject
68 - (BOOL)hasMediaType:(NSString*)mediaType;
69 - (NSString*)uniqueID;
70 - (NSString*)localizedName;
71 - (BOOL)isSuspended;
72 - (NSArray*)formats;
73 - (int32_t)transportType;
75 @end
77 // Originally AVCaptureDeviceFormat and coming from AVCaptureDevice.h.
78 MEDIA_EXPORT
79 @interface CrAVCaptureDeviceFormat : NSObject
81 - (CoreMediaGlue::CMFormatDescriptionRef)formatDescription;
82 - (NSArray*)videoSupportedFrameRateRanges;
84 @end
86 // Originally AVFrameRateRange and coming from AVCaptureDevice.h.
87 MEDIA_EXPORT
88 @interface CrAVFrameRateRange : NSObject
90 - (Float64)maxFrameRate;
92 @end
94 MEDIA_EXPORT
95 @interface CrAVCaptureInput // Originally from AVCaptureInput.h.
96 @end
98 MEDIA_EXPORT
99 @interface CrAVCaptureOutput // Originally from AVCaptureOutput.h.
100 @end
102 // Originally AVCaptureSession and coming from AVCaptureSession.h.
103 MEDIA_EXPORT
104 @interface CrAVCaptureSession : NSObject
106 - (void)release;
107 - (void)addInput:(CrAVCaptureInput*)input;
108 - (void)removeInput:(CrAVCaptureInput*)input;
109 - (void)addOutput:(CrAVCaptureOutput*)output;
110 - (void)removeOutput:(CrAVCaptureOutput*)output;
111 - (BOOL)isRunning;
112 - (void)startRunning;
113 - (void)stopRunning;
115 @end
117 // Originally AVCaptureConnection and coming from AVCaptureSession.h.
118 MEDIA_EXPORT
119 @interface CrAVCaptureConnection : NSObject
121 - (BOOL)isVideoMinFrameDurationSupported;
122 - (void)setVideoMinFrameDuration:(CoreMediaGlue::CMTime)minFrameRate;
123 - (BOOL)isVideoMaxFrameDurationSupported;
124 - (void)setVideoMaxFrameDuration:(CoreMediaGlue::CMTime)maxFrameRate;
126 @end
128 // Originally AVCaptureDeviceInput and coming from AVCaptureInput.h.
129 MEDIA_EXPORT
130 @interface CrAVCaptureDeviceInput : CrAVCaptureInput
132 @end
134 // Originally AVCaptureVideoDataOutputSampleBufferDelegate from
135 // AVCaptureOutput.h.
136 @protocol CrAVCaptureVideoDataOutputSampleBufferDelegate <NSObject>
138 @optional
140 - (void)captureOutput:(CrAVCaptureOutput*)captureOutput
141 didOutputSampleBuffer:(CoreMediaGlue::CMSampleBufferRef)sampleBuffer
142 fromConnection:(CrAVCaptureConnection*)connection;
144 @end
146 // Originally AVCaptureVideoDataOutput and coming from AVCaptureOutput.h.
147 MEDIA_EXPORT
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;
159 @end
161 // Class to provide access to class methods of AVCaptureDevice.
162 MEDIA_EXPORT
163 @interface AVCaptureDeviceGlue : NSObject
165 + (NSArray*)devices;
167 + (CrAVCaptureDevice*)deviceWithUniqueID:(NSString*)deviceUniqueID;
169 @end
171 // Class to provide access to class methods of AVCaptureDeviceInput.
172 MEDIA_EXPORT
173 @interface AVCaptureDeviceInputGlue : NSObject
175 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device
176 error:(NSError**)outError;
178 @end
180 #endif // defined(__OBJC__)
182 #endif // MEDIA_BASE_MAC_AVFOUNDATION_GLUE_H_