• Stars
    star
    130
  • Rank 275,997 (Top 6 %)
  • Language
    Objective-C
  • License
    ISC License
  • Created almost 5 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Mediasoup 3 iOS Client

mediasoup-ios-client

Objective-C wrapper library for libmediasoupclient for building mediasoup iOS based applications.

This project supports both 64 bit iOS devices and 64 bit iOS Simulators

Cocoapods version License

Website and Documentation

Support Forum


Getting Started

Cocoapods

Add the below into your Podfile:

use_frameworks!

target "target" do
  pod "mediasoup_ios_client"
end

You will need to set enable bitcode to false

Due to the size of the WebRTC.framework with bitcode, it cannot be uploaded to Github.

Swift users will need to implement a Objective-C Bridging Header

Bridging header sample:

https://github.com/ethand91/mediasoup-ios-client-sample/blob/master/mediasoup-ios-cient-sample/mediasoup-ios-cient-sample-Bridging-Header.h

Documentation

API

https://github.com/ethand91/mediasoup-ios-client/blob/master/documentation/Api.md

INSTALLATION (Only needed for development, not needed if you only intent to use the project)

https://github.com/ethand91/mediasoup-ios-client/blob/master/documentation/Installation.md

Usage Example

#import "mediasoup_client_ios/Mediasoupclient.h

// Initialize the underlaying libmediasoupclient
[Mediasoupclient initializePC];

// Create a Device
MediasoupDevice *device = [[MediasoupDevice alloc] init];

// Communicate with our server app to retrieve router RTP capabilities
NSString *routerRtpCapabilities = [mySignalling request:@"getRouterRtpCapabilities"];

// Load the device with the routerRtpCapabilities
[device load:routerRtpCapabilities];

// Check whether we can produce video to the router
if ![device canProduce:@"video"] {
 NSLog(@"cannot produce video");
 // Abort next steps
}

// Create a transport in the server for sending our media through it
NSDictionary *transportData = [mySignalling request:@"createTransport"];

// Object to handle SendTransportListener events
@interface SendTransportHandler: NSObject<SendTransportListener>
@property (nonatomic) id delegate;
@end

@implementation SendTransportHandler
-(void)onConnect:(Transport *)transport dtlsParameters:(NSString *)dtlsParameters {
 // Here we communicate out local parameters to our remote transport
 [mySignalling request:@"transport-connect" transportId:[transport getId] dtlsParameters:dtlsParameters];
}

-(void)onConnectionStateChange:(Transport *)transport connectionState:(NSString *)connectionState {
 NSLog(@"sendTransport::onConnectionStateChange newState = %@", connectionState);
}

-(NSString *)onProduce:(Transport *)transport kind:(NSString *)kind rtpParameters:(NSString *)rtpParameters appData:(NSString *)appData callback:(void(^)(NSString *))callback {
 // Here we must communicate our local parameters to our remote transport
 NSString *id = [mySignalling request:@"produce" transportId:[transport getId] kind:kind rtpParameters:rtpParameters appData:appData];
 
 callback(id);
}
@end

SendTransport *sendTransport = [device createSendTransport:sendTransportHandler.delegate id:transportData["id"] iceParameters:transportData["iceParameters"] iceCandidates:transportData["iceCandidates"] dtlsParameters:transportData["dtlsParameters"]];

// Get the device camera
NSArray *devices = [AVCaptureDevice devicesWithMediaType: AVMediaTypeVideo];

// Start capturing it
RTCPeerConnectionFactory *factory = [[RTCPeerConnectionFactory alloc] init];
RTCCameraVideoCapturer *videoCapturer = [[RTCCameraVideoCapturer alloc] init];
[videoCapturer startCaptureWithDevice:devices[0] format:[devices[0] activeFormat] fps:30];
RTCVideoSource *videoSource = [factory videoSource];
[videoSource adaptOutputFormatToWidth:640 height:480 fps:30];

RTCVideoTrack *videoTrack = [factory videoTrackWithSource:videoSource trackId:@"trackId"];

