// // ViewController.m // NewTestPhone // // Created by liang on 2021/3/31. // #import "ViewController.h" //#import "SMLinphoneConfig.h" #import "ESSipManager.h" #import "LinphoneManager.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; [self initESSip]; [self initUI]; } -(void)initESSip{ // [[SMLinphoneConfig instance] registeByUserName:@"1009" pwd:@"1234" domain:@"dnake.xswitch.cn:20401" tramsport:@"UDP"]; // [[ESSipManager instance] login:@"1009" password:@"1234" displayName:@"" domain:@"dnake.xswitch.cn" port:@"20401" withTransport:@"UDP"]; // [[SMLinphoneConfig instance] registeByUserName:@"1010" pwd:@"1234" domain:@"dnake.xswitch.cn:20401" tramsport:@"UDP"]; // [[SMLinphoneConfig instance] login:@"1010" password:@"1234" displayName:@"" domain:@"dnake.xswitch.cn" port:@"20401" withTransport:@"UDP"]; // [[SMLinphoneConfig instance] registeByUserName:@"9999" pwd:@"85521566" domain:@"47.114.117.27:5060" tramsport:@"UDP"]; // [[SMLinphoneConfig instance] registeByUserName:@"2002" pwd:@"1234" domain:@"192.168.3.8:5060" tramsport:@"UDP"]; [[ESSipManager instance] login:@"2002" password:@"1234" displayName:@"" domain:@"192.168.3.8" port:@"5060" withTransport:@"UDP"]; // [LinphoneManager.instance login:@"2002" password:@"1234" domain:@"192.168.3.8:5060"]; } -(void)initUI{ UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; [button addTarget:self action:@selector(clickBtn) forControlEvents:UIControlEventTouchUpInside]; button.frame = CGRectMake(20, 100, 60, 50); [button setTitle:@"拨号" forState:UIControlStateNormal]; [self.view addSubview:button]; UIButton *button2 = [UIButton buttonWithType:UIButtonTypeSystem]; [button2 addTarget:self action:@selector(clickBtn2) forControlEvents:UIControlEventTouchUpInside]; button2.frame = CGRectMake(90, 100, 60, 50); [button2 setTitle:@"挂断" forState:UIControlStateNormal]; [self.view addSubview:button2]; UIButton *button3 = [UIButton buttonWithType:UIButtonTypeSystem]; [button3 addTarget:self action:@selector(clickBtn3) forControlEvents:UIControlEventTouchUpInside]; button3.frame = CGRectMake(160, 100, 100, 50); [button3 setTitle:@"打开视频" forState:UIControlStateNormal]; [self.view addSubview:button3]; UIButton *button4 = [UIButton buttonWithType:UIButtonTypeSystem]; [button4 addTarget:self action:@selector(clickBtn4) forControlEvents:UIControlEventTouchUpInside]; button4.frame = CGRectMake(270, 100, 100, 50); [button4 setTitle:@"关闭摄像头" forState:UIControlStateNormal]; [self.view addSubview:button4]; UIButton *button5 = [UIButton buttonWithType:UIButtonTypeSystem]; [button5 addTarget:self action:@selector(clickBtn5) forControlEvents:UIControlEventTouchUpInside]; button5.frame = CGRectMake(20, 150, 60, 50); [button5 setTitle:@"接听" forState:UIControlStateNormal]; [self.view addSubview:button5]; UIView *playView = [[UIView alloc]initWithFrame:CGRectMake(0, 200, self.view.bounds.size.width, self.view.bounds.size.width*9/16)]; playView.backgroundColor = UIColor.blackColor; [self.view addSubview:playView]; UIView *play2View = [[UIView alloc]initWithFrame:CGRectMake(0, 220+self.view.bounds.size.width*9/16, 100, 100)]; play2View.backgroundColor = UIColor.blackColor; [self.view addSubview:play2View]; // // linphone_core_set_native_video_window_id([LinphoneManager getLc], (__bridge void *)(playView)); // linphone_core_set_native_preview_window_id([LinphoneManager getLc], (__bridge void *)(play2View)); // linphone_core_set_native_video_window_id([LinphoneManager getLc], (__bridge void *)(playView)); linphone_core_set_native_preview_window_id([LinphoneManager getLc], (__bridge void *)(play2View)); // [[SMLinphoneConfig instance] setCurrentVideoPreviewWindow:playView]; // [[SMLinphoneConfig instance] setRemoteVieoPreviewWindow:play2View]; // [[ESSipManager instance] configVideo:playView cameraView:nil]; } -(void)clickBtn{ // [[SMLinphoneConfig instance] callPhoneWithPhoneNumber:@"2003" withVideo:YES]; [[ESSipManager instance] call:@"2003" displayName:@""]; } -(void)clickBtn2{ // [[SMLinphoneConfig instance] hangUpCall]; [[ESSipManager instance] hangUpCall]; } -(void)clickBtn3{ // [[SMLinphoneConfig instance] requestOpenCamera]; [[ESSipManager instance] requestOpenCamera]; } -(void)clickBtn4{ // [[SMLinphoneConfig instance] closeCamera]; [[ESSipManager instance] closeCamera]; } -(void)clickBtn5{ // [[SMLinphoneConfig instance] acceptCall]; [[ESSipManager instance] acceptCall]; } //- (void)clickBtn{ //// [[ESSipManager instance] callPhoneWithPhoneNumber:@"1009" withVideo:YES]; // [[SMLinphoneConfig instance] callPhoneWithPhoneNumber:@"2003" withVideo:YES]; // //// [[ESSipManager instance] call:@"1111" displayName:@""]; //} // //-(void)clickBtn2{ //// [[ESSipManager instance] acceptCall]; // [[SMLinphoneConfig instance] acceptCall]; //} //-(void)clickBtn3{ //// [[ESSipManager instance] hangUpCall]; // [[SMLinphoneConfig instance] hangUpCall]; //} @end