当前位置: 首页>>代码示例>>Java>>正文


Java MediaStream类代码示例

本文整理汇总了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();
            }
        }
    });

}
 
开发者ID:vivek1794,项目名称:webrtc-android-codelab,代码行数:19,代码来源:MainActivity.java

示例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(); }
        }
    });
}
 
开发者ID:newbie007fx,项目名称:newwebrtc,代码行数:19,代码来源:VideoChatActivity.java

示例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));
                }
            }
        }
    });
}
 
开发者ID:nhancv,项目名称:nc-android-webrtcpeer,代码行数:23,代码来源:PeerConnectionClient.java

示例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));
        }
      }
    }
  });
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:23,代码来源:PeerConnectionClient.java

示例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));
			}
		}
	});
}
 
开发者ID:ardnezar,项目名称:webrtc-android,代码行数:21,代码来源:PeerConnectionClient.java

示例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);
}
 
开发者ID:seamlik,项目名称:viska-android,代码行数:21,代码来源:CallingActivity.java

示例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");
                }
            }
        }
    });
}
 
开发者ID:respoke,项目名称:respoke-sdk-android,代码行数:17,代码来源:RespokeCall.java

示例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);
}
 
开发者ID:angellsl10,项目名称:react-native-webrtc,代码行数:12,代码来源:PeerConnectionObserver.java

示例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);
}
 
开发者ID:angellsl10,项目名称:react-native-webrtc,代码行数:12,代码来源:RTCVideoViewManager.java

示例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);
}
 
开发者ID:angellsl10,项目名称:react-native-webrtc,代码行数:22,代码来源:WebRTCView.java

示例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));
  }

}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:16,代码来源:WebRtcCallService.java

示例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);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:49,代码来源:PeerConnectionWrapper.java

示例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));
        }
    });
}
 
开发者ID:newbie007fx,项目名称:newwebrtc,代码行数:12,代码来源:VideoChatActivity.java

示例14: onRemoveStream

import org.webrtc.MediaStream; //导入依赖的package包/类
@Override
public void onRemoveStream(final MediaStream stream) {
    executor.execute(new Runnable() {
        @Override
        public void run() {
            remoteVideoTrack = null;
        }
    });
}
 
开发者ID:nhancv,项目名称:nc-android-webrtcpeer,代码行数:10,代码来源:PeerConnectionClient.java

示例15: onRemoveStream

import org.webrtc.MediaStream; //导入依赖的package包/类
@Override
public void onRemoveStream(final MediaStream stream) {
  executor.execute(new Runnable() {
    @Override
    public void run() {
      remoteVideoTrack = null;
    }
  });
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:10,代码来源:PeerConnectionClient.java


注:本文中的org.webrtc.MediaStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。