1 /*transmitter.h       (c) 1999-2000 Derek J Smithies (dereks@ibm.net)
2  *                           Indranet Technologies ltd (lara@indranet.co.nz)
3  *
4  * This file is derived from vic, http://www-nrg.ee.lbl.gov/vic/
5  * Their copyright notice is below.
6  */
7 /*
8  * Copyright (c) 1993-1995 The Regents of the University of California.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. All advertising materials mentioning features or use of this software
20  *    must display the following acknowledgement:
21  * 	This product includes software developed by the Network Research
22  * 	Group at Lawrence Berkeley National Laboratory.
23  * 4. Neither the name of the University nor of the Laboratory may be used
24  *    to endorse or promote products derived from this software without
25  *    specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37  * SUCH DAMAGE.
38  *
39  */
40 
41 /************ Change log
42  *
43  * $Log$
44  * Revision 1.2  2006/07/31 09:09:22  csoutheren
45  * Checkin of validated codec used during development
46  *
47  * Revision 1.1.2.1  2006/04/06 01:17:17  csoutheren
48  * Initial version of H.261 video codec plugin for OPAL
49  *
50  * Revision 2.1  2003/03/15 23:43:00  robertj
51  * Update to OpenH323 v1.11.7
52  *
53  * Revision 1.9  2003/03/14 07:25:55  robertj
54  * Removed $header keyword so is not different on alternate repositories
55  *
56  * Revision 1.8  2002/04/05 00:53:19  dereks
57  * Modify video frame encoding so that frame is encoded on an incremental basis.
58  * Thanks to Walter Whitlock - good work.
59  *
60  * Revision 1.7  2002/01/04 02:48:05  dereks
61  * Fix previous commit so it compiles OK.
62  *
63  * Revision 1.6  2002/01/03 23:05:50  dereks
64  * Add methods to count number of H261 packets waiting to be sent.
65  *
66  * Revision 1.5  2001/05/10 05:25:44  robertj
67  * Removed need for VIC code to use ptlib.
68  *
69  * Revision 1.4  2000/12/19 22:22:34  dereks
70  * Remove connection to grabber-OS.cxx files. grabber-OS.cxx files no longer used.
71  * Video data is now read from a video channel, using the pwlib classes.
72  *
73  * Revision 1.3  2000/08/25 03:18:50  dereks
74  * Add change log facility (Thanks Robert for the info on implementation)
75  *
76  *
77  *
78  ********/
79 
80 
81 #ifndef vic_transmitter_h
82 #define vic_transmitter_h
83 
84 #include "config.h"
85 
86 #define MAXHDR 24
87 
88 
89 #include "dct.h"
90 /*
91  * The base object for performing the outbound path of
92  * the application level protocol.
93  */
94 class Transmitter {
95     public:
96 	Transmitter();
97         virtual ~Transmitter();
98 
99 	struct buffer {
100 		struct buffer* next;
101 		/*
102 		 * make buffer twice as big as necessary so we can
103 		 * run off end while doing in-place encoding.
104 		 */
105 		u_char data[2 * RTP_MTU];
106 	};
107 	struct pktbuf {
108 		struct pktbuf* next;
109     	        int lenHdr,lenBuf;
110 		u_char hdr[MAXHDR];
111 		buffer* buf;
112 	};
mtu()113         virtual int  mtu() { return 1024; }  //Maximum transfer unit.
114 	void StoreOnePacket(pktbuf*);
115 
116         //Returns a pointer to buffer in the next packet, + length of buffer;
117         //Frees the packet from the queue.
118 
119         void GetNextPacket(u_char ** hptr,u_char ** bptr, u_int & hlen, u_int & blen);
120 
121         //Returns true if there are packets still in the queue.
122         int PacketsOutStanding();
123 
124 	int GetCountPacketsOutStanding();
125 
126 	pktbuf* alloch();
127 	pktbuf* alloc();
128 
129     protected:
130         void PurgeBufferQueue(pktbuf *queue);
131 
132 	/*
133 	 * Buffer allocation hooks.
134 	 */
135 	void ReleaseOnePacket(pktbuf*);
136 
137 	/* packet transmission queue */
138 	pktbuf* head_;
139 	pktbuf* tail_;
140 
141 	 u_int   seqno_;
142 
143   private:
144 	 pktbuf* freehdrs_;
145 	 buffer* freebufs_;
146 };
147 
148 
149 
150 #endif
151 
152 
153 
154 
155