xref: /aosp_15_r20/external/webrtc/examples/objc/AppRTCMobile/mac/APPRTCAppDelegate.m (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker/*
2*d9f75844SAndroid Build Coastguard Worker *  Copyright 2014 The WebRTC Project Authors. All rights reserved.
3*d9f75844SAndroid Build Coastguard Worker *
4*d9f75844SAndroid Build Coastguard Worker *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker */
10*d9f75844SAndroid Build Coastguard Worker
11*d9f75844SAndroid Build Coastguard Worker#import "APPRTCAppDelegate.h"
12*d9f75844SAndroid Build Coastguard Worker#import "APPRTCViewController.h"
13*d9f75844SAndroid Build Coastguard Worker#import "sdk/objc/api/peerconnection/RTCSSLAdapter.h"
14*d9f75844SAndroid Build Coastguard Worker
15*d9f75844SAndroid Build Coastguard Worker@interface APPRTCAppDelegate () <NSWindowDelegate>
16*d9f75844SAndroid Build Coastguard Worker@end
17*d9f75844SAndroid Build Coastguard Worker
18*d9f75844SAndroid Build Coastguard Worker@implementation APPRTCAppDelegate {
19*d9f75844SAndroid Build Coastguard Worker  APPRTCViewController* _viewController;
20*d9f75844SAndroid Build Coastguard Worker  NSWindow* _window;
21*d9f75844SAndroid Build Coastguard Worker}
22*d9f75844SAndroid Build Coastguard Worker
23*d9f75844SAndroid Build Coastguard Worker#pragma mark - NSApplicationDelegate
24*d9f75844SAndroid Build Coastguard Worker
25*d9f75844SAndroid Build Coastguard Worker- (void)applicationDidFinishLaunching:(NSNotification*)notification {
26*d9f75844SAndroid Build Coastguard Worker  RTCInitializeSSL();
27*d9f75844SAndroid Build Coastguard Worker  NSScreen* screen = [NSScreen mainScreen];
28*d9f75844SAndroid Build Coastguard Worker  NSRect visibleRect = [screen visibleFrame];
29*d9f75844SAndroid Build Coastguard Worker  NSRect windowRect = NSMakeRect(NSMidX(visibleRect),
30*d9f75844SAndroid Build Coastguard Worker                                 NSMidY(visibleRect),
31*d9f75844SAndroid Build Coastguard Worker                                 1320,
32*d9f75844SAndroid Build Coastguard Worker                                 1140);
33*d9f75844SAndroid Build Coastguard Worker  NSUInteger styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable;
34*d9f75844SAndroid Build Coastguard Worker  _window = [[NSWindow alloc] initWithContentRect:windowRect
35*d9f75844SAndroid Build Coastguard Worker                                        styleMask:styleMask
36*d9f75844SAndroid Build Coastguard Worker                                          backing:NSBackingStoreBuffered
37*d9f75844SAndroid Build Coastguard Worker                                            defer:NO];
38*d9f75844SAndroid Build Coastguard Worker  _window.delegate = self;
39*d9f75844SAndroid Build Coastguard Worker  [_window makeKeyAndOrderFront:self];
40*d9f75844SAndroid Build Coastguard Worker  [_window makeMainWindow];
41*d9f75844SAndroid Build Coastguard Worker  _viewController = [[APPRTCViewController alloc] initWithNibName:nil
42*d9f75844SAndroid Build Coastguard Worker                                                           bundle:nil];
43*d9f75844SAndroid Build Coastguard Worker  [_window setContentView:[_viewController view]];
44*d9f75844SAndroid Build Coastguard Worker}
45*d9f75844SAndroid Build Coastguard Worker
46*d9f75844SAndroid Build Coastguard Worker#pragma mark - NSWindow
47*d9f75844SAndroid Build Coastguard Worker
48*d9f75844SAndroid Build Coastguard Worker- (void)windowWillClose:(NSNotification*)notification {
49*d9f75844SAndroid Build Coastguard Worker  [_viewController windowWillClose:notification];
50*d9f75844SAndroid Build Coastguard Worker  RTCCleanupSSL();
51*d9f75844SAndroid Build Coastguard Worker  [NSApp terminate:self];
52*d9f75844SAndroid Build Coastguard Worker}
53*d9f75844SAndroid Build Coastguard Worker
54*d9f75844SAndroid Build Coastguard Worker@end
55*d9f75844SAndroid Build Coastguard Worker
56