Bug 168610 - [MediaStream iOS] Respond to capture interruptions and notifications
Summary: [MediaStream iOS] Respond to capture interruptions and notifications
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Eric Carlson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-02-20 12:59 PST by Eric Carlson
Modified: 2017-02-23 18:38 PST (History)
2 users (show)

See Also:


Attachments
Proposed patch (22.44 KB, patch)
2017-02-20 15:17 PST, Eric Carlson
no flags Details | Formatted Diff | Diff
Patch for landing. (22.39 KB, patch)
2017-02-22 11:29 PST, Eric Carlson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Carlson 2017-02-20 12:59:49 PST
Respond to capture interruptions and notifications
Comment 1 Eric Carlson 2017-02-20 15:17:06 PST
Created attachment 302179 [details]
Proposed patch
Comment 2 WebKit Commit Bot 2017-02-20 15:19:33 PST
Attachment 302179 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm:423:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 1 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Jer Noble 2017-02-21 14:19:11 PST
Comment on attachment 302179 [details]
Proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=302179&action=review

r=me, with nits:

> Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm:83
> +#if PLATFORM(IOS)
> +SOFT_LINK_POINTER(AVFoundation, AVCaptureSessionRuntimeErrorNotification, NSString *)
> +SOFT_LINK_POINTER(AVFoundation, AVCaptureSessionWasInterruptedNotification, NSString *)
> +SOFT_LINK_POINTER(AVFoundation, AVCaptureSessionInterruptionEndedNotification, NSString *)
> +SOFT_LINK_POINTER(AVFoundation, AVCaptureSessionInterruptionReasonKey, NSString *)
> +SOFT_LINK_POINTER(AVFoundation, AVCaptureSessionErrorKey, NSString *)
> +#endif

Rather than defining these only on IOS, you could make these SOFT_LINK_POINTER_OPTIONAL().

> Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm:169
> +    if (![m_session isRunning])
> +        return;
> +
> +    [m_session stopRunning];

Seems like this could just be:

if ([m_session isRunning])
    [m_session stopRunning];

> Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm:180
> +    [m_objcObserver.get() addNotificationObservers];

You shouldn't need the .get() here.

> Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm:189
> +    [m_objcObserver.get() removeNotificationObservers];

Ditto.

> Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm:365
> +    [center addObserver:self selector:@selector(sessionRuntimeError:) name:AVCaptureSessionRuntimeErrorNotification object:session];
> +    [center addObserver:self selector:@selector(beginSessionInterrupted:) name:AVCaptureSessionWasInterruptedNotification object:session];
> +    [center addObserver:self selector:@selector(endSessionInterrupted:) name:AVCaptureSessionInterruptionEndedNotification object:session];

Though, if you make the notification names _OPTIONAL, you'll have to check them before adding observers here.

> Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm:419
> +    if (!m_callback)
> +        return;
> +
> +    m_callback->captureSessionRuntimeError(error);

This could be:

if (m_callback)
    m_callback->captureSessionRuntimeError(error);

> Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm:429
> +    if (!m_callback)
> +        return;
> +
> +    m_callback->captureSessionBeginInterruption(notification);

Ditto.

> Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm:440
> +    if (!m_callback)
> +        return;
> +
> +    m_callback->captureSessionEndInterruption(notification);

Ditto.
Comment 4 Radar WebKit Bug Importer 2017-02-22 11:19:36 PST
<rdar://problem/30656822>
Comment 5 Eric Carlson 2017-02-22 11:29:48 PST
Created attachment 302420 [details]
Patch for landing.
Comment 6 WebKit Commit Bot 2017-02-22 12:08:44 PST
Comment on attachment 302420 [details]
Patch for landing.

Clearing flags on attachment: 302420

Committed r212844: <http://trac.webkit.org/changeset/212844>