examples/MultimediaProtocols/RTPExample/inc/RTPFileStreamer.h

00001 /*
00002 Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008 � list of conditions and the following disclaimer.
00009 * Redistributions in binary form must reproduce the above copyright notice,
00010 � this list of conditions and the following disclaimer in the documentation
00011 � and/or other materials provided with the distribution.
00012 * Neither the name of Nokia Corporation nor the names of its contributors
00013 � may be used to endorse or promote products derived from this software
00014 � without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 Description:� 
00028 */
00029 
00030 
00031 #ifndef __RTPFILESTREAMER_H__
00032 #define __RTPFILESTREAMER_H__
00033 
00034 #include "commdbconnpref.h"
00035 #include <in_sock.h>
00036 #include <f32file.h>
00037 #include <rtp.h>
00038 
00039 
00040 class MFileStreamerObserver
00044 {
00045 public:
00046         virtual void NotifyPacketSent() {}
00047         virtual void NotifyPacketReceived() {}
00048         virtual void NotifyComplete() {}
00049         virtual void NotifyError() {}
00050 };
00051 
00052 
00053 
00054 class CRtpFileSender : public CActive
00059 {
00060 public:
00061         //Callbacks for the sender
00062         static void PacketSent(CRtpFileSender* aPtr, const TRtpEvent& aEvent);
00063         void DoPacketSent(const TRtpEvent& aEvent);
00064         static void SendError(CRtpFileSender* aPtr, const TRtpEvent& aEvent);
00065         void DoSendError(const TRtpEvent& aEvent);
00066         static CRtpFileSender* NewL(RRtpSession& aSession,RFs& aFs,const TDesC& aSrcFilename, TInt aPacketSize, TInt aDelayMicroSeconds);
00067         void StartL();
00068         void SetObserver(MFileStreamerObserver& aObserver)
00069                 {
00070                 iObserver = &aObserver;
00071                 }
00072         ~CRtpFileSender();
00073 private:
00074         CRtpFileSender(RRtpSession& aSession,RFs& aFs,TInt aPacketSize, TInt aDelayMicroSeconds);
00075         void ConstructL(const TDesC& aSrcFilename);
00076         void RunL();
00077         void DoCancel();
00078         
00079 
00080 private:
00081         RTimer  iSendIntervalTimer;
00082         TInt    iDelayMicroSecs;
00083         TInt    iPacketSize;
00084         RRtpSession&    iSession;
00085         RRtpSendSource  iSendSrc;
00086         RRtpSendPacket  iSendPacket;
00087         TPtr8                   iPayloadDesC;
00088         MFileStreamerObserver*  iObserver;
00089         RFile   iFile;
00090         RFs&    iFs;
00091 };
00092 
00093 
00094 
00095 
00096 class CRtpFileStreamer : public CBase
00102 {
00103 public:
00104 
00105     static CRtpFileStreamer* NewL(      RSocketServ& aRSocketServ,
00106                                                                 const TDesC& aSrcFilename,
00107                                                                 const TDesC& aDestFilename, 
00108                                                                 TInt aBlockLen,
00109                                                                 const TInetAddr& aDestAddr,
00110                                                                 TUint aLocalPort,TInt aConnId);
00111     
00112     ~CRtpFileStreamer();
00113         //Callbacks for the receiver
00114         static void NewSource(CRtpFileStreamer* aPtr, const TRtpEvent& aEvent);
00115         static void PacketArrived(CRtpFileStreamer* aPtr, const TRtpEvent& aEvent);
00116         inline RRtpReceiveSource& ReceiveSrc() 
00117                 {
00118                 return iRtpRecvSrc;
00119                 }
00120         void SendNextPacketL();
00121         void HandleReceivedPacketL();
00122         void SetObserver(MFileStreamerObserver& aObserver) 
00123                 {
00124                 iObserver = &aObserver;
00125                 if (iSender) iSender->SetObserver(aObserver);
00126                 }
00127         void StartL();
00128         
00129 private:
00130    CRtpFileStreamer( RSocketServ& aSocketServ, const TInetAddr& aDestAddr, TUint aLocalPort);
00131    void ConstructL(const TDesC& aSrcFilename, const TDesC& aDestFilename, TInt aPacketSize, TInt aDelayMicroSecs, TInt aConnId);
00132 public:
00133         RRtpReceivePacket iRecvPacket;
00134 private:
00135     RSocketServ& iSocketServ;
00136     RSocket iSocket;
00137         RSocket iRtcpSocket;
00138         RConnection     iConnection;
00139         TInetAddr                       iDestAddr;
00140         TUint                           iLocalPort;
00141     RRtpSession                 iRtpSession;
00142     RRtpReceiveSource   iRtpRecvSrc;
00143         MFileStreamerObserver*  iObserver;
00144         CRtpFileSender* iSender;
00145         RFs             iRFs;
00146         RFile   iDestFile;
00147 };
00148 
00149 
00150 #endif //__RTPFILESTREAMER_H__

Generated by  doxygen 1.6.2