Java源码示例:org.webrtc.RtpSender
示例1
protected void addStream(final MediaStream mediaStream) {
DCHECK(mediaStream);
DCHECK(pcExecutor);
pcExecutor.execute(() -> {
if (disposed()) {
return;
}
ArrayList<String> streamIds = new ArrayList<>();
streamIds.add(mediaStream.getId());
for (AudioTrack audioTrack : mediaStream.audioTracks) {
RtpSender audioSender = peerConnection.addTrack(audioTrack, streamIds);
audioRtpSenders.put(mediaStream.getId(), audioSender);
}
for (VideoTrack videoTrack : mediaStream.videoTracks) {
RtpSender videoSender = peerConnection.addTrack(videoTrack, streamIds);
videoRtpSenders.put(mediaStream.getId(), videoSender);
}
});
}
示例2
private void setMaxBitrate(RtpSender sender, Integer bitrate) {
if (sender == null) {
return;
}
RtpParameters rtpParameters = sender.getParameters();
if (rtpParameters == null) {
Log.e(LOG_TAG, "Null rtp paramters");
return;
}
for (RtpParameters.Encoding encoding : rtpParameters.encodings) {
encoding.maxBitrateBps = bitrate == null ? null : bitrate * 1000;
}
if (!sender.setParameters(rtpParameters)) {
Log.e(LOG_TAG, "Failed to configure max video bitrate");
}
}
示例3
private void findVideoSender() {
for (RtpSender sender : peerConnection.getSenders()) {
if (sender.track() != null) {
String trackType = sender.track().kind();
if (trackType.equals(VIDEO_TRACK_TYPE)) {
Log.d(TAG, "Found video sender.");
localVideoSender = sender;
}
}
}
}
示例4
private void findVideoSender(final BigInteger handleId) {
PeerConnection peerConnection = peerConnectionMap.get(handleId).peerConnection;
for (RtpSender sender : peerConnection.getSenders()) {
if (sender.track() != null) {
String trackType = sender.track().kind();
if (trackType.equals(VIDEO_TRACK_TYPE)) {
Log.d(TAG, "Found video sender.");
localVideoSender = sender;
}
}
}
}
示例5
private void findVideoSender() {
for (RtpSender sender : peerConnection.getSenders()) {
if (sender.track() != null) {
String trackType = sender.track().kind();
if (trackType.equals(VIDEO_TRACK_TYPE)) {
Log.d(TAG, "Found video sender.");
localVideoSender = sender;
}
}
}
}
示例6
private void findVideoSender() {
for (RtpSender sender : peerConnection.getSenders()) {
if (sender.track() != null) {
String trackType = sender.track().kind();
if (trackType.equals(VIDEO_TRACK_TYPE)) {
Log.d(TAG, "Found video sender.");
localVideoSender = sender;
}
}
}
}