Skip to content

Commit 5c16915

Browse files
committed
Merge branch 'release/1.10.13/master'
2 parents 5ff7135 + 5925d42 commit 5c16915

File tree

64 files changed

+1673
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1673
-241
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// Copyright 2023 Vector Creations Ltd
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
// Configuration settings file format documentation can be found at:
18+
// https://help.apple.com/xcode/#/dev745c5c974
19+
20+
#include "Config/AppIdentifiers.xcconfig"
21+
#include "Config/AppVersion.xcconfig"
22+
23+
PRODUCT_NAME = BroadcastUploadExtension
24+
PRODUCT_BUNDLE_IDENTIFIER = $(BROADCAST_UPLOAD_EXTENSION_BUNDLE_IDENTIFIER)
25+
26+
INFOPLIST_FILE = BroadcastUploadExtension/SupportingFiles/Info.plist
27+
28+
CODE_SIGN_ENTITLEMENTS = BroadcastUploadExtension/SupportingFiles/BroadcastUploadExtension.entitlements
29+
30+
SKIP_INSTALL = YES
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// Copyright 2020 Vector Creations Ltd
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
// Configuration settings file format documentation can be found at:
18+
// https://help.apple.com/xcode/#/dev745c5c974
19+
20+
#include "Common.xcconfig"
21+
#include "Pods/Target Support Files/Pods-RiotPods-BroadcastUploadExtension/Pods-RiotPods-BroadcastUploadExtension.debug.xcconfig"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// Copyright 2020 Vector Creations Ltd
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
// Configuration settings file format documentation can be found at:
18+
// https://help.apple.com/xcode/#/dev745c5c974
19+
20+
#include "Common.xcconfig"
21+
#include "Pods/Target Support Files/Pods-RiotPods-BroadcastUploadExtension/Pods-RiotPods-BroadcastUploadExtension.release.xcconfig"
22+
23+
PROVISIONING_PROFILE = $(BROADCAST_UPLOAD_EXTENSION_PROVISIONING_PROFILE)
24+
PROVISIONING_PROFILE_SPECIFIER = $(BROADCAST_UPLOAD_EXTENSION_PROVISIONING_PROFILE_SPECIFIER)
25+
26+
COPY_PHASE_STRIP = NO
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// License from the original repository:
3+
// https://github.com/jitsi/jitsi-meet-sdk-samples/blob/master/LICENSE
4+
5+
//
6+
// Atomic.swift
7+
// Broadcast Extension
8+
//
9+
// Created by Maksym Shcheglov.
10+
// https://www.onswiftwings.com/posts/atomic-property-wrapper/
11+
//
12+
13+
import Foundation
14+
15+
@propertyWrapper
16+
struct Atomic<Value> {
17+
18+
private var value: Value
19+
private let lock = NSLock()
20+
21+
init(wrappedValue value: Value) {
22+
self.value = value
23+
}
24+
25+
var wrappedValue: Value {
26+
get { load() }
27+
set { store(newValue: newValue) }
28+
}
29+
30+
func load() -> Value {
31+
lock.lock()
32+
defer { lock.unlock() }
33+
return value
34+
}
35+
36+
mutating func store(newValue: Value) {
37+
lock.lock()
38+
defer { lock.unlock() }
39+
value = newValue
40+
}
41+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// License from the original repository:
3+
// https://github.com/jitsi/jitsi-meet-sdk-samples/blob/master/LICENSE
4+
5+
//
6+
// DarwinNotificationCenter.swift
7+
// Broadcast Extension
8+
//
9+
// Created by Alex-Dan Bumbu on 23/03/2021.
10+
// Copyright © 2021 8x8, Inc. All rights reserved.
11+
//
12+
13+
import Foundation
14+
15+
enum DarwinNotification: String {
16+
case broadcastStarted = "iOS_BroadcastStarted"
17+
case broadcastStopped = "iOS_BroadcastStopped"
18+
}
19+
20+
class DarwinNotificationCenter {
21+
22+
static let shared = DarwinNotificationCenter()
23+
24+
private let notificationCenter: CFNotificationCenter
25+
26+
init() {
27+
notificationCenter = CFNotificationCenterGetDarwinNotifyCenter()
28+
}
29+
30+
func postNotification(_ name: DarwinNotification) {
31+
CFNotificationCenterPostNotification(notificationCenter, CFNotificationName(rawValue: name.rawValue as CFString), nil, nil, true)
32+
}
33+
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
//
2+
// License from the original repository:
3+
// https://github.com/jitsi/jitsi-meet-sdk-samples/blob/master/LICENSE
4+
//
5+
// SampleHandler.swift
6+
// Broadcast Extension
7+
//
8+
// Created by Alex-Dan Bumbu on 04.06.2021.
9+
//
10+
11+
import ReplayKit
12+
13+
import MatrixSDK
14+
15+
private enum Constants {
16+
// the App Group ID value that the app and the broadcast extension targets are setup with. It differs for each app.
17+
static let appGroupIdentifier = BuildSettings.applicationGroupIdentifier
18+
}
19+
20+
class SampleHandler: RPBroadcastSampleHandler {
21+
22+
private var clientConnection: SocketConnection?
23+
private var uploader: SampleUploader?
24+
25+
private var frameCount: Int = 0
26+
27+
private var socketFilePath: String {
28+
let sharedContainer = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: Constants.appGroupIdentifier)
29+
return sharedContainer?.appendingPathComponent("rtc_SSFD").path ?? ""
30+
}
31+
32+
override init() {
33+
super.init()
34+
setupLogger()
35+
36+
if let connection = SocketConnection(filePath: socketFilePath) {
37+
clientConnection = connection
38+
setupConnection()
39+
40+
uploader = SampleUploader(connection: connection)
41+
}
42+
}
43+
44+
override func broadcastStarted(withSetupInfo setupInfo: [String: NSObject]?) {
45+
// User has requested to start the broadcast. Setup info from the UI extension can be supplied but optional.
46+
frameCount = 0
47+
48+
DarwinNotificationCenter.shared.postNotification(.broadcastStarted)
49+
openConnection()
50+
}
51+
52+
override func broadcastPaused() {
53+
// User has requested to pause the broadcast. Samples will stop being delivered.
54+
}
55+
56+
override func broadcastResumed() {
57+
// User has requested to resume the broadcast. Samples delivery will resume.
58+
}
59+
60+
override func broadcastFinished() {
61+
// User has requested to finish the broadcast.
62+
DarwinNotificationCenter.shared.postNotification(.broadcastStopped)
63+
clientConnection?.close()
64+
}
65+
66+
override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) {
67+
switch sampleBufferType {
68+
case RPSampleBufferType.video:
69+
// very simple mechanism for adjusting frame rate by using every third frame
70+
frameCount += 1
71+
if frameCount % 3 == 0 {
72+
uploader?.send(sample: sampleBuffer)
73+
}
74+
default:
75+
break
76+
}
77+
}
78+
}
79+
80+
private extension SampleHandler {
81+
82+
func setupConnection() {
83+
clientConnection?.didClose = { [weak self] error in
84+
MXLog.error("client connection did close", context: error)
85+
86+
if let error = error {
87+
self?.finishBroadcastWithError(error)
88+
} else {
89+
// the displayed failure message is more user friendly when using NSError instead of Error
90+
let JMScreenSharingStopped = 10001
91+
let customError = NSError(domain: RPRecordingErrorDomain, code: JMScreenSharingStopped, userInfo: [NSLocalizedDescriptionKey: "Screen sharing stopped"])
92+
self?.finishBroadcastWithError(customError)
93+
}
94+
}
95+
}
96+
97+
func openConnection() {
98+
let queue = DispatchQueue(label: "broadcast.connectTimer")
99+
let timer = DispatchSource.makeTimerSource(queue: queue)
100+
timer.schedule(deadline: .now(), repeating: .milliseconds(100), leeway: .milliseconds(500))
101+
timer.setEventHandler { [weak self] in
102+
guard self?.clientConnection?.open() == true else {
103+
return
104+
}
105+
106+
timer.cancel()
107+
}
108+
109+
timer.resume()
110+
}
111+
112+
func setupLogger() {
113+
let configuration = MXLogConfiguration()
114+
configuration.logLevel = .verbose
115+
configuration.maxLogFilesCount = 100
116+
configuration.logFilesSizeLimit = 10 * 1024 * 1024; // 10MB
117+
configuration.subLogName = "broadcastUploadExtension"
118+
119+
if isatty(STDERR_FILENO) == 0 {
120+
configuration.redirectLogsToFiles = true
121+
}
122+
123+
MXLog.configure(configuration)
124+
}
125+
}

0 commit comments

Comments
 (0)