本文整理汇总了Java中org.webrtc.VideoCapturer类的典型用法代码示例。如果您正苦于以下问题:Java VideoCapturer类的具体用法?Java VideoCapturer怎么用?Java VideoCapturer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VideoCapturer类属于org.webrtc包,在下文中一共展示了VideoCapturer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createVideoCapturer
import org.webrtc.VideoCapturer; //导入依赖的package包/类
private VideoCapturer createVideoCapturer() {
VideoCapturer videoCapturer = null;
Log.d(TAG, "Creating capturer using camera2 API.");
// Creating camera capturer
Camera2Enumerator enumerator = new Camera2Enumerator(this);
final String[] deviceNames = enumerator.getDeviceNames();
Log.d(TAG, "Looking for back facing cameras.");
for (String deviceName : deviceNames) {
if (enumerator.isBackFacing(deviceName)) {
Log.d(TAG, "Creating back facing camera capturer.");
videoCapturer = enumerator.createCapturer(deviceName, null);
break;
}
}
if (videoCapturer == null) {
Log.e(TAG, "Failed to open camera.");
return null;
}
return videoCapturer;
}
示例2: createPeerConnectionClient
import org.webrtc.VideoCapturer; //导入依赖的package包/类
PeerConnectionClient createPeerConnectionClient(MockRenderer localRenderer,
MockRenderer remoteRenderer, PeerConnectionParameters peerConnectionParameters,
VideoCapturer videoCapturer, EglBase.Context eglContext) {
List<PeerConnection.IceServer> iceServers = new LinkedList<PeerConnection.IceServer>();
SignalingParameters signalingParameters =
new SignalingParameters(iceServers, true, // iceServers, initiator.
null, null, null, // clientId, wssUrl, wssPostUrl.
null, null); // offerSdp, iceCandidates.
PeerConnectionClient client = PeerConnectionClient.getInstance();
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
options.networkIgnoreMask = 0;
options.disableNetworkMonitor = true;
client.setPeerConnectionFactoryOptions(options);
client.createPeerConnectionFactory(
InstrumentationRegistry.getTargetContext(), peerConnectionParameters, this);
client.createPeerConnection(
eglContext, localRenderer, remoteRenderer, videoCapturer, signalingParameters);
client.createOffer();
return client;
}
示例3: getVideoCapturer
import org.webrtc.VideoCapturer; //导入依赖的package包/类
private VideoCapturer getVideoCapturer(CameraVideoCapturer.CameraEventsHandler eventsHandler) {
String[] cameraFacing = {"front", "back"};
int[] cameraIndex = {0, 1};
int[] cameraOrientation = {0, 90, 180, 270};
for (String facing : cameraFacing) {
for (int index : cameraIndex) {
for (int orientation : cameraOrientation) {
String name = "Camera " + index + ", Facing " + facing +
", Orientation " + orientation;
VideoCapturer capturer = VideoCapturerAndroid.create(name, eventsHandler);
if (capturer != null) {
Log.d("Using camera: ", name);
return capturer;
}
}
}
}
throw new RuntimeException("Failed to open capture");
}
示例4: getVideoCapturer
import org.webrtc.VideoCapturer; //导入依赖的package包/类
private VideoCapturer getVideoCapturer() {
String[] cameraFacing = {"front", "back"};
int[] cameraIndex = {0, 1};
int[] cameraOrientation = {0, 90, 180, 270};
for (String facing : cameraFacing) {
for (int index : cameraIndex) {
for (int orientation : cameraOrientation) {
String name = "Camera " + index + ", Facing " + facing +
", Orientation " + orientation;
VideoCapturer capturer = VideoCapturer.create(name);
if (capturer != null) {
return capturer;
}
}
}
}
throw new RuntimeException("Failed to open capturer");
}
示例5: addLocalStreams
import org.webrtc.VideoCapturer; //导入依赖的package包/类
private void addLocalStreams(Context context) {
AudioManager audioManager = ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE));
// TODO(fischman): figure out how to do this Right(tm) and remove the suppression.
@SuppressWarnings("deprecation")
boolean isWiredHeadsetOn = audioManager.isWiredHeadsetOn();
audioManager.setMode(isWiredHeadsetOn ? AudioManager.MODE_IN_CALL : AudioManager.MODE_IN_COMMUNICATION);
audioManager.setSpeakerphoneOn(!isWiredHeadsetOn);
localStream = peerConnectionFactory.createLocalMediaStream("ARDAMS");
if (!audioOnly) {
VideoCapturer capturer = getVideoCapturer();
MediaConstraints videoConstraints = new MediaConstraints();
videoSource = peerConnectionFactory.createVideoSource(capturer, videoConstraints);
VideoTrack videoTrack = peerConnectionFactory.createVideoTrack("ARDAMSv0", videoSource);
videoTrack.addRenderer(new VideoRenderer(localRender));
localStream.addTrack(videoTrack);
}
localStream.addTrack(peerConnectionFactory.createAudioTrack("ARDAMSa0", peerConnectionFactory.createAudioSource(new MediaConstraints())));
peerConnection.addStream(localStream);
}
示例6: getVideoCapturer
import org.webrtc.VideoCapturer; //导入依赖的package包/类
private VideoCapturer getVideoCapturer() {
String[] cameraFacing = { "front", "back" };
int[] cameraIndex = { 0, 1 };
int[] cameraOrientation = { 0, 90, 180, 270 };
for (String facing : cameraFacing) {
for (int index : cameraIndex) {
for (int orientation : cameraOrientation) {
String name = "Camera " + index + ", Facing " + facing +
", Orientation " + orientation;
VideoCapturer capturer = VideoCapturer.create(name);
if (capturer != null) {
//logAndToast("Using camera: " + name);
Log.d(TAG, "Using camera: " + name);
return capturer;
}
}
}
}
throw new RuntimeException("Failed to open capturer");
}
示例7: getVideoCapturer
import org.webrtc.VideoCapturer; //导入依赖的package包/类
private VideoCapturer getVideoCapturer() {
String[] cameraFacing = { "front", "back" };
int[] cameraIndex = { 0, 1 };
int[] cameraOrientation = { 0, 90, 180, 270 };
for (String facing : cameraFacing) {
for (int index : cameraIndex) {
for (int orientation : cameraOrientation) {
String name = "Camera " + index + ", Facing " + facing +
", Orientation " + orientation;
VideoCapturer capturer = VideoCapturer.create(name);
if (capturer != null) {
logAndToast("Using camera: " + name);
return capturer;
}
}
}
}
throw new RuntimeException("Failed to open capturer");
}
示例8: getVideoCapturer
import org.webrtc.VideoCapturer; //导入依赖的package包/类
/** get access to the camera */
private VideoCapturer getVideoCapturer() {
String[] cameraFacing = { "front", "back" };
int[] cameraIndex = { 0, 1 };
int[] cameraOrientation = { 0, 90, 180, 270 };
for (String facing : cameraFacing) {
for (int index : cameraIndex) {
for (int orientation : cameraOrientation) {
String name = "Camera " + index + ", Facing " + facing
+ ", Orientation " + orientation;
VideoCapturer capturer = VideoCapturer.create(name);
if (capturer != null) {
log("Using camera: " + name);
return capturer;
}
}
}
}
throw new RuntimeException("Failed to open capturer");
}
示例9: createPeerConnection
import org.webrtc.VideoCapturer; //导入依赖的package包/类
public void createPeerConnection(final EglBase.Context renderEGLContext,
final VideoRenderer.Callbacks localRender,
final VideoRenderer.Callbacks remoteRender,
final VideoCapturer videoCapturer,
final SignalingParameters signalingParameters) {
createPeerConnection(renderEGLContext, localRender, Collections.singletonList(remoteRender),
videoCapturer, signalingParameters);
}
示例10: createVideoTrack
import org.webrtc.VideoCapturer; //导入依赖的package包/类
private VideoTrack createVideoTrack(VideoCapturer capturer) {
videoSource = factory.createVideoSource(capturer);
capturer.startCapture(videoWidth, videoHeight, videoFps);
localVideoTrack = factory.createVideoTrack(VIDEO_TRACK_ID, videoSource);
if (localRender != null) {
localVideoTrack.setEnabled(renderVideo);
localVideoTrack.addRenderer(new VideoRenderer(localRender));
}
return localVideoTrack;
}
示例11: createVideoTrack
import org.webrtc.VideoCapturer; //导入依赖的package包/类
private VideoTrack createVideoTrack(VideoCapturer videoCapturer) {
mVideoSource = mPeerConnectionFactory.createVideoSource(videoCapturer);
videoCapturer.startCapture(videoWidth, videoHeight, videoHeight);
mLocalVideoTrack = mPeerConnectionFactory.createVideoTrack(VIDEO_TRACK_ID, mVideoSource);
mLocalVideoTrack.setEnabled(true);
mLocalVideoTrack.addRenderer(new VideoRenderer(localProxyRenderer));
return mLocalVideoTrack;
}
示例12: createVideoTrack
import org.webrtc.VideoCapturer; //导入依赖的package包/类
private VideoTrack createVideoTrack(VideoCapturer capturer) {
videoSource = factory.createVideoSource(capturer);
capturer.startCapture(videoWidth, videoHeight, videoFps);
localVideoTrack = factory.createVideoTrack(VIDEO_TRACK_ID, videoSource);
localVideoTrack.setEnabled(renderVideo);
localVideoTrack.addSink(localRender);
return localVideoTrack;
}
示例13: createScreenCapturer
import org.webrtc.VideoCapturer; //导入依赖的package包/类
@TargetApi(21)
private VideoCapturer createScreenCapturer() {
if (mediaProjectionPermissionResultCode != Activity.RESULT_OK) {
reportError("User didn't give permission to capture the screen.");
return null;
}
return new ScreenCapturerAndroid(
mediaProjectionPermissionResultData, new MediaProjection.Callback() {
@Override
public void onStop() {
reportError("User revoked permission to capture the screen.");
}
});
}
示例14: onConnectedToRoomInternal
import org.webrtc.VideoCapturer; //导入依赖的package包/类
private void onConnectedToRoomInternal(final SignalingParameters params) {
final long delta = System.currentTimeMillis() - callStartedTimeMs;
signalingParameters = params;
logAndToast("Creating peer connection, delay=" + delta + "ms");
VideoCapturer videoCapturer = null;
if (peerConnectionParameters.videoCallEnabled) {
videoCapturer = createVideoCapturer();
}
peerConnectionClient.createPeerConnection(
localProxyVideoSink, remoteRenderers, videoCapturer, signalingParameters);
if (signalingParameters.initiator) {
logAndToast("Creating OFFER...");
// Create offer. Offer SDP will be sent to answering client in
// PeerConnectionEvents.onLocalDescription event.
peerConnectionClient.createOffer();
} else {
if (params.offerSdp != null) {
peerConnectionClient.setRemoteDescription(params.offerSdp);
logAndToast("Creating ANSWER...");
// Create answer. Answer SDP will be sent to offering client in
// PeerConnectionEvents.onLocalDescription event.
peerConnectionClient.createAnswer();
}
if (params.iceCandidates != null) {
// Add remote ICE candidates from room.
for (IceCandidate iceCandidate : params.iceCandidates) {
peerConnectionClient.addRemoteIceCandidate(iceCandidate);
}
}
}
}
示例15: createVideoTrack
import org.webrtc.VideoCapturer; //导入依赖的package包/类
private VideoTrack createVideoTrack(VideoCapturer capturer) {
videoSource = factory.createVideoSource(capturer);
capturer.startCapture(videoWidth, videoHeight, videoFps);
localVideoTrack = factory.createVideoTrack(VIDEO_TRACK_ID, videoSource);
localVideoTrack.setEnabled(renderVideo);
localVideoTrack.addRenderer(new VideoRenderer(localRender));
return localVideoTrack;
}