dummy code to get sdp out of (non-working) libwebrtc
This commit is contained in:
parent
3b857e6894
commit
5b1d86d67e
|
@ -11,6 +11,7 @@
|
|||
-keep class com.google.android.gms.**
|
||||
|
||||
-keep class org.openintents.openpgp.*
|
||||
-keep class org.webrtc.** { *; }
|
||||
|
||||
-dontwarn org.bouncycastle.mail.**
|
||||
-dontwarn org.bouncycastle.x509.util.LDAPStoreHelper
|
||||
|
|
|
@ -8,8 +8,19 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.Maps;
|
||||
|
||||
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
|
||||
import org.webrtc.AudioSource;
|
||||
import org.webrtc.AudioTrack;
|
||||
import org.webrtc.DataChannel;
|
||||
import org.webrtc.IceCandidate;
|
||||
import org.webrtc.MediaConstraints;
|
||||
import org.webrtc.MediaStream;
|
||||
import org.webrtc.PeerConnection;
|
||||
import org.webrtc.PeerConnectionFactory;
|
||||
import org.webrtc.RtpReceiver;
|
||||
import org.webrtc.SdpObserver;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
|
@ -142,6 +153,7 @@ public class JingleRtpConnection extends AbstractJingleConnection {
|
|||
}
|
||||
|
||||
private void sendSessionInitiate() {
|
||||
setupWebRTC();
|
||||
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": sending session-initiate");
|
||||
}
|
||||
|
||||
|
@ -162,6 +174,110 @@ public class JingleRtpConnection extends AbstractJingleConnection {
|
|||
}
|
||||
}
|
||||
|
||||
private void setupWebRTC() {
|
||||
PeerConnectionFactory.initialize(
|
||||
PeerConnectionFactory.InitializationOptions.builder(xmppConnectionService).createInitializationOptions()
|
||||
);
|
||||
final PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
|
||||
PeerConnectionFactory peerConnectionFactory = PeerConnectionFactory.builder().createPeerConnectionFactory();
|
||||
|
||||
final AudioSource audioSource = peerConnectionFactory.createAudioSource(new MediaConstraints());
|
||||
|
||||
final AudioTrack audioTrack = peerConnectionFactory.createAudioTrack("my-audio-track", audioSource);
|
||||
final MediaStream stream = peerConnectionFactory.createLocalMediaStream("my-media-stream");
|
||||
stream.addTrack(audioTrack);
|
||||
|
||||
|
||||
PeerConnection peer = peerConnectionFactory.createPeerConnection(Collections.emptyList(), new PeerConnection.Observer() {
|
||||
@Override
|
||||
public void onSignalingChange(PeerConnection.SignalingState signalingState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIceConnectionReceivingChange(boolean b) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIceGatheringChange(PeerConnection.IceGatheringState iceGatheringState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIceCandidate(IceCandidate iceCandidate) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIceCandidatesRemoved(IceCandidate[] iceCandidates) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddStream(MediaStream mediaStream) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoveStream(MediaStream mediaStream) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataChannel(DataChannel dataChannel) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenegotiationNeeded() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddTrack(RtpReceiver rtpReceiver, MediaStream[] mediaStreams) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
peer.addStream(stream);
|
||||
|
||||
peer.createOffer(new SdpObserver() {
|
||||
|
||||
@Override
|
||||
public void onCreateSuccess(org.webrtc.SessionDescription description) {
|
||||
final SessionDescription sessionDescription = SessionDescription.parse(description.description);
|
||||
for (SessionDescription.Media media : sessionDescription.media) {
|
||||
Log.d(Config.LOGTAG, "media: " + media.protocol);
|
||||
for (SessionDescription.Attribute attribute : media.attributes) {
|
||||
Log.d(Config.LOGTAG, "attribute key=" + attribute.key + ", value=" + attribute.value);
|
||||
}
|
||||
}
|
||||
Log.d(Config.LOGTAG, sessionDescription.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateFailure(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetFailure(String s) {
|
||||
|
||||
}
|
||||
}, new MediaConstraints());
|
||||
}
|
||||
|
||||
private void pickupCallFromProposed() {
|
||||
transitionOrThrow(State.PROCEED);
|
||||
final MessagePacket messagePacket = new MessagePacket();
|
||||
|
|
|
@ -11,11 +11,11 @@ import eu.siacs.conversations.Config;
|
|||
|
||||
public class SessionDescription {
|
||||
|
||||
private final int version;
|
||||
private final String name;
|
||||
private final String connectionData;
|
||||
private final List<Attribute> attributes;
|
||||
private final List<Media> media;
|
||||
public final int version;
|
||||
public final String name;
|
||||
public final String connectionData;
|
||||
public final List<Attribute> attributes;
|
||||
public final List<Media> media;
|
||||
|
||||
|
||||
public SessionDescription(int version, String name, String connectionData, List<Attribute> attributes, List<Media> media) {
|
||||
|
@ -63,7 +63,8 @@ public class SessionDescription {
|
|||
break;
|
||||
case 'm':
|
||||
if (currentMediaBuilder == null) {
|
||||
sessionDescriptionBuilder.setAttributes(attributeBuilder.build());;
|
||||
sessionDescriptionBuilder.setAttributes(attributeBuilder.build());
|
||||
;
|
||||
} else {
|
||||
currentMediaBuilder.setAttributes(attributeBuilder.build());
|
||||
mediaBuilder.add(currentMediaBuilder.createMedia());
|
||||
|
@ -104,8 +105,8 @@ public class SessionDescription {
|
|||
}
|
||||
|
||||
public static class Attribute {
|
||||
private final String key;
|
||||
private final String value;
|
||||
public final String key;
|
||||
public final String value;
|
||||
|
||||
public Attribute(String key, String value) {
|
||||
this.key = key;
|
||||
|
@ -125,12 +126,12 @@ public class SessionDescription {
|
|||
}
|
||||
|
||||
public static class Media {
|
||||
private final String media;
|
||||
private final int port;
|
||||
private final String protocol;
|
||||
private final List<Integer> formats;
|
||||
private final String connectionData;
|
||||
private final List<Attribute> attributes;
|
||||
public final String media;
|
||||
public final int port;
|
||||
public final String protocol;
|
||||
public final List<Integer> formats;
|
||||
public final String connectionData;
|
||||
public final List<Attribute> attributes;
|
||||
|
||||
public Media(String media, int port, String protocol, List<Integer> formats, String connectionData, List<Attribute> attributes) {
|
||||
this.media = media;
|
||||
|
|
|
@ -52,6 +52,8 @@ public class RtpDescription extends GenericDescription {
|
|||
//TODO: support for https://xmpp.org/extensions/xep-0293.html
|
||||
|
||||
|
||||
//XEP-0294: Jingle RTP Header Extensions Negotiation
|
||||
//maps to `extmap:$id $uri`
|
||||
public static class RtpHeaderExtension extends Element {
|
||||
|
||||
private RtpHeaderExtension() {
|
||||
|
@ -76,6 +78,7 @@ public class RtpDescription extends GenericDescription {
|
|||
}
|
||||
}
|
||||
|
||||
//maps to `rtpmap $id $name/$clockrate/$channels`
|
||||
public static class PayloadType extends Element {
|
||||
|
||||
private PayloadType(String name, String xmlns) {
|
||||
|
@ -132,6 +135,8 @@ public class RtpDescription extends GenericDescription {
|
|||
}
|
||||
}
|
||||
|
||||
//map to `fmtp $id key=value;key=value
|
||||
//where id is the id of the parent payload-type
|
||||
public static class Parameter extends Element {
|
||||
|
||||
private Parameter() {
|
||||
|
|
Loading…
Reference in New Issue