Ejemplo n.º 1
0
		/// <summary>
		/// Asynchronously streams a windows screen and audio capture to a specified IP-Address.
		/// </summary>
		/// <returns>The windows screen to ip async.</returns>
		/// <param name="videoDeviceName">Video device name.</param>
		/// <param name="audioDeviceName">Audio device name.</param>
		/// <param name="ip">IP-Address.</param>
		/// <param name="mode">Streaming mode.</param>
		/// <param name="frameRate">Desired frame rate.</param>
		/// <param name="quality">Quality of compression.</param>
		public async Task<bool> StreamWindowsScreenToIpAsync (string videoDeviceName, string audioDeviceName, string ip, string port, VideoCodec vcodec, AudioCodec acodec, StreamingMode mode, int frameRate, Resolution outputSize, string videoExtras, int quality = 20) 
		{
			// TODO: -b for bitrate
			string input = string.Format (
				"-f dshow  -i video=\"{0}\":audio=\"{1}\" -r {2} -async 1 -vcodec {3} {4} -q {5} -s {6} -maxrate 750k -bufsize 3000k -acodec {7} -ab 128k",
				videoDeviceName, 
				audioDeviceName, 
				frameRate.ToString(), 
				FFmpegManager.GetCodecName(vcodec), 
				videoExtras,
				quality.ToString(),
				outputSize,
				FFmpegManager.GetCodecName(acodec)		
			);
			string output = string.Format (
				"-f mpegts udp://{0}:{1}?pkt_size=188?buffer_size=10000000?fifo_size=100000", 
				ip, 
				port
			);

			string args = input + " " + output;

			try {
				FFmpegProcess = FFmpegManager.GetFFmpegProcess(args);
			}
			catch(FileNotFoundException e) {
				throw new FileNotFoundException (e.Message, e);
			}

			FFmpegProcess.Start ();
			await Task.Run(() => FFmpegProcess.WaitForExit ());
			return true;
		}
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the SQL Azure database-based persistence queue using the specified streaming mode, data type and buffer settings.
 /// </summary>
 /// <param name="streamingMode">The type of buffer that will be used for streaming operations.</param>
 /// <param name="streamingDataType">The type of data that will be used for streaming operations.</param>
 /// <param name="initialBufferSize">The initial size of the buffer where data is being collected before flushed into a SQL Azure database.</param>
 /// <param name="maxBufferSize">The maximum allowed size of the data buffer.</param>
 public SqlAzurePersistenceQueue(StreamingMode streamingMode, StreamingDataType streamingDataType, int initialBufferSize, int maxBufferSize)
 {
     this.streamingMode         = streamingMode;
     this.streamingDataType     = streamingDataType;
     this.initialBufferSize     = initialBufferSize;
     this.maxBufferSize         = maxBufferSize;
     this.connectionRetryPolicy = RetryPolicyFactory.GetDefaultSqlConnectionRetryPolicy();
     this.commandRetryPolicy    = RetryPolicyFactory.GetDefaultSqlCommandRetryPolicy();
 }
Ejemplo n.º 3
0
        internal static IEnumerable <TarHeader> ReadHeader(StreamingMode mode, Stream stream, Encoding forceEncoding)
        {
            while (true)
            {
                TarHeader header = null;
                try
                {
                    BinaryReader reader = new BinaryReader(stream);
                    header = new TarHeader()
                    {
                        ForceEncoding = forceEncoding
                    };

                    if (!header.Read(reader))
                    {
                        yield break;
                    }
                    switch (mode)
                    {
                    case StreamingMode.Seekable:
                    {
                        header.DataStartPosition = reader.BaseStream.Position;

                        //skip to nearest 512
                        reader.BaseStream.Position += PadTo512(header.Size);
                    }
                    break;

                    case StreamingMode.Streaming:
                    {
                        header.PackedStream = new TarReadOnlySubStream(stream, header.Size);
                    }
                    break;

                    default:
                    {
                        throw new InvalidFormatException("Invalid StreamingMode");
                    }
                    }
                }
                catch
                {
                    header = null;
                }
                yield return(header);
            }
        }
