TryInit() private method

private TryInit ( ) : bool
return bool
示例#1
0
        public void NewStream(object sender, NewStreamEventArgs ea)
        {
            IPacketProvider     packetProvider      = ea.PacketProvider;
            VorbisStreamDecoder vorbisStreamDecoder = new VorbisStreamDecoder(packetProvider);

            if (vorbisStreamDecoder.TryInit())
            {
                _decoders.Add(vorbisStreamDecoder);
                _serials.Add(packetProvider.StreamSerial);
            }
            else
            {
                ea.IgnoreStream = true;
            }
        }
示例#2
0
        void NewStream(object sender, NewStreamEventArgs ea)
        {
            var packetProvider = ea.PacketProvider;
            var decoder        = new VorbisStreamDecoder(packetProvider);

            if (decoder.TryInit())
            {
                _decoders.Add(decoder);
                _serials.Add(packetProvider.StreamSerial);
            }
            else
            {
                // This is almost certainly not a Vorbis stream
                ea.IgnoreStream = true;
            }
        }
示例#3
0
        private void NewStream(int streamSerial)
        {
            DataPacket nextPacket = this._packetProvider.GetNextPacket(streamSerial);

            if ((int)nextPacket.PeekByte() != (int)VorbisStreamDecoder.InitialPacketMarker)
            {
                return;
            }
            VorbisStreamDecoder vorbisStreamDecoder = new VorbisStreamDecoder((Func <DataPacket>)(() =>
            {
                IPacketProvider local_0 = this._packetProvider;
                if (local_0 != null)
                {
                    return(local_0.GetNextPacket(streamSerial));
                }
                else
                {
                    return((DataPacket)null);
                }
            }), (Func <int>)(() =>
            {
                IPacketProvider local_0 = this._packetProvider;
                if (local_0 != null)
                {
                    return(local_0.GetTotalPageCount(streamSerial));
                }
                else
                {
                    return(0);
                }
            }));

            try
            {
                if (!vorbisStreamDecoder.TryInit(nextPacket))
                {
                    return;
                }
                this._decoders.Add(vorbisStreamDecoder);
                this._serials.Add(streamSerial);
            }
            catch (InvalidDataException ex)
            {
            }
        }
        void NewStream(object sender, NewStreamEventArgs ea)
        {
            var packetProvider = ea.PacketProvider;
            var decoder        = new VorbisStreamDecoder(packetProvider);

            if (decoder.TryInit())
            {
                _decoders.Add(decoder);
                _serials.Add(packetProvider.StreamSerial);
            }
            else
            {
                // NB: This could be an Ogg Skeleton stream...  We should check that, just in case
                // NB: This could be a RTP stream...  We should check that, just in case

                ea.IgnoreStream = true;
            }
        }
示例#5
0
        void NewStream(object sender, NewStreamEventArgs ea)
        {
            var packetProvider = ea.PacketProvider;
            var decoder = new VorbisStreamDecoder(packetProvider);
            if (decoder.TryInit())
            {
                _decoders.Add(decoder);
                _serials.Add(packetProvider.StreamSerial);
            }
            else
            {
                // NB: This could be an Ogg Skeleton stream...  We should check that, just in case
                // NB: This could be a RTP stream...  We should check that, just in case

                ea.IgnoreStream = true;
            }
        }
示例#6
0
 void NewStream(object sender, NewStreamEventArgs ea)
 {
     var packetProvider = ea.PacketProvider;
     var decoder = new VorbisStreamDecoder(packetProvider);
     if (decoder.TryInit())
     {
         _decoders.Add(decoder);
         _serials.Add(packetProvider.StreamSerial);
     }
     else
     {
         // This is almost certainly not a Vorbis stream
         ea.IgnoreStream = true;
     }
 }
示例#7
0
 private void NewStream(int streamSerial)
 {
   DataPacket nextPacket = this._packetProvider.GetNextPacket(streamSerial);
   if ((int) nextPacket.PeekByte() != (int) VorbisStreamDecoder.InitialPacketMarker)
     return;
   VorbisStreamDecoder vorbisStreamDecoder = new VorbisStreamDecoder((Func<DataPacket>) (() =>
   {
     IPacketProvider local_0 = this._packetProvider;
     if (local_0 != null)
       return local_0.GetNextPacket(streamSerial);
     else
       return (DataPacket) null;
   }), (Func<int>) (() =>
   {
     IPacketProvider local_0 = this._packetProvider;
     if (local_0 != null)
       return local_0.GetTotalPageCount(streamSerial);
     else
       return 0;
   }));
   try
   {
     if (!vorbisStreamDecoder.TryInit(nextPacket))
       return;
     this._decoders.Add(vorbisStreamDecoder);
     this._serials.Add(streamSerial);
   }
   catch (InvalidDataException ex)
   {
   }
 }
示例#8
0
        void NewStream(int streamSerial)
        {
            var initialPacket = _packetProvider.GetNextPacket(streamSerial);
            var checkByte = (byte)initialPacket.PeekByte();

            // TODO: determine what type of stream this is, load the correct decoder (or ignore
            //       it), then keep going.  If it's a skeleton stream, try to load it.  Only
            //       allow one instance.  Then force another page to be read.

            // for now, we only support the Vorbis decoder; Skeleton will happen later
            if (checkByte == VorbisStreamDecoder.InitialPacketMarker)
            {
                var decoder = new VorbisStreamDecoder(
                    () => {
                        var provider = _packetProvider;
                        if (provider != null)
                        {
                            return provider.GetNextPacket(streamSerial);
                        }
                        return null;
                    },
                    () =>
                    {
                        var provider = _packetProvider;
                        if (provider != null)
                        {
                            return provider.GetTotalPageCount(streamSerial);
                        }
                        return 0;
                    }
                );
                try
                {
                    if (decoder.TryInit(initialPacket))
                    {
                        // the init worked, so we have a valid stream...

                        _decoders.Add(decoder);
                        _serials.Add(streamSerial);
                    }
                    // else: the initial packet wasn't for Vorbis...
                }
                catch (InvalidDataException)
                {
                    // there was an error loading the headers... problem is, we're past the first packet, so we can't go back and try again...
                    // TODO: log the error
                }
            }
            // we're not supporting Skeleton yet...
            //else if (checkByte == Ogg.SkeletonDecoder.InitialPacketMarker)
            //{
            //    // load it
            //    if (_skeleton != null) throw new InvalidDataException("Second skeleton stream found!");
            //    _skeleton = new Ogg.SkeletonDecoder(() => _packetProvider.GetNextPacket(streamSerial));

            //    if (_skeleton.Init(initialPacket))
            //    {
            //        // force the next stream to load
            //        _packetProvider.FindNextStream(streamSerial);
            //    }
            //    else
            //    {
            //        _skeleton = null;
            //    }
            //}
        }