AgoraIO / Advanced-Video

MIT License
261 stars 336 forks source link

iOS 12+ screen recording during audio/video call started from main app. #217

Closed vladpre92 closed 4 years ago

vladpre92 commented 4 years ago

Hi guys, I'm trying to implement share screen feature during audio / video call (one to one) and I can't figure how to handle the things. The thing is that I make the channel setup in the main app, using CallKit remove user joins the call. In this example, the channel setup is made in the Broadcast Upload Extension with the AgoraUploader class.

I'm trying to achieve the following thing:

One possible solution is to inject the channel name from main app to extension (if possible), and join channel as a third person. When 3rd person joins channel will be treated as screen share feed and will replace user feed.

I don't have other solution.

Can somebody please throw me a hint? How do you guys handle this problem?

Thank you!

I realize this is not a bug but a support request. I can't find a proper solution and I thought that here somebody can give me a hint. Thank you!

plutoless commented 4 years ago

you are right. in this case you need to let extension join the same channel as a third person.

apiphoomchu commented 4 years ago

@plutoless and how to make it only 2 person? because if we use audio call and screen sharing at the same time it will consume many memory (RAM) and CPU

apiphoomchu commented 4 years ago

@plutoless If we use extension join the same channel as a third person it can produce audio lag on broadcaster iPad or iPhone

apiphoomchu commented 4 years ago

And I make some experiment that use iPad 5 (CPU A9 & 2GB of RAM) If I share my screen by let extension join the same channel and use agora video call (disable video) as a mic It will consume many memory (RAM) and CPU. Then it can make screen sharing crash (Invalid broadcast)

vladpre92 commented 4 years ago

@plutoless Thank you for your prompt response. I will try this solution if there is no other way. @Apiphoom what if you leave the channel from main app as soon as you join from broadcast extension with share screen and rejoin when screen sharing stopped. I think it involves using a server to monitor session status realtime, but it can be done. If you use Firebase in your project it's an easy task with realtime data.

apiphoomchu commented 4 years ago

@vladpre92 I already try that solution but I have a little problem if I use that solution I can't hear audio (mic audio) from audience. If you have another solution please let me know (:

apiphoomchu commented 4 years ago

@plutoless Did you have any solution????? I have no idea for know ):

vladpre92 commented 4 years ago

@Apiphoom I've implemented the solution joining the channel from extension like a "third person". From the main app, inside

rtcEngine(_ engine: AgoraRtcEngineKit, firstRemoteVideoDecodedOfUid uid: UInt, size: CGSize, elapsed: Int)

, I release the old camera feed canvas and replace it with a new one with the screen recording feed that I get from the extension. I don't see any CPU / RAM increase in the Debug Navigator. I tested on iPhone 7 with A10 chip, iOS 13. I have a 6 Plus device with A8 chip but I have iOS 11 installed for testing and my implementation is for iOS 12+.

Maybe you have a leak somewhere else or you don't release camera feed canvas.

Hope it helps!

apiphoomchu commented 4 years ago

@vladpre92 Thank!

plutoless commented 4 years ago

thanks guys. closed if no disagreement. feel free to reopen if issue persists.