AppRTCDemo
AppRTCDemo copied to clipboard
How can I change the rotation&performance of video or audio?
@YK-Unit : I don't find the interface in the code about camera rotation,switch font or back camera.Mean while,I can't find the audio interface . Can u tell me where are the interface in the code?
Thank u very much!
I get the camera in method - (BOOL)startRTCTaskAsInitiator:(BOOL)flag withTarget:(NSString *)targetJID
in RTCWorker.m. The way to get the front camera is here:
//add local video track
if (!self.localVideoCapture) {
NSString *cameraID = nil;
//** front camera
for (AVCaptureDevice *captureDevice in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo] ) {
if (!cameraID || captureDevice.position == AVCaptureDevicePositionFront) {
cameraID = [captureDevice localizedName];
}
}
self.localVideoCapture = [RTCVideoCapturer capturerWithDeviceName:cameraID];
}
If you want to get the back camera, you can use AVCaptureDevicePositionBack
instead of AVCaptureDevicePositionFront
.
@YK-Unit :It can help to get the back camera when begin to connect. I want to switch camera when the two accounts are chatting.So I can't find this interface . also there aren't interfaces include camera rotation,switch audio & video on off .For example, (RTCVideoCapturer *)capturerWithDeviceName:(NSString *)deviceName; in the RTCVideoCapturer.h file。 there aren't rotation interface,0°、90°,270° rotate。 can u help me?
@meontheroad I'm sorry to tell you I'm busy now, maybe you need to enable the functionality by yourself. But I think you can try to reset the localVideoCapture when you change the cameraID. And about the rotate, I have no idea now, maybe you can ask for others. Good luck^-^
- (void)addVideoView { self.rtcVideoView = [[RTCVideoView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width)]; self.rtcVideoView.transform=CGAffineTransformMakeRotation(M_PI/2); self.rtcVideoView.frame=CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); [self.view addSubview:self.rtcVideoView]; }
@charleslinkn :Thank
u very much for your help,`It's work normal,although it rotate the view not camera。By the the way,Can u tell me how I can switch camera device(between front to back camera)?
as @YK-Unit said
-
(BOOL)startRTCTaskAsInitiator:(BOOL)flag withTarget:(NSString *)targetJID in RTCWorker.m. The way to get the front camera is here:
//add local video track if (!self.localVideoCapture) { NSString cameraID = nil; //* front camera for (AVCaptureDevice *captureDevice in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo] ) { if (!cameraID || captureDevice.position == AVCaptureDevicePositionFront) { cameraID = [captureDevice localizedName]; } } self.localVideoCapture = [RTCVideoCapturer capturerWithDeviceName:cameraID]; } If you want to get the back camera, you can use AVCaptureDevicePositionBack instead of AVCaptureDevicePositionFront.
@charleslinkn :+1: I kown that.But I want to switch camera when the phone is translating with other device. What I mean is that how switch camera when the peer connection is working. Can u help me?