- Main Page
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

# OggFile.h

    00001 #pragma once
    00002
    00003 #include "..\BaseSplitter\BaseSplitter.h"
    00004
    00005 #pragma pack(push, 1)
    00006 struct OggPageHeader
    00007 {
    00008         DWORD capture_pattern;
    00009         BYTE stream_structure_version;
    00010         BYTE header_type_flag; enum {continued=1, first=2, last=4};
    00011         __int64 granule_position;
    00012         DWORD bitstream_serial_number;
    00013         DWORD page_sequence_number;
    00014         DWORD CRC_checksum;
    00015         BYTE number_page_segments;
    00016 };
    00017 struct OggVorbisIdHeader
    00018 {
    00019         DWORD vorbis_version;
    00020         BYTE audio_channels;
    00021         DWORD audio_sample_rate;
    00022         DWORD bitrate_maximum;
    00023         DWORD bitrate_nominal;
    00024         DWORD bitrate_minimum;
    00025         BYTE blocksize_0:4;
    00026         BYTE blocksize_1:4;
    00027         BYTE framing_flag;
    00028 };
    00029 struct OggVideoHeader
    00030 {
    00031         DWORD w, h;
    00032 };
    00033 struct OggAudioHeader
    00034 {
    00035         WORD nChannels, nBlockAlign;
    00036         DWORD nAvgBytesPerSec;
    00037 };
    00038 struct OggStreamHeader
    00039 {
    00040         char streamtype[8], subtype[4];
    00041         DWORD size;
    00042         __int64 time_unit, samples_per_unit;
    00043         DWORD default_len;
    00044     DWORD buffersize;
    00045         WORD bps;
    00046         WORD alignmentfix1;
    00047     union {OggVideoHeader v; OggAudioHeader a;};
    00048         DWORD alignmentfix2;
    00049 };
    00050 #pragma pack(pop)
    00051
    00052 class OggPage : public CArray<BYTE>
    00053 {
    00054 public:
    00055         OggPageHeader m_hdr;
    00056         CList<int> m_lens;
    00057         OggPage() {memset(&m_hdr, 0, sizeof(m_hdr));}
    00058 };
    00059
    00060 class COggFile : public CBaseSplitterFile
    00061 {
    00062         using CBaseSplitterFile::Read;
    00063
    00064         HRESULT Init();
    00065
    00066 public:
    00067         COggFile(IAsyncReader* pAsyncReader, HRESULT& hr);
    00068
    00069         bool Sync(HANDLE hBreak = NULL);
    00070         bool Read(OggPageHeader& hdr, HANDLE hBreak = NULL);
    00071         bool Read(OggPage& page, bool fFull = true, HANDLE hBreak = NULL);
    00072 };