Search in sources :

Example 36 with Channel

use of com.automatak.dnp3.Channel in project java-docs-samples by GoogleCloudPlatform.

the class CreateChannelWithBackupInput method createChannelWithBackupInput.

public static void createChannelWithBackupInput(String projectId, String location, String channelId, String primaryInputId, String backupInputId, 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-primary-input").setInput(InputName.of(projectId, location, primaryInputId).toString()).setAutomaticFailover(AutomaticFailover.newBuilder().addInputKeys("my-backup-input").build()).build()).addInputAttachments(1, InputAttachment.newBuilder().setKey("my-backup-input").setInput(InputName.of(projectId, location, backupInputId).toString())).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());
    }
}
Also used : AudioStream(com.google.cloud.video.livestream.v1.AudioStream) Channel(com.google.cloud.video.livestream.v1.Channel) VideoStream(com.google.cloud.video.livestream.v1.VideoStream) LivestreamServiceClient(com.google.cloud.video.livestream.v1.LivestreamServiceClient)

Example 37 with Channel

use of com.automatak.dnp3.Channel in project java-docs-samples by GoogleCloudPlatform.

the class GetChannel method getChannel.

public static void getChannel(String projectId, String location, String channelId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
        ChannelName name = ChannelName.of(projectId, location, channelId);
        Channel response = livestreamServiceClient.getChannel(name);
        System.out.println("Channel: " + response.getName());
    }
}
Also used : ChannelName(com.google.cloud.video.livestream.v1.ChannelName) Channel(com.google.cloud.video.livestream.v1.Channel) LivestreamServiceClient(com.google.cloud.video.livestream.v1.LivestreamServiceClient)

Example 38 with Channel

use of com.automatak.dnp3.Channel in project java-docs-samples by GoogleCloudPlatform.

the class ListChannels method listChannels.

public static void listChannels(String projectId, String location) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
        var listChannelsRequest = ListChannelsRequest.newBuilder().setParent(LocationName.of(projectId, location).toString()).build();
        LivestreamServiceClient.ListChannelsPagedResponse response = livestreamServiceClient.listChannels(listChannelsRequest);
        System.out.println("Channels:");
        for (Channel channel : response.iterateAll()) {
            System.out.println(channel.getName());
        }
    }
}
Also used : Channel(com.google.cloud.video.livestream.v1.Channel) LivestreamServiceClient(com.google.cloud.video.livestream.v1.LivestreamServiceClient)

Example 39 with Channel

use of com.automatak.dnp3.Channel in project wildfly-core by wildfly.

the class RemoteProxyControllerProtocolTestCase method setupProxyHandlers.