// Handler to handle producer events
@interface ProducerHandler : NSObject<ProducerListener>
@property (nonatomic) id delegate;
@end

@implementation ProducerHandler
-(void)onTransportClose:(Producer *)producer {
 NSLog(@"Producer::onTransportClose");
}
@end

// Produce out camera video
Producer *videoProducer = [sendTransport produce:producerHandler.delegate track:videoTrack encodings:nil codecOptions:nil];

Contributing

Clone the repo and install submodules

Due to the size of the WebRTC static library it cannot be uploaded to Github, therefore you will need to follow the instructions in the build folder and build it yourself. (This step is only needed for development, not for library usage)

git clone https://github.com/ethand91/mediasoup-ios-client.git
git submodule init
git submodule update

Unfortunately my Macbook broke and I currently can't afford a new one. :( Will continue this project when I get a new mac.


Like my work? Any support is appreciated.

Buy Me A Coffee

More Repositories

1

mediasoup3-record-demo

Simple Record Demo using Mediasoup 3 and GStreamer
JavaScript
198
star
2

mediasoup-ios-client-sample

Sample iOS mediasoup client sample
Swift
38
star
3

mediasoup-sample-server

Mediasoup sample server application
JavaScript
27
star
4

webrtc-tutorial

Simple WebRTC Tutorial
JavaScript
20
star
5

mediasoup-android-sample

Simple Mediasoup@3 Android Sample App
Java
18
star
6

mediasoup3-wsdemo

Mediasoup 3 Simple WS Demo
JavaScript
15
star
7

simple-meeting

A Simple Meeting Application
JavaScript
15
star
8

react-typescript-tailwind

Simple React app with Typescript and Tailwind
HTML
8
star
9

markdown-blog

Simple Markdown blog created with Nextjs and Tailwind
JavaScript
7
star
10

htmx-crud

Sample HTMX-CRUD Application
HTML
7
star
11

simple-htmx-form

Simple example showing HTMX
HTML
6
star
12

android_libwebrtc

Android libwebrtc file
5
star
13

python-youtube

Simple python script that downloads youtube videos
Python
5
star
14

webrtc-mac-src

WebRTC Mac src directory
C++
4
star
15

android-compose-store

Simple Android Compose Datastore Example
Kotlin
4
star
16

python-gender-age-detect

Simple Python 3 + OpenCV Age and Gender detector
Python
3
star
17

gstreamer-rtmp-sample

Sample showing how to stream webcam to an rtmp server
C++
3
star
18

compose-api-tutorial

Simple Android Compose API Example
Kotlin
2
star
19

screen-streaming

Simple example showing streaming the screen with GStreamer and C++
C++
2
star
20

webrtc-android

WebRTC Android Tutorial
Java
2
star
21

rails-tinder-clone

A Simple Tinder like clone created using Rails
Ruby
1
star
22

gstreamer-samples

Simple repo showing native GStreamer samples
C++
1
star
23

python-leaf-image-generation

Sample Python code that shows how to generate images with the Leaf API
Python
1
star
24

rtmp-to-local

Streaming RTMP stream to local example
C++
1
star
25

webrtc-gstreamer

Sample showing streaming camera with C++, GStreamer
C++
1
star
26

go-crud

Sample CRUD app using Go
Go
1
star
27

android-compose-todo

Simple Todo App created using Android compose
Kotlin
1
star
28

yolonas-object-detect

Object detection on images and videos using the latest YOLO NAS
Python
1
star
29

python-opencv-filters

Project showing some simple opencv/python filters
Python
1
star
30

mediarecorder-localfile-sample

Simple repo demonstrating the use of MediaRecorder API and saving the file locally.
JavaScript
1
star
31

rust-grpc

simple example showing rust and gRPC
Rust
1
star
32

omniauth-amazon-sp

Rails Omniauth Strategy for Amazon Selling Partner API
Ruby
1
star
33

opencv-segmentation

Sample showing image segmentation using opencv
Python
1
star
34

python-text-extraction

Simple Python text extraction using Tesseract OCR
Python
1
star
35

sample-sms

Simple Social media sample created using MERN
JavaScript
1
star