diff --git a/sflphone-common/src/call.h b/sflphone-common/src/call.h index 3cc99dbd5..bc04e4ce1 100644 --- a/sflphone-common/src/call.h +++ b/sflphone-common/src/call.h @@ -29,8 +29,8 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ -#ifndef CALL_H -#define CALL_H +#ifndef __CALL_H__ +#define __CALL_H__ #include // for mutex #include @@ -306,4 +306,4 @@ class Call: public Recordable std::string _filename; }; -#endif +#endif // __CALL_H__ diff --git a/sflphone-common/src/sip/sdp.cpp b/sflphone-common/src/sip/sdp.cpp index 4f9acb388..ee324cf11 100644 --- a/sflphone-common/src/sip/sdp.cpp +++ b/sflphone-common/src/sip/sdp.cpp @@ -569,6 +569,21 @@ void Sdp::addAudioMediaDescription() } } + +void Sdp::addVideoMediaDescription() +{ +#if 0 + pjmedia_sdp_media* med; + int nb_media, i; + + med = PJ_POOL_ZALLOC_T (memPool, pjmedia_sdp_media); + for (i=0; imedia[i] = med; + } +#endif +} + void Sdp::addSdesAttribute (const std::vector& crypto) { // temporary buffer used to store crypto attribute diff --git a/sflphone-common/src/sip/sdp.h b/sflphone-common/src/sip/sdp.h index 9b6cca457..bd9d15dc2 100644 --- a/sflphone-common/src/sip/sdp.h +++ b/sflphone-common/src/sip/sdp.h @@ -223,6 +223,13 @@ class Sdp localAudioPort_ = port; } + /** + * @param Set the published video port + */ + void setLocalPublishedVideoPort (int port) { + localVideoPort_ = port; + } + /** * @return The published audio port */ @@ -230,6 +237,13 @@ class Sdp return localAudioPort_; } + /** + * @return The published video port + */ + int getLocalPublishedVideoPort (void) const { + return localVideoPort_; + } + /** * Set remote's IP addr. [not protected] * @param ip The remote IP address @@ -254,6 +268,14 @@ class Sdp remoteAudioPort_ = port; } + /** + * Set remote's video port. [not protected] + * @param port The remote video port + */ + void setRemoteVideoPort (unsigned int port) { + remoteVideoPort_ = port; + } + /** * Return audio port at destination [mutex protected] * @return unsigned int The remote audio port @@ -263,6 +285,14 @@ class Sdp } + /** + * Return video port at destination [mutex protected] + * @return unsigned int The remote video port + */ + unsigned int getRemoteVideoPort() const { + return remoteVideoPort_; + } + /** * Get media list for this session */ @@ -368,11 +398,21 @@ class Sdp */ int localAudioPort_; + /** + * Local video port + */ + int localVideoPort_; + /** * Remote audio port */ unsigned int remoteAudioPort_; + /** + * Remote video port + */ + unsigned int remoteVideoPort_; + /** * Zrtp hello hash */ @@ -490,6 +530,11 @@ class Sdp */ void addAudioMediaDescription(); + /* + * Mandatory field: Media descriptions ("m=") + */ + void addVideoMediaDescription(); + /* * Adds a sdes attribute to the given media section. * diff --git a/sflphone-common/src/sip/sipcall.h b/sflphone-common/src/sip/sipcall.h index d758f0388..2c33426fb 100644 --- a/sflphone-common/src/sip/sipcall.h +++ b/sflphone-common/src/sip/sipcall.h @@ -29,8 +29,8 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ -#ifndef SIPCALL_H -#define SIPCALL_H +#ifndef __SIPCALL_H__ +#define __SIPCALL_H__ #include "call.h" @@ -196,4 +196,4 @@ class SIPCall : public Call }; -#endif +#endif // __SIPCALL_H__ diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index 61e2daa94..499127ad4 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -724,6 +724,7 @@ Call *SIPVoIPLink::newOutgoingCall (const CallID& id, const std::string& toUrl) _info ("UserAgent: Start audio rtp session"); call->getAudioRtp()->start (static_cast(audiocodec)); _info ("UserAgent: Start video rtp session"); + call->getVideoRtp()->updateDestination(call->getLocalIp(), call->getLocalVideoPort()); call->getVideoRtp()->start(); } catch (...) { throw VoipLinkException ("Could not start rtp session for early media"); @@ -1030,6 +1031,7 @@ SIPVoIPLink::offhold (const CallID& id) throw (VoipLinkException) call->getAudioRtp()->initAudioRtpConfig (call); call->getAudioRtp()->initAudioSymmetricRtpSession (call); call->getAudioRtp()->start (static_cast(audiocodec)); + call->getVideoRtp()->updateDestination(call->getLocalIp(), call->getLocalVideoPort()); call->getVideoRtp()->start(); } @@ -1811,6 +1813,7 @@ bool SIPVoIPLink::SIPNewIpToIpCall (const CallID& id, const std::string& to) call->getAudioRtp()->initAudioSymmetricRtpSession (call); call->getAudioRtp()->initLocalCryptoInfo (call); call->getAudioRtp()->start (static_cast(audiocodec)); + call->getVideoRtp()->updateDestination(call->getLocalIp(), call->getLocalVideoPort()); call->getVideoRtp()->start (); } catch (...) { _debug ("UserAgent: Unable to create RTP Session in new IP2IP call (%s:%d)", __FILE__, __LINE__); @@ -3463,6 +3466,7 @@ void sdp_media_update_cb (pjsip_inv_session *inv, pj_status_t status) try { call->getAudioRtp()->updateDestinationIpAddress(); + call->getVideoRtp()->updateDestination(call->getLocalIp(), call->getLocalVideoPort()); call->getAudioRtp()->setDtmfPayloadType(sdpSession->getTelephoneEventType()); } catch (...) { @@ -4068,6 +4072,8 @@ transaction_request_cb (pjsip_rx_data *rdata) try { _debug ("UserAgent: Create RTP session for this call"); call->getAudioRtp()->start (static_cast(audiocodec)); + call->getVideoRtp()->updateDestination(call->getLocalIp(), call->getLocalVideoPort()); + call->getVideoRtp()->start(); } catch (...) { _warn ("UserAgent: Error: Failed to create rtp thread from answer"); } @@ -4706,8 +4712,10 @@ bool setCallMediaLocal (SIPCall* call, const std::string &localIP) account = dynamic_cast (Manager::instance().getAccount (account_id)); - // Setting Audio + // Setting Audio and Video unsigned int callLocalAudioPort = RANDOM_LOCAL_PORT; + unsigned int callLocalVideoPort = RANDOM_LOCAL_PORT; + assert(callLocalAudioPort != callLocalVideoPort); unsigned int callLocalExternAudioPort = callLocalAudioPort; if (account->isStunEnabled ()) { @@ -4718,11 +4726,13 @@ bool setCallMediaLocal (SIPCall* call, const std::string &localIP) _debug ("UserAgent: Setting local ip address: %s", localIP.c_str()); _debug ("UserAgent: Setting local audio port to: %d", callLocalAudioPort); + _debug ("UserAgent: Setting local video port to: %d", callLocalVideoPort); _debug ("UserAgent: Setting local audio port (external) to: %d", callLocalExternAudioPort); // Set local audio port for SIPCall(id) call->setLocalIp (localIP); call->setLocalAudioPort (callLocalAudioPort); + call->setLocalVideoPort (callLocalVideoPort); call->getLocalSDP()->setPortToAllMedia (callLocalExternAudioPort); diff --git a/sflphone-common/src/video/video_rtp_factory.cpp b/sflphone-common/src/video/video_rtp_factory.cpp index 72d6ade6e..b7772eef3 100644 --- a/sflphone-common/src/video/video_rtp_factory.cpp +++ b/sflphone-common/src/video/video_rtp_factory.cpp @@ -61,4 +61,11 @@ void VideoRtpFactory::stop() session_->stop(); } +void VideoRtpFactory::updateDestination(const std::string &dest, + unsigned int port) +{ + session_->updateDestination(dest, port); +} + + } // end namespace sfl diff --git a/sflphone-common/src/video/video_rtp_factory.h b/sflphone-common/src/video/video_rtp_factory.h index f68a95585..00962fd70 100644 --- a/sflphone-common/src/video/video_rtp_factory.h +++ b/sflphone-common/src/video/video_rtp_factory.h @@ -39,6 +39,8 @@ class VideoRtpSession; class VideoRtpFactory { public: VideoRtpFactory(); + void updateDestination(const std::string &dest, + unsigned int port); /** * Start the video RTP thread of the type specified in the configuration diff --git a/sflphone-common/src/video/video_rtp_session.cpp b/sflphone-common/src/video/video_rtp_session.cpp index a58944628..accbe03b9 100644 --- a/sflphone-common/src/video/video_rtp_session.cpp +++ b/sflphone-common/src/video/video_rtp_session.cpp @@ -44,6 +44,15 @@ VideoRtpSession::VideoRtpSession(std::map args) : { } +void VideoRtpSession::updateDestination(const std::string &destination, + unsigned int port) +{ + std::stringstream tmp; + tmp << "rtp://" << destination << ":" << port; + args_["destination"] = tmp.str(); + std::cerr << "updated dest to " << args_["destination"] << std::endl; +} + void VideoRtpSession::test() { assert(sendThread_.get() == 0); diff --git a/sflphone-common/src/video/video_rtp_session.h b/sflphone-common/src/video/video_rtp_session.h index 703c5b9ab..e44e6419b 100644 --- a/sflphone-common/src/video/video_rtp_session.h +++ b/sflphone-common/src/video/video_rtp_session.h @@ -48,6 +48,8 @@ class VideoRtpSession { void test(); void test_loopback(); void stop(); + void updateDestination(const std::string &destination, + unsigned int port); private: std::tr1::shared_ptr sendThread_; std::tr1::shared_ptr receiveThread_; diff --git a/sflphone-common/src/video/video_send_thread.cpp b/sflphone-common/src/video/video_send_thread.cpp index 0913f3577..e605ff7cc 100644 --- a/sflphone-common/src/video/video_send_thread.cpp +++ b/sflphone-common/src/video/video_send_thread.cpp @@ -65,12 +65,15 @@ void VideoSendThread::print_and_save_sdp() std::ofstream sdp_file("test.sdp"); std::istringstream iss(sdp); std::string line; + sdp_ = ""; while (std::getline(iss, line)) { /* strip windows line ending */ - sdp_file << line.substr(0, line.length() - 1) << std::endl; - std::cerr << line << std::endl; + line = line.substr(0, line.length() - 1); + sdp_file << line << std::endl; + sdp_ += line + "\n"; } + std::cerr << sdp_ << std::endl; sdp_file << std::endl; sdp_file.close(); free(sdp); @@ -349,7 +352,8 @@ VideoSendThread::VideoSendThread(const std::map &args) encoderCtx_(0), videoStream_(0), inputCtx_(0), - outputCtx_(0) + outputCtx_(0), + sdp_("") {} void VideoSendThread::run() diff --git a/sflphone-common/src/video/video_send_thread.h b/sflphone-common/src/video/video_send_thread.h index 978624086..12a835bb1 100644 --- a/sflphone-common/src/video/video_send_thread.h +++ b/sflphone-common/src/video/video_send_thread.h @@ -70,6 +70,7 @@ class VideoSendThread : public ost::Thread { AVStream *videoStream_; AVFormatContext *inputCtx_; AVFormatContext *outputCtx_; + std::string sdp_; public: explicit VideoSendThread(const std::map &args); virtual ~VideoSendThread(); diff --git a/sflphone-common/test/Makefile.am b/sflphone-common/test/Makefile.am index e62c98853..3bba383f8 100644 --- a/sflphone-common/test/Makefile.am +++ b/sflphone-common/test/Makefile.am @@ -42,15 +42,15 @@ test_SOURCES = \ gaincontroltest.cpp LLIBS=$(CPPUNIT_LIBS) \ - ../src/sflphoned-logger.o \ - ../src/sflphoned-managerimpl.o \ - ../src/sflphoned-account.o\ - ../src/sflphoned-accountcreator.o \ - ../src/sflphoned-call.o \ - ../src/sflphoned-conference.o \ - ../src/sflphoned-eventthread.o \ - ../src/sflphoned-managerimpl_registration.o \ - ../src/sflphoned-numbercleaner.o \ - ../src/sflphoned-voiplink.o \ - ../src/sflphoned-preferences.o \ + ../src/logger.o \ + ../src/managerimpl.o \ + ../src/account.o\ + ../src/accountcreator.o \ + ../src/call.o \ + ../src/conference.o \ + ../src/eventthread.o \ + ../src/managerimpl_registration.o \ + ../src/numbercleaner.o \ + ../src/voiplink.o \ + ../src/preferences.o \ ../src/libsflphone.la