Esempio n. 1
0
        /// <summary>
        /// Updates each active video sink.
        /// </summary>
        /// <returns>A completed task indicating all video sinks have finished updating.</returns>
        private Task UpdateVideoSinks()
        {
            for (int i = 0; i < Instance.sinks.Count; ++i)
            {
                MLWebRTC.Sink sink = Instance.sinks[i];
                if (sink.Type != MediaStream.Track.Type.Video)
                {
                    continue;
                }
                ((MLWebRTC.VideoSink)sink).UpdateVideoSink();
            }

            return(Task.CompletedTask);
        }
Esempio n. 2
0
        /// <summary>
        /// Updates each video sink on a seperate thread and then calls InvokeOnNewFrame() to propagate any new frames to the main thread.
        /// </summary>
        private async Task ProcessVideoSinksAsync()
        {
            IsProcessingSinks = true;

            // Runs the UpdateVideoSinks on another thread and awaits the result.
            await Task.Run(UpdateVideoSinks);

            for (int i = 0; i < Instance.sinks.Count; ++i)
            {
                MLWebRTC.Sink sink = Instance.sinks[i];
                if (sink.Type != MediaStream.Track.Type.Video)
                {
                    continue;
                }
                ((MLWebRTC.VideoSink)sink).InvokeOnNewFrame();
            }
            IsProcessingSinks = false;
        }