examples/MultimediaProtocols/RTPExample/inc/RTPFileStreamer.h

00001 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
00002 // All rights reserved.
00003 // License: "Symbian Foundation License v1.0" to Symbian Foundation
00004 // members and "Symbian Foundation End User License Agreement v1.0"
00005 // to non-members at the URL
00006 // "http://www.symbianfoundation.org/legal/licencesv10.html".
00007 //
00008 // Initial Contributors:
00009 // Nokia Corporation - initial contribution.
00010 //
00011 // Contributors:
00012 //
00013 // Description:
00014 //
00015 
00016 #ifndef __RTPFILESTREAMER_H__
00017 #define __RTPFILESTREAMER_H__
00018 
00019 #include "commdbconnpref.h"
00020 #include <in_sock.h>
00021 #include <f32file.h>
00022 #include <rtp.h>
00023 
00024 
00025 class MFileStreamerObserver
00029 {
00030 public:
00031         virtual void NotifyPacketSent() {}
00032         virtual void NotifyPacketReceived() {}
00033         virtual void NotifyComplete() {}
00034         virtual void NotifyError() {}
00035 };
00036 
00037 
00038 
00039 class CRtpFileSender : public CActive
00044 {
00045 public:
00046         //Callbacks for the sender
00047         static void PacketSent(CRtpFileSender* aPtr, const TRtpEvent& aEvent);
00048         void DoPacketSent(const TRtpEvent& aEvent);
00049         static void SendError(CRtpFileSender* aPtr, const TRtpEvent& aEvent);
00050         void DoSendError(const TRtpEvent& aEvent);
00051         static CRtpFileSender* NewL(RRtpSession& aSession,RFs& aFs,const TDesC& aSrcFilename, TInt aPacketSize, TInt aDelayMicroSeconds);
00052         void StartL();
00053         void SetObserver(MFileStreamerObserver& aObserver)
00054                 {
00055                 iObserver = &aObserver;
00056                 }
00057         ~CRtpFileSender();
00058 private:
00059         CRtpFileSender(RRtpSession& aSession,RFs& aFs,TInt aPacketSize, TInt aDelayMicroSeconds);
00060         void ConstructL(const TDesC& aSrcFilename);
00061         void RunL();
00062         void DoCancel();
00063         
00064 
00065 private:
00066         RTimer  iSendIntervalTimer;
00067         TInt    iDelayMicroSecs;
00068         TInt    iPacketSize;
00069         RRtpSession&    iSession;
00070         RRtpSendSource  iSendSrc;
00071         RRtpSendPacket  iSendPacket;
00072         TPtr8                   iPayloadDesC;
00073         MFileStreamerObserver*  iObserver;
00074         RFile   iFile;
00075         RFs&    iFs;
00076 };
00077 
00078 
00079 
00080 
00081 class CRtpFileStreamer : public CBase
00087 {
00088 public:
00089 
00090     static CRtpFileStreamer* NewL(      RSocketServ& aRSocketServ,
00091                                                                 const TDesC& aSrcFilename,
00092                                                                 const TDesC& aDestFilename, 
00093                                                                 TInt aBlockLen,
00094                                                                 const TInetAddr& aDestAddr,
00095                                                                 TUint aLocalPort,TInt aConnId);
00096     
00097     ~CRtpFileStreamer();
00098         //Callbacks for the receiver
00099         static void NewSource(CRtpFileStreamer* aPtr, const TRtpEvent& aEvent);
00100         static void PacketArrived(CRtpFileStreamer* aPtr, const TRtpEvent& aEvent);
00101         inline RRtpReceiveSource& ReceiveSrc() 
00102                 {
00103                 return iRtpRecvSrc;
00104                 }
00105         void SendNextPacketL();
00106         void HandleReceivedPacketL();
00107         void SetObserver(MFileStreamerObserver& aObserver) 
00108                 {
00109                 iObserver = &aObserver;
00110                 if (iSender) iSender->SetObserver(aObserver);
00111                 }
00112         void StartL();
00113         
00114 private:
00115    CRtpFileStreamer( RSocketServ& aSocketServ, const TInetAddr& aDestAddr, TUint aLocalPort);
00116    void ConstructL(const TDesC& aSrcFilename, const TDesC& aDestFilename, TInt aPacketSize, TInt aDelayMicroSecs, TInt aConnId);
00117 public:
00118         RRtpReceivePacket iRecvPacket;
00119 private:
00120     RSocketServ& iSocketServ;
00121     RSocket iSocket;
00122         RSocket iRtcpSocket;
00123         RConnection     iConnection;
00124         TInetAddr                       iDestAddr;
00125         TUint                           iLocalPort;
00126     RRtpSession                 iRtpSession;
00127     RRtpReceiveSource   iRtpRecvSrc;
00128         MFileStreamerObserver*  iObserver;
00129         CRtpFileSender* iSender;
00130         RFs             iRFs;
00131         RFile   iDestFile;
00132 };
00133 
00134 
00135 #endif //__RTPFILESTREAMER_H__

Generated by  doxygen 1.6.2