Пример #1
0
        private StreamDescription WaitForStreamToExitPhase(StreamStatus phaseToExit, bool useMostRecentStreamDescription = false)
        {
            int remainingTime = WaitForPhaseExitTimeout;

            if (useMostRecentStreamDescription && MostRecentStreamDescription != null && MostRecentStreamDescription.StreamStatus != phaseToExit)
            {
                return(MostRecentStreamDescription);
            }
            while (true)
            {
                StreamDescription streamDescription = DescribeStream();
                if (streamDescription == null)
                {
                    Assert.Fail();
                }
                if (streamDescription.StreamStatus != phaseToExit)
                {
                    return(streamDescription);
                }
                if (remainingTime < 0)
                {
                    Assert.Fail();
                }
                Thread.Sleep(SleepTime * 1000);
                remainingTime -= SleepTime;
            }
        }
Пример #2
0
        private static StreamDescription GetStreamDescription(ResponseMessageStream stream)
        {
            var description = new StreamDescription()
            {
                Id = stream.Id.ToString("D"),
            };

            if (stream.Content.Headers.TryGetValues(HeaderNames.ContentType, out IEnumerable <string> contentType))
            {
                description.ContentType = contentType?.FirstOrDefault();
            }

            if (stream.Content.Headers.TryGetValues(HeaderNames.ContentLength, out IEnumerable <string> contentLength))
            {
                var value = contentLength?.FirstOrDefault();
                if (value != null && int.TryParse(value, out int length))
                {
                    description.Length = length;
                }
            }
            else
            {
                description.Length = (int?)stream.Content.Headers.ContentLength;
            }

            return(description);
        }
Пример #3
0
        public bool ChangeStream(StreamDescription stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream), "stream cannot be null");
            }

            if (availableStreams.Count <= stream.Id)
            {
                throw new ArgumentOutOfRangeException();
            }

            var newMedia          = availableStreams[stream.Id].Media;
            var newRepresentation = availableStreams[stream.Id].Representation;

            var newStream = new DashStream(newMedia, newRepresentation);

            if (currentStream.Media.Type.Value != newMedia.Type.Value)
            {
                throw new ArgumentException("wrong media type");
            }

            if (newStream.Equals(currentStream))
            {
                Logger.Info($"Selected stream {stream.Id} {stream.Description} already playing. Not changing.");
                return(false);
            }

            SetStream(newStream);
            Logger.Info($"Stream {stream.Id} {stream.Description} set.");
            return(true);
        }
        private void CameraInitialized(HoloLensCamera sender, bool initializeSuccessful)
        {
            DebugLog("HoloLensCamera initialized");
            StreamDescription streamDesc = sender.StreamSelector.Select(StreamCompare.EqualTo, 1280, 720).StreamDescriptions[0];

            sender.Start(streamDesc);
        }
Пример #5
0
        private void OnChangeActiveSubtitleStream(StreamDescription description)
        {
            var found = currentClip.Subtitles?.First(info => info.Id == description.Id);

            if (found == null)
            {
                throw new ArgumentException();
            }
            cuesMap = new SubtitleFacade().LoadSubtitles(found);
        }
Пример #6
0
        public void OnChangeActiveStream(StreamDescription stream)
        {
            if (stream.StreamType == StreamType.Subtitle)
            {
                OnChangeActiveSubtitleStream(stream);
                return;
            }

            throw new NotImplementedException();
        }
Пример #7
0
        public void OnChangeActiveStream_UnknownSubtitles_ThrowsArgumentException()
        {
            var demuxerMock       = Substitute.For <IDemuxerController>();
            var clipDefinition    = new ClipDefinition();
            var dataProvider      = new HLSDataProvider(demuxerMock, clipDefinition);
            var streamDescription = new StreamDescription
            {
                StreamType = StreamType.Subtitle
            };

            Assert.Throws <ArgumentException>(() => dataProvider.ChangeActiveStream(streamDescription));
        }
Пример #8
0
    private void OnCameraInitialized(HoloLensCamera sender, bool initializeSuccessful)
    {
        // choose the first video with 720p resolution
        StreamDescription streamDesc = pvCamera.StreamSelector.Select(StreamCompare.EqualTo, 1280, 720).StreamDescriptions[0];

        Debug.Log($"Selecting {streamDesc.Resolution.Width}x{streamDesc.Resolution.Height}@{streamDesc.Resolution.Framerate}fps");

        // initialized, but not running
        pvCamera.Start(streamDesc);

        Debug.Log("Starting camera");
        startCamera = true;
    }