Ejemplo n.º 4
0
 internal static IEnumerable <TarEntry> GetEntries(StreamingMode mode, Stream stream, CompressionType compressionType)
 {
     foreach (TarHeader h in TarHeaderFactory.ReadHeader(mode, stream))
     {
         if (h != null)
         {
             if (mode == StreamingMode.Seekable)
             {
                 yield return(new TarEntry(new TarFilePart(h, stream), compressionType));
             }
             else
             {
                 yield return(new TarEntry(new TarFilePart(h, null), compressionType));
             }
         }
     }
 }
Ejemplo n.º 5
0
        internal static IEnumerable <TarEntry> GetEntries(StreamingMode mode, Stream stream, SharpCompress.Common.CompressionType compressionType)
        {
            foreach (TarHeader iteratorVariable0 in TarHeaderFactory.ReadHeader(mode, stream))
            {
                if (iteratorVariable0 == null)
                {
                    continue;
                }
                if (mode == StreamingMode.Seekable)
                {
                    yield return(new TarEntry(new TarFilePart(iteratorVariable0, stream), compressionType));

                    continue;
                }
                yield return(new TarEntry(new TarFilePart(iteratorVariable0, null), compressionType));
            }
        }
Ejemplo n.º 6
0
 internal static IEnumerable<TarEntry> GetEntries(StreamingMode mode, Stream stream, CompressionType compressionType)
 {
     foreach (TarHeader h in TarHeaderFactory.ReadHeader(mode, stream))
     {
         if (h != null)
         {
             if (mode == StreamingMode.Seekable)
             {
                 yield return new TarEntry(new TarFilePart(h, stream), compressionType);
             }
             else
             {
                 yield return new TarEntry(new TarFilePart(h, null), compressionType);
             }
         }
     }
 }
Ejemplo n.º 7
0
        internal static IEnumerable <TarHeader> ReadHeader(StreamingMode mode, Stream stream)
        {
            TarHeader iteratorVariable0;
            bool      flag2;

            goto Label_012E;
Label_010E:
            yield return(iteratorVariable0);

Label_012E:
            flag2             = true;
            iteratorVariable0 = null;
            try
            {
                BinaryReader reader = new BinaryReader(stream);
                iteratorVariable0 = new TarHeader();
                if (iteratorVariable0.Read(reader))
                {
                    switch (mode)
                    {
                    case StreamingMode.Streaming:
                        iteratorVariable0.PackedStream = new TarReadOnlySubStream(stream, iteratorVariable0.Size);
                        goto Label_010E;

                    case StreamingMode.Seekable:
                    {
                        iteratorVariable0.DataStartPosition = new long?(reader.BaseStream.Position);
                        Stream baseStream = reader.BaseStream;
                        baseStream.Position += PadTo512(iteratorVariable0.Size);
                        goto Label_010E;
                    }
                    }
                    throw new InvalidFormatException("Invalid StreamingMode");
                }
                goto Label_0135;
            }
            catch
            {
                iteratorVariable0 = null;
            }
            goto Label_010E;
            Label_0135 :;
        }
