本文整理汇总了Java中org.kurento.jsonrpc.JsonUtils类的典型用法代码示例。如果您正苦于以下问题:Java JsonUtils类的具体用法?Java JsonUtils怎么用?Java JsonUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonUtils类属于org.kurento.jsonrpc包,在下文中一共展示了JsonUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performWebRtcNegotiation
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
public String performWebRtcNegotiation(final WebSocketSession session, String sdpOffer) {
log.info("Starting WebRTC negotiation in session {}", sessionId);
// Subscribe to ICE candidates
webRtcEndpoint.addOnIceCandidateListener(new EventListener<OnIceCandidateEvent>() {
@Override
public void onEvent(OnIceCandidateEvent event) {
JsonObject response = new JsonObject();
response.addProperty("id", "iceCandidate");
response.add("candidate", JsonUtils.toJsonObject(event.getCandidate()));
handler.sendMessage(session, new TextMessage(response.toString()));
}
});
// SDP negotiation
String sdpAnswer = webRtcEndpoint.processOffer(sdpOffer);
// Gather ICE candidates
webRtcEndpoint.gatherCandidates();
return sdpAnswer;
}
示例2: kmsManager
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public KurentoClientProvider kmsManager() {
JsonArray kmsUris = getPropertyJson(KMSS_URIS_PROPERTY, KMSS_URIS_DEFAULT, JsonArray.class);
List<String> kmsWsUris = JsonUtils.toStringList(kmsUris);
if (kmsWsUris.isEmpty()) {
throw new IllegalArgumentException(KMSS_URIS_PROPERTY
+ " should contain at least one kms url");
}
String firstKmsWsUri = kmsWsUris.get(0);
if (firstKmsWsUri.equals("autodiscovery")) {
log.info("Using autodiscovery rules to locate KMS on every pipeline");
return new AutodiscoveryKurentoClientProvider();
} else {
log.info("Configuring Kurento Room Server to use first of the following kmss: " + kmsWsUris);
return new FixedOneKmsManager(firstKmsWsUri);
}
}
示例3: processEvent
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
private void processEvent(RomEventHandler eventHandler, Request<JsonObject> request) {
JsonObject params = request.getParams();
try {
params = (JsonObject) params.get("value");
} catch (Exception e) {
log.trace("Exception processing event: getting value", e);
}
String objectRef = params.get(ONEVENT_OBJECT).getAsString();
String subscription = "";
if (params.has(ONEVENT_SUBSCRIPTION)) {
subscription = params.get(ONEVENT_SUBSCRIPTION).getAsString();
}
String type = params.get(ONEVENT_TYPE).getAsString();
JsonObject jsonData = (JsonObject) params.get(ONEVENT_DATA);
Props data = JsonUtils.fromJson(jsonData, Props.class);
eventHandler.processEvent(objectRef, subscription, type, data);
}
示例4: objectToJsonConversion
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void objectToJsonConversion() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("prop1", "XXX");
jsonObject.addProperty("prop2", 33);
jsonObject.addProperty("prop3", "YYY");
jsonObject.addProperty("prop4", 5.5f);
ComplexParam param = JsonUtils.fromJson(jsonObject, ComplexParam.class);
assertEquals(param.getProp1(), "XXX");
assertEquals(param.getProp2(), 33);
assertEquals(param.getProp3(), "YYY");
assertEquals(param.getProp4(), 5.5f, 0.01);
}
示例5: propsToJsonConversion
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void propsToJsonConversion() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("prop1", "XXX");
jsonObject.addProperty("prop2", 33);
jsonObject.addProperty("prop3", "YYY");
jsonObject.addProperty("prop4", 5.5f);
Props props = JsonUtils.fromJson(jsonObject, Props.class);
assertEquals(props.getProp("prop1"), "XXX");
assertEquals(props.getProp("prop2"), 33);
assertEquals(props.getProp("prop3"), "YYY");
assertEquals(props.getProp("prop4"), 5.5f);
}
示例6: jsonToPropsConversion
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void jsonToPropsConversion() {
Props param = new Props();
param.add("prop1", "XXX");
param.add("prop2", 33);
param.add("prop3", "YYY");
param.add("prop4", 5.5f);
JsonObject jsonObject = JsonUtils.toJsonObject(param);
assertEquals(jsonObject.get("prop1").getAsString(), "XXX");
assertEquals(jsonObject.get("prop2").getAsInt(), 33);
assertEquals(jsonObject.get("prop3").getAsString(), "YYY");
assertEquals(jsonObject.get("prop4").getAsFloat(), 5.5f, 0.01);
}
示例7: requestTest
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void requestTest() {
Params params = new Params();
params.param1 = "Value1";
params.param2 = "Value2";
params.data = new Data();
params.data.data1 = "XX";
params.data.data2 = "YY";
Request<Params> request = new Request<Params>(1, "method", params);
String requestJson = JsonUtils.toJsonRequest(request);
log.debug(requestJson);
Request<Params> newRequest = JsonUtils.fromJsonRequest(requestJson, Params.class);
Assert.assertEquals(params.param1, newRequest.getParams().param1);
Assert.assertEquals(params.param2, newRequest.getParams().param2);
Assert.assertEquals(params.data.data1, newRequest.getParams().data.data1);
Assert.assertEquals(params.data.data2, newRequest.getParams().data.data2);
}
示例8: noResultResponseTest
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void noResultResponseTest() {
Response<Void> response = new Response<Void>(1);
response.setSessionId("xxxxxxx");
String responseJson = response.toString();
JsonParser parser = new JsonParser();
JsonObject expected = (JsonObject) parser
.parse("{\"id\":1,\"result\":{\"sessionId\":\"xxxxxxx\"},\"jsonrpc\":\"2.0\"}");
JsonObject result = (JsonObject) parser.parse(responseJson);
Assert.assertEquals(expected, result);
log.debug(responseJson);
Response<Void> newResponse = JsonUtils.fromJsonResponse(responseJson, Void.class);
// Assert.assertEquals(null, newResponse.getResult());
Assert.assertEquals(newResponse.getSessionId(), "xxxxxxx");
}
示例9: responseTest
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void responseTest() {
Data data = new Data();
data.data1 = "Value1";
Response<Data> response = new Response<Data>(1, data);
response.setSessionId("xxxxxxx");
String responseJson = response.toString();
Assert.assertEquals(
"{\"id\":1,\"result\":{\"data1\":\"Value1\",\"sessionId\":\"xxxxxxx\"},\"jsonrpc\":\"2.0\"}",
responseJson);
log.debug(responseJson);
Response<Data> newResponse = JsonUtils.fromJsonResponse(responseJson, Data.class);
Assert.assertEquals(data.data1, newResponse.getResult().data1);
Assert.assertEquals(newResponse.getSessionId(), "xxxxxxx");
}
示例10: getEndpointForUser
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
private WebRtcEndpoint getEndpointForUser(final UserSession sender) {
if (sender.getName().equals(name)) {
log.debug("PARTICIPANT {}: configuring loopback", this.name);
return outgoingMedia;
}
log.debug("PARTICIPANT {}: receiving video from {}", this.name, sender.getName());
WebRtcEndpoint incoming = incomingMedia.get(sender.getName());
if (incoming == null) {
log.debug("PARTICIPANT {}: creating new endpoint for {}", this.name, sender.getName());
incoming = new WebRtcEndpoint.Builder(pipeline).build();
incoming.addIceCandidateFoundListener(new EventListener<IceCandidateFoundEvent>() {
@Override
public void onEvent(IceCandidateFoundEvent event) {
JsonObject response = new JsonObject();
response.addProperty("id", "iceCandidate");
response.addProperty("name", sender.getName());
response.add("candidate", JsonUtils.toJsonObject(event.getCandidate()));
try {
synchronized (session) {
session.sendMessage(new TextMessage(response.toString()));
}
} catch (IOException e) {
log.debug(e.getMessage());
}
}
});
incomingMedia.put(sender.getName(), incoming);
}
log.debug("PARTICIPANT {}: obtained endpoint for {}", this.name, sender.getName());
sender.getOutgoingWebRtcPeer().connect(incoming);
return incoming;
}
示例11: UserSession
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
public UserSession(final String name, String roomName, final WebSocketSession session,
MediaPipeline pipeline) {
this.pipeline = pipeline;
this.name = name;
this.session = session;
this.roomName = roomName;
this.outgoingMedia = new WebRtcEndpoint.Builder(pipeline).build();
this.outgoingMedia.addIceCandidateFoundListener(new EventListener<IceCandidateFoundEvent>() {
@Override
public void onEvent(IceCandidateFoundEvent event) {
JsonObject response = new JsonObject();
response.addProperty("id", "iceCandidate");
response.addProperty("name", name);
response.add("candidate", JsonUtils.toJsonObject(event.getCandidate()));
try {
synchronized (session) {
session.sendMessage(new TextMessage(response.toString()));
}
} catch (IOException e) {
log.debug(e.getMessage());
}
}
});
}
示例12: startSession
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
public String startSession(final WebSocketSession session, String sdpOffer) {
// One KurentoClient instance per session (reserving points per session)
Properties properties = new Properties();
properties.add("loadPoints", POINTS_PER_SESSION);
kurentoClient = KurentoClient.create(properties);
log.info("Created kurentoClient (session {})", sessionId);
// Media logic (pipeline and media elements connectivity)
mediaPipeline = kurentoClient.createMediaPipeline();
log.info("Created Media Pipeline {} (session {})", mediaPipeline.getId(), sessionId);
webRtcEndpoint = new WebRtcEndpoint.Builder(mediaPipeline).build();
FaceOverlayFilter faceOverlayFilter = new FaceOverlayFilter.Builder(mediaPipeline).build();
faceOverlayFilter.setOverlayedImage("http://files.kurento.org/img/mario-wings.png", -0.35F,
-1.2F, 1.6F, 1.6F);
webRtcEndpoint.connect(faceOverlayFilter);
faceOverlayFilter.connect(webRtcEndpoint);
// WebRTC negotiation
webRtcEndpoint.addOnIceCandidateListener(new EventListener<OnIceCandidateEvent>() {
@Override
public void onEvent(OnIceCandidateEvent event) {
JsonObject response = new JsonObject();
response.addProperty("id", "iceCandidate");
response.add("candidate", JsonUtils.toJsonObject(event.getCandidate()));
handler.sendMessage(session, new TextMessage(response.toString()));
}
});
String sdpAnswer = webRtcEndpoint.processOffer(sdpOffer);
webRtcEndpoint.gatherCandidates();
return sdpAnswer;
}
示例13: kmsManager
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Bean
public KmsManager kmsManager() {
JsonArray kmsUris =
getPropertyJson(KurentoRoomServerApp.KMSS_URIS_PROPERTY,
KurentoRoomServerApp.KMSS_URIS_DEFAULT, JsonArray.class);
List<String> kmsWsUris = JsonUtils.toStringList(kmsUris);
log.info("Configuring Kurento Room Server to use the following kmss: "
+ kmsWsUris);
FixedNKmsManager fixedKmsManager =
new FixedNKmsManager(kmsWsUris, DEMO_KMS_NODE_LIMIT);
fixedKmsManager.setAuthRegex(DEMO_AUTH_REGEX);
return fixedKmsManager;
}
示例14: kmsManager
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Override
public KmsManager kmsManager() {
JsonArray kmsUris = getPropertyJson(KurentoRoomServerApp.KMSS_URIS_PROPERTY,
KurentoRoomServerApp.KMSS_URIS_DEFAULT, JsonArray.class);
List<String> kmsWsUris = JsonUtils.toStringList(kmsUris);
log.info("Configuring Kurento Room Server to use the following kmss: {}", kmsWsUris);
FixedNKmsManager fixedKmsManager = new FixedNKmsManager(kmsWsUris, DEMO_KMS_NODE_LIMIT);
fixedKmsManager.setAuthRegex(DEMO_AUTH_REGEX);
log.debug("Authorization regex for new rooms: {}", DEMO_AUTH_REGEX);
return fixedKmsManager;
}
示例15: createUnsubscribeRequest
import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
public RequestAndResponseType createUnsubscribeRequest(String objectRef,
String listenerSubscription) {
JsonObject params = JsonUtils.toJsonObject(
new Props(UNSUBSCRIBE_OBJECT, objectRef).add(UNSUBSCRIBE_LISTENER, listenerSubscription));
return new RequestAndResponseType(new Request<>(UNSUBSCRIBE_METHOD, params), Void.class);
}