root/vic/branches/cc/rtp/transmitter.h @ 4610

Revision 4610, 4.4 KB (checked in by soohyunc, 4 years ago)

Transmitter timestamp and its offset.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2 * Copyright (c) 1993-1995 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 *    must display the following acknowledgement:
15 *      This product includes software developed by the Network Research
16 *      Group at Lawrence Berkeley National Laboratory.
17 * 4. Neither the name of the University nor of the Laboratory may be used
18 *    to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#) $Header$ (LBL)
34 * $Id$
35 */
36
37#ifndef vic_transmitter_h
38#define vic_transmitter_h
39
40#ifdef WIN32
41//#include <winsock.h>
42#else
43#include <sys/param.h>
44#include <sys/socket.h>
45#include <sys/uio.h>
46#endif
47#include "vic_tcl.h"
48#include "timer.h"
49#include "rtp.h"
50#include "inet.h"
51#include "pktbuf-rtp.h"
52#include "cc/tfwc_sndr.h"
53#include "cc/tfwc_rcvr.h"
54
55#define NOCC    100
56#define WBCC    101
57#define RBCC    102
58
59/*
60 * The base object for performing the outbound path of
61 * the application level protocol.
62 */
63class Transmitter : public TclObject, public Timer,
64        public TfwcSndr, public TfwcRcvr {
65    public:
66        Transmitter();
67        virtual void timeout();
68
69        struct buffer {
70                struct buffer* next;
71                /*
72                 * make buffer twice as big as necessary so we can
73                 * run off end while doing in-place encoding.
74                 */
75                u_char data[2 * RTP_MTU];
76        };
77/*      struct pktbuf {
78                struct pktbuf* next;
79                iovec iov[2];
80                u_char hdr[MAXHDR];
81                buffer* buf;
82                int layer;
83        };*/
84        static void dump(int fd);
85        static inline void seqno(u_int16_t s) { seqno_ = s; }
86        inline void bps(int kbps) { kbps = kbps_; }
87        inline void loop_layer(int loop_layer) { loop_layer_ = loop_layer; }
88        inline int loop_layer() { return loop_layer_; }
89        inline int mtu() { return (mtu_); }
90        void flush();
91        void send(pktbuf*);
92        inline bool is_cc_on() { return is_cc_active_; }
93        void cc_tfwc_output();
94        void cc_tfrc_output();
95
96        /*
97         * Buffer allocation hooks.
98         */
99        //pktbuf* alloch(u_int32_t, int fmt);
100        //void release(pktbuf*);
101        //pktbuf* alloc(u_int32_t, int fmt);
102
103        inline double tx_now() {
104                timeval tv;
105                ::gettimeofday(&tv, NULL);
106                return ((double) tv.tv_sec + 1e-6 * (double) tv.tv_usec);
107        }
108        double tx_now_offset_;
109
110protected:
111        void update(int nbytes);
112        void dump(int fd, iovec*, int iovel) const;
113        void loopback(pktbuf*);
114        void output(pktbuf* pb);
115        virtual void transmit(pktbuf* pb) = 0;
116        double gettimeofday_secs() const;
117        double txtime(pktbuf* pb);
118
119        int mtu_;               /* mtu of wire (as seen by application) */
120        msghdr mh_;
121
122        int nf_;                /* number of frames sent */
123        int nb_;                /* number of bytes sent */
124        int np_;                /* number of packets sent */
125       
126        int kbps_;              /* bit-rate for interpkt spacing */
127        double nextpkttime_;
128
129        /* packet transmission queue */
130        int busy_;
131        pktbuf* head_;
132        pktbuf* tail_;
133
134        int loop_layer_;        /* # of layers to loop back (for testing) */
135
136        int loopback_;          /* true to loopback data packets */
137        static int dumpfd_;     /* fd to dump packet stream to */
138        static u_int16_t seqno_;
139
140        /* Cc related variables */
141        bool is_cc_active_;     /* is Cc module activated?              */
142        bool is_first_;         /* is this first CC'd data packet?      */
143        int cc_type_;
144
145    private:
146        static pktbuf* freehdrs_;
147        static buffer* freebufs_;
148        static int nbufs_;
149        static int nhdrs_;
150};
151
152#endif
Note: See TracBrowser for help on using the browser.