Ejemplo n.º 8
0
        internal static IEnumerable<TarHeader> ReadHeader(StreamingMode mode, Stream stream)
        {
            TarHeader iteratorVariable0;
            bool flag2;
            goto Label_012E;
            Label_010E:
            yield return iteratorVariable0;
            Label_012E:
            flag2 = true;
            iteratorVariable0 = null;
            try
            {
                BinaryReader reader = new BinaryReader(stream);
                iteratorVariable0 = new TarHeader();
                if (iteratorVariable0.Read(reader))
                {
                    switch (mode)
                    {
                        case StreamingMode.Streaming:
                            iteratorVariable0.PackedStream = new TarReadOnlySubStream(stream, iteratorVariable0.Size);
                            goto Label_010E;

                        case StreamingMode.Seekable:
                        {
                            iteratorVariable0.DataStartPosition = new long?(reader.BaseStream.Position);
                            Stream baseStream = reader.BaseStream;
                            baseStream.Position += PadTo512(iteratorVariable0.Size);
                            goto Label_010E;
                        }
                    }
                    throw new InvalidFormatException("Invalid StreamingMode");
                }
                goto Label_0135;
            }
            catch
            {
                iteratorVariable0 = null;
            }
            goto Label_010E;
            Label_0135:;
        }
Ejemplo n.º 9
0
 internal static IEnumerable<TarHeader> ReadHeader(StreamingMode mode, Stream stream)
 {
     while (true)
     {
         TarHeader header = null;
         try
         {
             BinaryReader reader = new BinaryReader(stream);
             header = new TarHeader();
             if (!header.Read(reader))
             {
                 yield break;
             }
             switch (mode)
             {
                 case StreamingMode.Seekable:
                     {
                         header.DataStartPosition = reader.BaseStream.Position;
                         //skip to nearest 512
                         reader.BaseStream.Position += PadTo512(header.Size);
                     }
                     break;
                 case StreamingMode.Streaming:
                     {
                         header.PackedStream = new TarReadOnlySubStream(stream, header.Size);
                     }
                     break;
                 default:
                     {
                         throw new InvalidFormatException("Invalid StreamingMode");
                     }
             }
         }
         catch
         {
             header = null;
         }
         yield return header;
     }
 }
Ejemplo n.º 10
0
 internal RarVolume(StreamingMode mode, RarOptions options)
 {
     this.options = options;
     headerFactory = new RarHeaderFactory(mode, options);
 }
Ejemplo n.º 11
0
        private const int MAX_SFX_SIZE = 0x80000 - 16; //archive.cpp line 136

        internal RarHeaderFactory(StreamingMode mode, Options options, string password = null)
        {
            StreamingMode = mode;
            Options       = options;
            Password      = password;
        }
Ejemplo n.º 12
0
 internal static IEnumerable<TarEntry> GetEntries(StreamingMode mode, Stream stream, SharpCompress.Common.CompressionType compressionType)
 {
     foreach (TarHeader iteratorVariable0 in TarHeaderFactory.ReadHeader(mode, stream))
     {
         if (iteratorVariable0 == null)
         {
             continue;
         }
         if (mode == StreamingMode.Seekable)
         {
             yield return new TarEntry(new TarFilePart(iteratorVariable0, stream), compressionType);
             continue;
         }
         yield return new TarEntry(new TarFilePart(iteratorVariable0, null), compressionType);
     }
 }
Ejemplo n.º 13
0
 protected ZipHeaderFactory(StreamingMode mode, string password)
 {
     this.mode = mode;
     this.password = password;
 }
Ejemplo n.º 14
0
 internal RarVolume(StreamingMode mode, Stream stream, string password, Options options)
     : base(stream, options)
 {
     headerFactory = new RarHeaderFactory(mode, options, password);
 }
Ejemplo n.º 15
0
 protected ZipHeaderFactory(StreamingMode mode, string password)
 {
     this.mode     = mode;
     this.password = password;
 }
Ejemplo n.º 16
0
        private const int MAX_SFX_SIZE = 0x80000 - 16; //archive.cpp line 136

        internal RarHeaderFactory(StreamingMode mode, ReaderOptions options)
        {
            StreamingMode = mode;
            Options       = options;
        }
Ejemplo n.º 17
0
        private int MAX_SFX_SIZE = 0x80000 - 16; //archive.cpp line 136

        internal RarHeaderFactory(StreamingMode mode, Options options)
        {
            StreamingMode = mode;
            Options = options;
        }
