r2760 - in branches/rtcp_ntp: mediahandler rtp/rtcp sip
matts at minisip.org
matts at minisip.org
Tue Sep 12 09:40:35 CEST 2006
Author: matts
Date: 2006-09-12 09:40:34 +0200 (Tue, 12 Sep 2006)
New Revision: 2760
Modified:
branches/rtcp_ntp/mediahandler/MediaHandler.cxx
branches/rtcp_ntp/mediahandler/MediaStream.cxx
branches/rtcp_ntp/mediahandler/RtpReceiver.cxx
branches/rtcp_ntp/rtp/rtcp/RtcpReceiver.cpp
branches/rtcp_ntp/rtp/rtcp/RtcpSRManager.cpp
branches/rtcp_ntp/rtp/rtcp/RtcpSRManager.h
branches/rtcp_ntp/rtp/rtcp/StreamStatistics.cpp
branches/rtcp_ntp/rtp/rtcp/StreamStatistics.h
branches/rtcp_ntp/sip/Sip.cxx
Log:
Commiting code that was left on dev machine, ccsser2.
enabled NTP; if flag NTP_ENABLED is set you are able to use NTP
enabled RTCP; if flag RTCP_ENABLED is set you are able to use RTCP
Modified: branches/rtcp_ntp/mediahandler/MediaHandler.cxx
===================================================================
--- branches/rtcp_ntp/mediahandler/MediaHandler.cxx 2006-09-11 18:17:20 UTC (rev 2759)
+++ branches/rtcp_ntp/mediahandler/MediaHandler.cxx 2006-09-12 07:40:34 UTC (rev 2760)
@@ -1,303 +1,289 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/* Copyright (C) 2004, 2005
- *
- * Authors: Erik Eliasson <eliasson at it.kth.se>
- * Johan Bilien <jobi at via.ecp.fr>
-*/
-
-#include<config.h>
-#include<string.h>
-#include"../sdp/SdpPacket.h"
-#include<libmikey/keyagreement.h>
-#include"../sip/SipDialogSecurityConfig.h"
-#include"../sip/SipSoftPhoneConfiguration.h"
-#include"../minisip/ipprovider/IpProvider.h"
-#include"../codecs/Codec.h"
-#include"Session.h"
-#include"MediaStream.h"
-#include"MediaHandler.h"
-#include"Media.h"
-#include"RtpReceiver.h"
-#include"MediaCommandString.h"
-#include<libmnetutil/UDPSocket.h>
-
-#include"../soundcard/SoundIO.h"
-#include"../soundcard/SoundDevice.h"
-#include"../codecs/Codec.h"
-
-#ifdef RTCP_ENABLED
-#include "../rtp/rtcp/RtcpSender.h"
-#include "../rtp/rtcp/RtcpReceiver.h"
-#include "../rtp/rtcp/StreamStatistics.h"
-#endif
-
-
-#ifdef VIDEO_SUPPORT
-#include"../video/grabber/Grabber.h"
-#include"../video/display/VideoDisplay.h"
-#include"../video/codec/VideoCodec.h"
-#include"../video/codec/AVCoder.h"
-#include"../video/codec/AVDecoder.h"
-#include"../video/mixer/ImageMixer.h"
-#endif
-
-
-using namespace std;
-
-MediaHandler::MediaHandler( MRef<SipSoftPhoneConfiguration *> config, MRef<IpProvider *> ipProvider ){
-
- this->ipProvider = ipProvider;
- this->config = config;
- init();
-}
-
-void MediaHandler::init(){
-
- media.clear();
-
-#ifdef VIDEO_SUPPORT
- MRef<Grabber *> grabber = Grabber::create( config->videoDevice );
- MRef<VideoCodec *> videoCodec = new VideoCodec();
- MRef<ImageMixer *> mixer = NULL;//new ImageMixer();
- MRef<VideoMedia *> videoMedia = new VideoMedia( *videoCodec, NULL/*display*/, mixer, grabber, config->frameWidth, config->frameHeight );
- if( mixer ){
- mixer->setMedia( videoMedia );
- }
- registerMedia( *videoMedia );
-#endif
-
- string soundDev = config->soundDevice;
- if( soundDev != "" ){
-
- MRef<SoundDevice *> sounddev = SoundDevice::create( soundDev );
- MRef<SoundIO *> soundIo = new SoundIO(
- sounddev,
- config->soundIOmixerType,
- 2, //number of channels
- 48000 ); //sampling rate
-
- std::list<MRef<Codec *> > codecList;
- std::list<std::string>::iterator iCodec;
- MRef<Codec *> selectedCodec;
-
- for( iCodec = config->audioCodecs.begin();
- iCodec != config->audioCodecs.end();
- iCodec ++ ){
-
- selectedCodec = (Codec*)*AudioCodec::create( *iCodec );
- if( selectedCodec ){
-#ifdef DEBUG_OUTPUT
- cerr << "Adding audio codec: " << selectedCodec->getCodecName() << endl;
-#endif
- codecList.push_back( selectedCodec );
- }
- }
-
- MRef<AudioMedia *> media = new AudioMedia( soundIo, codecList );
-
- registerMedia( *media );
- audioMedia = media;
- }
-
-// muteAllButOne = config->muteAllButOne;
-
- ringtoneFile = config->ringtone;
-}
-
-// MediaHandler::~MediaHandler() {
-// cerr << "~MediaHandler" << endl;
-// if( ! Session::registry ){
-// cerr << "deleting session::registry" << endl;
-// }
-// }
-
-
-MRef<Session *> MediaHandler::createSession( SipDialogSecurityConfig &securityConfig, string callId ){
-
- list< MRef<Media *> >::iterator i;
- MRef<Session *> session;
- MRef<MediaStreamReceiver *> rStream;
- MRef<MediaStreamSender *> sStream;
- MRef<RtpReceiver *> rtpReceiver;
-
-#ifdef RTCP_ENABLED
- MRef<RtcpSender *> rtcpSender;
- MRef<RtcpReceiver *> rtcpReceiver;
- MRef<StreamStatistics *> sStt;
-#endif
-
- string contactIp;
-
- contactIp = ipProvider->getExternalIp();
-
- session = new Session( contactIp, securityConfig );
- session->setCallId( callId );
-
- for( i = media.begin(); i != media.end(); i++ ){
- if( (*i)->receive ){
-#ifdef NTP_ENABLED
- rtpReceiver = new RtpReceiver( ipProvider, config->getNTPhandler() );
-#else
- rtpReceiver = new RtpReceiver( ipProvider );
-#endif
-
-#ifdef RTCP_ENABLED
- sStt=new StreamStatistics();
-
- #ifdef NTP_ENABLED
- rtcpSender=new RtcpSender( rtpReceiver->getPort()+1, sStt, config->getNTPhandler() );
- #else
- rtcpSender=new RtcpSender( rtpReceiver->getPort()+1 , sStt );
- #endif
-
- rtpReceiver->setRtcpSender(rtcpSender);
-
- rStream = new MediaStreamReceiver( *i, rtpReceiver, ipProvider );
-
- rStream->setSStatistic(sStt);
-#else
-
- rStream = new MediaStreamReceiver( *i, rtpReceiver, ipProvider );
-#endif
- session->addMediaStreamReceiver( rStream );
- }
-
- if( (*i)->send ){
-
-#ifdef RTCP_ENABLED
- #ifdef NTP_ENABLED
- rtcpReceiver = new RtcpReceiver(rtcpSender->getSocket(), config->getNTPhandler(), sStt);
- #else
- rtcpReceiver = new RtcpReceiver(rtcpSender->getSocket(),sStt);
- #endif
- sStream = new MediaStreamSender( *i, rtpReceiver->getSocket());
-
- sStream->setRtcpReceiver(rtcpReceiver);
-
- sStream->setSStatistic(sStt);
-
-#else
- sStream = new MediaStreamSender( *i, rtpReceiver->getSocket());
-#endif
- session->addMediaStreamSender( sStream );
- }
- }
-
- //set the audio settings for this session ...
- session->muteSenders( true );
- session->silenceSources( false );
-
- return session;
-
-}
-
-
-void MediaHandler::registerMedia( MRef<Media*> media ){
- this->media.push_back( media );
-}
-
-void MediaHandler::handleCommand( CommandString command ){
- if( command.getOp() == MediaCommandString::start_ringing ){
-// cerr << "MediaHandler::handleCmd - start ringing" << endl;
- if( audioMedia && ringtoneFile != "" ){
- audioMedia->startRinging( ringtoneFile );
- }
- return;
- }
-
- if( command.getOp() == MediaCommandString::stop_ringing ){
-// cerr << "MediaHandler::handleCmd - stop ringing" << endl;
- if( audioMedia ){
- audioMedia->stopRinging();
- }
- return;
- }
-
- if( command.getOp() == MediaCommandString::session_debug ){
-#ifdef DEBUG_OUTPUT
- cerr << getDebugString() << endl;
-#endif
- return;
- }
-
- if( command.getOp() == MediaCommandString::set_session_sound_settings ){
- bool turnOn;
-#ifdef DEBUG_OUTPUT
- cerr << "MediaHandler::handleCmd: received set session sound settings"
- << endl << " " << command.getString() << endl;
-#endif
- if( command.getParam2() == "ON" ) turnOn = true;
- else turnOn = false;
- setSessionSoundSettings( command.getDestinationId(),
- command.getParam(),
- turnOn );
- return;
- }
-
- if( command.getOp() == MediaCommandString::reload ){
- init();
- return;
- }
-}
-
-std::string MediaHandler::getExtIP(){
- return ipProvider->getExternalIp();
-}
-
-void MediaHandler::setSessionSoundSettings( std::string callid, std::string side, bool turnOn ) {
- list<MRef<Session *> >::iterator iSession;
-
- //what to do with received audio
- if( side == "receivers" ) {
- sessionsLock.lock();
- for( iSession = sessions.begin(); iSession != sessions.end(); iSession++ ){
- if( (*iSession)->getCallId() == callid ){
- //the meaning of turnOn is the opposite of the Session:: functions ... silence/mute
- (*iSession)->silenceSources( ! turnOn );
- }
- }
- sessionsLock.unlock();
- } else if ( side == "senders" ) { //what to do with audio to be sent over the net
- //set the sender ON as requested ...
- sessionsLock.lock();
- for( iSession = sessions.begin(); iSession != sessions.end(); iSession++ ){
- if( (*iSession)->getCallId() == callid ){
- //the meaning of turnOn is the opposite of the Session:: functions ... silence/mute
- (*iSession)->muteSenders( !turnOn );
-
- }
- }
- sessionsLock.unlock();
- } else {
- cerr << "MediaHandler::setSessionSoundSettings - not understood" << endl;
- return;
- }
-
-}
-
-#ifdef DEBUG_OUTPUT
-string MediaHandler::getDebugString() {
- string ret;
- ret = getMemObjectType() + ": Debug Info\n";
- for( std::list<MRef<Session *> >::iterator it = sessions.begin();
- it != sessions.end(); it++ ) {
- ret += "** Session : \n" + (*it)->getDebugString() + "\n";
- }
- return ret;
-}
-#endif
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* Copyright (C) 2004, 2005
+ *
+ * Authors: Erik Eliasson <eliasson at it.kth.se>
+ * Johan Bilien <jobi at via.ecp.fr>
+*/
+
+#include<config.h>
+#include<string.h>
+#include"../sdp/SdpPacket.h"
+#include<libmikey/keyagreement.h>
+#include"../sip/SipDialogSecurityConfig.h"
+#include"../sip/SipSoftPhoneConfiguration.h"
+#include"../minisip/ipprovider/IpProvider.h"
+#include"../codecs/Codec.h"
+#include"Session.h"
+#include"MediaStream.h"
+#include"MediaHandler.h"
+#include"Media.h"
+#include"RtpReceiver.h"
+#include"MediaCommandString.h"
+#include<libmnetutil/UDPSocket.h>
+
+#include"../soundcard/SoundIO.h"
+#include"../soundcard/SoundDevice.h"
+#include"../codecs/Codec.h"
+
+#ifdef RTCP_ENABLED
+#include "../rtp/rtcp/RtcpSender.h"
+#include "../rtp/rtcp/RtcpReceiver.h"
+#include "../rtp/rtcp/StreamStatistics.h"
+#endif
+
+
+#ifdef VIDEO_SUPPORT
+#include"../video/grabber/Grabber.h"
+#include"../video/display/VideoDisplay.h"
+#include"../video/codec/VideoCodec.h"
+#include"../video/codec/AVCoder.h"
+#include"../video/codec/AVDecoder.h"
+#include"../video/mixer/ImageMixer.h"
+#endif
+
+
+using namespace std;
+
+MediaHandler::MediaHandler( MRef<SipSoftPhoneConfiguration *> config, MRef<IpProvider *> ipProvider ){
+
+ this->ipProvider = ipProvider;
+ this->config = config;
+ init();
+}
+
+void MediaHandler::init(){
+
+ media.clear();
+
+#ifdef VIDEO_SUPPORT
+ MRef<Grabber *> grabber = Grabber::create( config->videoDevice );
+ MRef<VideoCodec *> videoCodec = new VideoCodec();
+ MRef<ImageMixer *> mixer = NULL;//new ImageMixer();
+ MRef<VideoMedia *> videoMedia = new VideoMedia( *videoCodec, NULL/*display*/, mixer, grabber, config->frameWidth, config->frameHeight );
+ if( mixer ){
+ mixer->setMedia( videoMedia );
+ }
+ registerMedia( *videoMedia );
+#endif
+
+ string soundDev = config->soundDevice;
+ if( soundDev != "" ){
+
+ MRef<SoundDevice *> sounddev = SoundDevice::create( soundDev );
+ MRef<SoundIO *> soundIo = new SoundIO(
+ sounddev,
+ config->soundIOmixerType,
+ 2, //number of channels
+ 48000 ); //sampling rate
+
+ std::list<MRef<Codec *> > codecList;
+ std::list<std::string>::iterator iCodec;
+ MRef<Codec *> selectedCodec;
+
+ for( iCodec = config->audioCodecs.begin();
+ iCodec != config->audioCodecs.end();
+ iCodec ++ ){
+
+ selectedCodec = (Codec*)*AudioCodec::create( *iCodec );
+ if( selectedCodec ){
+#ifdef DEBUG_OUTPUT
+ cerr << "Adding audio codec: " << selectedCodec->getCodecName() << endl;
+#endif
+ codecList.push_back( selectedCodec );
+ }
+ }
+
+ MRef<AudioMedia *> media = new AudioMedia( soundIo, codecList );
+
+ registerMedia( *media );
+ audioMedia = media;
+ }
+
+ ringtoneFile = config->ringtone;
+}
+
+
+MRef<Session *> MediaHandler::createSession( SipDialogSecurityConfig &securityConfig, string callId ){
+
+ list< MRef<Media *> >::iterator i;
+ MRef<Session *> session;
+ MRef<MediaStreamReceiver *> rStream;
+ MRef<MediaStreamSender *> sStream;
+ MRef<RtpReceiver *> rtpReceiver;
+
+#ifdef RTCP_ENABLED
+ MRef<RtcpSender *> rtcpSender;
+ MRef<RtcpReceiver *> rtcpReceiver;
+ MRef<StreamStatistics *> sStt;
+#endif
+
+ string contactIp;
+
+ contactIp = ipProvider->getExternalIp();
+
+ session = new Session( contactIp, securityConfig );
+ session->setCallId( callId );
+
+ for( i = media.begin(); i != media.end(); i++ ){
+ if( (*i)->receive ){
+#ifdef NTP_ENABLED
+ rtpReceiver = new RtpReceiver( ipProvider, config->getNTPhandler() );
+#else
+ rtpReceiver = new RtpReceiver( ipProvider );
+#endif
+
+#ifdef RTCP_ENABLED
+
+ #ifdef NTP_ENABLED
+ sStt = new StreamStatistics(config->getNTPhandler());
+ #else
+ rtcpSender=new RtcpSender( rtpReceiver->getPort()+1 , sStt );
+ #endif
+
+ rtcpSender = new RtcpSender( rtpReceiver->getPort()+1 , sStt );
+ rtpReceiver->setRtcpSender(rtcpSender);
+
+ rStream = new MediaStreamReceiver( *i, rtpReceiver, ipProvider );
+
+ rStream->setSStatistic(sStt);
+#else
+
+ rStream = new MediaStreamReceiver( *i, rtpReceiver, ipProvider );
+#endif
+ session->addMediaStreamReceiver( rStream );
+ }
+
+ if( (*i)->send ){
+
+#ifdef RTCP_ENABLED
+ sStream = new MediaStreamSender( *i, rtpReceiver->getSocket());
+
+ sStream->setRtcpReceiver(rtcpReceiver);
+
+ sStream->setSStatistic(sStt);
+
+#else
+ sStream = new MediaStreamSender( *i, rtpReceiver->getSocket());
+#endif
+ session->addMediaStreamSender( sStream );
+ }
+ }
+
+ //set the audio settings for this session ...
+ session->muteSenders( true );
+ session->silenceSources( false );
+
+ return session;
+
+}
+
+
+void MediaHandler::registerMedia( MRef<Media*> media ){
+ this->media.push_back( media );
+}
+
+void MediaHandler::handleCommand( CommandString command ){
+ if( command.getOp() == MediaCommandString::start_ringing ){
+// cerr << "MediaHandler::handleCmd - start ringing" << endl;
+ if( audioMedia && ringtoneFile != "" ){
+ audioMedia->startRinging( ringtoneFile );
+ }
+ return;
+ }
+
+ if( command.getOp() == MediaCommandString::stop_ringing ){
+// cerr << "MediaHandler::handleCmd - stop ringing" << endl;
+ if( audioMedia ){
+ audioMedia->stopRinging();
+ }
+ return;
+ }
+
+ if( command.getOp() == MediaCommandString::session_debug ){
+#ifdef DEBUG_OUTPUT
+ cerr << getDebugString() << endl;
+#endif
+ return;
+ }
+
+ if( command.getOp() == MediaCommandString::set_session_sound_settings ){
+ bool turnOn;
+#ifdef DEBUG_OUTPUT
+ cerr << "MediaHandler::handleCmd: received set session sound settings"
+ << endl << " " << command.getString() << endl;
+#endif
+ if( command.getParam2() == "ON" ) turnOn = true;
+ else turnOn = false;
+ setSessionSoundSettings( command.getDestinationId(),
+ command.getParam(),
+ turnOn );
+ return;
+ }
+
+ if( command.getOp() == MediaCommandString::reload ){
+ init();
+ return;
+ }
+}
+
+std::string MediaHandler::getExtIP(){
+ return ipProvider->getExternalIp();
+}
+
+void MediaHandler::setSessionSoundSettings( std::string callid, std::string side, bool turnOn ) {
+ list<MRef<Session *> >::iterator iSession;
+
+ //what to do with received audio
+ if( side == "receivers" ) {
+ sessionsLock.lock();
+ for( iSession = sessions.begin(); iSession != sessions.end(); iSession++ ){
+ if( (*iSession)->getCallId() == callid ){
+ //the meaning of turnOn is the opposite of the Session:: functions ... silence/mute
+ (*iSession)->silenceSources( ! turnOn );
+ }
+ }
+ sessionsLock.unlock();
+ } else if ( side == "senders" ) { //what to do with audio to be sent over the net
+ //set the sender ON as requested ...
+ sessionsLock.lock();
+ for( iSession = sessions.begin(); iSession != sessions.end(); iSession++ ){
+ if( (*iSession)->getCallId() == callid ){
+ //the meaning of turnOn is the opposite of the Session:: functions ... silence/mute
+ (*iSession)->muteSenders( !turnOn );
+
+ }
+ }
+ sessionsLock.unlock();
+ } else {
+ cerr << "MediaHandler::setSessionSoundSettings - not understood" << endl;
+ return;
+ }
+
+}
+
+#ifdef DEBUG_OUTPUT
+string MediaHandler::getDebugString() {
+ string ret;
+ ret = getMemObjectType() + ": Debug Info\n";
+ for( std::list<MRef<Session *> >::iterator it = sessions.begin();
+ it != sessions.end(); it++ ) {
+ ret += "** Session : \n" + (*it)->getDebugString() + "\n";
+ }
+ return ret;
+}
+#endif
Modified: branches/rtcp_ntp/mediahandler/MediaStream.cxx
===================================================================
--- branches/rtcp_ntp/mediahandler/MediaStream.cxx 2006-09-11 18:17:20 UTC (rev 2759)
+++ branches/rtcp_ntp/mediahandler/MediaStream.cxx 2006-09-12 07:40:34 UTC (rev 2760)
@@ -306,10 +306,6 @@
media->playData( *packet );
-#ifdef RTCP_ENABLED
- sStt->incRPacketCount();
- sStt->incROctetCount(packet->size());
-#endif
}
void MediaStreamReceiver::gotSsrc( uint32_t ssrc ){
@@ -437,6 +433,9 @@
sStt->incSPacketCount();
sStt->incSOctetCount(packet->size());
sStt->setLastRtpTs(packet->getHeader().getTimestamp());
+ #ifdef NTP_ENABLED
+ sStt->createNTPtimestamp();
+ #endif
#endif
delete packet;
Modified: branches/rtcp_ntp/mediahandler/RtpReceiver.cxx
===================================================================
--- branches/rtcp_ntp/mediahandler/RtpReceiver.cxx 2006-09-11 18:17:20 UTC (rev 2759)
+++ branches/rtcp_ntp/mediahandler/RtpReceiver.cxx 2006-09-12 07:40:34 UTC (rev 2760)
@@ -1,265 +1,265 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/* Copyright (C) 2004, 2005
- *
- * Authors: Erik Eliasson <eliasson at it.kth.se>
- * Johan Bilien <jobi at via.ecp.fr>
-*/
-
-#include<config.h>
-
-#include"RtpReceiver.h"
-#include"MediaStream.h"
-#include"../minisip/ipprovider/IpProvider.h"
-#include<libmnetutil/NetworkException.h>
-#include<libmnetutil/UDPSocket.h>
-#include<libmutil/Thread.h>
-#include"../rtp/SRtpPacket.h"
-#include"../codecs/Codec.h"
-#include<iostream>
-
-#include<libmutil/itoa.h> //for debug ... remove ... cesc
-
-#include<stdio.h>
-#include<sys/types.h>
-#include<stdlib.h> //for rand
-
-
-#ifdef WIN32
-#include<winsock2.h>
-#include<windows.h>
-#endif
-
-#ifdef RTCP_ENABLED
-#define FEEDBACKINTERVAL 25
-#include"../rtp/rtcp/RtcpPacket.h"
-#include"../rtp/rtcp/RtcpReportSR.h"
-
- #ifdef NTP_ENABLED
- #include"../rtp/rtcp/NTP.h"
- #endif
-
- //#ifdef WIN32
- //#include<ibmts.h>
- //#endif
-
-#endif
-
-
-#ifdef _MSC_VER
-#include<errno.h>
-
-#else
-#include<sys/time.h>
-#include<unistd.h>
-#include<errno.h>
-#endif
-
-//Set the range of rtp usable ports ... starting at min and spanning a range, up to max
-#define RTP_LOCAL_PORT_RANGE_MIN 30000
-#define RTP_LOCAL_PORT_RANGE 5000
-#define RTP_LOCAL_PORT_RANGE_MAX RTP_LOCAL_PORT_RANGE_MIN + RTP_LOCAL_PORT_RANGE
-#define RTP_RECEIVER_MAX_RETRIES 5
-
-
-using namespace std;
-
-RtpReceiver::RtpReceiver( MRef<IpProvider *> ipProvider){
-
- socket = NULL;
-
- int portretry = 0;
- for (; portretry<RTP_RECEIVER_MAX_RETRIES; portretry++ ) {
- //generate a random port, even number, in the given range
- float randPartial = (float)rand() / RAND_MAX;
- int port = (int) (RTP_LOCAL_PORT_RANGE * randPartial );
- port = 2 * (int)( port/2 ); //turn this into an even number
- port += RTP_LOCAL_PORT_RANGE_MIN; //add the min port to set it within the range
- #ifdef DEBUG_OUTPUT
- printf( "RtpReceiver:: final trying port = %d\n", port );
- #endif
- try{
- socket = new UDPSocket( port );
- if( socket ) {
- break;
- }
- }
- catch( NetworkException & exc ){
- // FIXME: do something nice
-// merr << "Minisip could not create a UDP socket!" << end;
-// merr << "Check your network settings." << end;
-// exit( 1 );
- #ifdef DEBUG_OUTPUT
- cerr << "RtpReceiver: Could not create UDP socket" << endl;
- #endif
- }
- }
- if( portretry == RTP_RECEIVER_MAX_RETRIES && !socket ) {
- merr << "Minisip could not create a UDP socket!" << end;
- merr << "Check your network settings." << end << "Quitting badly" << end;
- exit( 1 );
- }
-
- externalPort = ipProvider->getExternalPort( socket );
-
- kill = false;
-
- thread = new Thread(this);
-}
-
-#ifdef NTP_ENABLED
-RtpReceiver::RtpReceiver(MRef<IpProvider *> ipProvider, MRef<NTP *> NTPhandler) {
- this->ntp = NTPhandler;
-
- socket = NULL;
-
- int portretry = 0;
- for (; portretry<RTP_RECEIVER_MAX_RETRIES; portretry++ ) {
- //generate a random port, even number, in the given range
- float randPartial = (float)rand() / RAND_MAX;
- int port = (int) (RTP_LOCAL_PORT_RANGE * randPartial );
- port = 2 * (int)( port/2 ); //turn this into an even number
- port += RTP_LOCAL_PORT_RANGE_MIN; //add the min port to set it within the range
- #ifdef DEBUG_OUTPUT
- printf( "RtpReceiver:: final trying port = %d\n", port );
- #endif
- try{
- socket = new UDPSocket( port );
- if( socket ) {
- break;
- }
- }
- catch( NetworkException & exc ){
- // FIXME: do something nice
-// merr << "Minisip could not create a UDP socket!" << end;
-// merr << "Check your network settings." << end;
-// exit( 1 );
- #ifdef DEBUG_OUTPUT
- cerr << "RtpReceiver: Could not create UDP socket" << endl;
- #endif
- }
- }
- if( portretry == RTP_RECEIVER_MAX_RETRIES && !socket ) {
- merr << "Minisip could not create a UDP socket!" << end;
- merr << "Check your network settings." << end << "Quitting badly" << end;
- exit( 1 );
- }
-
- externalPort = ipProvider->getExternalPort( socket );
-
- kill = false;
-
- thread = new Thread(this);
-}
-
-
-#endif
-
-RtpReceiver::~RtpReceiver(){
- thread->join();
- delete thread;
- socket->close();
-}
-
-/**
- register a mediaStreamReceiver ... if the receiver is already registered,
- update the exhisting one to point to the new receiver.
-*/
-void RtpReceiver::registerMediaStream( MRef<MediaStreamReceiver *> mediaStream ){
- list< MRef<MediaStreamReceiver *> >::iterator iter;
- mediaStreamsLock.lock();
- /* Don't register new streams if the receiver is being closed */
- if( !kill ){
- bool found = false;
- //cerr << "RtpReceiver::registerMediaStream: register done!" << endl;
- for( iter = mediaStreams.begin();
- iter != mediaStreams.end();
- iter++ ) {
- if( (*iter)->getId() == mediaStream->getId() ) {
- found = true;
- #ifdef DEBUG_OUTPUT
- cerr << "RtpRcvr::registerMediaStream: media stream already registered. Updating MRef." << endl;
- #endif
- (*iter) = mediaStream;
- break;
- }
- }
- if( !found ) {
- mediaStreams.push_back( mediaStream );
- }
- }
- mediaStreamsLock.unlock();
-}
-
-void RtpReceiver::unregisterMediaStream( MRef<MediaStreamReceiver *> mediaStream ){
-#ifdef DEBUG_OUTPUT
- // cerr << "RtpReceiver::unregisterMediaStream: Before taking lock" << endl;
-#endif
- mediaStreamsLock.lock();
- mediaStreams.remove( mediaStream );
- if( mediaStreams.size() == 0 ){
- /* End the thread */
- kill = true;
- }
- mediaStreamsLock.unlock();
-#ifdef DEBUG_OUTPUT
- // cerr << "RtpReceiver::unregisterMediaStream: After taking lock" << endl;
-#endif
-}
-
-uint16_t RtpReceiver::getPort(){
- return externalPort;
-}
-
-MRef<UDPSocket *> RtpReceiver::getSocket(){
- return socket;
-}
-#ifdef NTP_ENABLED
-void RtpReceiver::setNTPhandler(MRef<NTP*> NTPhandler) {
- this->ntp = NTPhandler;
-}
-#endif
-
-#ifdef RTCP_ENABLED
-
-void RtpReceiver::setRtcpSender(MRef<RtcpSender*> rtcpSender){
- this->rtcpSender=rtcpSender;
-}
-
-#endif
-
-void RtpReceiver::run() {
-
- MRef<SRtpPacket *> packet;
-
-#ifdef RTCP_ENABLED
- IPAddress *remoteAddress=NULL;
- int32_t remotePort=0;
- #ifdef NTP_ENABLED
- //MRef<NTP *> ntp = new NTP();
- static MRef <NTPtimestamp *> currentTs = ntp->getNTPtimestamp();
- //static MRef <NTPtimestamp *> compareTs = ntp->getNTPtimestamp();
- //cout << "\n ###compareTs: " << compareTs->getNTP_MSW();
- #endif
-#endif
-
- while( !kill ) {
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+/* Copyright (C) 2004, 2005
+ *
+ * Authors: Erik Eliasson <eliasson at it.kth.se>
+ * Johan Bilien <jobi at via.ecp.fr>
+*/
+
+#include<config.h>
+
+#include"RtpReceiver.h"
+#include"MediaStream.h"
+#include"../minisip/ipprovider/IpProvider.h"
+#include<libmnetutil/NetworkException.h>
+#include<libmnetutil/UDPSocket.h>
+#include<libmutil/Thread.h>
+#include"../rtp/SRtpPacket.h"
+#include"../codecs/Codec.h"
+#include<iostream>
+
+#include<libmutil/itoa.h> //for debug ... remove ... cesc
+
+#include<stdio.h>
+#include<sys/types.h>
+#include<stdlib.h> //for rand
+
+
+#ifdef WIN32
+#include<winsock2.h>
+#include<windows.h>
+#endif
+
#ifdef RTCP_ENABLED
+#define FEEDBACKINTERVAL 25
+#include"../rtp/rtcp/RtcpPacket.h"
+#include"../rtp/rtcp/RtcpReportSR.h"
+
+ #ifdef NTP_ENABLED
+ #include"../rtp/rtcp/NTP.h"
+ #endif
+
+ //#ifdef WIN32
+ //#include<ibmts.h>
+ //#endif
+
+#endif
+
+
+#ifdef _MSC_VER
+#include<errno.h>
+
+#else
+#include<sys/time.h>
+#include<unistd.h>
+#include<errno.h>
+#endif
+
+//Set the range of rtp usable ports ... starting at min and spanning a range, up to max
+#define RTP_LOCAL_PORT_RANGE_MIN 30000
+#define RTP_LOCAL_PORT_RANGE 5000
+#define RTP_LOCAL_PORT_RANGE_MAX RTP_LOCAL_PORT_RANGE_MIN + RTP_LOCAL_PORT_RANGE
+#define RTP_RECEIVER_MAX_RETRIES 5
+
+
+using namespace std;
+
+RtpReceiver::RtpReceiver( MRef<IpProvider *> ipProvider){
+
+ socket = NULL;
+
+ int portretry = 0;
+ for (; portretry<RTP_RECEIVER_MAX_RETRIES; portretry++ ) {
+ //generate a random port, even number, in the given range
+ float randPartial = (float)rand() / RAND_MAX;
+ int port = (int) (RTP_LOCAL_PORT_RANGE * randPartial );
+ port = 2 * (int)( port/2 ); //turn this into an even number
+ port += RTP_LOCAL_PORT_RANGE_MIN; //add the min port to set it within the range
+ #ifdef DEBUG_OUTPUT
+ printf( "RtpReceiver:: final trying port = %d\n", port );
+ #endif
+ try{
+ socket = new UDPSocket( port );
+ if( socket ) {
+ break;
+ }
+ }
+ catch( NetworkException & exc ){
+ // FIXME: do something nice
+// merr << "Minisip could not create a UDP socket!" << end;
+// merr << "Check your network settings." << end;
+// exit( 1 );
+ #ifdef DEBUG_OUTPUT
+ cerr << "RtpReceiver: Could not create UDP socket" << endl;
+ #endif
+ }
+ }
+ if( portretry == RTP_RECEIVER_MAX_RETRIES && !socket ) {
+ merr << "Minisip could not create a UDP socket!" << end;
+ merr << "Check your network settings." << end << "Quitting badly" << end;
+ exit( 1 );
+ }
+
+ externalPort = ipProvider->getExternalPort( socket );
+
+ kill = false;
+
+ thread = new Thread(this);
+}
+
+#ifdef NTP_ENABLED
+RtpReceiver::RtpReceiver(MRef<IpProvider *> ipProvider, MRef<NTP *> NTPhandler) {
+ this->ntp = NTPhandler;
+
+ socket = NULL;
+
+ int portretry = 0;
+ for (; portretry<RTP_RECEIVER_MAX_RETRIES; portretry++ ) {
+ //generate a random port, even number, in the given range
+ float randPartial = (float)rand() / RAND_MAX;
+ int port = (int) (RTP_LOCAL_PORT_RANGE * randPartial );
+ port = 2 * (int)( port/2 ); //turn this into an even number
+ port += RTP_LOCAL_PORT_RANGE_MIN; //add the min port to set it within the range
+ #ifdef DEBUG_OUTPUT
+ printf( "RtpReceiver:: final trying port = %d\n", port );
+ #endif
+ try{
+ socket = new UDPSocket( port );
+ if( socket ) {
+ break;
+ }
+ }
+ catch( NetworkException & exc ){
+ // FIXME: do something nice
+// merr << "Minisip could not create a UDP socket!" << end;
+// merr << "Check your network settings." << end;
+// exit( 1 );
+ #ifdef DEBUG_OUTPUT
+ cerr << "RtpReceiver: Could not create UDP socket" << endl;
+ #endif
+ }
+ }
+ if( portretry == RTP_RECEIVER_MAX_RETRIES && !socket ) {
+ merr << "Minisip could not create a UDP socket!" << end;
+ merr << "Check your network settings." << end << "Quitting badly" << end;
+ exit( 1 );
+ }
+
+ externalPort = ipProvider->getExternalPort( socket );
+
+ kill = false;
+
+ thread = new Thread(this);
+}
+
+
+#endif
+
+RtpReceiver::~RtpReceiver(){
+ thread->join();
+ delete thread;
+ socket->close();
+}
+
+/**
+ register a mediaStreamReceiver ... if the receiver is already registered,
+ update the exhisting one to point to the new receiver.
+*/
+void RtpReceiver::registerMediaStream( MRef<MediaStreamReceiver *> mediaStream ){
+ list< MRef<MediaStreamReceiver *> >::iterator iter;
+ mediaStreamsLock.lock();
+ /* Don't register new streams if the receiver is being closed */
+ if( !kill ){
+ bool found = false;
+ //cerr << "RtpReceiver::registerMediaStream: register done!" << endl;
+ for( iter = mediaStreams.begin();
+ iter != mediaStreams.end();
+ iter++ ) {
+ if( (*iter)->getId() == mediaStream->getId() ) {
+ found = true;
+ #ifdef DEBUG_OUTPUT
+ cerr << "RtpRcvr::registerMediaStream: media stream already registered. Updating MRef." << endl;
+ #endif
+ (*iter) = mediaStream;
+ break;
+ }
+ }
+ if( !found ) {
+ mediaStreams.push_back( mediaStream );
+ }
+ }
+ mediaStreamsLock.unlock();
+}
+
+void RtpReceiver::unregisterMediaStream( MRef<MediaStreamReceiver *> mediaStream ){
+#ifdef DEBUG_OUTPUT
+ // cerr << "RtpReceiver::unregisterMediaStream: Before taking lock" << endl;
+#endif
+ mediaStreamsLock.lock();
+ mediaStreams.remove( mediaStream );
+ if( mediaStreams.size() == 0 ){
+ /* End the thread */
+ kill = true;
+ }
+ mediaStreamsLock.unlock();
+#ifdef DEBUG_OUTPUT
+ // cerr << "RtpReceiver::unregisterMediaStream: After taking lock" << endl;
+#endif
+}
+
+uint16_t RtpReceiver::getPort(){
+ return externalPort;
+}
+
+MRef<UDPSocket *> RtpReceiver::getSocket(){
+ return socket;
+}
+#ifdef NTP_ENABLED
+void RtpReceiver::setNTPhandler(MRef<NTP*> NTPhandler) {
+ this->ntp = NTPhandler;
+}
+#endif
+
+#ifdef RTCP_ENABLED
+
+void RtpReceiver::setRtcpSender(MRef<RtcpSender*> rtcpSender){
+ this->rtcpSender=rtcpSender;
+}
+
+#endif
+
+void RtpReceiver::run() {
+
+ MRef<SRtpPacket *> packet;
+
+#ifdef RTCP_ENABLED
+ IPAddress *remoteAddress=NULL;
+ int32_t remotePort=0;
+ #ifdef NTP_ENABLED
+ //MRef<NTP *> ntp = new NTP();
+ static MRef <NTPtimestamp *> currentTs = ntp->getNTPtimestamp();
+ //static MRef <NTPtimestamp *> compareTs = ntp->getNTPtimestamp();
+ //cout << "\n ###compareTs: " << compareTs->getNTP_MSW();
+ #endif
+#endif
+
+ while( !kill ) {
+
+#ifdef RTCP_ENABLED
static RtcpPacket *rtcpPacket;
static bool firstTime = true;
@@ -317,75 +317,76 @@
//cout << "\n +++compareTs: " << compareTs->getNTP_MSW();
}
#endif // RTCP_ENABLED
-
- list< MRef<MediaStreamReceiver *> >::iterator i;
- fd_set rfds;
- struct timeval tv;
- int ret = -1;
-
- FD_ZERO( &rfds );
- FD_SET( socket->getFd(), &rfds );
-
- tv.tv_sec = 0;
- tv.tv_usec = 100000;
-
- while( ret < 0 ){
- ret = select( socket->getFd() + 1, &rfds, NULL, NULL, &tv );
- if( ret < 0 ){
-#ifdef DEBUG_OUTPUT
- //FIXME: do something better
- cerr << "RtpReceiver::run() - select returned -1" << endl;
-#endif
- if( errno == EINTR ) { continue; }
- else {
- kill = true;
- break;
- }
- }
- }
-
- if( kill ) {
-
- break;
- }
-
- //cout << "\n after kill - ret: " << ret;
-
- if( ret == 0 /* timeout */ ){
- //notify the mediaStreams of the timeout
- for( i = mediaStreams.begin();
- i != mediaStreams.end(); i++ ){
- (*i)->handleRtpPacket( NULL );
- }
- continue;
- }
-
- try{
-#ifdef RTCP_ENABLED
- packet = SRtpPacket::readPacket(**socket, remoteAddress, remotePort);
-#else
- packet = SRtpPacket::readPacket( **socket );
-#endif
- }
-
- catch (NetworkException & exc ) {
- continue;
- }
-
- if( !packet ){
- continue;
- }
+
+ list< MRef<MediaStreamReceiver *> >::iterator i;
+ fd_set rfds;
+ struct timeval tv;
+ int ret = -1;
+
+ FD_ZERO( &rfds );
+ FD_SET( socket->getFd(), &rfds );
+
+ tv.tv_sec = 0;
+ tv.tv_usec = 100000;
+
+ while( ret < 0 ){
+ ret = select( socket->getFd() + 1, &rfds, NULL, NULL, &tv );
+ if( ret < 0 ){
+#ifdef DEBUG_OUTPUT
+ //FIXME: do something better
+ cerr << "RtpReceiver::run() - select returned -1" << endl;
+#endif
+ if( errno == EINTR ) { continue; }
+ else {
+ kill = true;
+ break;
+ }
+ }
+ }
+
+ if( kill ) {
+
+ break;
+ }
+
+ //cout << "\n after kill - ret: " << ret;
+
+ if( ret == 0 /* timeout */ ){
+ //notify the mediaStreams of the timeout
+ for( i = mediaStreams.begin();
+ i != mediaStreams.end(); i++ ){
+ (*i)->handleRtpPacket( NULL );
+ }
+ continue;
+ }
+
+ try{
#ifdef RTCP_ENABLED
+ packet = SRtpPacket::readPacket(**socket, remoteAddress, remotePort);
+#else
+ packet = SRtpPacket::readPacket( **socket );
+#endif
+ }
+
+ catch (NetworkException & exc ) {
+ continue;
+ }
+
+ if( !packet ){
+ continue;
+ }
+
+ // TODO: authenticate RTP packets
+#ifdef RTCP_ENABLED
// **************************************
// RTP packet arrived
- // calculate jitter
- // check seq-#
+ // calculate jitter, check seq-#, etc
rtcpSender->getRtcpSRManager().prepareSR(packet, time);
// first packet --> re-start timer, because now we are getting packets !!
if (firstTime) {
- rtcpSender->setSSRC(packet->getHeader().getSSRC());
- rtcpSender->setRemoteAddress(remoteAddress);
+ rtcpSender->setSSRC(packet->getHeader().getSSRC());
+ rtcpSender->setRemoteAddress(remoteAddress);
rtcpSender->setRemotePort(remotePort + 1);
//timeout = rtcpSender->getRtcpInterval();
@@ -396,27 +397,27 @@
}
#endif // RTCP_ENABLED
-
- mediaStreamsLock.lock();
- for( i = mediaStreams.begin(); i != mediaStreams.end(); i++ ){
- std::list<MRef<Codec *> > codecs = (*i)->getAvailableCodecs();
- std::list<MRef<Codec *> >::iterator iC;
- //printf( "|" );
- for( iC = codecs.begin(); iC != codecs.end(); iC ++ ){
- if ( (*iC)->getSdpMediaType() == packet->getHeader().getPayloadType() ) {
- (*i)->handleRtpPacket( packet );
- //printf( "~" );
- break;
- }
- }
- }
-
- mediaStreamsLock.unlock();
- packet = NULL;
- } // end while
-
-#ifdef DEBUG_OUTPUT
- rtcpSender->sendRtcpPacket();
- cout << "\n\n RtpReceiver::run has ended.";
-#endif
-} // end RtpReceiver::run
+
+ mediaStreamsLock.lock();
+ for( i = mediaStreams.begin(); i != mediaStreams.end(); i++ ){
+ std::list<MRef<Codec *> > codecs = (*i)->getAvailableCodecs();
+ std::list<MRef<Codec *> >::iterator iC;
+ //printf( "|" );
+ for( iC = codecs.begin(); iC != codecs.end(); iC ++ ){
+ if ( (*iC)->getSdpMediaType() == packet->getHeader().getPayloadType() ) {
+ (*i)->handleRtpPacket( packet );
+ //printf( "~" );
+ break;
+ }
+ }
+ }
+
+ mediaStreamsLock.unlock();
+ packet = NULL;
+ } // end while
+
+#ifdef DEBUG_OUTPUT
+ rtcpSender->sendRtcpPacket();
+ cout << "\n\n RtpReceiver::run has ended.";
+#endif
+} // end RtpReceiver::run
Modified: branches/rtcp_ntp/rtp/rtcp/RtcpReceiver.cpp
===================================================================
--- branches/rtcp_ntp/rtp/rtcp/RtcpReceiver.cpp 2006-09-11 18:17:20 UTC (rev 2759)
+++ branches/rtcp_ntp/rtp/rtcp/RtcpReceiver.cpp 2006-09-12 07:40:34 UTC (rev 2760)
@@ -22,6 +22,9 @@
RtcpReceiver::RtcpReceiver(MRef<UDPSocket*> socket, MRef<StreamStatistics *> sStt):sStt(sStt){
rtcpSock=socket;
+#ifdef NTP_ENABLED
+ ntp = sStt->getNTP();
+#endif
localPort=socket->getPort();
kill=false;
}
Modified: branches/rtcp_ntp/rtp/rtcp/RtcpSRManager.cpp
===================================================================
--- branches/rtcp_ntp/rtp/rtcp/RtcpSRManager.cpp 2006-09-11 18:17:20 UTC (rev 2759)
+++ branches/rtcp_ntp/rtp/rtcp/RtcpSRManager.cpp 2006-09-12 07:40:34 UTC (rev 2760)
@@ -15,7 +15,7 @@
*/
/**
- * For more information about this class, see the thesises of Franz Mayer
+ * For more information about this class, see the theses of Franz Mayer
* and Xiaokun Yi.
*/
@@ -34,7 +34,12 @@
RtcpSRManager::RtcpSRManager(MRef<StreamStatistics *> sStt):sStt(sStt){
initSR();
+
+#ifdef NTP_ENABLED
+ this->ntp = sStt->getNTP();
+#endif
}
+
#ifdef NTP_ENABLED
RtcpSRManager::RtcpSRManager(MRef<StreamStatistics *> sStt, MRef<NTP *> NTPhandler):sStt(sStt){
this->ntp = NTPhandler;
@@ -144,10 +149,11 @@
static int32_t D; // Deviation
// calculate deviation; 1 sample = 125 microsec.
- D = (time - oldTime) - ((RtpTimestamp - oldRtpTimestamp) * 125);
+ //D = (time - oldTime) - ((RtpTimestamp - oldRtpTimestamp) * 125);
+ D = ((time - oldTime) / 125) - (RtpTimestamp - oldRtpTimestamp);
// it will always round DOWN (if it is 0.75 it will be 0)
- this->jitter = ( this->jitter + (abs(D) - this->jitter) ) / 16;
+ this->jitter = ( this->jitter + (abs(D) - this->jitter) ) / 16;
//cout << "\n jitterCalc: " << time << " oldTime: " << oldTime << " jitter: " << this->jitter;
oldTime = time;
@@ -166,7 +172,10 @@
firstTime = false;
}
update_seq(seq);
- this->received++;
+ this->received++;
+ sStt->incRPacketCount();
+ sStt->incROctetCount(rp->size());
+
jitterCalc(rp->getHeader().getTimestamp(), currentTs);
//cout << "\n packet # " << this->received << " -- seq: " << seq;
}
@@ -233,14 +242,22 @@
DLSR = ts->getMID_Diff(sStt->getLSR());
}
+ //uint64_t ntp_diff = ntp->calcDiff(ts, sStt->getNTPtimestamp());
+ uint64_t rtp_diff = (ntp->calcDiff(ts, sStt->getNTPtimestamp()) / 125);
+
printf("\n\n RtcpSRManager | MSW.LSW | MID | LSR | DLSR | \n %u.%u | %u | %u | %u",
ts->getNTP_MSW(),
ts->getNTP_LSW(),
ts->getNTP_MID(),
LSR, DLSR);
+ printf("\n sStt_NTP: %u.%u ",
+ sStt->getNTPtimestamp()->getNTP_MSW(),
+ sStt->getNTPtimestamp()->getNTP_LSW());
+ cout << " in RTP2: " << rtp_diff ;
+
RtcpReportSR *sr=new RtcpReportSR(*(new RtcpReportSenderInfo(
- sStt->getLastRtpTs(),
+ sStt->getLastRtpTs() + rtp_diff,
sStt->getSPacketCount(),
sStt->getSOctetCount(),
ts->getNTP_MSW(),
Modified: branches/rtcp_ntp/rtp/rtcp/RtcpSRManager.h
===================================================================
--- branches/rtcp_ntp/rtp/rtcp/RtcpSRManager.h 2006-09-11 18:17:20 UTC (rev 2759)
+++ branches/rtcp_ntp/rtp/rtcp/RtcpSRManager.h 2006-09-12 07:40:34 UTC (rev 2760)
@@ -94,7 +94,7 @@
unsigned int fractionLost:8; // like in RFC-3550
int cumulativeLost:24; // like in RFC-3550
int lost;
- uint32_t jitter;
+ uint32_t jitter; // measured in RTP timestamps
uint32_t lSR;
uint32_t dLSR;
Modified: branches/rtcp_ntp/rtp/rtcp/StreamStatistics.cpp
===================================================================
--- branches/rtcp_ntp/rtp/rtcp/StreamStatistics.cpp 2006-09-11 18:17:20 UTC (rev 2759)
+++ branches/rtcp_ntp/rtp/rtcp/StreamStatistics.cpp 2006-09-12 07:40:34 UTC (rev 2760)
@@ -1,9 +1,23 @@
#include "StreamStatistics.h"
-
#include "CodecManager.h"
+StreamStatistics::StreamStatistics() {
+ ssrc = 0;
+ sPacketCount = 0;
+ sOctetCount = 0;
+ rPacketCount = 0;
+ rOctetCount = 0;
+ lastRtpTs = 0;
+ ssrc_n = 0;
+ fractionLoss = 0;
+ sNtpMSW = 0;
+ sNtpLSW = 0;
+ LSR = 0;
+ lossUpdated=false;
+}
-StreamStatistics::StreamStatistics(){
+#ifdef NTP_ENABLED
+StreamStatistics::StreamStatistics(MRef<NTP *> ntp) {
ssrc = 0;
sPacketCount = 0;
sOctetCount = 0;
@@ -16,10 +30,15 @@
sNtpLSW = 0;
LSR = 0;
lossUpdated=false;
-
+ this->ntp = ntp;
}
+#endif
StreamStatistics::~StreamStatistics(){
}
-
+//
+//void StreamStatistics::createNTPtimestamp() {
+//
+//
+//}
\ No newline at end of file
Modified: branches/rtcp_ntp/rtp/rtcp/StreamStatistics.h
===================================================================
--- branches/rtcp_ntp/rtp/rtcp/StreamStatistics.h 2006-09-11 18:17:20 UTC (rev 2759)
+++ branches/rtcp_ntp/rtp/rtcp/StreamStatistics.h 2006-09-12 07:40:34 UTC (rev 2760)
@@ -5,9 +5,14 @@
#include <libmutil/MemObject.h>
#include "CodecManager.h"
+#ifdef NTP_ENABLED
+ #include "NTP.h"
+#endif
+
class StreamStatistics:public MObject{
public:
StreamStatistics();
+ StreamStatistics(MRef<NTP *> ntp);
~StreamStatistics();
@@ -60,6 +65,13 @@
uint32_t getSNtpLSW() { return this->sNtpLSW; };
+#ifdef NTP_ENABLED
+ void setNTP(MRef<NTP *> ntp) { this->ntp = ntp; }
+ MRef<NTP *> getNTP() { return this->ntp; }
+
+ void createNTPtimestamp() { this->ntpTs = ntp->getFullNTPtimestamp(); };
+ MRef<NTPtimestamp *> getNTPtimestamp() { return this->ntpTs; }
+#endif
private:
uint32_t ssrc;
@@ -78,7 +90,10 @@
uint32_t LSR; // last received Sender Report
CodecManager cm;
-
+#ifdef NTP_ENABLED
+ MRef<NTP *> ntp;
+ MRef<NTPtimestamp *> ntpTs;
+#endif
};
#endif
\ No newline at end of file
Modified: branches/rtcp_ntp/sip/Sip.cxx
===================================================================
--- branches/rtcp_ntp/sip/Sip.cxx 2006-09-11 18:17:20 UTC (rev 2759)
+++ branches/rtcp_ntp/sip/Sip.cxx 2006-09-12 07:40:34 UTC (rev 2760)
@@ -116,7 +116,7 @@
*/
/*
-void Sip::registerMediaStream(MRef<SdpPacket*> sdppack){
+void Sip::registerMediaStream (MRef<SdpPacket*> sdppack){
}
*/
More information about the Minisip-devel
mailing list