コード例 #1
0
ファイル: AudioDriver.cs プロジェクト: zwiglm/NeoAxisEngine
        internal bool CheckSecondHeader(ogg.Packet p, ref bool needMoreData)
        {
            needMoreData = false;
            //We have all headers already, so just return
            if (headerCount == 3)
            {
                return(false);
            }

            int retVal = vorbisStreamState.packetout(p);

            if (retVal == 1)
            {
                if (vorbisInfo.synthesis_headerin(vorbisComment, p) != 0)
                {
                    throw new Exception("Invalid stream");
                }

                headerCount++;
                return(true);
            }
            else if (retVal < 0)              //error
            {
                throw new Exception("Invalid stream");
            }

            //Need more data
            needMoreData = true;
            return(true);
        }
コード例 #2
0
ファイル: VideoDriver.cs プロジェクト: zwiglm/NeoAxisEngine
        //

        public VideoDriver()
        {
            theoraInfo    = new theora.Info();
            theoraComment = new theora.Comment();
            theoraState   = new theora.State();
            yuvBuffer     = new theora.YUVBuffer();
            oggPacket     = new ogg.Packet();
        }
コード例 #3
0
ファイル: VideoDriver.cs プロジェクト: zwiglm/NeoAxisEngine
 internal bool DecodePrimaryHeader(ogg.Packet p, ogg.StreamState s)
 {
     if (theoraInfo.decode_header(theoraComment, p) >= 0)
     {
         //This is the Theora stream, so store it
         theoraStreamState = s;
         headerCount       = 1;
         return(true);
     }
     return(false);
 }
コード例 #4
0
ファイル: AudioDriver.cs プロジェクト: zwiglm/NeoAxisEngine
 internal bool DecodePrimaryHeader(ogg.Packet p, ogg.StreamState s)
 {
     if (vorbisInfo.synthesis_headerin(vorbisComment, p) >= 0)
     {
         //This is vorbis stream, so store it
         vorbisStreamState = s;
         headerCount       = 1;
         return(true);
     }
     return(false);
 }
コード例 #5
0
ファイル: OggFile.cs プロジェクト: zwiglm/NeoAxisEngine
        /// <summary>
        /// internal method to parse all secondary headers
        /// </summary>
        void ParseSecondaryHeaders()
        {
            ogg.Packet tempOggPacket = new ogg.Packet();
            bool       theoraNotDone = true;
            bool       vorbisNotDone = true;

            //Loop until all secondary headers of theora and/or vorbis are parsed
            while ((videoDriver != null && theoraNotDone) ||
                   (audioDriver != null && vorbisNotDone))
            {
                bool needMoreData = false;

                while (videoDriver != null && theoraNotDone && !needMoreData)
                {
                    theoraNotDone = videoDriver.CheckSecondHeader(tempOggPacket, ref needMoreData);
                }

                while (audioDriver != null && vorbisNotDone && !needMoreData)
                {
                    vorbisNotDone = audioDriver.CheckSecondHeader(tempOggPacket, ref needMoreData);
                }

                //Buffer some more data
                if (oggSyncState.pageout(oggPage) > 0)
                {
                    //This is done blindly, because stream only accept them selfs
                    if (videoDriver != null)
                    {
                        videoDriver.PageIn(oggPage);
                    }
                    if (audioDriver != null)
                    {
                        audioDriver.PageIn(oggPage);
                    }
                }
                else
                {
                    if (BufferData() == 0)
                    {
                        tempOggPacket.Dispose();
                        throw new Exception("Invalid ogg file");
                    }
                }
            }

            tempOggPacket.Dispose();
        }
コード例 #6
0
ファイル: VideoDriver.cs プロジェクト: zwiglm/NeoAxisEngine
        public virtual void Dispose()
        {
            if (oggPacket != null)
            {
                oggPacket.Dispose();
                oggPacket = null;
            }

            if (yuvBuffer != null)
            {
                yuvBuffer.Dispose();
                yuvBuffer = null;
            }

            if (theoraState != null)
            {
                theoraState.Dispose();
                theoraState = null;
            }

            if (theoraInfo != null)
            {
                theoraInfo.Dispose();
                theoraInfo = null;
            }

            if (theoraComment != null)
            {
                theoraComment.Dispose();
                theoraComment = null;
            }

            if (theoraStreamState != null)
            {
                theoraStreamState.Dispose();
                theoraStreamState = null;
            }

            GC.SuppressFinalize(this);
        }
