Beispiel #1
0
        private void Cam_OnVideoNewFrame(Bitmap bitmap, byte[] buffer)
        {
            pictureBox1.Image = bitmap;
            StreamingProtocol ptc    = new StreamingProtocol();
            Thread            thread = new Thread(delegate()
            {
                Image img    = null;
                byte[] arr   = new byte[1024];
                ptc.StreamID = "minhduc";
                lock (synlock)
                {
                    arr = ImageConverter.ImageConverter.ConvertImageToByteArray(bitmap);
                }
                ptc.Image = arr;
                ptc.Sound = buffer;
                lock (synlock1)
                {
                    img = ImageConverter.ImageConverter.CovertByteArrayToImage(arr);
                }
                pictureBox2.Image = img;
            });

            thread.Start();



            richTextBox2.Invoke(new MethodInvoker(delegate()
            {
                richTextBox2.Text = "";
                foreach (var item in buffer)
                {
                    richTextBox2.AppendText(item.ToString());
                }
            }));
        }
 public static ChannelInput ConfigureDefaultInput(StreamingProtocol protocol, List <IPRange> allowList)
 {
     return(new ChannelInput
     {
         StreamingProtocol = protocol,
         AccessControl = allowList.CreateChannelAccessControl()
     });
 }
Beispiel #3
0
        public void SendStream(string streamID, byte[] image, byte[] sound, EndPoint client)
        {
            StreamingProtocol streamProtocol = new StreamingProtocol();

            streamProtocol.Image    = image;
            streamProtocol.Sound    = sound;
            streamProtocol.StreamID = streamID;
            SendPacket(2, streamProtocol.ToBytes(), client);
        }
        public void SendStream(string streamID, byte[] image, byte[] sound, IPEndPoint server)
        {
            StreamingProtocol protocol = new StreamingProtocol();

            protocol.Image    = image;
            protocol.Sound    = sound;
            protocol.StreamID = streamID;
            SendPacket(2, server, protocol.ToBytes());
        }
Beispiel #5
0
        public void CreateChannel(string channelName)
        {
            ChannelEncodingType channelType    = ChannelEncodingType.None;
            StreamingProtocol   ingestProtocol = StreamingProtocol.RTMP;
            IChannel            channel        = CreateChannel(channelName, channelType, ingestProtocol);

            foreach (IProgram program in channel.Programs)
            {
                CreateLocator(null, LocatorType.OnDemandOrigin, program.Asset, null);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Read UDP network data.
        /// </summary>
        private void read()
        {
            stopListening = false;

            udpClient = new UdpClient(listenPort);
            IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, listenPort);

            try
            {
                while (!stopListening)
                {
                    byte[] receiveBytes = udpClient.Receive(ref groupEP);

                    string result = "";
                    result += (char)(receiveBytes[4]);
                    result += (char)(receiveBytes[5]);
                    StreamingProtocol packId = (StreamingProtocol)Int32.Parse(result);

                    if (packId == StreamingProtocol.SPPoseQuaternion)
                    {
                        if (receiveBytes.Length > 15)
                        {
                            int streamID = receiveBytes[16];
                            if (streamID >= 0 && streamID < NUM_STREAMS)
                            {
                                if (segmentCounts[streamID] == 0)
                                {
                                    segmentCounts[streamID] = receiveBytes.Length / 32;
                                }
                                poseActors[streamID].setPacket(receiveBytes);
                                availableStreams[streamID] = true;
                            }
                        }
                    }
                    else if (packId == StreamingProtocol.SPPoseUnity3D)
                    {
                        Debug.LogError("[xsens] Unity3D protocol no longer supported. Please uncheck this datapacket in the Network Streamer preferences in MVN Studio");
                    }
                }
            }
            catch (Exception e)
            {
                Debug.Log(e);
                Debug.Log("[xsens] XsStreamReader terminated");
                Console.WriteLine("[xsens] XsStreamReader terminated.");
            }
            finally
            {
                udpClient.Close();
                udpClient = null;
            }
        }
 /// <summary>
 /// Creates an Ingest channel
 /// </summary>
 /// <param name="ipRangeName"></param>
 /// <returns></returns>
 private ChannelInput CreateChannelInput(StreamingProtocol streamingProtocol)
 {
     return(new ChannelInput
     {
         StreamingProtocol = streamingProtocol,
         AccessControl = new ChannelAccessControl
         {
             IPAllowList = new List <IPRange>
             {
                 allowAllIPRange
             }
         }
     });
 }
        public string CreateChannel(string channelName, MediaEncoding channelEncoding, MediaProtocol inputProtocol,
                                    string inputAddressAuthorized, int?inputSubnetPrefixLength,
                                    string previewAddressAuthorized, int?previewSubnetPrefixLength,
                                    int?archiveWindowMinutes, bool archiveEncryption)
        {
            ChannelEncodingType channelType     = (ChannelEncodingType)channelEncoding;
            StreamingProtocol   channelProtocol = (StreamingProtocol)inputProtocol;
            IChannel            channel         = CreateChannel(channelName, channelType, channelProtocol, inputAddressAuthorized, inputSubnetPrefixLength, previewAddressAuthorized, previewSubnetPrefixLength);

            CreatePrograms(channel, archiveWindowMinutes, archiveEncryption);
            foreach (IProgram program in channel.Programs)
            {
                CreateLocator(LocatorType.OnDemandOrigin, program.Asset);
            }
            return(channel.Id);
        }
 public static ChannelCreationOptions CreateNewChannelOptions(
     string name,
     ChannelEncodingType encodingType,
     StreamingProtocol protocol,
     string encodingPreset,
     string slateAssetId
     )
 {
     return(new ChannelCreationOptions
     {
         Name = string.Format("New-Channel-{0}", DateTime.UtcNow.ToOADate().ToString().Replace(".", "-")),
         Description = "Newly Created Channel",
         EncodingType = encodingType,
         Input = ConfigureDefaultInput(protocol, GetDefaultIpAllowList()),
         Preview = ConfigureChannelPreview(null),
         Output = new ChannelOutput(),
         Encoding = encodingType != ChannelEncodingType.None ? GetDefaultEncoding(encodingPreset) : null,
         Slate = encodingType != ChannelEncodingType.None ? GetDefaultSlate(slateAssetId) : null
     });
 }
Beispiel #10
0
        /// <summary>
        /// Creates an instance of ChannelCreationOptions class.
        /// </summary>
        /// <param name="name">Name of the channel to be created</param>
        /// <param name="inputStreamingProtocol">the Streaming Protocol of the channel input</param>
        /// <param name="inputIPAllowList">the IP allow list for the channel input access control</param>
        public ChannelCreationOptions(
            string name,
            StreamingProtocol inputStreamingProtocol,
            IEnumerable <IPRange> inputIPAllowList)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("name");
            }
            if (inputIPAllowList == null)
            {
                throw new ArgumentNullException("inputIPAllowList");
            }

            Name  = name;
            Input = new ChannelInput
            {
                StreamingProtocol = inputStreamingProtocol,
                AccessControl     = new ChannelAccessControl
                {
                    IPAllowList = (inputIPAllowList as IList <IPRange>) ?? inputIPAllowList.ToList()
                }
            };
        }
        /// <summary>
        /// Creates an instance of ChannelCreationOptions class.
        /// </summary>
        /// <param name="name">Name of the channel to be created</param>
        /// <param name="inputStreamingProtocol">the Streaming Protocol of the channel input</param>
        /// <param name="inputIPAllowList">the IP allow list for the channel input access control</param>
        public ChannelCreationOptions(
            string name, 
            StreamingProtocol inputStreamingProtocol,
            IEnumerable<IPRange> inputIPAllowList)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("name");
            }
            if (inputIPAllowList == null)
            {
                throw new ArgumentNullException("inputIPAllowList");
            }

            Name = name;
            Input = new ChannelInput
            {
                StreamingProtocol = inputStreamingProtocol,
                AccessControl = new ChannelAccessControl
                {
                    IPAllowList = (inputIPAllowList as IList<IPRange>) ?? inputIPAllowList.ToList()
                }
            };
        }
