コード例 #1
0
ファイル: ChronoTests.cs プロジェクト: Grandbrain/RTSPPlayer
        public async Task <bool> TestGetUniqueTimestamp64(int numberOfTimestamps)
        {
            IEnumerable <long> GetUniqueTimestamps64()
            {
                return(Enumerable.Range(1, numberOfTimestamps)
                       .Select(_ => Chrono.GetUniqueTimestamp64())
                       .ToList());
            }

            var result = await Task.WhenAll(
                Task.Run(GetUniqueTimestamps64),
                Task.Run(GetUniqueTimestamps64),
                Task.Run(GetUniqueTimestamps64));

            return(result.GroupBy(item => item).All(group => group.Count() == 1));
        }
コード例 #2
0
ファイル: MediaSystem.cs プロジェクト: Grandbrain/RTSPPlayer
        /// <summary>
        /// Creates a new network frame.
        /// </summary>
        /// <param name="systemName">System name.</param>
        /// <param name="streamName">Stream name.</param>
        /// <param name="totalFramesReceived">Total number of frames received by the media stream so far.</param>
        /// <param name="mediaFrame">Media frame.</param>
        /// <param name="metadataRequired">Indicates whether to include metadata.</param>
        /// <returns>A new network frame.</returns>
        private static NetworkFrame CreateNetworkFrame(string systemName, string streamName, int totalFramesReceived,
                                                       RawFrame mediaFrame, bool metadataRequired)
        {
            byte interpretation = mediaFrame switch
            {
                RawAudioFrame _ => 1,
                RawVideoFrame _ => 2,
                 _ => 0
            };

            return(new NetworkFrame(
                       (ulong)Chrono.GetUniqueTimestamp64(),
                       (uint)totalFramesReceived,
                       interpretation,
                       systemName,
                       streamName,
                       CreateDataSegments(mediaFrame, metadataRequired)));
        }