Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / media / video / capture / mac / avfoundation_glue.h
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.
4
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.
11
12 #ifndef MEDIA_VIDEO_CAPTURE_MAC_AVFOUNDATION_GLUE_H_
13 #define MEDIA_VIDEO_CAPTURE_MAC_AVFOUNDATION_GLUE_H_
14
15 #import <Foundation/Foundation.h>
16
17 #include "base/basictypes.h"
18 #include "media/base/media_export.h"
19 #import "media/video/capture/mac/coremedia_glue.h"
20
21 class MEDIA_EXPORT AVFoundationGlue {
22  public:
23   // This method returns true if the OS version supports AVFoundation and the
24   // AVFoundation bundle could be loaded correctly, or false otherwise.
25   static bool IsAVFoundationSupported();
26
27   static NSBundle const* AVFoundationBundle();
28
29   static void* AVFoundationLibraryHandle();
30
31   // Originally coming from AVCaptureDevice.h but in global namespace.
32   static NSString* AVCaptureDeviceWasConnectedNotification();
33   static NSString* AVCaptureDeviceWasDisconnectedNotification();
34
35   // Originally coming from AVMediaFormat.h but in global namespace.
36   static NSString* AVMediaTypeVideo();
37   static NSString* AVMediaTypeAudio();
38   static NSString* AVMediaTypeMuxed();
39
40   // Originally from AVCaptureSession.h but in global namespace.
41   static NSString* AVCaptureSessionRuntimeErrorNotification();
42   static NSString* AVCaptureSessionDidStopRunningNotification();
43   static NSString* AVCaptureSessionErrorKey();
44   static NSString* AVCaptureSessionPreset320x240();
45   static NSString* AVCaptureSessionPreset640x480();
46   static NSString* AVCaptureSessionPreset1280x720();
47
48   // Originally from AVVideoSettings.h but in global namespace.
49   static NSString* AVVideoScalingModeKey();
50   static NSString* AVVideoScalingModeResizeAspect();
51
52   static Class AVCaptureSessionClass();
53   static Class AVCaptureVideoDataOutputClass();
54
55  private:
56   DISALLOW_IMPLICIT_CONSTRUCTORS(AVFoundationGlue);
57 };
58
59 // Originally AVCaptureDevice and coming from AVCaptureDevice.h
60 MEDIA_EXPORT
61 @interface CrAVCaptureDevice : NSObject
62
63 - (BOOL)hasMediaType:(NSString*)mediaType;
64 - (NSString*)uniqueID;
65 - (NSString*)localizedName;
66 - (BOOL)supportsAVCaptureSessionPreset:(NSString*)preset;
67 - (NSArray*)formats;
68
69 @end
70
71 // Originally AVCaptureDeviceFormat and coming from AVCaptureDevice.h.
72 MEDIA_EXPORT
73 @interface CrAVCaptureDeviceFormat : NSObject
74
75 - (CoreMediaGlue::CMFormatDescriptionRef)formatDescription;
76 - (NSArray*)videoSupportedFrameRateRanges;
77
78 @end
79
80 // Originally AVFrameRateRange and coming from AVCaptureDevice.h.
81 MEDIA_EXPORT
82 @interface CrAVFrameRateRange : NSObject
83
84 - (Float64)maxFrameRate;
85
86 @end
87
88 MEDIA_EXPORT
89 @interface CrAVCaptureInput  // Originally from AVCaptureInput.h.
90 @end
91
92 MEDIA_EXPORT
93 @interface CrAVCaptureOutput  // Originally from AVCaptureOutput.h.
94 @end
95
96 // Originally AVCaptureSession and coming from AVCaptureSession.h.
97 MEDIA_EXPORT
98 @interface CrAVCaptureSession : NSObject
99
100 - (void)release;
101 - (BOOL)canSetSessionPreset:(NSString*)preset;
102 - (void)setSessionPreset:(NSString*)preset;
103 - (NSString*)sessionPreset;
104 - (void)addInput:(CrAVCaptureInput*)input;
105 - (void)removeInput:(CrAVCaptureInput*)input;
106 - (void)addOutput:(CrAVCaptureOutput*)output;
107 - (void)removeOutput:(CrAVCaptureOutput*)output;
108 - (BOOL)isRunning;
109 - (void)startRunning;
110 - (void)stopRunning;
111
112 @end
113
114 // Originally AVCaptureConnection and coming from AVCaptureSession.h.
115 MEDIA_EXPORT
116 @interface CrAVCaptureConnection : NSObject
117
118 - (BOOL)isVideoMinFrameDurationSupported;
119 - (void)setVideoMinFrameDuration:(CoreMediaGlue::CMTime)minFrameRate;
120 - (BOOL)isVideoMaxFrameDurationSupported;
121 - (void)setVideoMaxFrameDuration:(CoreMediaGlue::CMTime)maxFrameRate;
122
123 @end
124
125 // Originally AVCaptureDeviceInput and coming from AVCaptureInput.h.
126 MEDIA_EXPORT
127 @interface CrAVCaptureDeviceInput : CrAVCaptureInput
128
129 @end
130
131 // Originally AVCaptureVideoDataOutputSampleBufferDelegate from
132 // AVCaptureOutput.h.
133 @protocol CrAVCaptureVideoDataOutputSampleBufferDelegate <NSObject>
134
135 @optional
136
137 - (void)captureOutput:(CrAVCaptureOutput*)captureOutput
138 didOutputSampleBuffer:(CoreMediaGlue::CMSampleBufferRef)sampleBuffer
139        fromConnection:(CrAVCaptureConnection*)connection;
140
141 @end
142
143 // Originally AVCaptureVideoDataOutput and coming from AVCaptureOutput.h.
144 MEDIA_EXPORT
145 @interface CrAVCaptureVideoDataOutput : CrAVCaptureOutput
146
147 - (oneway void)release;
148 - (void)setSampleBufferDelegate:(id)sampleBufferDelegate
149                           queue:(dispatch_queue_t)sampleBufferCallbackQueue;
150
151 - (void)setVideoSettings:(NSDictionary*)videoSettings;
152 - (NSDictionary*)videoSettings;
153 - (CrAVCaptureConnection*)connectionWithMediaType:(NSString*)mediaType;
154
155 @end
156
157 // Class to provide access to class methods of AVCaptureDevice.
158 MEDIA_EXPORT
159 @interface AVCaptureDeviceGlue : NSObject
160
161 + (NSArray*)devices;
162
163 + (CrAVCaptureDevice*)deviceWithUniqueID:(NSString*)deviceUniqueID;
164
165 @end
166
167 // Class to provide access to class methods of AVCaptureDeviceInput.
168 MEDIA_EXPORT
169 @interface AVCaptureDeviceInputGlue : NSObject
170
171 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device
172                                            error:(NSError**)outError;
173
174 @end
175
176 #endif  // MEDIA_VIDEO_CAPTURE_MAC_AVFOUNDATION_GLUE_H_