Comments (9)
I'm in the same boat as you, i have tried several guides and they all seem to not build correctly.
Apparently the webrtc code runs hot on lower end devices, you should check out the google code forum about it.
from apprtc-ios.
Originally, I doubt the high fps (up to 44 or higher) can be the reason. Finally I feel disappointed when I try to lower the frame rate using the codes below. The CPU usage still goes to 120% or even higher!
- (RTCMediaConstraints )defaultMediaStreamConstraints {
NSArray *mandatoryConstraints = @[
[[RTCPair alloc] initWithKey:@"maxHeight" value:[NSString stringWithFormat:@"%d",self.maxHeight]],
[[RTCPair alloc] initWithKey:@"maxWidth" value:[NSString stringWithFormat:@"%d",self.maxWidth]],
[[RTCPair alloc] initWithKey:@"maxFrameRate" value:[NSString stringWithFormat:@"%d",self.maxFrameRate]],
[[RTCPair alloc] initWithKey:@"minFrameRate" value:[NSString stringWithFormat:@"%d",self.minFrameRate]]
];
RTCMediaConstraints theConstraints =
[[RTCMediaConstraints alloc]
initWithMandatoryConstraints:mandatoryConstraints
optionalConstraints:@[@"frameRate":@"15"]];
return theConstraints;
}
However, there is some evidence that the renderer can be the cause due to the following site:
https://perch.co/blog/perchrtc-custom-webrtc-rendering/
I would give a try if there is any progress and share with you guys.
from apprtc-ios.
i have decided to use opentok, their library works perfect for webrtc, but you have to go through them.
from apprtc-ios.
pochuang,
You mean that the webRtc lib ignores an initialization of mandatoryConstraints ?
from apprtc-ios.
Finally, I found that the AVCaptureSession could be the reason why my iphone is burning! Before this adjustment, the cpu usage is always 120% or higher, but after this it drops down to 70%! This is a very huge change although it's not a very great solution. The magic is to set sessionPreset to low like this:
-
(RTCMediaConstraints *)defaultMediaStreamConstraints {
static RTCMediaConstraints *defaultMediaStreamConstraints;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSArray *mandatoryConstraints = @[
[[RTCPair alloc] initWithKey:@"maxHeight" value:[NSString stringWithFormat:@"%d",self.maxHeight]],
[[RTCPair alloc] initWithKey:@"maxWidth" value:[NSString stringWithFormat:@"%d",self.maxWidth]],
[[RTCPair alloc] initWithKey:@"minWidth" value:[NSString stringWithFormat:@"%d",self.minWidth]],
[[RTCPair alloc] initWithKey:@"minHeight" value:[NSString stringWithFormat:@"%d",self.minWidth]],
[[RTCPair alloc] initWithKey:@"maxFrameRate" value:[NSString stringWithFormat:@"%d",self.maxFrameRate]],
[[RTCPair alloc] initWithKey:@"minFrameRate" value:[NSString stringWithFormat:@"%d",self.minFrameRate]]
];NSArray *optionalConstraints = @[]; defaultMediaStreamConstraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:mandatoryConstraints optionalConstraints:optionalConstraints];
});
return defaultMediaStreamConstraints;
}
#if !TARGET_IPHONE_SIMULATOR && TARGET_OS_IPHONE
RTCMediaConstraints *mediaConstraints = [self defaultMediaStreamConstraints];
RTCAVFoundationVideoSource *source =
[[RTCAVFoundationVideoSource alloc] initWithFactory:_factory
constraints:mediaConstraints];
if ([source.captureSession canSetSessionPreset:AVCaptureSessionPresetLow]) {
source.captureSession.sessionPreset = AVCaptureSessionPresetLow;
}
#endif
I am still working on this for a better solution. If you have any idea here, please let me know.
from apprtc-ios.
Please make a pull request for more details, what are values your self.maxHeight, self.minWidth etc..? The values is important and affect on a performance of CPU.
And does it make sense to use a "dispatch_once" ? I would like to contribute towards it, because I look into this problem.
from apprtc-ios.
The accepted values are listed below:
#define DEFAULT_MAX_HEIGHT 960
#define DEFAULT_MAX_WIDTH 720
#define DEFAULT_MIN_FRAME_RATE 5
#define DEFAULT_MAX_FRAME_RATE 12
#define ENABLE_BOOST_PERFORMANCE YES
The minWidth and minHeight do not work, so I modified it like this:
- (RTCMediaConstraints *)defaultMediaStreamConstraints {
NSArray *mandatoryConstraints = @[
[[RTCPair alloc] initWithKey:@"maxHeight" value:[NSString stringWithFormat:@"%d",self.maxHeight]],
[[RTCPair alloc] initWithKey:@"maxWidth" value:[NSString stringWithFormat:@"%d",self.maxWidth]],
[[RTCPair alloc] initWithKey:@"maxFrameRate" value:[NSString stringWithFormat:@"%d",self.maxFrameRate]],
[[RTCPair alloc] initWithKey:@"minFrameRate" value:[NSString stringWithFormat:@"%d",self.minFrameRate]]
];
NSArray *optionalConstraints = @[];
RTCMediaConstraints* theConstraints =
[[RTCMediaConstraints alloc]
initWithMandatoryConstraints:mandatoryConstraints
optionalConstraints:optionalConstraints];
return theConstraints;
}
And the sessionPreset part like this:
#if !TARGET_IPHONE_SIMULATOR && TARGET_OS_IPHONE
RTCMediaConstraints *mediaConstraints = [self defaultMediaStreamConstraints];
RTCAVFoundationVideoSource *source =
[[RTCAVFoundationVideoSource alloc] initWithFactory:_factory
constraints:mediaConstraints];
if(ENABLE_BOOST_PERFORMANCE){
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
if ([source.captureSession canSetSessionPreset:AVCaptureSessionPresetLow]) {
[source.captureSession stopRunning];
source.captureSession.sessionPreset = AVCaptureSessionPresetLow;
[source.captureSession startRunning];
}
});
}
videoTrack =
[[RTCVideoTrack alloc] initWithFactory:_factory
source:source
trackId:@"ARDAMSv0"];
#endif
WebRTC will change sessionPreset due to your device's resolution at first. That will make your video more clear but become heavy to CPU. You may take a look at the source code downloaded from google.
The video resolution and frame rate you received from others will also affect CPU in iPhone. For me, I reduce it to 640x480.
Now the CPU usage is down to 58% or a little higher than 60%. Not pretty satisfying compared to Android's (the CPU usage is 30% only!) but is workable for now.
By the way, It will take a long time to change sessionPresent when your captureSession is already running. For my situation, I need to stop it temporarily and start it latter after making changes.
from apprtc-ios.
hi all.
how can you fixup the video card problem?
from apprtc-ios.
is this problem fixed in the newest version? Or do we still need to make changes manually?
from apprtc-ios.
Related Issues (20)
- IOS Native App for WebRTC
- Error posting data: The network connection was lost.
- Xcode 10 issue with -lstdc++.6 HOT 3
- Call freezed then ended automatically
- [__NSSingleEntryDictionaryI length]: unrecognized selector sent to instance 0x281de6360 ??
- Voice is not exchanging between peers with CallKit
- Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) When add stream to peerconnection
- Unknown selected data source for Port Speaker (type: Speaker)
- Failed to set remote video description send parameters HOT 1
- project successfully build but doesn't run HOT 3
- iceRestart option in createOffer
- I want to remove Echo and Noise, but didn't success
- failed to create session description webrtc in ios
- Local video doesn't be rendered. It doesn't be sent to remote machine on IOS 13 HOT 23
- How to capture a local vidoe stream apply filter and and share with peer
- How to use this project on the Swift? HOT 4
- local and remote video not call delegate function HOT 1
- how can i run this code HOT 4
- Can I use this to chat with ordinary pictures and texts at the same time
- one-to-one videos
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apprtc-ios.