本文整理汇总了C#中NVorbis.VorbisStreamDecoder.TryInit方法的典型用法代码示例。如果您正苦于以下问题:C# VorbisStreamDecoder.TryInit方法的具体用法?C# VorbisStreamDecoder.TryInit怎么用?C# VorbisStreamDecoder.TryInit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NVorbis.VorbisStreamDecoder
的用法示例。
在下文中一共展示了VorbisStreamDecoder.TryInit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewStream
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;
}
}
示例2: NewStream
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)
{
}
}
示例3: NewStream
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;
}
}
示例4: NewStream
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;
// }
//}
}