]> git.sesse.net Git - ffmpeg/blobdiff - libavdevice/avfoundation.m
avcodec/adpcm_ima_apm: remove old extradata format
[ffmpeg] / libavdevice / avfoundation.m
index 43b2edb44d9e869feec1bf9ffeb2abbfdb3b8ac1..bad3760159a234bcbb779183c854c7ddc59ae292 100644 (file)
@@ -99,6 +99,7 @@ typedef struct
     int             capture_raw_data;
     int             drop_late_frames;
     int             video_is_muxed;
+    int             video_is_screen;
 
     int             list_devices;
     int             video_device_index;
@@ -131,7 +132,9 @@ typedef struct
     CMSampleBufferRef         current_audio_frame;
 
     AVCaptureDevice          *observed_device;
+#if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
     AVCaptureDeviceTransportControlsPlaybackMode observed_mode;
+#endif
     int                      observed_quit;
 } AVFContext;
 
@@ -168,6 +171,7 @@ static void unlock_frames(AVFContext* ctx)
         _context = context;
 
         // start observing if a device is set for it
+#if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
         if (_context->observed_device) {
             NSString *keyPath = NSStringFromSelector(@selector(transportControlsPlaybackMode));
             NSKeyValueObservingOptions options = NSKeyValueObservingOptionNew;
@@ -177,14 +181,19 @@ static void unlock_frames(AVFContext* ctx)
                                            options: options
                                            context: _context];
         }
+#endif
     }
     return self;
 }
 
 - (void)dealloc {
     // stop observing if a device is set for it
-    NSString *keyPath = NSStringFromSelector(@selector(transportControlsPlaybackMode));
-    [_context->observed_device removeObserver: self forKeyPath: keyPath];
+#if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
+    if (_context->observed_device) {
+        NSString *keyPath = NSStringFromSelector(@selector(transportControlsPlaybackMode));
+        [_context->observed_device removeObserver: self forKeyPath: keyPath];
+    }
+#endif
     [super dealloc];
 }
 
@@ -193,6 +202,7 @@ static void unlock_frames(AVFContext* ctx)
                         change:(NSDictionary *)change
                        context:(void *)context {
     if (context == _context) {
+#if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
         AVCaptureDeviceTransportControlsPlaybackMode mode =
             [change[NSKeyValueChangeNewKey] integerValue];
 
@@ -202,6 +212,7 @@ static void unlock_frames(AVFContext* ctx)
             }
             _context->observed_mode = mode;
         }
+#endif
     } else {
         [super observeValueForKeyPath: keyPath
                              ofObject: object
@@ -537,14 +548,18 @@ static int add_video_device(AVFormatContext *s, AVCaptureDevice *video_device)
     }
     [ctx->video_output setAlwaysDiscardsLateVideoFrames:ctx->drop_late_frames];
 
+#if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
     // check for transport control support and set observer device if supported
-    int trans_ctrl = [video_device transportControlsSupported];
-    AVCaptureDeviceTransportControlsPlaybackMode trans_mode = [video_device transportControlsPlaybackMode];
+    if (!ctx->video_is_screen) {
+        int trans_ctrl = [video_device transportControlsSupported];
+        AVCaptureDeviceTransportControlsPlaybackMode trans_mode = [video_device transportControlsPlaybackMode];
 
-    if (trans_ctrl) {
-        ctx->observed_mode   = trans_mode;
-        ctx->observed_device = video_device;
+        if (trans_ctrl) {
+            ctx->observed_mode   = trans_mode;
+            ctx->observed_device = video_device;
+        }
     }
+#endif
 
     ctx->avf_delegate = [[AVFFrameReceiver alloc] initWithContext:ctx];
 
@@ -742,7 +757,6 @@ static int get_audio_config(AVFormatContext *s)
 static int avf_read_header(AVFormatContext *s)
 {
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    int capture_screen      = 0;
     uint32_t num_screens    = 0;
     AVFContext *ctx         = (AVFContext*)s->priv_data;
     AVCaptureDevice *video_device = nil;
@@ -839,7 +853,7 @@ static int avf_read_header(AVFormatContext *s)
             }
 
             video_device = (AVCaptureDevice*) capture_screen_input;
-            capture_screen = 1;
+            ctx->video_is_screen = 1;
 #endif
          } else {
             av_log(ctx, AV_LOG_ERROR, "Invalid device index\n");
@@ -876,7 +890,7 @@ static int avf_read_header(AVFormatContext *s)
                 AVCaptureScreenInput* capture_screen_input = [[[AVCaptureScreenInput alloc] initWithDisplayID:screens[idx]] autorelease];
                 video_device = (AVCaptureDevice*) capture_screen_input;
                 ctx->video_device_index = ctx->num_video_devices + idx;
-                capture_screen = 1;
+                ctx->video_is_screen = 1;
 
                 if (ctx->framerate.num > 0) {
                     capture_screen_input.minFrameDuration = CMTimeMake(ctx->framerate.den, ctx->framerate.num);
@@ -967,7 +981,7 @@ static int avf_read_header(AVFormatContext *s)
 
     /* Unlock device configuration only after the session is started so it
      * does not reset the capture formats */
-    if (!capture_screen) {
+    if (!ctx->video_is_screen) {
         [video_device unlockForConfiguration];
     }
 
@@ -1200,7 +1214,7 @@ static const AVClass avf_class = {
     .category   = AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT,
 };
 
-AVInputFormat ff_avfoundation_demuxer = {
+const AVInputFormat ff_avfoundation_demuxer = {
     .name           = "avfoundation",
     .long_name      = NULL_IF_CONFIG_SMALL("AVFoundation input device"),
     .priv_data_size = sizeof(AVFContext),