Search in sources :

Example 31 with Channel

use of com.google.cloud.video.livestream.v1.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());
    }
}
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 32 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project java-docs-samples by GoogleCloudPlatform.

the class StartChannel method startChannel.

public static void startChannel(String projectId, String location, String channelId) throws InterruptedException, ExecutionException, TimeoutException, 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);
        livestreamServiceClient.startChannelAsync(name).get(1, TimeUnit.MINUTES);
        System.out.println("Started channel");
    }
}
Also used : ChannelName(com.google.cloud.video.livestream.v1.ChannelName) LivestreamServiceClient(com.google.cloud.video.livestream.v1.LivestreamServiceClient)

Example 33 with Channel

use of com.google.cloud.video.livestream.v1.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());
    }
}
Also used : Channel(com.google.cloud.video.livestream.v1.Channel) LivestreamServiceClient(com.google.cloud.video.livestream.v1.LivestreamServiceClient)

Example 34 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project java-docs-samples by GoogleCloudPlatform.

the class DeleteChannelEvent method deleteChannelEvent.

public static void deleteChannelEvent(String projectId, String location, String channelId, String eventId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
        var deleteEventRequest = DeleteEventRequest.newBuilder().setName(EventName.of(projectId, location, channelId, eventId).toString()).build();
        livestreamServiceClient.deleteEvent(deleteEventRequest);
        System.out.println("Deleted channel event");
    }
}
Also used : LivestreamServiceClient(com.google.cloud.video.livestream.v1.LivestreamServiceClient)

Example 35 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project java-docs-samples by GoogleCloudPlatform.

the class GetChannelEvent method getChannelEvent.

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

Aggregations

Channel (org.jboss.remoting3.Channel)41 IOException (java.io.IOException)29 Test (org.junit.Test)14 LivestreamServiceClient (com.google.cloud.video.livestream.v1.LivestreamServiceClient)13 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 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 Event (com.google.cloud.video.livestream.v1.Event)4