Beispiel #12
0
        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 string ReturnNameForProtocol(StreamingProtocol protocol)
        {
            string name = "";
            switch (protocol)
            {
                case StreamingProtocol.FragmentedMP4:
                    name = "Fragmented MP4 (Smooth)";
                    break;

                case StreamingProtocol.RTMP:
                    name = "RTMP";
                    break;

                case StreamingProtocol.RTPMPEG2TS:
                    name = "RTP (MPEG-TS)";
                    break;
            }
            return name;
        }
 /// <summary>
 /// Asynchronously create a new channel.
 /// </summary>
 /// <param name="name">Unique name of the channel.</param>
 /// <param name="inputProtocol">Channel input streaming protocol</param>
 /// <param name="inputIPAllowList">Channel input IP allow list</param>
 /// <returns>The channel creation task.</returns>
 public Task <IChannel> CreateAsync(string name, StreamingProtocol inputProtocol, IEnumerable <IPRange> inputIPAllowList)
 {
     return(CreateAsync(new ChannelCreationOptions(name, inputProtocol, inputIPAllowList)));
 }
        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));
        }
        /// <summary>
        /// Creates a Channel and starts it
        /// </summary>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="streamingProtocol"></param>
        /// <returns></returns>
        public async Task <IChannel> CreateChannelIfNotExistsAsync(string name, string description, StreamingProtocol streamingProtocol)
        {
            IChannel channel;

            // Check if a channel with that name exists
            channel = GetChannelByName(name);

            if (channel == null)
            {
                // Add channel to Azure Media Service
                channel = await CloudMediaContext.Channels.CreateAsync(
                    new ChannelCreationOptions
                {
                    Name        = name,
                    Description = description,
                    Input       = CreateChannelInput(streamingProtocol),
                    Preview     = CreateChannelPreview(),
                    Output      = CreateChannelOutput()
                });
            }

            // Set Cross Domain policy as needed
            UpdateCrossSiteAccessPoliciesForChannelIfNeeded(channel);

            // Start the channel
            if (channel.State != ChannelState.Starting || channel.State != ChannelState.Running)
            {
                await channel.StartAsync();
            }

            // Return channel
            return(channel);
        }
 /// <summary>
 /// Sends create channel operation to the service and returns. Use Operations collection to get operation's status.
 /// </summary>
 /// <param name="name">Unique name of the channel.</param>
 /// <param name="inputProtocol">Channel input streaming protocol</param>
 /// <param name="inputIPAllowList">Channel input IP allow list</param>
 /// <returns>Operation info that can be used to track the operation.</returns>
 public IOperation SendCreateOperation(string name, StreamingProtocol inputProtocol, IEnumerable <IPRange> inputIPAllowList)
 {
     return(SendCreateOperation(new ChannelCreationOptions(name, inputProtocol, inputIPAllowList)));
 }