Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Merge membrane-webrtc-ios into ios-client-sdk (#15)
Browse files Browse the repository at this point in the history
This PR is merging logic from
https://github.com/jellyfish-dev/membrane-webrtc-ios into this
repository. So we can keep only one SDK for iOS.

Next phase would be to generate new documentation for joined library and
update/release new version of `ios-client-sdk`


> [!NOTE]  
> Commit history from previous repo is preserved using trick from
https://gfscott.com/blog/merge-git-repos-and-keep-commit-history/

---------

Co-authored-by: Jakub Perżyło <[email protected]>
Co-authored-by: Jakub Perżyło <[email protected]>
Co-authored-by: Angelika Serwa <[email protected]>
Co-authored-by: Rohan Panchal <[email protected]>
Co-authored-by: pawelgil <[email protected]>
Co-authored-by: Michał Śledź <[email protected]>
Co-authored-by: Michał Śledź <[email protected]>
Co-authored-by: Karol Sygiet <[email protected]>
Co-authored-by: incubo4u <[email protected]>
Co-authored-by: Michał Hoffmann <[email protected]>
Co-authored-by: karkakol <[email protected]>
Co-authored-by: Karol Kąkol <[email protected]>
  • Loading branch information
13 people authored May 10, 2024
1 parent 007d4ec commit a3a1a65
Show file tree
Hide file tree
Showing 66 changed files with 5,228 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push]

jobs:
lint:
runs-on: macos-12
runs-on: macos-14
steps:
- uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
build:
runs-on: macos-12
runs-on: macos-14
steps:
- uses: actions/checkout@v3

