Kev*_*vin 2 objective-c ios webrtc ios7
我终于有了一个可以与其他对等方建立连接的应用程序,并且两个对等方都从远程接收音频和视频.这是一个iOS
使用原生的应用程序RTC
API
.我现在正在尝试我可以做些什么来提高质量,所以我开始寻找媒体限制的选项.
这是我的初始化代码:
//init
peerConnectionFactory = [[RTCPeerConnectionFactory alloc] init];
[RTCPeerConnectionFactory initializeSSL];
//set 2 arrays to be used for the media constraints
NSMutableArray *m = [[NSMutableArray alloc] init];
NSMutableArray *o = [[NSMutableArray alloc] init];
//add stuff to the mandatory array
[m addObject:[[RTCPair alloc] initWithKey:@"OfferToReceiveAudio" value:@"true"]];
[m addObject:[[RTCPair alloc] initWithKey:@"OfferToReceiveVideo" value:@"true"]];
//add stuff to the optional array
//these lines are disabled for now, because my colleague working on the Android version does not support dtls yet
//[o addObject:[[RTCPair alloc] initWithKey:@"internalSctpDataChannels" value:@"true"]];
//[o addObject:[[RTCPair alloc] initWithKey:@"DtlsSrtpKeyAgreement" value:@"true"]];
//use the 2 arrays to init the media constraints
constraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:m optionalConstraints:o];
//init stun and turn servers
RTCICEServer *turn = [[RTCICEServer alloc] initWithURI:[NSURL URLWithString:@"turn:numb.viagenie.ca:3478"] username:@"*" password:@"*"];
RTCICEServer *stun = [[RTCICEServer alloc] initWithURI:[NSURL URLWithString:@"stun:stun.l.google.com:19302"] username:@"" password:@""];
NSArray *iceServers = [[NSArray alloc] initWithObjects:turn, stun, nil];
//init the peerconnection object
peerConnection = [peerConnectionFactory peerConnectionWithICEServers:nil
constraints:constraints
delegate:self];
Run Code Online (Sandbox Code Playgroud)
我试着设置以下RTCPairs:
首先我尝试了这些,只是为了看看它会做什么.
[o addObject:[[RTCPair alloc] initWithKey:@"minWidth" value:@"1280"]];
[o addObject:[[RTCPair alloc] initWithKey:@"minHeight" value:@"720"]];
Run Code Online (Sandbox Code Playgroud)
它没有做任何事.
然后我尝试了这些线(没有前面的2).
[m addObject:[[RTCPair alloc] initWithKey:@"minWidth" value:@"1280"]];
[m addObject:[[RTCPair alloc] initWithKey:@"minHeight" value:@"720"]];
Run Code Online (Sandbox Code Playgroud)
这导致应用程序卡在生成冰候选人.
认为设备可能不支持如此高的分辨率我尝试了以下.
[o addObject:[[RTCPair alloc] initWithKey:@"maxWidth" value:@"320"]];
[o addObject:[[RTCPair alloc] initWithKey:@"maxHeight" value:@"180"]];
Run Code Online (Sandbox Code Playgroud)
没有效果了.
我尝试了一些更多的组合我不记得了,但对我来说好像添加任何东西,除了OfferToReceiveAudio
和OfferToReceiveVideo
强制性阵列刚刚打破了整个过程,并添加什么可选的阵列被忽略(尽管设置dtls
的事情使得它无法连接到该Android
版本).
我正在为peerconnection初始化设置约束,但必须为videosource设置它们.创建本地媒体流时,您必须指定摄像头,使用该摄像头初始化捕获器,然后设置视频源以使用该捕获器.设置该视频源时,您可以传递约束.
归档时间: |
|
查看次数: |
1693 次 |
最近记录: |