UDPVideoStreamSvr.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2005 Andras Varga
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU Lesser General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU Lesser General Public License
00015 // along with this program; if not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 
00019 //
00020 // based on the video streaming app of the similar name by Johnny Lai
00021 //
00022 
00023 #ifndef UDPVIDEOSTREAMSVR_H
00024 #define UDPVIDEOSTREAMSVR_H
00025 
00026 #include <vector>
00027 #include <omnetpp.h>
00028 #include "UDPAppBase.h"
00029 
00030 
00038 class INET_API UDPVideoStreamSvr : public UDPAppBase
00039 {
00040   public:
00044     struct VideoStreamData
00045     {
00046         IPvXAddress clientAddr;   
00047         int clientPort;           
00048         long videoSize;           
00049         long bytesLeft;           
00050         long numPkSent;           
00051     };
00052 
00053   protected:
00054     typedef std::vector<VideoStreamData *> VideoStreamVector;
00055     VideoStreamVector streamVector;
00056 
00057     // module parameters
00058     int serverPort;
00059     cPar *waitInterval;
00060     cPar *packetLen;
00061     cPar *videoSize;
00062 
00063     // statistics
00064     unsigned int numStreams;  // number of video streams served
00065     unsigned long numPkSent;  // total number of packets sent
00066 
00067   protected:
00068     // process stream request from client
00069     virtual void processStreamRequest(cMessage *msg);
00070 
00071     // send a packet of the given video stream
00072     virtual void sendStreamData(cMessage *timer);
00073 
00074   public:
00075     UDPVideoStreamSvr();
00076     virtual ~UDPVideoStreamSvr();
00077 
00078   protected:
00080 
00081     virtual void initialize();
00082     virtual void finish();
00083     virtual void handleMessage(cMessage* msg);
00085 };
00086 
00087 
00088 #endif
00089 
00090