Expand Down
31 changes: 20 additions & 11 deletions JellyfishClient.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
{
"object": {
"pins": [
{
"package": "MembraneRTC",
"repositoryURL": "https://github.com/jellyfish-dev/membrane-webrtc-ios.git",
"state": {
"branch": null,
"revision": "09e3922df714e768876a30f0a84903824a63536e",
"version": "5.0.0"
}
},
{
"package": "Mockingbird",
"repositoryURL": "https://github.com/birdrides/mockingbird.git",
Expand Down Expand Up @@ -42,8 +33,8 @@
"repositoryURL": "https://github.com/webrtc-sdk/Specs.git",
"state": {
"branch": null,
"revision": "aaef003e42a5ec34c3ff44abc6c352d18e39a278",
"version": "104.5112.15"
"revision": "4fa8d6d647fc759cdd0265fd413d2f28ea2e0e08",
"version": "114.5735.8"
}
},
{
Expand All @@ -55,6 +46,24 @@
"version": "3.1.2"
}
},
{
"package": "SwiftDocCPlugin",
"repositoryURL": "https://github.com/apple/swift-docc-plugin",
"state": {
"branch": null,
"revision": "26ac5758409154cc448d7ab82389c520fa8a8247",
"version": "1.3.0"
}
},
{
"package": "SymbolKit",
"repositoryURL": "https://github.com/apple/swift-docc-symbolkit",
"state": {
"branch": null,
"revision": "b45d1f2ed151d057b54504d653e0da5552844e34",
"version": "1.0.0"
}
},
{
"package": "swift-log",
"repositoryURL": "https://github.com/apple/swift-log.git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ extension ContentViewController: JellyfishClientListener {

func onSendMediaEvent(event: SerializedMediaEvent) {}

func onJoined(peerID: String, peersInRoom: [Peer]) {
func onJoined(peerID: String, peersInRoom: [Endpoint]) {
self.localParticipantId = peerID

let localParticipant = Participant(id: peerID, displayName: "Me", isAudioTrackActive: true)
Expand Down Expand Up @@ -163,7 +163,7 @@ extension ContentViewController: JellyfishClientListener {
errorMessage = "Failed to join a room"
}

func onTrackReady(ctx: TrackContext) {
func onTrackReady(ctx: JellyfishTrackContext) {
guard var participant = participants[ctx.peer.id] else {
return
}
Expand Down Expand Up @@ -207,15 +207,15 @@ extension ContentViewController: JellyfishClientListener {
}
}

func onTrackAdded(ctx _: TrackContext) {}
func onTrackAdded(ctx _: JellyfishTrackContext) {}

func onTrackRemoved(ctx: TrackContext) {
func onTrackRemoved(ctx: JellyfishTrackContext) {
if let video = participantVideos.first(where: { $0.id == ctx.trackId }) {
remove(video: video)
}
}

func onTrackUpdated(ctx: TrackContext) {
func onTrackUpdated(ctx: JellyfishTrackContext) {
let isActive = ctx.metadata["active"] as? Bool ?? false

if ctx.metadata["type"] as? String == "camera" {
Expand All @@ -236,22 +236,22 @@ extension ContentViewController: JellyfishClientListener {
}
}

func onPeerJoined(peer: Peer) {
func onPeerJoined(peer: Endpoint) {
self.participants[peer.id] = Participant(
id: peer.id, displayName: peer.metadata["displayName"] as? String ?? "", isAudioTrackActive: false)
let pv =
ParticipantVideo(id: peer.id, participant: participants[peer.id]!, videoTrack: nil, isActive: false)
add(video: pv)
}

func onPeerLeft(peer: Peer) {
func onPeerLeft(peer: Endpoint) {
DispatchQueue.main.async {
self.participants.removeValue(forKey: peer.id)
self.participantVideos = self.participantVideos.filter({ $0.participant.id != peer.id })
}
}

func onPeerUpdated(peer _: Peer) {}
func onPeerUpdated(peer _: Endpoint) {}

func onSocketClose(code: Int, reason: String) {
if code != 1000 || reason == "invalid token" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import MembraneRTC
import JellyfishClientSdk
import SwiftUI

struct ParticipantVideoView: View {
Expand Down
34 changes: 34 additions & 0 deletions JellyfishSDK.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Be sure to run `pod lib lint MembraneRTC.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
s.name = 'JellyfishSDK'
s.version = '0.3.0'
s.summary = 'Jellyfish SDK fully compatible with `Membrane RTC Engine` for iOS.'

s.homepage = 'https://github.com/jellyfish-dev/ios-client-sdk'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = { :type => 'Apache-2.0 license', :file => 'LICENSE' }
s.author = { 'Software Mansion' => 'https://swmansion.com' }
s.source = { :git => 'https://github.com/jellyfish-dev/ios-client-sdk.git', :tag => s.version.to_s }

s.ios.deployment_target = '13.0'
s.swift_version = '5.0'

s.source_files = 'Sources/**/*'
s.dependency 'WebRTC-SDK', '114.5735.08'
s.dependency 'SwiftProtobuf'
s.dependency 'PromisesSwift'
s.dependency 'SwiftPhoenixClient', '~> 4.0.0'
s.dependency 'SwiftLogJellyfish', '1.5.2'
s.pod_target_xcconfig = { 'ENABLE_BITCODE' => 'NO' }

s.subspec "Broadcast" do |spec|
spec.source_files = "Sources/MembraneRTC/Media/BroadcastSampleSource.swift", "Sources/MembraneRTC/IPC/**/*.{h,m,mm,swift}"
end
end
31 changes: 20 additions & 11 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
{
"object": {
"pins": [
{
"package": "MembraneRTC",
"repositoryURL": "https://github.com/jellyfish-dev/membrane-webrtc-ios.git",
"state": {
"branch": null,
"revision": "09e3922df714e768876a30f0a84903824a63536e",
"version": "5.0.0"
}
},
{
"package": "Mockingbird",
"repositoryURL": "https://github.com/birdrides/mockingbird.git",
Expand Down Expand Up @@ -42,8 +33,8 @@
"repositoryURL": "https://github.com/webrtc-sdk/Specs.git",
"state": {
"branch": null,
"revision": "aaef003e42a5ec34c3ff44abc6c352d18e39a278",
"version": "104.5112.15"
"revision": "4fa8d6d647fc759cdd0265fd413d2f28ea2e0e08",
"version": "114.5735.8"
}
},
{
Expand All @@ -55,6 +46,24 @@
"version": "3.1.2"
}
},
{
"package": "SwiftDocCPlugin",
"repositoryURL": "https://github.com/apple/swift-docc-plugin",
"state": {
"branch": null,
"revision": "26ac5758409154cc448d7ab82389c520fa8a8247",
"version": "1.3.0"
}
},
{
"package": "SymbolKit",
"repositoryURL": "https://github.com/apple/swift-docc-symbolkit",
"state": {
"branch": null,
"revision": "b45d1f2ed151d057b54504d653e0da5552844e34",
"version": "1.0.0"
}
},
{
"package": "swift-log",
"repositoryURL": "https://github.com/apple/swift-log.git",
Expand Down
23 changes: 18 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@ let package = Package(
targets: ["JellyfishClientSdk"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-protobuf.git", from: "1.6.0"),
.package(url: "https://github.com/jellyfish-dev/membrane-webrtc-ios.git", from:"5.0.0"),
.package(name: "WebRTC", url: "https://github.com/webrtc-sdk/Specs.git", .exact("114.5735.08")),
.package(
name: "SwiftProtobuf", url: "https://github.com/apple/swift-protobuf.git",
.upToNextMajor(from: "1.18.0")),
.package(url: "https://github.com/daltoniam/Starscream.git", from: "3.0.0"),
.package(name: "Mockingbird", url: "https://github.com/birdrides/mockingbird.git", .upToNextMinor(from: "0.20.0")),
.package(
name: "Mockingbird", url: "https://github.com/birdrides/mockingbird.git",
.upToNextMinor(from: "0.20.0")),
.package(
name: "Promises", url: "https://github.com/google/promises.git", .upToNextMajor(from: "2.0.0")
),
.package(
name: "SwiftPhoenixClient", url: "https://github.com/davidstump/SwiftPhoenixClient.git",
.upToNextMajor(from: "4.0.0")),
.package(url: "https://github.com/apple/swift-log.git", .upToNextMajor(from: "1.4.2")),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),

],
targets: [
Expand All @@ -27,9 +39,10 @@ let package = Package(
.target(
name: "JellyfishClientSdk",
dependencies: [
.product(name: "MembraneRTC", package: "membrane-webrtc-ios"),
.product(name: "SwiftProtobuf", package: "swift-protobuf"),
"WebRTC", "SwiftProtobuf", "Promises", "SwiftPhoenixClient",
.product(name: "Starscream", package: "Starscream"),
.product(name: "FBLPromises", package: "Promises"),
.product(name: "Logging", package: "swift-log"),
],
path: "Sources"),
.testTarget(name: "JellyfishClientSdkTests", dependencies: ["JellyfishClientSdk", "Mockingbird"]),
Expand Down
23 changes: 23 additions & 0 deletions Sources/Documentation.docc/MembraneRTC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# ``MembraneRTC``

MembraneRTC client.

The client is responsible for relaying MembraneRTC Engine specific messages through given reliable transport layer.
Once initialized, the client is responsbile for exchaning necessary messages via provided `EventTransport` and managing underlying
`RTCPeerConnection`. The goal of the client is to be as lean as possible, meaning that all activies regarding the session such as moderating
should be implemented by the user himself on top of the `MembraneRTC`.

The user's ability of interacting with the client is greatly liimited to the essential actions such as joining/leaving the session,
adding/removing local tracks and receiving information about remote peers and their tracks that can be played by the user.

User can request 3 different types of local tracks that will get forwareded to the server by the client:
- `LocalAudioTrack` - an audio track utilizing device's microphone
- `LocalVideoTrack` - a video track that can utilize device's camera or if necessay use video playback from a file (useful for testing with a simulator)
- `LocalBroadcastScreenTrack` - a screencast track taking advantage of `Broadcast Upload Extension` to record device's screen even if the app is minimized

It is recommended to request necessary audio and video tracks before joining the room but it does not mean it can't be done afterwards (in case of screencast)

Once the user received `onConnected` notification they can call the `join` method to initialize joining the session.
After receiving `onJoinSuccess` a user will receive notification about various peers joining/leaving the session, new tracks being published and ready for playback
or going inactive.

18 changes: 8 additions & 10 deletions Sources/JellyfishClientSdk/JellyfishClientInternal.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import Foundation
import Starscream

import class MembraneRTC.TrackContext

internal class JellyfishClientInternal: MembraneRTCDelegate, WebSocketDelegate {
private var config: Config?
private var webSocket: JellyfishWebsocket?
Expand Down Expand Up @@ -82,15 +80,15 @@ internal class JellyfishClientInternal: MembraneRTCDelegate, WebSocketDelegate {
webrtcClient?.receiveMediaEvent(mediaEvent: event)
}

func onEndpointAdded(endpoint: Peer) {
func onEndpointAdded(endpoint: Endpoint) {
listener.onPeerJoined(peer: endpoint)
}

func onEndpointRemoved(endpoint: Peer) {
func onEndpointRemoved(endpoint: Endpoint) {
listener.onPeerLeft(peer: endpoint)
}

func onEndpointUpdated(endpoint: Peer) {
func onEndpointUpdated(endpoint: Endpoint) {
listener.onPeerUpdated(peer: endpoint)
}

Expand All @@ -108,22 +106,22 @@ internal class JellyfishClientInternal: MembraneRTCDelegate, WebSocketDelegate {
sendEvent(peerMessage: serialzedData)
}

func onTrackAdded(ctx: MembraneRTC.TrackContext) {
func onTrackAdded(ctx: TrackContext) {
let trackContext = JellyfishTrackContext(trackContext: ctx)
listener.onTrackAdded(ctx: trackContext)
}

func onTrackReady(ctx: MembraneRTC.TrackContext) {
func onTrackReady(ctx: TrackContext) {
let trackContext = JellyfishTrackContext(trackContext: ctx)
listener.onTrackReady(ctx: trackContext)
}

func onTrackRemoved(ctx: MembraneRTC.TrackContext) {
func onTrackRemoved(ctx: TrackContext) {
let trackContext = JellyfishTrackContext(trackContext: ctx)
listener.onTrackRemoved(ctx: trackContext)
}

func onTrackUpdated(ctx: MembraneRTC.TrackContext) {
func onTrackUpdated(ctx: TrackContext) {
let trackContext = JellyfishTrackContext(trackContext: ctx)
listener.onTrackUpdated(ctx: trackContext)
}
Expand Down Expand Up @@ -156,7 +154,7 @@ internal class JellyfishClientInternal: MembraneRTCDelegate, WebSocketDelegate {
listener.onDisconnected()
}

func onConnected(endpointId: String, otherEndpoints: [Peer]) {
func onConnected(endpointId: String, otherEndpoints: [Endpoint]) {
listener.onJoined(peerID: endpointId, peersInRoom: otherEndpoints)
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/JellyfishClientSdk/JellyfishClientListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public protocol JellyfishClientListener {
/**
* Called when peer was accepted.
*/
func onJoined(peerID: String, peersInRoom: [Peer])
func onJoined(peerID: String, peersInRoom: [Endpoint])

/**
* Called when peer was not accepted
Expand All @@ -44,17 +44,17 @@ public protocol JellyfishClientListener {
/**
* Called each time new peer joins the room.
*/
func onPeerJoined(peer: Peer)
func onPeerJoined(peer: Endpoint)

/**
* Called each time peer leaves the room.
*/
func onPeerLeft(peer: Peer)
func onPeerLeft(peer: Endpoint)

/**
* Called each time peer has its metadata updated.
*/
func onPeerUpdated(peer: Peer)
func onPeerUpdated(peer: Endpoint)

/**
* Called when data in a new track arrives.
Expand Down
1 change: 0 additions & 1 deletion Sources/JellyfishClientSdk/JellyfishClientSdk.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import MembraneRTC
import Starscream
import WebRTC

Expand Down
Loading

0 comments on commit a3a1a65

Please sign in to comment.