Пример #9
0
        public void DescribeStreamTest()
        {
            StreamDescription streamDescription = DescribeStream();

            if (streamDescription == null)
            {
                Assert.Fail();
            }
            Utils.AssertFalse(streamDescription.HasMoreShards);
            Utils.AssertFalse(string.IsNullOrEmpty(streamDescription.StreamARN));
            Assert.AreEqual(StreamName, streamDescription.StreamName);
            Utils.AssertTrue(streamDescription.StreamStatus == StreamStatus.CREATING || streamDescription.StreamStatus == StreamStatus.ACTIVE);
        }
Пример #10
0
        public async Task ChangeActiveStream(StreamDescription streamDescription)
        {
            // Change stream and seek to "current time". Forces new presentation to be played as soon as
            // seek completes.
            var canReposition = dataProvider.ChangeActiveStream(streamDescription) &&
                                dataProvider.IsSeekingSupported() &&
                                (streamDescription.StreamType == StreamType.Video || streamDescription.StreamType == StreamType.Audio);

            if (!canReposition)
            {
                return;
            }

            await SeekTo(CurrentPosition);
        }
Пример #11
0
        public Task ChangeActiveStream(StreamDescription streamDescription)
        {
            Logger.Info($"ChangeActiveStream {streamDescription.StreamType} {streamDescription.Id} {streamDescription.Description}");

            var isAV = streamDescription.StreamType == StreamType.Audio ||
                       streamDescription.StreamType == StreamType.Video;

            if (!isAV)
            {
                dataProvider.ChangeActiveStream(streamDescription);
                return(Task.CompletedTask);
            }

            return(playerController.OnRepresentationChanged(streamDescription));
        }
Пример #12
0
        public SubtitleInfo GetSubtitleInfo(StreamDescription description)
        {
            // Subtitle Infos gets cleared/updated during manifest reloads
            // no locks = possible false positives when checking subtitleInfos.Count.
            //
            lock (subtitleInfos)
            {
                if (description.Id >= subtitleInfos.Count)
                {
                    throw new ArgumentException("Invalid subtitle description");
                }

                // Create a copy!
                return(new SubtitleInfo(subtitleInfos[description.Id]));
            }
        }
Пример #13
0
        public void IncreaseAndDecreaseStreamRetentionTest()
        {
            StreamDescription streamDescription = WaitForStreamToExitPhase(StreamStatus.CREATING, true);

            Assert.AreEqual(StreamStatus.ACTIVE, streamDescription.StreamStatus);

            var            retentionHours    = streamDescription.RetentionPeriodHours;
            var            newRetentionHours = retentionHours * 2;
            AutoResetEvent ars = new AutoResetEvent(false);
            Exception      responseException = new Exception();

            Client.IncreaseStreamRetentionPeriodAsync(new IncreaseStreamRetentionPeriodRequest
            {
                StreamName           = StreamName,
                RetentionPeriodHours = newRetentionHours
            }, (response) =>
            {
                responseException = response.Exception;
                ars.Set();
            }, new AsyncOptions {
                ExecuteCallbackOnMainThread = false
            });
            ars.WaitOne();

            Assert.IsNull(responseException);
            streamDescription = WaitForStreamToExitPhase(StreamStatus.UPDATING);
            Assert.AreEqual(StreamStatus.ACTIVE, streamDescription.StreamStatus);
            Assert.AreEqual(newRetentionHours, streamDescription.RetentionPeriodHours);

            Client.DecreaseStreamRetentionPeriodAsync(new DecreaseStreamRetentionPeriodRequest
            {
                StreamName           = StreamName,
                RetentionPeriodHours = retentionHours
            }, (response) =>
            {
                responseException = response.Exception;
                ars.Set();
            }, new AsyncOptions {
                ExecuteCallbackOnMainThread = false
            });
            ars.WaitOne();

            Assert.IsNull(responseException);
            streamDescription = WaitForStreamToExitPhase(StreamStatus.UPDATING);
            Assert.AreEqual(StreamStatus.ACTIVE, streamDescription.StreamStatus);
            Assert.AreEqual(retentionHours, streamDescription.RetentionPeriodHours);
        }
Пример #14
0
        public void OnChangeActiveStream(StreamDescription stream)
        {
            switch (stream.StreamType)
            {
            case StreamType.Audio:
                audioPipeline.ChangeStream(stream);
                break;

            case StreamType.Video:
                videoPipeline.ChangeStream(stream);
                break;

            case StreamType.Subtitle:
                OnChangeActiveSubtitleStream(stream);
                break;
            }
        }