Ejemplo n.º 18
0
        public static IConnectableObservable <StreamingMessage> StartStreaming(int suffix, StreamingMode mode, string param = null)
        {
            if (Tokens == null || suffix >= Tokens.Count || suffix < 0)
            {
                return(null);
            }

            try
            {
                switch (mode)
                {
                case StreamingMode.Filter:
                    if (param == null)
                    {
                        return(null);
                    }

                    return(Tokens[suffix].Streaming.FilterAsObservable(replies => "all", track => param).Publish());

                default:
                    return(null);
                }
            }
            catch (Exception e)
            {
                DebugConsole.Write(e);
                return(null);
            }
        }
Ejemplo n.º 19
0
        private const int MAX_SFX_SIZE = 0x80000 - 16; //archive.cpp line 136

        #endregion Fields

        #region Constructors

        internal RarHeaderFactory(StreamingMode mode, Options options, string password = null)
        {
            StreamingMode = mode;
            Options = options;
            Password = password;
        }
Ejemplo n.º 20
0
 internal static IEnumerable <TarHeader> ReadHeader(StreamingMode mode, Stream stream) =>
Ejemplo n.º 21
0
 internal RarArchiveVolume(StreamingMode mode, RarOptions options)
     : base(mode, options)
 {
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the SQL Azure database-based persistence queue using the specified streaming mode.
 /// </summary>
 /// <param name="streamingMode">The type of buffer that will be used for streaming operations.</param>
 public SqlAzurePersistenceQueue(StreamingMode streamingMode) : this(streamingMode, StreamingDataType.Raw)
 {
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the SQL Azure database-based persistence queue using the specified streaming mode and data type.
 /// </summary>
 /// <param name="streamingMode">The type of buffer that will be used for streaming operations.</param>
 /// <param name="streamingDataType">The type of data that will be used for streaming operations.</param>
 public SqlAzurePersistenceQueue(StreamingMode streamingMode, StreamingDataType streamingDataType) : this(streamingMode, streamingDataType, DefaultInitialBufferSize, DefaultMaxBufferSize)
 {
 }
Ejemplo n.º 24
0
 internal RarVolume(StreamingMode mode, RarOptions options)
 {
     this.options  = options;
     headerFactory = new RarHeaderFactory(mode, options);
 }
Ejemplo n.º 25
0
    public async Task <Option <MediaStream> > SelectAudioStream(
        MediaVersion version,
        StreamingMode streamingMode,
        string channelNumber,
        string preferredAudioLanguage)
    {
        if (streamingMode == StreamingMode.HttpLiveStreamingDirect &&
            string.IsNullOrWhiteSpace(preferredAudioLanguage))
        {
            _logger.LogDebug(
                "Channel {Number} is HLS Direct with no preferred audio language; using all audio streams",
                channelNumber);
            return(None);
        }

        var audioStreams = version.Streams.Filter(s => s.MediaStreamKind == MediaStreamKind.Audio).ToList();

        string language = (preferredAudioLanguage ?? string.Empty).ToLowerInvariant();

        if (string.IsNullOrWhiteSpace(language))
        {
            _logger.LogDebug("Channel {Number} has no preferred audio language code", channelNumber);
            Option <string> maybeDefaultLanguage = await _configElementRepository.GetValue <string>(
                ConfigElementKey.FFmpegPreferredLanguageCode);

            maybeDefaultLanguage.Match(
                lang => language = lang.ToLowerInvariant(),
                () =>
            {
                _logger.LogDebug("FFmpeg has no preferred audio language code; falling back to {Code}", "eng");
                language = "eng";
            });
        }

        List <string> allCodes = await _searchRepository.GetAllLanguageCodes(new List <string> {
            language
        });

        if (allCodes.Count > 1)
        {
            _logger.LogDebug("Preferred audio language has multiple codes {Codes}", allCodes);
        }

        var correctLanguage = audioStreams.Filter(
            s => allCodes.Any(
                c => string.Equals(
                    s.Language,
                    c,
                    StringComparison.InvariantCultureIgnoreCase))).ToList();

        if (correctLanguage.Any())
        {
            _logger.LogDebug(
                "Found {Count} audio streams with preferred audio language code(s) {Code}; selecting stream with most channels",
                correctLanguage.Count,
                allCodes);

            return(correctLanguage.OrderByDescending(s => s.Channels).Head());
        }

        _logger.LogDebug(
            "Unable to find audio stream with preferred audio language code(s) {Code}; selecting stream with most channels",
            allCodes);

        return(audioStreams.OrderByDescending(s => s.Channels).Head());
    }
Ejemplo n.º 26
0
 protected ZipHeaderFactory(StreamingMode mode, string password, Encoding forceEncoding)
 {
     this.mode          = mode;
     this.password      = password;
     this.forceEncoding = forceEncoding;
 }
Ejemplo n.º 27
0
    public async Task <Option <Subtitle> > SelectSubtitleStream(
        MediaVersion version,
        List <Subtitle> subtitles,
        StreamingMode streamingMode,
        string channelNumber,
        string preferredSubtitleLanguage,
        ChannelSubtitleMode subtitleMode)
    {
        if (subtitleMode == ChannelSubtitleMode.None)
        {
            return(None);
        }

        if (streamingMode == StreamingMode.HttpLiveStreamingDirect &&
            string.IsNullOrWhiteSpace(preferredSubtitleLanguage))
        {
            // _logger.LogDebug(
            //     "Channel {Number} is HLS Direct with no preferred subtitle language; using all subtitle streams",
            //     channel.Number);
            return(None);
        }

        string language = (preferredSubtitleLanguage ?? string.Empty).ToLowerInvariant();

        if (string.IsNullOrWhiteSpace(language))
        {
            _logger.LogDebug("Channel {Number} has no preferred subtitle language code", channelNumber);
        }
        else
        {
            // filter to preferred language
            List <string> allCodes = await _searchRepository.GetAllLanguageCodes(new List <string> {
                language
            });

            subtitles = subtitles
                        .Filter(
                s => allCodes.Any(c => string.Equals(s.Language, c, StringComparison.InvariantCultureIgnoreCase)))
                        .ToList();
        }

        if (subtitles.Count > 0)
        {
            switch (subtitleMode)
            {
            case ChannelSubtitleMode.Forced:
                foreach (Subtitle subtitle in subtitles.OrderBy(s => s.StreamIndex).Find(s => s.Forced))
                {
                    return(subtitle);
                }

                break;

            case ChannelSubtitleMode.Default:
                foreach (Subtitle subtitle in subtitles.OrderBy(s => s.Default ? 0 : 1).ThenBy(s => s.StreamIndex))
                {
                    return(subtitle);
                }

                break;

            case ChannelSubtitleMode.Any:
                foreach (Subtitle subtitle in subtitles.OrderBy(s => s.StreamIndex).HeadOrNone())
                {
                    return(subtitle);
                }

                break;
            }
        }

        _logger.LogDebug(
            "Found no subtitles for channel {ChannelNumber} with mode {Mode} matching language {Language}",
            channelNumber,
            subtitleMode,
            preferredSubtitleLanguage);

        return(None);
    }
Ejemplo n.º 28
0
 protected ZipHeaderFactory(StreamingMode mode, string password, ArchiveEncoding archiveEncoding)
 {
     this._mode            = mode;
     this._password        = password;
     this._archiveEncoding = archiveEncoding;
 }
Ejemplo n.º 29
0
 internal RarVolume(StreamingMode mode, Stream stream, Options options)
     : this(mode, stream, null, options)
 {
 }
Ejemplo n.º 30
0
        static void Main(string[] args)
        {
            APIWrapper api = new APIWrapper();

            // Search for devices.
            int[]        devID   = null;
            string[]     devSN   = null;
            string[]     devType = null;
            ReturnStatus rs      = api.DEVICE_Search(ref devID, ref devSN, ref devType);

            // Reset and connect to the first device detected.
            rs = api.DEVICE_Reset(devID[0]);
            rs = api.DEVICE_Connect(devID[0]);

            // The following is an example on how to use the return status of an API function.
            // For simplicity, it will not be used in the rest of the program.
            // This is a fatal error: the device could not be connected.
            if (rs != ReturnStatus.noError)
            {
                Console.WriteLine("\nERROR: " + rs);
                goto end;
            }
            else // print the name of the connected device.
            {
                Console.WriteLine("\nCONNECTED TO: " + devType[0]);
            }

            // Set the center frequency and reference level.
            rs = api.CONFIG_SetCenterFreq(103.3e6);
            rs = api.CONFIG_SetReferenceLevel(-10);

            // Define parameters for file output.
            int           msec     = 5;                                 // Time to record.
            int           numfiles = 10;                                // Number of files to output.
            string        fn       = "IFSTREAM";                        // Output file name base.
            string        fp       = ".";                               // Output file path.
            StreamingMode fmode    = StreamingMode.StreamingModeFramed; // Set the streaming mode.
            int           fnsuffix = -1;                                // Filename suffix.

            // Prepare for streaming.
            rs = api.IFSTREAM_SetDiskFilePath(fp);
            rs = api.IFSTREAM_SetDiskFilenameBase(fn);
            rs = api.IFSTREAM_SetDiskFilenameSuffix(fnsuffix);
            rs = api.IFSTREAM_SetDiskFileMode(fmode);
            rs = api.IFSTREAM_SetDiskFileLength(msec);
            rs = api.IFSTREAM_SetDiskFileCount(numfiles);

            // Put the device into Run mode to begin streaming.
            rs = api.DEVICE_Run();

            // Begin streaming.
            rs = api.IFSTREAM_SetEnable(true);
            Console.WriteLine("\nIF Streaming has started...");
            bool isActive = true;

            // While IFSTREAM has Active status, continue streaming.
            while (isActive)
            {
                rs = api.IFSTREAM_GetActiveStatus(ref isActive);
            }

            // Disconnect the device and finish up.
            rs = api.IFSTREAM_SetEnable(false);

            rs = api.DEVICE_Stop();
            rs = api.DEVICE_Disconnect();

end:
            Console.WriteLine("\nIF Data to R3F routine complete.");
            Console.WriteLine("\nPress enter key to exit...");
            Console.ReadKey();
        }
Ejemplo n.º 31
0
 internal RarVolume(StreamingMode mode, Stream stream, string password, Options options)
     : base(stream, options)
 {
     headerFactory = new RarHeaderFactory(mode, options, password);
 }
Ejemplo n.º 32
0
 internal RarVolume(StreamingMode mode, Stream stream, ReaderOptions options)
     : base(stream, options)
 {
     _headerFactory = new RarHeaderFactory(mode, options);
 }
Ejemplo n.º 33
0
 internal RarArchiveVolume(StreamingMode mode, RarOptions options)
     : base(mode, options)
 {
 }
Ejemplo n.º 34
0
 internal RarVolume(StreamingMode mode, Stream stream,  Options options)
     : this(mode, stream, null, options)
 {
 }
Ejemplo n.º 35
0
 internal RarHeaderFactory(StreamingMode mode, Options options)
     : this(mode, options, null)
 {
 }
Ejemplo n.º 36
0
 internal RarHeaderFactory(StreamingMode mode, Options options)
     : this(mode, options, null)
 {
 }
Ejemplo n.º 37
0
 internal static IEnumerable <TarEntry> GetEntries(StreamingMode mode, Stream stream, SharpCompress.Common.CompressionType compressionType) =>