00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _TCP_STREAM_SINK_HH
00022 #define _TCP_STREAM_SINK_HH
00023
00024 #ifndef _MEDIA_SINK_HH
00025 #include "MediaSink.hh"
00026 #endif
00027
00028 #define TCP_STREAM_SINK_BUFFER_SIZE 10000
00029
00030 class TCPStreamSink: public MediaSink {
00031 public:
00032 static TCPStreamSink* createNew(UsageEnvironment& env, int socketNum);
00033
00034
00035
00036 protected:
00037 TCPStreamSink(UsageEnvironment& env, int socketNum);
00038 virtual ~TCPStreamSink();
00039
00040 protected:
00041
00042 virtual Boolean continuePlaying();
00043
00044 private:
00045 void processBuffer();
00046
00047 static void socketWritableHandler(void* clientData, int mask);
00048 void socketWritableHandler1();
00049
00050 static void afterGettingFrame(void* clientData, unsigned frameSize, unsigned numTruncatedBytes,
00051 struct timeval , unsigned );
00052 void afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes);
00053
00054 static void ourOnSourceClosure(void* clientData);
00055 void ourOnSourceClosure1();
00056
00057 unsigned numUnwrittenBytes() const { return fUnwrittenBytesEnd - fUnwrittenBytesStart; }
00058 unsigned freeBufferSpace() const { return TCP_STREAM_SINK_BUFFER_SIZE - fUnwrittenBytesEnd; }
00059
00060 private:
00061 unsigned char fBuffer[TCP_STREAM_SINK_BUFFER_SIZE];
00062 unsigned fUnwrittenBytesStart, fUnwrittenBytesEnd;
00063 Boolean fInputSourceIsOpen, fOutputSocketIsWritable;
00064 int fOutputSocketNum;
00065 };
00066
00067 #endif