diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | e2de64d6f1beb9e492daf5b886e19933c1fa41dd (patch) | |
tree | 9047cf9e6b5c43878d5bf82660adae77ceee097a /mpeglib/lib/oggvorbis/ovFramer.cpp | |
download | tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.tar.gz tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'mpeglib/lib/oggvorbis/ovFramer.cpp')
-rw-r--r-- | mpeglib/lib/oggvorbis/ovFramer.cpp | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/mpeglib/lib/oggvorbis/ovFramer.cpp b/mpeglib/lib/oggvorbis/ovFramer.cpp new file mode 100644 index 00000000..ca3506af --- /dev/null +++ b/mpeglib/lib/oggvorbis/ovFramer.cpp @@ -0,0 +1,128 @@ +/* + frames raw data into Ogg/Vorbis frames. + Copyright (C) 2001 Martin Vogt + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation. + + For more information look at the file COPYRIGHT in this package + + */ + + + +#include "ovFramer.h" + +#define OGG_SYNC_BUFF_SIZE 4096 + + +#define _OV_SETSERIAL 1 +#define _OV_STREAMIN 2 +#define _OV_STREAMOUT 3 + +#include <iostream> + +using namespace std; + + +#ifdef OGG_VORBIS + +OVFramer::OVFramer(OGGFrame* dest):Framer(1) { + if (dest == NULL) { + cout << "OGGFrame NULL in OVFramer"<<endl; + exit(-1); + } + this->dest=dest; + /********** Decode setup ************/ + ogg_sync_init(&oy); /* Now we can read pages */ + + vorbis_state=_OV_SETSERIAL; +} + + +OVFramer::~OVFramer() { + /* OK, clean up the framer */ + ogg_sync_clear(&oy); +} + + +int OVFramer::find_frame(RawDataBuffer* input,RawDataBuffer* store) { + while(input->eof()==true) { + cout << "input eof"<<endl; + return false; + } + + if (vorbis_state == _OV_STREAMOUT) { + if(ogg_stream_packetout(&os,(ogg_packet*)dest->getData())!=1){ + vorbis_state=_OV_STREAMIN; + return false; + } + return true; + } + + // do we have ogg packets in the ogg framer? + if (ogg_sync_pageout(&oy,&og) == 0) { + // no, ok insert some. + int bytes=input->untilend(); + input->inc(bytes); + store->inc(bytes); + ogg_sync_wrote(&oy,bytes); + // and setup the next buffer + /* submit a 4k block to libvorbis' Ogg layer */ + buffer=ogg_sync_buffer(&oy,OGG_SYNC_BUFF_SIZE); + /* override our own dummy buffer with size 1 */ + setRemoteFrameBuffer((unsigned char*)buffer,OGG_SYNC_BUFF_SIZE); + return false; + } + // we have an ogg page + // now try to build an ogg packet + switch(vorbis_state) { + case _OV_SETSERIAL: + /* Get the serial number and set up the rest of decode. */ + /* serialno first; use it to set up a logical stream */ + ogg_stream_init(&os,ogg_page_serialno(&og)); + vorbis_state=_OV_STREAMIN; + // yes we need to put this into the "pager" + // no break. + case _OV_STREAMIN: + if(ogg_stream_pagein(&os,&og)<0){ + /* error; stream version mismatch perhaps */ + fprintf(stderr,"Error reading first page of Ogg bitstream data.\n"); + exit(1); + } + vorbis_state=_OV_STREAMOUT; + break; + default: + cout << "unknow vorbis_state"<<endl; + exit(-1); + } + + return false; +} + +int OVFramer::read_frame(RawDataBuffer* ,RawDataBuffer* ) { + return true; +} + + + +void OVFramer::unsync(RawDataBuffer* store,int lReset) { + if (lReset) { + store->setpos(0); + ogg_sync_reset(&oy); + /* submit a 4k block to libvorbis' Ogg layer */ + buffer=ogg_sync_buffer(&oy,OGG_SYNC_BUFF_SIZE); + /* override our own dummy buffer with size 1 */ + setRemoteFrameBuffer((unsigned char*)buffer,OGG_SYNC_BUFF_SIZE); + } + +} + + +void OVFramer::printPrivateStates() { + cout << "OVFramer::printPrivateStates"<<endl; +} + + +#endif |