Exemple #1
0
        public void Attach(IStreamConsumer consumer)
        {
            if (!consumer.AcceptType.IsAssignableFrom(ValueType))
            {
                throw new ArgumentException($"Type not match, streamer value type: {ValueType}, consumer accept type: {consumer.AcceptType}");
            }
            var priority = consumer.Priority;

            try
            {
                _consumersLock.EnterWriteLock();
                if (!_consumers.IsEmpty())
                {
                    if (_consumers.Contains(consumer))
                    {
                        throw new ArgumentException("The given consumer is already attached");
                    }
                    var node = _consumers.First;
                    while (node != null)
                    {
                        if (node.Value.Priority > priority)
                        {
                            _consumers.AddBefore(node, consumer);
                            return;
                        }
                        node = node.Next;
                    }
                }
                _consumers.AddLast(consumer);
            }
            finally
            {
                _consumersLock.ExitWriteLock();
            }
        }
Exemple #2
0
 public NumberController(
     IDistributedLog distributedLog,
     IStreamConsumer consumer,
     ITopicNamingConvention namingConvention, ILogger <NumberController> logger)
 {
     _distributedLog   = distributedLog;
     _consumer         = consumer;
     _namingConvention = namingConvention;
     _logger           = logger;
 }
Exemple #3
0
 public EventProjector(
     IStreamConsumer streamConsumer,
     ITopicNamingConvention topicNamingConvention,
     IEnumerable <IEventApplier <TEvent> > eventAppliers,
     ILogger <EventProjector <TEvent> > logger)
 {
     _streamConsumer        = streamConsumer;
     _topicNamingConvention = topicNamingConvention;
     _eventAppliers         = eventAppliers;
     _logger = logger;
 }
Exemple #4
0
        /// <summary>
        /// Initialize this instance.
        /// </summary>
        /// <param name="consumer">Related transport stream.</param>
        /// <param name="pid">Corresponding transport stream identifier.</param>
        /// <param name="isPCR">Set if this stream provides the PCR from the PTS information
        /// in the PES headers.</param>
        protected StreamBase(IStreamConsumer consumer, short pid, bool isPCR)
        {
            // Remember
            m_Consumer2 = consumer as IStreamConsumer2;
            Consumer    = consumer;
            IsPCR       = isPCR;
            PID         = pid;

            // Configure
            EnableDataFlow = !AwaitKeyFrame || !IsPCR;
        }
Exemple #5
0
        public Streamer(IStreamProducer producer, IStreamConsumer consumer, CancellationToken cancellationToken)
        {
            var options     = new PipeOptions(minimumSegmentSize: 8 * 1024);
            var triggerSize = Math.Min(options.Pool.MaxBufferSize, options.MinimumSegmentSize);
            var pipe        = new Pipe(options);

            ConsumerCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
            Producer = producer ?? throw new ArgumentNullException(nameof(producer));
            Consumer = consumer ?? throw new ArgumentNullException(nameof(consumer));
            Writer   = new PipeWriterWrapper <Streamer>(pipe.Writer, triggerSize, ProductionStartedCallback, WriterCompletionCallback, this);
            Reader   = pipe.Reader;
        }
Exemple #6
0
 public bool Detach(IStreamConsumer consumer)
 {
     if (!consumer.AcceptType.IsAssignableFrom(ValueType))
     {
         return(false);
     }
     try
     {
         _consumersLock.EnterWriteLock();
         return(_consumers.Remove(consumer));
     }
     finally
     {
         _consumersLock.ExitWriteLock();
     }
 }
Exemple #7
0
 public MarkerStreamer(IClock clock, IStreamConsumer <Timestamped <int> > consumer) : this(clock) => Attach(consumer);
Exemple #8
0
 public BiosignalStreamer(IBiosignalSampler biosignalSampler, IClock clock, IStreamConsumer <Timestamped <ISample> > consumer, ArrayQuery channelSelector = null)
     : this(biosignalSampler, clock, channelSelector) => Attach(consumer);
 public GazePointStreamer(IEyeTracker eyeTracker, IClock clock, IStreamConsumer <Timestamped <IGazePoint> > consumer) : this(eyeTracker, clock) => Attach(consumer);
 /// <summary>
 /// Initialize this instance.
 /// </summary>
 /// <remarks>
 /// This stream will not provide the PCR.
 /// </remarks>
 /// <param name="consumer">Related transport stream.</param>
 /// <param name="pid">Corresponding transport stream identifier.</param>
 protected StreamBase( IStreamConsumer consumer, short pid )
     : this( consumer, pid, false )
 {
 }
Exemple #11
0
 public void SetUp()
 {
     _consumer = new StreamConsumer(_log.Object);
 }
Exemple #12
0
 internal void Consumer(IStreamConsumer <StreamHandle> consumer)
 {
     Contract.Requires(consumer != null);
     this.streamConsumer = consumer;
 }
Exemple #13
0
 internal void Consumer(IStreamConsumer <StreamHandle> consumer)
 {
     Debug.Assert(consumer is object);
     _streamConsumer = consumer;
 }
 public void OneTimeSetup()
 {
     _log      = new InMemoryDistributedLog();
     _consumer = new StreamConsumer(_log);
 }
