Android native client support

@jmillan, I can do that, but wouldn’t it be better to create a new top category for the android port?

The Android port uses libmediasoupclient C++ library, that we support. We have limited time and we do not directly support 3rd party iOS or Android libs yet (we have not authored them).

Pls create an issue in Github directly and we can discuss it there.

Thanks for the reply. I got it working, but only with VP8. Did you ever try your implementation with H264 on the Android Emulator?

Regarding the H264 issue I think I told you where the problem is, right?

On Android, webrtc only support h264 using MediaCodec and do not implement software codec. Use a android mobile phone for test or change the source code adding the h264 software codec support.

We were talking in the other thread about it, but that doesn’t seem to be the problem. The h264 codec is correctly matched by mediasoup.

Interesting. I would then expect device.getRtpCapabilities() not to contain the H264 codec. But it still does.

Anyway, probably that’s my problem. So I guess I need to get the webrtc source, compile it with H264 support and plug it in the android emulator.

Thank you for this!

Check the libmediasoupclient installation section in the website. It tells you how to build libwebrtc with h264.

1 Like

Didn’t manage to get the libwebrtc (m74 nor m79) to build. :frowning:

/usr/lib/gcc/x86_64-linux-gnu/9/include-fixed/bits/statx.h:38:25: error: missing binary operator before token "("
   38 | #if __glibc_has_include ("__linux__/stat.h")
      |                         ^
/usr/lib/gcc/x86_64-linux-gnu/9/include-fixed/bits/statx.h:46:10: fatal error: bits/statx-generic.h: No such file or directory
   46 | #include <bits/statx-generic.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~

Definitely no idea, sorry. I was able to build libwebrtc in Linux Debian some time ago, but no expertise enough on it.

This is the mailing list where to ask such a question:

https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!forum/discuss-webrtc

Downgrading from Ubuntu 19.10 to 18.04 solved the libwebrtc build problem.

@haiyangwu

I have a problem running the same app on different Ubuntu distros. In Ubuntu 19.10 I could stream (VP8) from a mediasoup server to an android app running in the android emulator

In Ubuntu 18.04 though, calling device.getRtpCapabilities() in the app returns no codecs:

{"codecs":[],"fecMechanisms":[],"headerExtensions":[{"kind":"video","preferredId":4,"uri":"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"},{"kind":"video","preferredId":5,"uri":"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"},{"kind":"video","preferredId":6,"uri":"http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07"},{"kind":"audio","preferredId":10,"uri":"urn:ietf:params:rtp-hdrext:ssrc-audio-level"},{"kind":"video","preferredId":11,"uri":"urn:3gpp:video-orientation"},{"kind":"video","preferredId":12,"uri":"urn:ietf:params:rtp-hdrext:toffset"}]}

The router rtpCapabilities received from the server look right:

{"codecs":[{"kind":"video","mimeType":"video\/VP8","clockRate":90000,"rtcpFeedback":[{"type":"nack","parameter":""},{"type":"nack","parameter":"pli"},{"type":"ccm","parameter":"fir"},{"type":"goog-remb","parameter":""},{"type":"transport-cc","parameter":""}],"channels":1,"parameters":{},"preferredPayloadType":96},{"kind":"video","mimeType":"video\/rtx","preferredPayloadType":100,"clockRate":90000,"channels":1,"parameters":{"apt":96},"rtcpFeedback":[]}],"headerExtensions":[{"kind":"audio","uri":"urn:ietf:params:rtp-hdrext:sdes:mid","preferredId":1,"preferredEncrypt":false,"direction":"recvonly"},{"kind":"video","uri":"urn:ietf:params:rtp-hdrext:sdes:mid","preferredId":1,"preferredEncrypt":false,"direction":"recvonly"},{"kind":"video","uri":"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","preferredId":2,"preferredEncrypt":false,"direction":"recvonly"},{"kind":"video","uri":"urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id","preferredId":3,"preferredEncrypt":false,"direction":"recvonly"},{"kind":"audio","uri":"http:\/\/www.webrtc.org\/experiments\/rtp-hdrext\/abs-send-time","preferredId":4,"preferredEncrypt":false,"direction":"sendrecv"},{"kind":"video","uri":"http:\/\/www.webrtc.org\/experiments\/rtp-hdrext\/abs-send-time","preferredId":4,"preferredEncrypt":false,"direction":"sendrecv"},{"kind":"audio","uri":"http:\/\/www.ietf.org\/id\/draft-holmer-rmcat-transport-wide-cc-extensions-01","preferredId":5,"preferredEncrypt":false,"direction":"recvonly"},{"kind":"video","uri":"http:\/\/www.ietf.org\/id\/draft-holmer-rmcat-transport-wide-cc-extensions-01","preferredId":5,"preferredEncrypt":false,"direction":"sendrecv"},{"kind":"video","uri":"http:\/\/tools.ietf.org\/html\/draft-ietf-avtext-framemarking-07","preferredId":6,"preferredEncrypt":false,"direction":"sendrecv"},{"kind":"video","uri":"urn:ietf:params:rtp-hdrext:framemarking","preferredId":7,"preferredEncrypt":false,"direction":"sendrecv"},{"kind":"audio","uri":"urn:ietf:params:rtp-hdrext:ssrc-audio-level","preferredId":10,"preferredEncrypt":false,"direction":"sendrecv"},{"kind":"video","uri":"urn:3gpp:video-orientation","preferredId":11,"preferredEncrypt":false,"direction":"sendrecv"},{"kind":"video","uri":"urn:ietf:params:rtp-hdrext:toffset","preferredId":12,"preferredEncrypt":false,"direction":"sendrecv"}]}

