mediasoup android client side library https://mediasoup.org
Include mediasoup-client-android
into your project, for example, as a Gradle compile dependency:
implementation 'org.mediasoup.droid:mediasoup-client:3.0.8-beta-3'
- Initialize
MediasoupClient
MediasoupClient.initialize(getApplicationContext());
- Create
Device
and loadrouterRtpCapabilities
Device mMediasoupDevice = new Device();
// ...
// routerRtpCapabilities, the response of request `getRouterRtpCapabilities` from mediasoup-demo server
mMediasoupDevice.load(routerRtpCapabilities)
- Create
SendTransport
and produceMediaStreamTrack
// ...
// res, the response of request `createWebRtcTransport` from mediasoup-demo server
JSONObject info = new JSONObject(res);
String id = info.optString("id");
String iceParameters = info.optString("iceParameters");
String iceCandidates = info.optString("iceCandidates");
String dtlsParameters = info.optString("dtlsParameters");
String sctpParameters = info.optString("sctpParameters");
SendTransport mSendTransport =
mMediasoupDevice.createSendTransport(
sendTransportListener, id, iceParameters, iceCandidates, dtlsParameters);
// ...
// mLocalVideoTrack, created by `org.webrtc.PeerConnectionFactory`
Producer mCamProducer =
mSendTransport.produce(
producer -> {
Logger.e(TAG, "onTransportClose(), camProducer");
},
mLocalVideoTrack, null, null);
- Create
RecvTransport
and consumeMediaStreamTrack
// ...
// res, the response of request `createWebRtcTransport` from mediasoup-demo server
JSONObject info = new JSONObject(res);
String id = info.optString("id");
String iceParameters = info.optString("iceParameters");
String iceCandidates = info.optString("iceCandidates");
String dtlsParameters = info.optString("dtlsParameters");
String sctpParameters = info.optString("sctpParameters");
RecvTransport mRecvTransport =
mMediasoupDevice.createRecvTransport(
recvTransportListener, id, iceParameters, iceCandidates, dtlsParameters);
// ...
// request, the request `newConsumer` from mediasoup-demo server
JSONObject data = request.getData();
String peerId = data.optString("peerId");
String producerId = data.optString("producerId");
String id = data.optString("id");
String kind = data.optString("kind");
String rtpParameters = data.optString("rtpParameters");
String type = data.optString("type");
String appData = data.optString("appData");
Consumer consumer =
mRecvTransport.consume(
c -> {
Logger.w(TAG, "onTransportClose for consume");
},
id, producerId, kind, rtpParameters, appData);
- libmediasoupclient mediasoup client side C++ library which supported by mediasoup team
- webrtc-android-build my personal
webrtc
android prebuilt static library which may be compiled with some patch
- sync to the latest version of libmediasoupclient and adapter to
webrtc
m79 - support
DataProducer
etc - add convenient
Gradle Tasks
for sync, compile and so on - add script to use
generate-jni
to automatic generate `xxx-jni.h - add java MediaSoupClientException mapping to `MediaSoupClientErrors.hpp
- document
For bugs, feature requests, and discussion please use GitHub Issues.
Haiyang Wu(@haiyangwu at Github)