本文整理汇总了Java中org.webrtc.MediaStream类的典型用法代码示例。如果您正苦于以下问题:Java MediaStream类的具体用法?Java MediaStream怎么用?Java MediaStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MediaStream类属于org.webrtc包,在下文中一共展示了MediaStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gotRemoteStream
import org.webrtc.MediaStream; //导入依赖的package包/类
private void gotRemoteStream(MediaStream stream) {
//we have remote video stream. add to the renderer.
final VideoTrack videoTrack = stream.videoTracks.getFirst();
AudioTrack audioTrack = stream.audioTracks.getFirst();
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
remoteRenderer = new VideoRenderer(remoteVideoView);
remoteVideoView.setVisibility(View.VISIBLE);
videoTrack.addRenderer(remoteRenderer);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
示例2: onAddRemoteStream
import org.webrtc.MediaStream; //导入依赖的package包/类
@Override
public void onAddRemoteStream(final MediaStream remoteStream, final PnPeer peer) {
super.onAddRemoteStream(remoteStream, peer); // Will log values
VideoChatActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(VideoChatActivity.this,"Connected to " + peer.getId(), Toast.LENGTH_SHORT).show();
try {
if(remoteStream.audioTracks.size()==0 || remoteStream.videoTracks.size()==0) return;
mCallStatus.setVisibility(View.GONE);
remoteStream.videoTracks.get(0).addRenderer(new VideoRenderer(remoteRender));
VideoRendererGui.update(remoteRender, 0, 0, 100, 100, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, false);
VideoRendererGui.update(localRender, 72, 65, 25, 25, VideoRendererGui.ScalingType.SCALE_ASPECT_FIT, true);
}
catch (Exception e){ e.printStackTrace(); }
}
});
}
示例3: onAddStream
import org.webrtc.MediaStream; //导入依赖的package包/类
@Override
public void onAddStream(final MediaStream stream) {
executor.execute(new Runnable() {
@Override
public void run() {
if (peerConnection == null || isError) {
return;
}
if (stream.audioTracks.size() > 1 || stream.videoTracks.size() > 1) {
reportError("Weird-looking stream: " + stream);
return;
}
if (stream.videoTracks.size() == 1) {
remoteVideoTrack = stream.videoTracks.get(0);
remoteVideoTrack.setEnabled(renderVideo);
for (VideoRenderer.Callbacks remoteRender : remoteRenders) {
remoteVideoTrack.addRenderer(new VideoRenderer(remoteRender));
}
}
}
});
}
示例4: onAddStream
import org.webrtc.MediaStream; //导入依赖的package包/类
@Override
public void onAddStream(final MediaStream stream) {
executor.execute(new Runnable() {
@Override
public void run() {
if (peerConnection == null || isError) {
return;
}
if (stream.audioTracks.size() > 1 || stream.videoTracks.size() > 1) {
reportError("Weird-looking stream: " + stream);
return;
}
if (stream.videoTracks.size() == 1) {
remoteVideoTrack = stream.videoTracks.get(0);
remoteVideoTrack.setEnabled(renderVideo);
for (VideoRenderer.Callbacks remoteRender : remoteRenders) {
remoteVideoTrack.addRenderer(new VideoRenderer(remoteRender));
}
}
}
});
}
示例5: onAddStream
import org.webrtc.MediaStream; //导入依赖的package包/类
@Override
public void onAddStream(final MediaStream stream) {
executor.execute(new Runnable() {
@Override
public void run() {
if (peerConnection == null || isError) {
return;
}
if (stream.audioTracks.size() > 1 || stream.videoTracks.size() > 1) {
reportError("Weird-looking stream: " + stream);
return;
}
if (stream.videoTracks.size() == 1) {
remoteVideoTrack = stream.videoTracks.get(0);
remoteVideoTrack.setEnabled(renderVideo);
remoteVideoTrack.addRenderer(new VideoRenderer(remoteRender));
}
}
});
}
示例6: initializeOutboundCall
import org.webrtc.MediaStream; //导入依赖的package包/类
private void initializeOutboundCall() {
id = UUID.randomUUID().toString();
final Application application = (Application) getApplication();
final PeerConnectionFactory factory = application.getWebRtcFactory();
final MediaStream mediaStream = factory.createLocalMediaStream(UUID.randomUUID().toString());
mediaStream.addTrack(factory.createAudioTrack(
UUID.randomUUID().toString(),
factory.createAudioSource(CONSTRAINTS)
));
peerConnection = factory.createPeerConnection(
application.getBuiltInIceServers(),
CONSTRAINTS,
new PeerConnectionObserver()
);
peerConnection.addStream(mediaStream);
peerConnection.createOffer(sdpObserver, CONSTRAINTS);
}
示例7: onAddStream
import org.webrtc.MediaStream; //导入依赖的package包/类
@Override public void onAddStream(final MediaStream stream){
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
if (isActive()) {
if (stream.audioTracks.size() <= 1 && stream.videoTracks.size() <= 1) {
if (stream.videoTracks.size() == 1) {
stream.videoTracks.get(0).addRenderer(
new VideoRenderer(remoteRender));
}
} else {
postErrorToListener("An invalid stream was added");
}
}
}
});
}
示例8: onRemoveStream
import org.webrtc.MediaStream; //导入依赖的package包/类
@Override
public void onRemoveStream(MediaStream mediaStream) {
String streamReactTag = webRTCModule.onRemoveStream(mediaStream);
if (streamReactTag == null) {
return;
}
WritableMap params = Arguments.createMap();
params.putInt("id", id);
params.putString("streamId", streamReactTag);
webRTCModule.sendEvent("peerConnectionRemovedStream", params);
}
示例9: setStreamURL
import org.webrtc.MediaStream; //导入依赖的package包/类
@ReactProp(name = "streamURL")
public void setStreamURL(WebRTCView view, String streamURL) {
MediaStream mediaStream;
if (streamURL == null) {
mediaStream = null;
} else {
WebRTCModule module = mContext.getNativeModule(WebRTCModule.class);
mediaStream = module.mMediaStreams.get(streamURL);
}
view.setStream(mediaStream);
}
示例10: setStream
import org.webrtc.MediaStream; //导入依赖的package包/类
/**
* Sets the {@code MediaStream} to be rendered by this {@code WebRTCView}.
* The implementation renders the first {@link VideoTrack}, if any, of the
* specified {@code mediaStream}.
*
* @param mediaStream The {@code MediaStream} to be rendered by this
* {@code WebRTCView} or {@code null}.
*/
public void setStream(MediaStream mediaStream) {
VideoTrack videoTrack;
if (mediaStream == null) {
videoTrack = null;
} else {
List<VideoTrack> videoTracks = mediaStream.videoTracks;
videoTrack = videoTracks.isEmpty() ? null : videoTracks.get(0);
}
setVideoTrack(videoTrack);
}
示例11: onAddStream
import org.webrtc.MediaStream; //导入依赖的package包/类
@Override
public void onAddStream(MediaStream stream) {
Log.w(TAG, "onAddStream:" + stream);
for (AudioTrack audioTrack : stream.audioTracks) {
audioTrack.setEnabled(true);
}
if (stream.videoTracks != null && stream.videoTracks.size() == 1) {
VideoTrack videoTrack = stream.videoTracks.getFirst();
videoTrack.setEnabled(true);
videoTrack.addRenderer(new VideoRenderer(remoteRenderer));
}
}
示例12: PeerConnectionWrapper
import org.webrtc.MediaStream; //导入依赖的package包/类
public PeerConnectionWrapper(@NonNull Context context,
@NonNull PeerConnectionFactory factory,
@NonNull PeerConnection.Observer observer,
@NonNull VideoRenderer.Callbacks localRenderer,
@NonNull List<PeerConnection.IceServer> turnServers,
boolean hideIp)
{
List<PeerConnection.IceServer> iceServers = new LinkedList<>();
iceServers.add(STUN_SERVER);
iceServers.addAll(turnServers);
MediaConstraints constraints = new MediaConstraints();
MediaConstraints audioConstraints = new MediaConstraints();
PeerConnection.RTCConfiguration configuration = new PeerConnection.RTCConfiguration(iceServers);
configuration.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE;
configuration.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.REQUIRE;
if (hideIp) {
configuration.iceTransportsType = PeerConnection.IceTransportsType.RELAY;
}
constraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true"));
audioConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true"));
this.peerConnection = factory.createPeerConnection(configuration, constraints, observer);
this.videoCapturer = createVideoCapturer(context);
MediaStream mediaStream = factory.createLocalMediaStream("ARDAMS");
this.audioSource = factory.createAudioSource(audioConstraints);
this.audioTrack = factory.createAudioTrack("ARDAMSa0", audioSource);
this.audioTrack.setEnabled(false);
mediaStream.addTrack(audioTrack);
if (videoCapturer != null) {
this.videoSource = factory.createVideoSource(videoCapturer);
this.videoTrack = factory.createVideoTrack("ARDAMSv0", videoSource);
this.videoTrack.addRenderer(new VideoRenderer(localRenderer));
this.videoTrack.setEnabled(false);
mediaStream.addTrack(videoTrack);
} else {
this.videoSource = null;
this.videoTrack = null;
}
this.peerConnection.addStream(mediaStream);
}
示例13: onLocalStream
import org.webrtc.MediaStream; //导入依赖的package包/类
@Override
public void onLocalStream(final MediaStream localStream) {
super.onLocalStream(localStream); // Will log values
VideoChatActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if(localStream.videoTracks.size()==0) return;
localStream.videoTracks.get(0).addRenderer(new VideoRenderer(localRender));
}
});
}
示例14: onRemoveStream
import org.webrtc.MediaStream; //导入依赖的package包/类
@Override
public void onRemoveStream(final MediaStream stream) {
executor.execute(new Runnable() {
@Override
public void run() {
remoteVideoTrack = null;
}
});
}
示例15: onRemoveStream
import org.webrtc.MediaStream; //导入依赖的package包/类
@Override
public void onRemoveStream(final MediaStream stream) {
executor.execute(new Runnable() {
@Override
public void run() {
remoteVideoTrack = null;
}
});
}