private RemoteProxyController setupProxyHandlers(final ModelController proxiedController) {
    try {
        channels = new RemoteChannelPairSetup();
        channels.setupRemoting(new ManagementChannelInitialization() {

            @Override
            public ManagementChannelHandler startReceiving(Channel channel) {
                final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
                final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
                support.addHandlerFactory(new TransactionalProtocolOperationHandler(proxiedController, support, responseAttachmentSupport));
                channel.addCloseHandler(new CloseHandler<Channel>() {

                    @Override
                    public void handleClose(Channel closed, IOException exception) {
                        support.shutdownNow();
                    }
                });
                channel.receiveMessage(support.getReceiver());
                return support;
            }
        });
        channels.startClientConnetion();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    final Channel clientChannel = channels.getClientChannel();
    final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(clientChannel);
    final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
    final RemoteProxyController proxyController = RemoteProxyController.create(support, PathAddress.pathAddress(), ProxyOperationAddressTranslator.HOST);
    clientChannel.addCloseHandler(new CloseHandler<Channel>() {

        @Override
        public void handleClose(Channel closed, IOException exception) {
            support.shutdownNow();
        }
    });
    clientChannel.receiveMessage(support.getReceiver());
    return proxyController;
}
Also used : ManagementClientChannelStrategy(org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy) ManagementChannelHandler(org.jboss.as.protocol.mgmt.ManagementChannelHandler) Channel(org.jboss.remoting3.Channel) ManagementChannelInitialization(org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization) IOException(java.io.IOException) IOException(java.io.IOException) RemoteChannelPairSetup(org.jboss.as.controller.support.RemoteChannelPairSetup) CloseHandler(org.jboss.remoting3.CloseHandler) RemoteProxyController(org.jboss.as.controller.remote.RemoteProxyController) TransactionalProtocolOperationHandler(org.jboss.as.controller.remote.TransactionalProtocolOperationHandler)

Example 40 with Channel

use of com.automatak.dnp3.Channel in project wildfly-core by wildfly.

the class RemoteChannelProxyControllerTestCase method createProxyController.

@Override
protected ProxyController createProxyController(final ModelController proxiedController, final PathAddress proxyNodeAddress) {
    try {
        channels = new RemoteChannelPairSetup();
        channels.setupRemoting(new ManagementChannelInitialization() {

            @Override
            public ManagementChannelHandler startReceiving(Channel channel) {
                final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
                final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
                support.addHandlerFactory(new TransactionalProtocolOperationHandler(proxiedController, support, new ResponseAttachmentInputStreamSupport()));
                channel.addCloseHandler(new CloseHandler<Channel>() {

                    @Override
                    public void handleClose(Channel closed, IOException exception) {
                        support.shutdownNow();
                    }
                });
                channel.receiveMessage(support.getReceiver());
                return support;
            }
        });
        channels.startClientConnetion();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    final Channel clientChannel = channels.getClientChannel();
    final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(clientChannel);
    final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
    final RemoteProxyController proxyController = RemoteProxyController.create(support, proxyNodeAddress, ProxyOperationAddressTranslator.SERVER);
    clientChannel.addCloseHandler(new CloseHandler<Channel>() {

        @Override
        public void handleClose(Channel closed, IOException exception) {
            support.shutdownNow();
        }
    });
    clientChannel.receiveMessage(support.getReceiver());
    return proxyController;
}
Also used : ManagementClientChannelStrategy(org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy) ManagementChannelHandler(org.jboss.as.protocol.mgmt.ManagementChannelHandler) Channel(org.jboss.remoting3.Channel) ResponseAttachmentInputStreamSupport(org.jboss.as.controller.remote.ResponseAttachmentInputStreamSupport) ManagementChannelInitialization(org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization) IOException(java.io.IOException) IOException(java.io.IOException) RemoteChannelPairSetup(org.jboss.as.controller.support.RemoteChannelPairSetup) CloseHandler(org.jboss.remoting3.CloseHandler) RemoteProxyController(org.jboss.as.controller.remote.RemoteProxyController) TransactionalProtocolOperationHandler(org.jboss.as.controller.remote.TransactionalProtocolOperationHandler)

Aggregations

Channel (org.jboss.remoting3.Channel)41 IOException (java.io.IOException)29 Test (org.junit.Test)14 Connection (org.jboss.remoting3.Connection)12 MessageInputStream (org.jboss.remoting3.MessageInputStream)12 CountDownLatch (java.util.concurrent.CountDownLatch)10 OpenListener (org.jboss.remoting3.OpenListener)10 MessageOutputStream (org.jboss.remoting3.MessageOutputStream)9 InetSocketAddress (java.net.InetSocketAddress)8 URI (java.net.URI)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)8 IoFuture (org.xnio.IoFuture)7 Channel (com.google.cloud.video.livestream.v1.Channel)6 LivestreamServiceClient (com.google.cloud.video.livestream.v1.LivestreamServiceClient)6 URISyntaxException (java.net.URISyntaxException)6 ManagementClientChannelStrategy (org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy)6 FutureResult (org.xnio.FutureResult)6 ManagementChannelHandler (org.jboss.as.protocol.mgmt.ManagementChannelHandler)5 Endpoint (org.jboss.remoting3.Endpoint)5 ProtocolConnectionConfiguration (org.jboss.as.protocol.ProtocolConnectionConfiguration)4