我想保持一些事物彼此分开(在这种情况下,轮询数据库的15秒间隔任务,以及从我们的SIP服务器接收推送通知的第三方库).我想将它们分开以保持代码更具可读性,但我也认为保持单独的任务更加清晰,你知道,分开...
这就是说,为此使用多个服务是不好的做法?使用多个线程的服务可能更好吗?甚至可以使用多种服务吗?
我还没有真正尝试过任何东西,我不急于重写代码,如果它可能是一件坏事.
我正在开发一个iPad应用程序,它可以加载一些图像并进行视频通话.通过http检索图像,视频流超过rtp.有没有办法衡量我的应用程序正在执行的所有下载和上传?我不是在寻找调试工具,我想记录客户使用的带宽.
我在界面构建器中创建了一个UICollectionView.我引用了它
@property (strong, nonatomic) IBOutlet UICollectionView *contactList;
Run Code Online (Sandbox Code Playgroud)
在我的.h文件和@synthesize contactList中; 在我的.m文件中.
我尝试使用以下代码在纵向和横向中实现略微不同的布局:
- (void) adjustViewsForOrientation:(UIInterfaceOrientation) orientation {
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
UICollectionViewFlowLayout *flow = (UICollectionViewFlowLayout*)contactList.collectionViewLayout;
flow.sectionInset = UIEdgeInsetsMake(48, 80, 48, 0);
flow.minimumLineSpacing = 80;
} else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
UICollectionViewFlowLayout *flow = (UICollectionViewFlowLayout*)contactList.collectionViewLayout;
flow.sectionInset = UIEdgeInsetsMake(48, 64, 48, 0);
flow.minimumLineSpacing = 64;
}
}
Run Code Online (Sandbox Code Playgroud)
这完美地工作,但我也想改变大小(在横向上我每页有2*3网格,而在肖像中它是3*2网格).我尝试设置这样的大小:
CGRect frame = [contactList frame];
frame.size.width = 960;
[contactList setFrame:frame];
Run Code Online (Sandbox Code Playgroud)
但它不会更新.没有错误,但视图没有更新.它只是保持与以前相同的大小.我需要做些什么来更新视图?
我正在尝试webRTC在iPad(iOS7)上运行应用程序.我正处于我的设备显示本地视频和一个尝试显示远程视频(添加流)的位置,但远程视频屏幕保持黑色.
在试图弄清楚为什么我的远程视频屏幕是黑色时,我发现了这个callback:
- (void)peerConnectionOnRenegotiationNeeded:(RTCPeerConnection *)peerConnection_ {
NSLog(@"peerConnectionOnRenegotiationNeeded:(RTCPeerConnection *)%@",peerConnection_);
}
Run Code Online (Sandbox Code Playgroud)
在appRTC示例中,它实现如下:
- (void)peerConnectionOnRenegotiationNeeded:(RTCPeerConnection*)peerConnection {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"PCO onRenegotiationNeeded - ignoring because AppRTC has a "
"predefined negotiation strategy");
});
}
Run Code Online (Sandbox Code Playgroud)
调用此方法时应该怎么做?我问这个因为我认为我的一切都和示例差不多,只是信号不同,但它仍然不起作用.我想我应该在这个回调激发时做点什么,因为我没有像示例那样的"预定义协商策略".
我的环境:
我有一个应用程序需要互联网连接我使用的某个库(XIMSS for Communigate).它从服务器接收状态更新,我无法更改lib的源.有没有办法检测设备是否与互联网断开连接?我想避免每隔x秒ping一次服务器,看看是否还有连接.
我有一个使用webrtc的voip应用程序.我最近重新设计了许多代码,使信令更加一致.我现在唯一的大问题是,当我关闭对等连接时,应用程序崩溃了一些内部opengl代码.我使用此代码关闭连接:
[peerConnection removeStream:lms];
[peerConnection close];
peerConnection = nil;
Run Code Online (Sandbox Code Playgroud)
我之前使用的代码几乎删除了与webrtc相关的任何内容,但我发现很多对象都可以重用,只需要在应用程序启动时进行.我该怎么做才能确保应用程序不会崩溃我结束通话的所有内容?
编辑:
我将上面的代码移动到后台线程,它不再崩溃.但现在,经过几次通话后,我的日志会被以下行发送垃圾邮件(大约每秒3或4次):
Failed to make complete framebuffer object 8cdd
Run Code Online (Sandbox Code Playgroud)
发生这种情况时,这是日志历史记录的最后一部分:
2014-10-14 11:53:45.045 BeeldZorgApp[4912:3903] peerConnection iceConnectionChanged:(RTCICEConnectionState)2
2014-10-14 11:53:45.046 BeeldZorgApp[4912:3903] peerConnection iceConnectionChanged:(RTCICEConnectionState)3
2014-10-14 11:53:50.732 BeeldZorgApp[4912:3903] peerConnectionOnRenegotiationNeeded:(RTCPeerConnection *)<RTCPeerConnection: 0x157c9640>
2014-10-14 11:53:50.742 BeeldZorgApp[4912:3903] peerConnection iceConnectionChanged:(RTCICEConnectionState)6
2014-10-14 11:53:50.743 BeeldZorgApp[4912:3903] peerConnection signalingStateChanged:(RTCSignalingState)5
2014-10-14 11:53:59.955 BeeldZorgApp[4912:3903] peerConnectionOnRenegotiationNeeded:(RTCPeerConnection *)<RTCPeerConnection: 0x19a62e30>
2014-10-14 11:53:59.980 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.028 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.091 BeeldZorgApp[4912:60b] Failed to …Run Code Online (Sandbox Code Playgroud) 我终于有了一个可以与其他对等方建立连接的应用程序,并且两个对等方都从远程接收音频和视频.这是一个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 …Run Code Online (Sandbox Code Playgroud) 我有一个iOS应用程序,它使用一些具有大量元素的viewcontrollers.我在界面构建器中(在故事板中)构建了viewcontrollers.对于一些关键元素(loginbutton,重要文本等),我创建了一个IBOutlet,以便能够在我的代码中使用这些元素(主要调整文本/图形).
对于我需要快速修复的其他一些(例如我以编程方式显示和隐藏的活动指示器),我选择不创建IBOutlet,而是给它们一个标签号并通过该viewWithTag:(NSInteger)方法访问它们.
这似乎对我有用(这只是我的第二个iOS项目,所以这可能是完全错误的).但是现在视图控制器变得越来越复杂,我发现很难记住我已经用于标签的数字.除了通过所有元素并检查他们的标签之外,有没有办法跟踪这个?
也许以这种方式使用标签是完全错误的,在这种情况下也很好.我可以查看它们一次,只为我现在使用标签的所有情况创建IBOutlets.
我写了这个小函数来初始化一段shader时间试图搞定GLSL.
void createShader(string code, GLuint type) {
GLint success;
GLuint errorLogSize = 1024;
vector<GLchar> errorLog(errorLogSize);
cout << "trying to add shader, shader version is " << glGetString(GL_SHADING_LANGUAGE_VERSION) << " and opengl version is " << glGetString(GL_VERSION) << endl;
GLuint program = glCreateProgram();
GLuint obj = glCreateShader(type);
if (obj == 0) {
cout << "failed to create shader" << endl;
return;
} else {
cout << "created shader" << endl;
}
const GLchar* p = code.c_str();
GLint …Run Code Online (Sandbox Code Playgroud) 在 iOS 上我可以这样做:
// set a new camera id
cameraId = ([cameraId isEqualToString:frontCameraId]) ? backCameraId : frontCameraId;
// determine if the stream has a video track
BOOL hasActiveVideoTrack = ([self.localMediaStream.videoTracks count] > 0);
// remove video track from the stream
if (hasActiveVideoTrack) {
[self.localMediaStream removeVideoTrack:self.localVideoTrack];
}
// remove renderer from the video track
[self.localVideoTrack removeRenderer:self.localVideoView];
// re init the capturer, video source and video track
localVideoCapturer = nil;
localVideoSource = nil;
localVideoCapturer = [RTCVideoCapturer capturerWithDeviceName:cameraId];
localVideoSource = [peerConnectionFactory videoSourceWithCapturer:localVideoCapturer constraints:mediaConstraints]; …Run Code Online (Sandbox Code Playgroud) 在这段代码我很困惑为什么它打印出"0 1 2 3"而不是"3 2 1 0"
int y = 3;
String s = " ";
while (y>-1)
{
s = y + " " + s;
y--;
}
System.out.print(s);
Run Code Online (Sandbox Code Playgroud)
谢谢.
ios ×7
objective-c ×6
webrtc ×4
android ×1
c++ ×1
glsl ×1
ios7 ×1
ipad ×1
java ×1
javascript ×1
networking ×1
opengl ×1
service ×1
uistoryboard ×1