ogmstreams.h 3.36 KB
Newer Older
1 2 3 4 5 6
#ifndef __OGGSTREAMS_H
#define __OGGSTREAMS_H

/*
 * Taken from http://tobias.everwicked.com/packfmt.htm
 *
Mikhail Karpenko's avatar
Mikhail Karpenko committed
7 8 9 10 11 12 13 14 15

   First packet (header)
   ---------------------

   pos    | content                 | description
   -------+-------------------------+----------------------------------
   0x0000 | 0x01                    | indicates 'header packet'
   -------+-------------------------+----------------------------------
   0x0001 | stream_header           | the size is indicated in the
16
 |                         | size member
Mikhail Karpenko's avatar
Mikhail Karpenko committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33


   Second packet (comment)
   -----------------------

   pos    | content                 | description
   -------+-------------------------+----------------------------------
   0x0000 | 0x03                    | indicates 'comment packet'
   -------+-------------------------+----------------------------------
   0x0001 | data                    | see vorbis doc on www.xiph.org

   Data packets
   ------------

   pos      | content                 | description
   ---------+-------------------------+----------------------------------
   0x0000   | Bit0  0                 | indicates data packet
34 35 36 37 38 39 40
 | Bit1  Bit 2 of lenbytes |
 | Bit2  unused            |
 | Bit3  keyframe          |
 | Bit4  unused            |
 | Bit5  unused            |
 | Bit6  Bit 0 of lenbytes |
 | Bit7  Bit 1 of lenbytes |
Mikhail Karpenko's avatar
Mikhail Karpenko committed
41 42
   ---------+-------------------------+----------------------------------
   0x0001   | LowByte                 | Length of this packet in samples
43 44
 | ...                     | (frames for video, samples for
 | HighByte                | audio, 1ms units for text)
Mikhail Karpenko's avatar
Mikhail Karpenko committed
45 46 47 48
   ---------+-------------------------+----------------------------------
   0x0001+  | data                    | packet contents
   lenbytes |                         |

49 50 51 52 53 54 55
 *
 *
 */

//// OggDS headers
// Header for the new header format
typedef struct stream_header_video {
Mikhail Karpenko's avatar
Mikhail Karpenko committed
56 57
	ogg_int32_t width;
	ogg_int32_t height;
58 59 60
} stream_header_video;

typedef struct stream_header_audio {
Mikhail Karpenko's avatar
Mikhail Karpenko committed
61 62 63
	ogg_int16_t channels;
	ogg_int16_t blockalign;
	ogg_int32_t avgbytespersec;
64 65 66
} stream_header_audio;

typedef struct stream_header {
Mikhail Karpenko's avatar
Mikhail Karpenko committed
67 68
	char streamtype[8];
	char subtype[4];
69

Mikhail Karpenko's avatar
Mikhail Karpenko committed
70
	ogg_int32_t size;               // size of the structure
71

Mikhail Karpenko's avatar
Mikhail Karpenko committed
72 73 74
	ogg_int64_t time_unit;          // in reference time
	ogg_int64_t samples_per_unit;
	ogg_int32_t default_len;        // in media time
75

Mikhail Karpenko's avatar
Mikhail Karpenko committed
76
	ogg_int32_t buffersize;
77
//	ogg_int16_t     bits_per_sample;
Mikhail Karpenko's avatar
Mikhail Karpenko committed
78
	ogg_int32_t bits_per_sample;
79 80 81 82 83 84 85 86 87

	union {
		// Video specific
		stream_header_video video;
		// Audio specific
		stream_header_audio audio;
	} sh;

//	ogg_int16_t     padding;
Mikhail Karpenko's avatar
Mikhail Karpenko committed
88
	ogg_int32_t padding;
89 90 91 92

} stream_header;

typedef struct old_stream_header {
Mikhail Karpenko's avatar
Mikhail Karpenko committed
93 94
	char streamtype[8];
	char subtype[4];
95

Mikhail Karpenko's avatar
Mikhail Karpenko committed
96
	ogg_int32_t size;               // size of the structure
97

Mikhail Karpenko's avatar
Mikhail Karpenko committed
98 99 100
	ogg_int64_t time_unit;          // in reference time
	ogg_int64_t samples_per_unit;
	ogg_int32_t default_len;        // in media time
101

Mikhail Karpenko's avatar
Mikhail Karpenko committed
102 103
	ogg_int32_t buffersize;
	ogg_int16_t bits_per_sample;
104

Mikhail Karpenko's avatar
Mikhail Karpenko committed
105
	ogg_int16_t padding;
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123

	union {
		// Video specific
		stream_header_video video;
		// Audio specific
		stream_header_audio audio;
	} sh;

} old_stream_header;

/// Some defines from OggDS
#define PACKET_TYPE_HEADER       0x01
#define PACKET_TYPE_COMMENT      0x03
#define PACKET_TYPE_BITS         0x07
#define PACKET_LEN_BITS01        0xc0
#define PACKET_LEN_BITS2         0x02
#define PACKET_IS_SYNCPOINT      0x08

Mikhail Karpenko's avatar
Mikhail Karpenko committed
124
#endif                                                  /* __OGGSTREAMS_H */