コード例 #7
0
ファイル: AudioDriver.cs プロジェクト: zwiglm/NeoAxisEngine
        public virtual void Dispose()
        {
            if (oggPacket != null)
            {
                oggPacket.Dispose();
                oggPacket = null;
            }

            if (vorbisDSPState != null)
            {
                vorbisDSPState.Dispose();
                vorbisDSPState = null;
            }

            if (vorbisBlock != null)
            {
                vorbisBlock.Dispose();
                vorbisBlock = null;
            }

            if (vorbisInfo != null)
            {
                vorbisInfo.Dispose();
                vorbisInfo = null;
            }

            if (vorbisComment != null)
            {
                vorbisComment.Dispose();
                vorbisComment = null;
            }

            if (vorbisStreamState != null)
            {
                vorbisStreamState.Dispose();
                vorbisStreamState = null;
            }
        }
コード例 #8
0
ファイル: VideoDriver.cs プロジェクト: zwiglm/NeoAxisEngine
        internal bool CheckSecondHeader(ogg.Packet p, ref bool needMoreData)
        {
            needMoreData = false;
            if (headerCount == 3)
            {
                //Call to allow driver to setup any needed structures
                //OnInit( new Vec2i( (int)theoraInfo.width, (int)theoraInfo.height ) );
                headerCount = 4;
                return(false);
            }
            else if (headerCount == 4)
            {
                return(false);
            }

            int retVal = theoraStreamState.packetout(p);

            if (retVal == 1)
            {
                if (theoraInfo.decode_header(theoraComment, p) != 0)
                {
                    throw new Exception("invalid stream");
                }

                headerCount++;
                return(true);
            }
            else if (retVal < 0)              //error
            {
                throw new Exception("invalid stream");
            }

            //Need more data, so return true
            needMoreData = true;
            return(true);
        }
コード例 #9
0
ファイル: AudioDriver.cs プロジェクト: zwiglm/NeoAxisEngine
        //

        public AudioDriver()
        {
            vorbisInfo    = new vorbis.Info();
            vorbisComment = new vorbis.Comment();
            oggPacket     = new ogg.Packet();
        }
コード例 #10
0
ファイル: OggFile.cs プロジェクト: zwiglm/NeoAxisEngine
        /// <summary>
        /// internal method for parsing the main stream headers
        /// </summary>
        void ParsePrimaryHeaders()
        {
            ogg.Packet tempOggPacket  = new ogg.Packet();
            bool       notDone        = true;
            int        vorbis_streams = 0;
            int        theora_streams = 0;

            while (notDone)
            {
                if (BufferData() == 0)
                {
                    tempOggPacket.Dispose();
                    throw new Exception("Invalid ogg file");
                }

                //Check for page data
                while (oggSyncState.pageout(oggPage) > 0)
                {
                    //is this an initial header? If not, stop
                    if (oggPage.bos() == 0)
                    {
                        //This is done blindly, because stream only accept them selfs
                        if (videoDriver != null && theora_streams > 0)
                        {
                            videoDriver.PageIn(oggPage);
                        }
                        if (audioDriver != null && vorbis_streams > 0)
                        {
                            audioDriver.PageIn(oggPage);
                        }
                        notDone = false;
                        break;
                    }

                    ogg.StreamState oggStateTest = new ogg.StreamState(oggPage.serialno());
                    //oggStateTest.init( oggPage.serialno() );
                    oggStateTest.pagein(oggPage);
                    oggStateTest.packetout(tempOggPacket);

                    //identify the codec
                    if (videoDriver != null && videoDriver.DecodePrimaryHeader(tempOggPacket, oggStateTest))
                    {
                        theora_streams = 1;
                    }
                    else if (audioDriver != null && audioDriver.DecodePrimaryHeader(tempOggPacket, oggStateTest))
                    {
                        vorbis_streams = 1;
                    }
                    else
                    {
                        oggStateTest.Dispose();
                    }
                }         //end while ogg_sync_pageout
            }             //end while notdone

            //if pri headers not found, then remove driver
            if (theora_streams == 0 && videoDriver != null)
            {
                videoDriver.Dispose();
                videoDriver = null;
            }
            if (vorbis_streams == 0 && audioDriver != null)
            {
                audioDriver.Dispose();
                audioDriver = null;
            }

            tempOggPacket.Dispose();
        }