JLChen
2021-08-02 38f4fb064df09f344fc3237409c76a9fba2a8a9e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//
//  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