Do you have any idea why device.getRtpCapabilities() returns no codecs?
How can I activate the MSC_DEBUG libmediasoup debug messages in the app?

Thanks!

Add a MSC_LOG_DEV() in Handler::GetNativeRtpCapabilities() static method to print the generated offer. The device capabilities are obtained by parsing it.

So run cmake . -Bbuild with -DMEDIASOUPCLIENT_LOG_DEV:BOOL=ON.

If I read this correctly, seems like there’s only audio supported:

[DEBUG] Handler::GetNativeRtpCapabilities() | The OFFER: [offer:v=0
o=- 3300157352786126585 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0 1
a=msid-semantic: WMS
m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 102 0 8 106 105 13 110 112 113 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:BHtr
a=ice-pwd:UwbRGk6OBNx4Yv7s5RCWSr/y
a=ice-options:trickle
a=fingerprint:sha-256 74:D0:9E:51:75:C9:B1:E5:C3:44:0D:AD:33:D1:89:7A:D8:0A:5F:AA:61:C0:27:0D:23:B3:26:B5:34:E7:7E:14
a=setup:actpass
a=mid:0
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=sendrecv
a=msid:- c00bccde-0a6c-478c-8609-e8323dcc13ab
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap

So there’s really no problem with libmediasoupclient, but with the underlying device capabilities. Which I come from libwebrtc, right?

Are you compiling libwebrtc with rtc_use_h264=true flag?

I don’t understand. There should be a m=video section. In fact, a=group:BUNDLE references a=mid:0 (the audio section) and a=mid:1 (which does not exist in the SDP so makes no sense at all).

Which version of libmediasoupclient are you using?

Looks like you have not shared the full SDP but jut part of it indeed.

I really wish I did. Here is a longer excerpt:

2020-03-04 11:16:34.696 2754-4248/com.example.mytest I/mediasoupclient-jni: [TRACE] PeerConnection::AddTransceiver()
2020-03-04 11:16:34.697 2754-4249/com.example.mytest I/mediasoupclient-jni: [TRACE] PeerConnection::OnRenegotiationNeeded()
2020-03-04 11:16:34.697 2754-4248/com.example.mytest I/mediasoupclient-jni: [TRACE] PeerConnection::AddTransceiver()
2020-03-04 11:16:34.697 2754-4249/com.example.mytest I/mediasoupclient-jni: [TRACE] PeerConnection::OnRenegotiationNeeded()
2020-03-04 11:16:34.697 2754-4248/com.example.mytest I/mediasoupclient-jni: [TRACE] PeerConnection::CreateOffer()
2020-03-04 11:16:34.717 2754-4248/com.example.mytest D/mediasoupclient-jni: [DEBUG] Handler::GetNativeRtpCapabilities() | The OFFER: [offer:v=0
o=- 4414643570178211956 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0 1
a=msid-semantic: WMS
m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 102 0 8 106 105 13 110 112 113 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:ZmqJ
a=ice-pwd:YMFlPoL36FA+FW3oL3Vi8v6I
a=ice-options:trickle
a=fingerprint:sha-256 1E:7A:EA:90:02:56:94:90:B3:73:2D:F9:6E:FD:BC:5D:93:75:F4:8E:3D:68:38:7F:1B:9E:77:3D:E5:42:5C:3E
a=setup:actpass
a=mid:0
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=sendrecv
a=msid:- 60ad06d2-fec3-467f-a374-466a67a1f9ee
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap
2020-03-04 11:16:34.879 2754-4248/com.example.mytest I/mediasoupclient-jni: [TRACE] Sdp::Utils::extractRtpCapabilities()
2020-03-04 11:16:34.886 2754-4250/com.example.mytest I/org.webrtc.Logging: WebRtcAudioManager: dispose@[name=Thread-23, id=159]
2020-03-04 11:16:34.887 2754-4248/com.example.mytest I/mediasoupclient-jni: [TRACE] ortc::getExtendedRtpCapabilities()
2020-03-04 11:16:34.887 2754-4248/com.example.mytest I/mediasoupclient-jni: [TRACE] ortc::matchCodecs()
2020-03-04 11:16:34.888 2754-4248/com.example.mytest I/chatty: uid=10086(com.example.mytest) EventThread identical 29 lines
2020-03-04 11:16:34.888 2754-4248/com.example.mytest I/mediasoupclient-jni: [TRACE] ortc::matchCodecs()
2020-03-04 11:16:34.888 2754-4248/com.example.mytest I/mediasoupclient-jni: [TRACE] ortc::matchHeaderExtensions()
2020-03-04 11:16:34.891 2754-4248/com.example.mytest I/chatty: uid=10086(com.example.mytest) EventThread identical 129 lines
2020-03-04 11:16:34.891 2754-4248/com.example.mytest I/mediasoupclient-jni: [TRACE] ortc::matchHeaderExtensions()
2020-03-04 11:16:34.891 2754-4248/com.example.mytest I/mediasoupclient-jni: [TRACE] ortc::canSend()
2020-03-04 11:16:34.891 2754-4248/com.example.mytest I/mediasoupclient-jni: [TRACE] ortc::canSend()
2020-03-04 11:16:34.891 2754-4248/com.example.mytest I/mediasoupclient-jni: [TRACE] ortc::getRecvRtpCapabilities()
2020-03-04 11:16:34.891 2754-4248/com.example.mytest D/mediasoupclient-jni: [DEBUG] Device::Load() | succeeded

I’m using @haiyangwu version (I guess 3.0.4). I just cloned his repository and added this:

json Handler::GetNativeRtpCapabilities()
{
MSC_TRACE();

std::unique_ptrPeerConnection::PrivateListener privateListener(
new PeerConnection::PrivateListener());
std::unique_ptr pc(new PeerConnection(privateListener.get(), nullptr));

(void)pc->AddTransceiver(cricket::MediaType::MEDIA_TYPE_AUDIO);
(void)pc->AddTransceiver(cricket::MediaType::MEDIA_TYPE_VIDEO);

// May throw.
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions options;
auto offer = pc->CreateOffer(options);

MSC_DEBUG("The OFFER: [offer:%s]", offer.c_str()); // this is what I added

auto sdpObject = sdptransform::parse(offer);
auto nativeRtpCapabilities = Sdp::Utils::extractRtpCapabilities(sdpObject);

return nativeRtpCapabilities;
}

libmediasoup is built there with these flags:

    externalNativeBuild {
        cmake {
            // Passes optional arguments to CMake.
            arguments "-DLIBWEBRTC_INCLUDE_PATH=" + WEBRTC_INC_PATH,
                    "-DLIBWEBRTC_BINARY_PATH=" + WEBRTC_LIB_PATH,
                    "-DMEDIASOUPCLIENT_BUILD_TESTS=OFF",
                    "-DSDPTRANSFORM_BUILD_TESTS=OFF",
                    "-DSDPTRANSFORM_BUILD_READMEHELPER=OFF",
                    "-DMEDIASOUPCLIENT_LOG_TRACE=1",
                    "-DMEDIASOUPCLIENT_LOG_DEV=1",
                    "-DMEDIASOUPCLIENT_LOG_DEV:BOOL=ON"
        }
    }

No, I don’t compile it for now with h264 support.

As I said, this works on Ubuntu 19.04. Could it have something to do with some drivers? I had to uninstall nouveau and install some Nvidia drivers, among other things to get the system running which I unfortunately can’t remember now.