Recognizes if input is ogg or not.
[xiph.git] / xiph-rtp / xiph_rtp.h
blob6b02f65d061c9a052d32a0c09055f4ab9c61d80d
1 /*
2 Copyright (c) 2005, Fluendo / Xiph.Org
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright notice,
8 this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
14 * Neither the name of the Xiph.Org nor the names of its contributors may
15 be used to endorse or promote products derived from this software without
16 specific prior written permission.
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 THE POSSIBILITY OF SUCH DAMAGE.
30 Author: Luca Barbato <lu_zero@gentoo.org>
34 #ifndef XIPH_RTP_H
35 #define XIPH_RTP_H
37 /**
38 * Specific vorbis/theora header
41 typedef struct header_bitfield {
42 unsigned int cbident:24;
43 unsigned int frag_type:2;
44 unsigned int data_type:2;
45 unsigned int pkts:4;
46 } header_bitfield_t;
48 /**
49 * Standard rtp header
52 typedef struct rtp_headers {
53 /* v, p, x, cc flags */
54 unsigned int flags1:8;
56 /* m, pt flags */
57 unsigned int flags2:8;
59 unsigned int sequence:16;
60 unsigned int timestamp:32;
61 unsigned int ssrc:32;
62 } rtp_headers_t;
65 typedef struct framestack {
66 int stacksize;
67 int stackcount;
68 unsigned char* framestack;
69 } framestack_t;
72 /**
73 * Context structure for rtp transmission
76 //FIXME restructure with a separate codec struct
77 typedef struct xiph_rtp {
78 /* network related */
79 struct sockaddr_in rtpsock;
80 int socket;
81 header_bitfield_t bitfield;
82 rtp_headers_t headers;
83 /* rtp related*/
84 framestack_t fs;
85 /* stream related */
86 ogg_sync_state oy;
87 ogg_stream_state os;
88 ogg_page og;
89 ogg_packet op;
90 ogg_packet header[3];
91 /* codec generic */
92 int codec; // 0 = vorbis, 1 = theora, 2 = speex
93 #ifdef HAVE_VORBIS
94 /* codec specific (vorbis)*/
95 vorbis_info vi;
96 vorbis_comment vc;
97 vorbis_dsp_state vd;
98 vorbis_block vb;
99 #endif
100 #ifdef HAVE_THEORA
101 /* codec specific (theora)*/
102 theora_info ti;
103 theora_comment tc;
104 theora_state td;
105 unsigned int gp_shift;
106 #endif
107 /* codec specific (speex) */
108 //FIXME
110 } xiph_rtp_t;
112 int createsocket (xiph_rtp_t *xr, char *addr, unsigned int port,
113 unsigned char TTL);
115 void creatertp (xiph_rtp_t *xr, unsigned char* vorbdata, int length,
116 long timestamp, long sleeptime, int type, int last);
118 int sendrtp (xiph_rtp_t *xr, const void *data, int len);
120 int makeheader (xiph_rtp_t *xr, unsigned char *packet, int length);
122 int ogg_copy_packet(ogg_packet *dst, ogg_packet *src);
124 #endif