mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-07 22:02:12 +08:00
* #6254: update destination IP and port for video
This commit is contained in:
@ -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 <cc++/thread.h> // for mutex
|
||||
#include <sstream>
|
||||
@ -306,4 +306,4 @@ class Call: public Recordable
|
||||
std::string _filename;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // __CALL_H__
|
||||
|
@ -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; i<nb_media; i++) {
|
||||
setMediaDescriptorLine (getLocalMediaCap() [i], &med);
|
||||
localSession->media[i] = med;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Sdp::addSdesAttribute (const std::vector<std::string>& crypto)
|
||||
{
|
||||
// temporary buffer used to store crypto attribute
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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__
|
||||
|
@ -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<sfl::AudioCodec *>(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<sfl::AudioCodec *>(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<sfl::AudioCodec *>(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<sfl::AudioCodec *>(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<SIPAccount *> (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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -44,6 +44,15 @@ VideoRtpSession::VideoRtpSession(std::map<std::string,std::string> 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);
|
||||
|
@ -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<VideoSendThread> sendThread_;
|
||||
std::tr1::shared_ptr<VideoReceiveThread> receiveThread_;
|
||||
|
@ -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<std::string, std::string> &args)
|
||||
encoderCtx_(0),
|
||||
videoStream_(0),
|
||||
inputCtx_(0),
|
||||
outputCtx_(0)
|
||||
outputCtx_(0),
|
||||
sdp_("")
|
||||
{}
|
||||
|
||||
void VideoSendThread::run()
|
||||
|
@ -70,6 +70,7 @@ class VideoSendThread : public ost::Thread {
|
||||
AVStream *videoStream_;
|
||||
AVFormatContext *inputCtx_;
|
||||
AVFormatContext *outputCtx_;
|
||||
std::string sdp_;
|
||||
public:
|
||||
explicit VideoSendThread(const std::map<std::string, std::string> &args);
|
||||
virtual ~VideoSendThread();
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user