use of org.jitsi.impl.neomedia.device.MediaDeviceImpl in project Spark by igniterealtime.
the class VideoChannel method start.
/**
* Starts the transmission. Returns null if transmission started ok.
* Otherwise it returns a string with the reason why the setup failed.
* Starts receive also.
*/
public synchronized String start() {
try {
MediaService mediaService = LibJitsi.getMediaService();
MediaDevice device = mediaService.getDefaultDevice(MediaType.VIDEO, MediaUseCase.ANY);
List<MediaDevice> devices = mediaService.getDevices(MediaType.VIDEO, MediaUseCase.ANY);
for (MediaDevice foundDevice : devices) {
if (foundDevice instanceof MediaDeviceImpl) {
MediaDeviceImpl amdi = (MediaDeviceImpl) foundDevice;
if (locator.equals(amdi.getCaptureDeviceInfo().getLocator())) {
System.out.println("Test" + locator + "-" + amdi.getCaptureDeviceInfo().getLocator());
device = foundDevice;
}
}
}
System.out.println("Device:" + device);
mediaStream = mediaService.createMediaStream(device);
mediaStream.setDirection(MediaDirection.SENDRECV);
MediaFormat usedformat = mediaService.getFormatFactory().createMediaFormat("H264", MediaFormatFactory.CLOCK_RATE_NOT_SPECIFIED);
byte dynamicRTPPayloadType = 99;
mediaStream.addDynamicRTPPayloadType(dynamicRTPPayloadType, usedformat);
mediaStream.setFormat(usedformat);
connector = new DefaultStreamConnector(new DatagramSocket(this.localPort), new DatagramSocket(this.localRTCPPort));
mediaStream.setConnector(connector);
mediaStream.setTarget(new MediaStreamTarget(new InetSocketAddress(this.ipAddress, this.remotePort), new InetSocketAddress(this.ipAddress, this.remoteRTCPPort)));
mediaStream.setName(MediaType.VIDEO.toString());
((VideoMediaStream) mediaStream).addVideoListener(new VideoListener() {
@Override
public void videoAdded(VideoEvent arg0) {
checkVideo();
}
@Override
public void videoRemoved(VideoEvent arg0) {
}
@Override
public void videoUpdate(VideoEvent arg0) {
}
});
mediaStream.start();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Aggregations