root / otg / trunk / src / cpp / stream.h

Revision 598, 2.7 kB (checked in by zhibinwu, 3 years ago)

adding clockref

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#ifndef STREAM_H
2#define STREAM_H
3
4#include "unixtime.h"
5#include "port.h"
6#include "packet.h"
7#include "generator.h"
8#include "dataqueue.h"
9#include <string.h>
10#include "orbitapp.h"
11//#include "oml_orbit_winlab_otg.h"
12
13
14/**
15 * Stream class is over a Port. It is the pseudo-application of the port.
16 * Streams are orginized as "stream list" --- a double-link table structure. each stream has two pointers pointed
17 * to the previous and next object in the stream list.
18 */
19//class OTGApp;
20
21class Stream {
22  friend class Port;
23  friend class Packet;
24  friend class Generator;
25public:
26 Stream(short id);
27 Stream(short id, Generator *gen, Port* port, OrbitApp* app, int clockref=-1);
28 Stream* prev_;
29 Stream* next_;
30 Packet *packetcache_;   ///< cache a packet here to send, only one packet pointer, not point to an array or queue.
31 
32protected:
33 unsigned long seqno_;  ///< number of packets sent or received  by this stream
34 Generator *gen_;      ///< the generator to feed packets to this stream
35 Port* port_;          /// the port for sending packets out.
36 short streamid_; /// stream identifier. because one OTG get multiple streams.  correponding to a pair of unique IP/Port addresses
37 //double starttime_;  ///< starting time of a stream
38 UnixTime streamclock_; ///<Contorl the timing of stream
39 OrbitApp *app_;    ///<each stream server the purpose for a certain application
40 bool paused_;  ///< indicate whether stream is paused
41       
42public:
43 /**
44  * obtain the stream identifier
45  */ 
46 inline short getID(){return streamid_;} 
47/**
48 * Function to get the packet pointer of this stream
49 */
50inline Packet* getPacket(){ return packetcache_;}
51/**
52 * Function to get the current sequence number of this stream
53 */   
54inline unsigned long getSeqno(){return seqno_;}
55
56//bool stampPktID();
57bool loadPacket();
58void startStream();
59void pauseStream();
60void resumeStream(); 
61void exitStream();
62//void otgMeasureReport();
63/**
64 * Function to indicate the deliver time of this stream.
65 *@return the next (future) deliver time of a packet recently cached (generated) for this stream. The multiplexing function has to compare those deliver times for each stream if there are multiple streams present.
66 *@see Port::pickPacket
67 */
68 inline double getDeliverTime() { 
69     if (packetcache_ != NULL) 
70             return packetcache_->getTimeStamp();
71     //otherwise
72     return 0; // 0 should be an error!!! Exception
73 }
74 /**
75  * Function to load a generator for a stream. Each stream must bind to a generator.
76  */
77 inline void loadGenerator(Generator *gen){ gen_ = gen; } 
78 /**
79  * Function to select a "port" to send a stream. Each stream must bind to a Port
80  */
81 inline void bindPort(Port *port){ port_ = port; } 
82 inline Generator *getGenerator(){return gen_;}               
83 inline Port *getPort(){return port_;}
84};
85
86
87 
88#endif
Note: See TracBrowser for help on using the browser.