summaryrefslogtreecommitdiffstats
path: root/mpeglib/lib/oggvorbis/ovFramer.h
blob: 4845fddb3908f3ff680404f627c59b0449023761 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
  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

 */


#ifndef __OVFRAMER_H
#define __OVFRAMER_H


#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#ifdef OGG_VORBIS

#include <vorbis/codec.h>
#include "../frame/framer.h"
#include "oggFrame.h"

/**

   This framer works directly on the raw ogg_packet as output
   Note: the internal setup makes sure, that we initialize
   the ogg stream to the first found logical bitstream.
   (For now this should mean: we found vorbis)
   When the frame goes into the "HAS" state, you have the ogg
   packet in the in the dest struct from the constructor.
*/

class OVFramer : public Framer {

  int vorbis_state;

  ogg_sync_state   oy; /* sync and verify incoming physical bitstream */
  ogg_stream_state os; /* take physical pages, weld into a logical
                          stream of packets */
  ogg_page         og; /* one Ogg bitstream page.  Vorbis packets are inside */

  char *buffer;        /* sync buffer from ogg */

  OGGFrame*      dest; /* one raw packet of data for decode */

 public:
  // IMPORTANT: because we use this ptr internally the 
  //            data to op cannot be on the stack!
  OVFramer(OGGFrame* dest);
  ~OVFramer();


 private:

  int find_frame(RawDataBuffer* input,RawDataBuffer* store);
  int read_frame(RawDataBuffer* input,RawDataBuffer* store);

  void unsync(RawDataBuffer* store,int lReset);
  void printPrivateStates();

};
#endif

#endif