Home | History | Annotate | Download | only in mac
      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 
     45   // Originally from AVVideoSettings.h but in global namespace.
     46   static NSString* AVVideoScalingModeKey();
     47   static NSString* AVVideoScalingModeResizeAspectFill();
     48 
     49   static Class AVCaptureSessionClass();
     50   static Class AVCaptureVideoDataOutputClass();
     51 
     52  private:
     53   DISALLOW_IMPLICIT_CONSTRUCTORS(AVFoundationGlue);
     54 };
     55 
     56 // Originally AVCaptureDevice and coming from AVCaptureDevice.h
     57 MEDIA_EXPORT
     58 @interface CrAVCaptureDevice : NSObject
     59 
     60 - (BOOL)hasMediaType:(NSString*)mediaType;
     61 - (NSString*)uniqueID;
     62 - (NSString*)localizedName;
     63 - (BOOL)isSuspended;
     64 - (NSArray*)formats;
     65 
     66 @end
     67 
     68 // Originally AVCaptureDeviceFormat and coming from AVCaptureDevice.h.
     69 MEDIA_EXPORT
     70 @interface CrAVCaptureDeviceFormat : NSObject
     71 
     72 - (CoreMediaGlue::CMFormatDescriptionRef)formatDescription;
     73 - (NSArray*)videoSupportedFrameRateRanges;
     74 
     75 @end
     76 
     77 // Originally AVFrameRateRange and coming from AVCaptureDevice.h.
     78 MEDIA_EXPORT
     79 @interface CrAVFrameRateRange : NSObject
     80 
     81 - (Float64)maxFrameRate;
     82 
     83 @end
     84 
     85 MEDIA_EXPORT
     86 @interface CrAVCaptureInput  // Originally from AVCaptureInput.h.
     87 @end
     88 
     89 MEDIA_EXPORT
     90 @interface CrAVCaptureOutput  // Originally from AVCaptureOutput.h.
     91 @end
     92 
     93 // Originally AVCaptureSession and coming from AVCaptureSession.h.
     94 MEDIA_EXPORT
     95 @interface CrAVCaptureSession : NSObject
     96 
     97 - (void)release;
     98 - (void)addInput:(CrAVCaptureInput*)input;
     99 - (void)removeInput:(CrAVCaptureInput*)input;
    100 - (void)addOutput:(CrAVCaptureOutput*)output;
    101 - (void)removeOutput:(CrAVCaptureOutput*)output;
    102 - (BOOL)isRunning;
    103 - (void)startRunning;
    104 - (void)stopRunning;
    105 
    106 @end
    107 
    108 // Originally AVCaptureConnection and coming from AVCaptureSession.h.
    109 MEDIA_EXPORT
    110 @interface CrAVCaptureConnection : NSObject
    111 
    112 - (BOOL)isVideoMinFrameDurationSupported;
    113 - (void)setVideoMinFrameDuration:(CoreMediaGlue::CMTime)minFrameRate;
    114 - (BOOL)isVideoMaxFrameDurationSupported;
    115 - (void)setVideoMaxFrameDuration:(CoreMediaGlue::CMTime)maxFrameRate;
    116 
    117 @end
    118 
    119 // Originally AVCaptureDeviceInput and coming from AVCaptureInput.h.
    120 MEDIA_EXPORT
    121 @interface CrAVCaptureDeviceInput : CrAVCaptureInput
    122 
    123 @end
    124 
    125 // Originally AVCaptureVideoDataOutputSampleBufferDelegate from
    126 // AVCaptureOutput.h.
    127 @protocol CrAVCaptureVideoDataOutputSampleBufferDelegate <NSObject>
    128 
    129 @optional
    130 
    131 - (void)captureOutput:(CrAVCaptureOutput*)captureOutput
    132 didOutputSampleBuffer:(CoreMediaGlue::CMSampleBufferRef)sampleBuffer
    133        fromConnection:(CrAVCaptureConnection*)connection;
    134 
    135 @end
    136 
    137 // Originally AVCaptureVideoDataOutput and coming from AVCaptureOutput.h.
    138 MEDIA_EXPORT
    139 @interface CrAVCaptureVideoDataOutput : CrAVCaptureOutput
    140 
    141 - (oneway void)release;
    142 - (void)setSampleBufferDelegate:(id)sampleBufferDelegate
    143                           queue:(dispatch_queue_t)sampleBufferCallbackQueue;
    144 
    145 - (void)setVideoSettings:(NSDictionary*)videoSettings;
    146 - (NSDictionary*)videoSettings;
    147 - (CrAVCaptureConnection*)connectionWithMediaType:(NSString*)mediaType;
    148 
    149 @end
    150 
    151 // Class to provide access to class methods of AVCaptureDevice.
    152 MEDIA_EXPORT
    153 @interface AVCaptureDeviceGlue : NSObject
    154 
    155 + (NSArray*)devices;
    156 
    157 + (CrAVCaptureDevice*)deviceWithUniqueID:(NSString*)deviceUniqueID;
    158 
    159 @end
    160 
    161 // Class to provide access to class methods of AVCaptureDeviceInput.
    162 MEDIA_EXPORT
    163 @interface AVCaptureDeviceInputGlue : NSObject
    164 
    165 + (CrAVCaptureDeviceInput*)deviceInputWithDevice:(CrAVCaptureDevice*)device
    166                                            error:(NSError**)outError;
    167 
    168 @end
    169 
    170 #endif  // MEDIA_VIDEO_CAPTURE_MAC_AVFOUNDATION_GLUE_H_
    171