private IChannel CreateChannel(string channelName, ChannelEncodingType channelType, StreamingProtocol ingestProtocol) { ChannelCreationOptions creationOptions = new ChannelCreationOptions(); creationOptions.Name = channelName; creationOptions.EncodingType = channelType; IPRange allAddresses = new IPRange(); allAddresses.Address = new IPAddress(0); allAddresses.Name = Constants.Media.Stream.AddressRangeAll; allAddresses.SubnetPrefixLength = 0; creationOptions.Input = new ChannelInput(); creationOptions.Input.AccessControl = new ChannelAccessControl(); creationOptions.Input.AccessControl.IPAllowList = new List <IPRange>(); creationOptions.Input.AccessControl.IPAllowList.Add(allAddresses); creationOptions.Input.StreamingProtocol = ingestProtocol; creationOptions.Preview = new ChannelPreview(); creationOptions.Preview.AccessControl = new ChannelAccessControl(); creationOptions.Preview.AccessControl.IPAllowList = new List <IPRange>(); creationOptions.Preview.AccessControl.IPAllowList.Add(allAddresses); IChannel channel = _media.Channels.Create(creationOptions); CreateProgram(channel); return(channel); }
public static IChannel CreateAndStartChannel() { var channelInput = CreateChannelInput(); var channePreview = CreateChannelPreview(); var channelEncoding = CreateChannelEncoding(); ChannelCreationOptions options = new ChannelCreationOptions { // EncodingType = ChannelEncodingType.Standard, Name = ChannelName, Input = channelInput, Preview = channePreview, Encoding = channelEncoding }; Log("Creating channel"); IOperation channelCreateOperation = _context.Channels.SendCreateOperation(options); string channelId = TrackOperation(channelCreateOperation, "Channel create"); IChannel channel = _context.Channels.Where(c => c.Id == channelId).FirstOrDefault(); Log("Starting channel"); var channelStartOperation = channel.SendStartOperation(); TrackOperation(channelStartOperation, "Channel start"); return(channel); }
public void TestStreamSelectionPersistence() { var channelOptions = new ChannelCreationOptions { Name = Guid.NewGuid().ToString().Substring(0, 30), Input = MakeChannelInput(), Preview = MakeChannelPreview(), Output = MakeChannelOutput(), EncodingType = ChannelEncodingType.Standard, Encoding = new ChannelEncoding { SystemPreset = "Default720p", VideoStreams = new List <VideoStream> { new VideoStream { Index = 0 } }.AsReadOnly(), AudioStreams = new List <AudioStream> { new AudioStream { Index = 1, Language = "eng" }, new AudioStream { Index = 2, Language = "fra" }, new AudioStream { Index = 3, Language = "spa" } }.AsReadOnly() } }; IChannel channel = _mediaContext.Channels.Create(channelOptions); Assert.AreEqual(channelOptions.Encoding.AudioStreams.Count, channel.Encoding.AudioStreams.Count); for (int i = 0; i < channelOptions.Encoding.AudioStreams.Count; ++i) { Assert.AreEqual(channelOptions.Encoding.AudioStreams[i].Index, channel.Encoding.AudioStreams[i].Index); Assert.AreEqual(channelOptions.Encoding.AudioStreams[i].Language, channel.Encoding.AudioStreams[i].Language); } Assert.AreEqual(channelOptions.Encoding.VideoStreams.Count, channel.Encoding.VideoStreams.Count); for (int i = 0; i < channelOptions.Encoding.VideoStreams.Count; ++i) { Assert.AreEqual(channelOptions.Encoding.VideoStreams[i].Index, channel.Encoding.VideoStreams[i].Index); } channel.Delete(); }
public static async Task <IModel> CreateChannelAsync(this IBusClient busClient, ChannelCreationOptions options = null, CancellationToken token = default(CancellationToken)) { var context = await busClient.InvokeAsync(CreateChannelPipe, token : token); return(context.GetChannel()); }
private IChannel CreateChannel(string channelName, ChannelEncodingType channelType, StreamingProtocol channelProtocol, string inputAddressAuthorized, int?inputSubnetPrefixLength, string previewAddressAuthorized, int?previewSubnetPrefixLength) { IPRange inputAddressRange = new IPRange(); if (string.IsNullOrEmpty(inputAddressAuthorized)) { inputAddressRange.Name = Constant.Media.Live.AllowAnyAddress; inputAddressRange.Address = new IPAddress(0); inputAddressRange.SubnetPrefixLength = 0; } else { inputAddressRange.Name = Constant.Media.Live.AllowAuthorizedAddress; inputAddressRange.Address = IPAddress.Parse(inputAddressAuthorized); inputAddressRange.SubnetPrefixLength = inputSubnetPrefixLength.Value; } IPRange previewAddressRange = new IPRange(); if (string.IsNullOrEmpty(previewAddressAuthorized)) { previewAddressRange.Name = Constant.Media.Live.AllowAnyAddress; previewAddressRange.Address = new IPAddress(0); previewAddressRange.SubnetPrefixLength = 0; } else { previewAddressRange.Name = Constant.Media.Live.AllowAuthorizedAddress; previewAddressRange.Address = IPAddress.Parse(previewAddressAuthorized); previewAddressRange.SubnetPrefixLength = previewSubnetPrefixLength.Value; } ChannelCreationOptions channelOptions = new ChannelCreationOptions() { Name = channelName, EncodingType = channelType, Input = new ChannelInput() { StreamingProtocol = channelProtocol, AccessControl = new ChannelAccessControl() { IPAllowList = new IPRange[] { inputAddressRange } } }, Preview = new ChannelPreview() { AccessControl = new ChannelAccessControl() { IPAllowList = new IPRange[] { previewAddressRange } } } }; if (channelType != ChannelEncodingType.None) { channelOptions.Encoding = new ChannelEncoding() { SystemPreset = Constant.Media.Live.ChannelEncodingPreset }; } return(_media.Channels.Create(channelOptions)); }
public void TestStreamSelectionPersistence() { var channelOptions = new ChannelCreationOptions { Name = Guid.NewGuid().ToString().Substring(0, 30), Input = MakeChannelInput(), Preview = MakeChannelPreview(), Output = MakeChannelOutput(), EncodingType = ChannelEncodingType.Standard, Encoding = new ChannelEncoding { SystemPreset = "Default720p", VideoStreams = new List<VideoStream> { new VideoStream { Index = 0 } }.AsReadOnly(), AudioStreams = new List<AudioStream> { new AudioStream { Index = 1, Language = "eng" }, new AudioStream { Index = 2, Language = "fra" }, new AudioStream { Index = 3, Language = "spa" } }.AsReadOnly() } }; IChannel channel = _mediaContext.Channels.Create(channelOptions); Assert.AreEqual(channelOptions.Encoding.AudioStreams.Count, channel.Encoding.AudioStreams.Count); for (int i = 0; i < channelOptions.Encoding.AudioStreams.Count; ++i) { Assert.AreEqual(channelOptions.Encoding.AudioStreams[i].Index, channel.Encoding.AudioStreams[i].Index); Assert.AreEqual(channelOptions.Encoding.AudioStreams[i].Language, channel.Encoding.AudioStreams[i].Language); } Assert.AreEqual(channelOptions.Encoding.VideoStreams.Count, channel.Encoding.VideoStreams.Count); for (int i = 0; i < channelOptions.Encoding.VideoStreams.Count; ++i) { Assert.AreEqual(channelOptions.Encoding.VideoStreams[i].Index, channel.Encoding.VideoStreams[i].Index); } channel.Delete(); }