mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
WIP
This commit is contained in:
parent
c2724de5c3
commit
5e9179bab3
@ -17,11 +17,16 @@ public final class GroupCallController: ViewController {
|
||||
private var callContext: GroupCallContext?
|
||||
private var callDisposable: Disposable?
|
||||
private var memberCountDisposable: Disposable?
|
||||
private var isMutedDisposable: Disposable?
|
||||
private let audioSessionActive = Promise<Bool>(false)
|
||||
|
||||
private var memberCount: Int = 0
|
||||
private let memberCountNode: ImmediateTextNode
|
||||
|
||||
private var isMuted: Bool = false
|
||||
private let isMutedNode: ImmediateTextNode
|
||||
private let muteButton: HighlightableButtonNode
|
||||
|
||||
private var validLayout: ContainerViewLayout?
|
||||
|
||||
init(context: AccountContext) {
|
||||
@ -29,6 +34,9 @@ public final class GroupCallController: ViewController {
|
||||
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
self.memberCountNode = ImmediateTextNode()
|
||||
self.isMutedNode = ImmediateTextNode()
|
||||
|
||||
self.muteButton = HighlightableButtonNode()
|
||||
|
||||
super.init()
|
||||
|
||||
@ -36,6 +44,9 @@ public final class GroupCallController: ViewController {
|
||||
|
||||
self.addSubnode(self.memberCountNode)
|
||||
|
||||
self.muteButton.addSubnode(self.isMutedNode)
|
||||
self.addSubnode(self.muteButton)
|
||||
|
||||
let audioSessionActive = self.audioSessionActive
|
||||
self.callDisposable = self.context.sharedContext.mediaManager.audioSession.push(audioSessionType: .voiceCall, manualActivate: { audioSessionControl in
|
||||
audioSessionControl.activate({ _ in })
|
||||
@ -51,7 +62,7 @@ public final class GroupCallController: ViewController {
|
||||
let callContext = GroupCallContext(audioSessionActive: self.audioSessionActive.get())
|
||||
self.callContext = callContext
|
||||
|
||||
memberCountDisposable = (callContext.memberCount
|
||||
self.memberCountDisposable = (callContext.memberCount
|
||||
|> deliverOnMainQueue).start(next: { [weak self] value in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
@ -61,6 +72,19 @@ public final class GroupCallController: ViewController {
|
||||
strongSelf.containerLayoutUpdated(layout, transition: .immediate)
|
||||
}
|
||||
})
|
||||
|
||||
self.isMutedDisposable = (callContext.isMuted
|
||||
|> deliverOnMainQueue).start(next: { [weak self] value in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.isMuted = value
|
||||
if let layout = strongSelf.validLayout {
|
||||
strongSelf.containerLayoutUpdated(layout, transition: .immediate)
|
||||
}
|
||||
})
|
||||
|
||||
self.muteButton.addTarget(self, action: #selector(self.muteButtonPressed), forControlEvents: .touchUpInside)
|
||||
}
|
||||
|
||||
deinit {
|
||||
@ -68,12 +92,26 @@ public final class GroupCallController: ViewController {
|
||||
self.memberCountDisposable?.dispose()
|
||||
}
|
||||
|
||||
@objc private func muteButtonPressed() {
|
||||
self.callContext?.toggleIsMuted()
|
||||
}
|
||||
|
||||
func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||
self.validLayout = layout
|
||||
|
||||
self.memberCountNode.attributedText = NSAttributedString(string: "Members: \(self.memberCount)", font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
||||
|
||||
self.isMutedNode.attributedText = NSAttributedString(string: self.isMuted ? "Unmute" : "Mute", font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemAccentColor)
|
||||
|
||||
let textSize = self.memberCountNode.updateLayout(CGSize(width: layout.size.width - 16.0 * 2.0, height: 100.0))
|
||||
transition.updateFrameAdditiveToCenter(node: self.memberCountNode, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - textSize.width) / 2.0), y: floor((layout.size.width - textSize.width) / 2.0)), size: textSize))
|
||||
let isMutedSize = self.isMutedNode.updateLayout(CGSize(width: layout.size.width - 16.0 * 2.0, height: 100.0))
|
||||
|
||||
let textFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - textSize.width) / 2.0), y: floor((layout.size.height - textSize.width) / 2.0)), size: textSize)
|
||||
transition.updateFrameAdditiveToCenter(node: self.memberCountNode, frame: textFrame)
|
||||
|
||||
let isMutedFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - isMutedSize.width) / 2.0), y: textFrame.maxY + 12.0), size: isMutedSize)
|
||||
transition.updateFrame(node: self.muteButton, frame: isMutedFrame)
|
||||
self.isMutedNode.frame = CGRect(origin: CGPoint(), size: isMutedFrame.size)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3158,24 +3158,6 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
private var groupCall: GroupCallContext?
|
||||
|
||||
private func requestCall(isVideo: Bool) {
|
||||
#if DEBUG
|
||||
|
||||
let audioSessionActive = Promise<Bool>(false)
|
||||
self.groupCallDisposable.set(self.context.sharedContext.mediaManager.audioSession.push(audioSessionType: .voiceCall, manualActivate: { [weak self] audioSessionControl in
|
||||
audioSessionControl.activate({ _ in })
|
||||
audioSessionActive.set(.single(true))
|
||||
}, deactivate: {
|
||||
return Signal { subscriber in
|
||||
subscriber.putCompletion()
|
||||
return EmptyDisposable
|
||||
}
|
||||
}, availableOutputsChanged: { _, _ in
|
||||
}))
|
||||
|
||||
self.groupCall = GroupCallContext(audioSessionActive: audioSessionActive.get())
|
||||
return;
|
||||
#endif
|
||||
|
||||
guard let peer = self.data?.peer as? TelegramUser, let cachedUserData = self.data?.cachedData as? CachedUserData else {
|
||||
return
|
||||
}
|
||||
|
@ -691,7 +691,7 @@ private extension ConferenceDescription {
|
||||
appendSdp("a=ice-lite")
|
||||
|
||||
for ssrc in bundleSsrcs {
|
||||
appendSdp("m=audio \(ssrc.isMain ? "1" : "0") RTP/SAVPF 111 103 104 126")
|
||||
appendSdp("m=audio \(ssrc.isMain ? "1" : "0") RTP/SAVPF 111 126")
|
||||
if ssrc.isMain {
|
||||
appendSdp("c=IN IP4 0.0.0.0")
|
||||
}
|
||||
@ -722,7 +722,9 @@ private extension ConferenceDescription {
|
||||
candidateString.append("\(candidate.priority) ")
|
||||
|
||||
var ip = candidate.ip
|
||||
ip = bridgeHost
|
||||
if ip.hasPrefix("192.") {
|
||||
ip = bridgeHost
|
||||
}
|
||||
candidateString.append("\(ip) ")
|
||||
candidateString.append("\(candidate.port) ")
|
||||
|
||||
@ -752,10 +754,10 @@ private extension ConferenceDescription {
|
||||
}
|
||||
|
||||
appendSdp("a=rtpmap:111 opus/48000/2")
|
||||
appendSdp("a=rtpmap:103 ISAC/16000")
|
||||
appendSdp("a=rtpmap:104 ISAC/32000")
|
||||
//appendSdp("a=rtpmap:103 ISAC/16000")
|
||||
//appendSdp("a=rtpmap:104 ISAC/32000")
|
||||
appendSdp("a=rtpmap:126 telephone-event/8000")
|
||||
appendSdp("a=fmtp:111 minptime=10; useinbandfec=1")
|
||||
appendSdp("a=fmtp:111 minptime=10; useinbandfec=1; usedtx=1")
|
||||
appendSdp("a=rtcp:1 IN IP4 0.0.0.0")
|
||||
appendSdp("a=rtcp-mux")
|
||||
appendSdp("a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level")
|
||||
@ -930,7 +932,7 @@ private extension ConferenceDescription {
|
||||
] as [String: Any]] as [Any]
|
||||
]
|
||||
),
|
||||
ConferenceDescription.Content.Channel.PayloadType(
|
||||
/*ConferenceDescription.Content.Channel.PayloadType(
|
||||
id: 103,
|
||||
name: "ISAC",
|
||||
clockrate: 16000,
|
||||
@ -941,7 +943,7 @@ private extension ConferenceDescription {
|
||||
name: "ISAC",
|
||||
clockrate: 32000,
|
||||
channels: 1
|
||||
),
|
||||
),*/
|
||||
ConferenceDescription.Content.Channel.PayloadType(
|
||||
id: 126,
|
||||
name: "telephone-event",
|
||||
@ -996,8 +998,30 @@ private extension ConferenceDescription {
|
||||
}
|
||||
}
|
||||
|
||||
var candidates: [ConferenceDescription.Transport.Candidate] = []
|
||||
/*for line in getLines(prefix: "a=candidate:") {
|
||||
let scanner = Scanner(string: line)
|
||||
if #available(iOS 13.0, *) {
|
||||
candidates.append(ConferenceDescription.Transport.Candidate(
|
||||
id: "",
|
||||
generation: 0,
|
||||
component: "",
|
||||
protocol: "",
|
||||
tcpType: nil,
|
||||
ip: "",
|
||||
port: 0,
|
||||
foundation: "",
|
||||
priority: 0,
|
||||
type: "",
|
||||
network: 0,
|
||||
relAddr: nil,
|
||||
relPort: nil
|
||||
))
|
||||
}
|
||||
}*/
|
||||
|
||||
let transport = ConferenceDescription.Transport(
|
||||
candidates: [],
|
||||
candidates: candidates,
|
||||
fingerprints: fingerprints,
|
||||
ufrag: ufrag,
|
||||
pwd: pwd
|
||||
@ -1110,11 +1134,14 @@ public final class GroupCallContext {
|
||||
|
||||
let memberCount = ValuePromise<Int>(0, ignoreRepeated: true)
|
||||
|
||||
private var isMutedValue: Bool = false
|
||||
let isMuted = ValuePromise<Bool>(false, ignoreRepeated: true)
|
||||
|
||||
init(queue: Queue, audioSessionActive: Signal<Bool, NoError>) {
|
||||
self.queue = queue
|
||||
|
||||
self.sessionId = UInt32.random(in: 0 ..< UInt32(Int32.max))
|
||||
self.colibriHost = "192.168.8.118"
|
||||
self.colibriHost = "51.11.141.27"
|
||||
//self.colibriHost = "192.168.93.24"
|
||||
//self.colibriHost = "51.104.206.109"
|
||||
|
||||
@ -1392,6 +1419,12 @@ public final class GroupCallContext {
|
||||
strongSelf.pollOnceDelayed()
|
||||
}))
|
||||
}
|
||||
|
||||
func toggleIsMuted() {
|
||||
self.isMutedValue = !self.isMutedValue
|
||||
self.isMuted.set(self.isMutedValue)
|
||||
self.context.setIsMuted(self.isMutedValue)
|
||||
}
|
||||
}
|
||||
|
||||
private let queue = Queue()
|
||||
@ -1415,4 +1448,22 @@ public final class GroupCallContext {
|
||||
return disposable
|
||||
}
|
||||
}
|
||||
|
||||
public var isMuted: Signal<Bool, NoError> {
|
||||
return Signal { subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
self.impl.with { impl in
|
||||
disposable.set(impl.isMuted.get().start(next: { value in
|
||||
subscriber.putNext(value)
|
||||
}))
|
||||
}
|
||||
return disposable
|
||||
}
|
||||
}
|
||||
|
||||
public func toggleIsMuted() {
|
||||
self.impl.with { impl in
|
||||
impl.toggleIsMuted()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
- (void)emitOffer;
|
||||
- (void)setOfferSdp:(NSString * _Nonnull)offerSdp isPartial:(bool)isPartial;
|
||||
- (void)setIsMuted:(bool)isMuted;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -48,4 +48,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setIsMuted:(bool)isMuted {
|
||||
if (_instance) {
|
||||
_instance->setIsMuted(isMuted);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 8d0707f074999f77263ec32b3955e8f7f856cea4
|
||||
Subproject commit 4f7501d281b851e6302b2a2d7298c733eee82414
|
2
third-party/webrtc/webrtc-ios
vendored
2
third-party/webrtc/webrtc-ios
vendored
@ -1 +1 @@
|
||||
Subproject commit 11255bcfff3180210a012f368e2d2bcd169b6877
|
||||
Subproject commit 782743c7931d09c1d2e4a0cf6cd349ee45452f1d
|
Loading…
x
Reference in New Issue
Block a user