这个类在FP2模拟器上运行良好,但是在FP1的模拟器上会卡死,只能关闭模拟器。我测试过了,是卡在接收这个活动对象里,只要我不调用接收的活动对象,就没有问题。
udpsocket.h
#ifndef UDPSOCKET_H
#define UDPSOCKET_H
// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include <es_sock.h>
#include <in_sock.h>
#include "SocketDgram.h"
// CLASS DECLARATION
class CUdpReader;
class CUdpWriter;
/**
* CUDPSocket
*
*/
class CUDPSocket: public CUdpReader::MObserver, public CUdpWriter::MObserver
{
public:
///Rtp package Observer
class MAppObserver
{
public:
virtual void OnRtpPacketReceived(const TDesC8 &aPayloadData, TInt aRtpType) = 0;
};
public:
// Constructors and destructor
/**
* Constructor for performing 1st stage construction
*/
CUDPSocket(MAppObserver& aPacketObserver,RSocketServ& aSocketServer,
RConnection& aConnection,TInetAddr& aRtpAddr,TInetAddr& aRtcpAddr);
/**
* Destructor.
*/
virtual ~CUDPSocket();
/**
* Two-phased constructor.
*/
static CUDPSocket* NewL(MAppObserver& aPacketObserver,RSocketServ& aSocketServer,
RConnection& aConnection,TInetAddr& aRtpAddr,TInetAddr& aRtcpAddr);
/**
* Two-phased constructor.
*/
static CUDPSocket* NewLC(MAppObserver& aPacketObserver,RSocketServ& aSocketServer,
RConnection& aConnection,TInetAddr& aRtpAddr,TInetAddr& aRtcpAddr);
/**
* EPOC default constructor for performing 2nd stage construction
*/
void ConstructL();
public:
/* Close existing RTP session
*
*/
void CloseSession();
/*!
@function StartRTPConnection
@Initializes RTP streams.
*/
void StartRTPConnectionL(TUint aLocalPort = 5000, TBool aEnableRtcp = ETrue, TInt aRtpType = 0);
/* Send rtp packet
*
*/
void SendRtpPacketL(TDesC8& aBuffer);
/*!
@function StartSending
@Starts sending the RTP packets to Remote IP address.
*/
void StartSending();
/*!
@function StopSending
@Starts sending the RTP packets to Remote IP address.
*/
void StopSending();
void ErrorNotify(TInt aErrCode);
//From MTimerNotify
void TimerExpired(TInt aError);
// From MRtpObserver
//void RtpPacketReceived(TRtpId aStreamId,const TRtpRecvHeader & aHeaderInfo, const TDesC8 & aPayloadData);
//From MRtcpObserver
//void SdesReceived(TRtpSSRC aSSRC, const TRtpSdesParams& aParams);
//void ByeReceived(TRtpId aStreamId, TRtpSSRC aSSRC, const TDesC8& aReason);
//void AppReceived(TRtpId aStreamId, TRtpSSRC aSSRC, const TRtcpApp& aApp);