Exemple #15
0
 public static DelegatedStreamConsumer <TIn> Map <TIn, TOut>(this IStreamConsumer <TOut> consumer, Func <TIn, TOut> mapFunc) =>
 new DelegatedStreamConsumer <TIn>(input => consumer.Accept(mapFunc(input)), consumer.Priority);
        /// <summary>
        /// Initialize this instance.
        /// </summary>
        /// <param name="consumer">Related transport stream.</param>
        /// <param name="pid">Corresponding transport stream identifier.</param>
        /// <param name="isPCR">Set if this stream provides the PCR from the PTS information
        /// in the PES headers.</param>
        protected StreamBase( IStreamConsumer consumer, short pid, bool isPCR )
        {
            // Remember
            m_Consumer2 = consumer as IStreamConsumer2;
            Consumer = consumer;
            IsPCR = isPCR;
            PID = pid;

            // Configure
            EnableDataFlow = !AwaitKeyFrame || !IsPCR;
        }
Exemple #17
0
 /// <summary>
 /// Initialize this instance.
 /// </summary>
 /// <remarks>
 /// This stream will not provide the PCR.
 /// </remarks>
 /// <param name="consumer">Related transport stream.</param>
 /// <param name="pid">Corresponding transport stream identifier.</param>
 protected StreamBase(IStreamConsumer consumer, short pid)
     : this(consumer, pid, false)
 {
 }
		/// <summary>
		/// Create a new instance.
		/// </summary>
		/// <param name="consumer">Related transport stream.</param>
		/// <param name="pid">Transport stream identifier for this audio stream.</param>
		/// <param name="isPCR">Set if this stream supplies the PCR.</param>
		public AudioStream(IStreamConsumer consumer, short pid, bool isPCR)
			: base(consumer, pid, isPCR)
		{
		}
Exemple #19
0
 public void Dispose()
 {
     _pendingRead.Dispose();
     _streamConsumer = null;
 }
 public BoundConsumer(IStreamConsumer <T> consumer, Action <T> store)
 {
     _consumer = consumer ?? throw new ArgumentNullException(nameof(consumer));
     _store    = store ?? throw new ArgumentNullException(nameof(store));
 }
Exemple #21
0
 public void Dispose()
 {
     this.bufferQueue.Dispose();
     this.streamConsumer = null;
 }
 public ConsumerDestination(IStreamConsumer consumer)
 => _consumer = consumer ?? throw new ArgumentNullException(nameof(consumer));
 public VideoFrameStreamer(IVideoSource videoSource, IClock clock, IStreamConsumer <Timestamped <IVideoFrame> > consumer) : this(videoSource, clock) => Attach(consumer);
        /// <summary>
        /// Erzeugt eine neue Repräsentation.
        /// </summary>
        /// <param name="consumer">Der zugehörige Gesamtdatenstrom, im Allgemeinen ein
        /// <i>Transport Stream</i> <see cref="Manager"/>.</param>
        /// <param name="pid">Die Datenstromkennung im Gesamtstrom.</param>
        /// <param name="isPCR">Gesetzt, wenn dieser Datenstrom die Zeitbasis für den Gesamtstrom
        /// bereitstellt (sehr unüblich für Untertitel).</param>
        public SubtitleStream(IStreamConsumer consumer, short pid, bool isPCR)
			: base(consumer, pid, isPCR)
		{
		}
 public ChainedConsumer(IStreamTransformation transformation, IStreamConsumer consumer)
 {
     _transformation = transformation ?? throw new ArgumentNullException(nameof(transformation));
     _consumer       = consumer ?? throw new ArgumentNullException(nameof(consumer));
 }
Exemple #26
0
 public void Dispose()
 {
     this.pendingRead.Dispose();
     this.streamConsumer = null;
 }
Exemple #27
0
 /// <summary>
 /// Create a new instance.
 /// </summary>
 /// <param name="consumer">Related transport stream.</param>
 /// <param name="pid">Transport stream identifier for this video stream.</param>
 /// <param name="isPCR">Set if this stream supplies the PCR.</param>
 public HDTVStream(IStreamConsumer consumer, short pid, bool isPCR)
     : base(consumer, pid, isPCR)
 {
 }
 /// <summary>
 /// Erzeugt eine neue Repräsentation.
 /// </summary>
 /// <param name="consumer">Der zugehörige Gesamtdatenstrom, im Allgemeinen ein
 /// <i>Transport Stream</i> <see cref="Manager"/>.</param>
 /// <param name="pid">Die Datenstromkennung im Gesamtstrom.</param>
 /// <param name="isPCR">Gesetzt, wenn dieser Datenstrom die Zeitbasis für den Gesamtstrom
 /// bereitstellt (sehr unüblich für Untertitel).</param>
 public SubtitleStream(IStreamConsumer consumer, short pid, bool isPCR)
     : base(consumer, pid, isPCR)
 {
 }