Пример #15
0
        public void ChangeStream(StreamDescription stream)
        {
            Logger.Info("");

            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream), "stream cannot be null");
            }

            if (availableStreams.Count <= stream.Id)
            {
                throw new ArgumentOutOfRangeException();
            }

            var newMedia          = availableStreams[stream.Id].Media;
            var newRepresentation = availableStreams[stream.Id].Representation;

            // Share lock with switchStreamIfNeeded. Change stream may happen on a separate thread.
            // As such, we do not want 2 starts happening
            // - One as a manual stream selection
            // - One as a adaptive stream switching.
            //
            lock (switchStreamLock)
            {
                var newStream = new DashStream(newMedia, newRepresentation);

                if (currentStream.Media.Type.Value != newMedia.Type.Value)
                {
                    throw new ArgumentException("wrong media type");
                }

                DisableAdaptiveStreaming = true;

                FlushPipeline().ContinueWith(task =>
                {
                    if (task.Status == TaskStatus.RanToCompletion)
                    {
                        StartPipeline(newStream);
                    }
                },
                                             TaskScheduler.FromCurrentSynchronizationContext());
            }
        }
Пример #16
0
        public bool ChangeActiveStream(StreamDescription stream)
        {
            Logger.Info("");

            switch (stream.StreamType)
            {
            case StreamType.Audio:
                return(audioPipeline.ChangeStream(stream));

            case StreamType.Video:
                return(videoPipeline.ChangeStream(stream));

            case StreamType.Subtitle:
                OnChangeActiveSubtitleStream(stream);
                return(true);
            }

            return(false);
        }
Пример #17
0
        public void ChangeActiveStream(StreamDescription stream)
        {
            Logger.Info("");

            switch (stream.StreamType)
            {
            case StreamType.Audio:
                audioPipeline.ChangeStream(stream);
                break;

            case StreamType.Video:
                videoPipeline.ChangeStream(stream);
                break;

            case StreamType.Subtitle:
                OnChangeActiveSubtitleStream(stream);
                return;

            default:
                return;
            }
        }
Пример #18
0
        public async Task <bool> UpdateStormEvent(string update)
        {
            try
            {
                var kcsb = new KustoConnectionStringBuilder(_options.ADXCluster, _options.ADXDatabase)
                           .WithAadUserPromptAuthentication();

                using (var queryProvider = KustoIngestFactory.CreateDirectIngestClient(kcsb))
                {
                    // Ingest from a file according to the required properties
                    var kustoIngestionProperties = new KustoQueuedIngestionProperties(databaseName: _options.ADXDatabase, tableName: _options.ADXTable)
                    {
                        // Setting the report level to FailuresAndSuccesses will cause both successful and failed ingestions to be reported
                        // (Rather than the default "FailuresOnly" level - which is demonstrated in the
                        // 'Ingest From Local File(s) using KustoQueuedIngestClient and Ingestion Validation' section)
                        ReportLevel = IngestionReportLevel.FailuresAndSuccesses,
                        // Choose the report method of choice. 'Queue' is the default method.
                        // For the sake of the example, we will choose it anyway.
                        ReportMethod = IngestionReportMethod.Queue,
                        Format       = DataSourceFormat.json
                    };

                    StreamDescription sd = new StreamDescription
                    {
                        SourceId = Guid.NewGuid(),
                        Stream   = GenericHelper.GenerateStreamFromString(update)
                    };

                    await queryProvider.IngestFromStreamAsync(sd, kustoIngestionProperties);
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #19
0
        private StreamDescription DescribeStream()
        {
            StreamDescription streamDescription = null;
            Exception         responseException = new Exception();
            AutoResetEvent    ars = new AutoResetEvent(false);

            Client.DescribeStreamAsync(new DescribeStreamRequest
            {
                StreamName = StreamName
            }, (response) =>
            {
                responseException = response.Exception;
                if (responseException == null)
                {
                    streamDescription           = response.Response.StreamDescription;
                    MostRecentStreamDescription = streamDescription;
                }
                ars.Set();
            }, new AsyncOptions {
                ExecuteCallbackOnMainThread = false
            });
            ars.WaitOne();
            return(streamDescription);
        }
Пример #20
0
 public void OnChangeActiveStream(StreamDescription stream)
 {
     throw new NotImplementedException();
 }
Пример #21
0
 public Task ChangeActiveStream(StreamDescription streamDescription)
 {
     return(playerThread.Factory.StartNew(async() => await proxied.ChangeActiveStream(streamDescription)));
 }
Пример #22
0
        private void OnChangeActiveSubtitleStream(StreamDescription description)
        {
            var subtitleInfo = manifestProvider.GetSubtitleInfo(description);

            cuesMap = new SubtitleFacade().LoadSubtitles(subtitleInfo);
        }
Пример #23
0
 public void ChangeActiveStream(StreamDescription streamDescription)
 {
     dataProvider.OnChangeActiveStream(streamDescription);
 }
Пример #24
0
 public override string ToString()
 {
     return($"{Id}: ({Latitude}, {Longitude}) --> {StreamDescription.Pretty()}");
 }
Пример #25
0
 public void ChangeActiveStream(StreamDescription streamDescription)
 {
     playerThread.Factory.StartNew(() => proxied.ChangeActiveStream(streamDescription));
 }