r3559 - in trunk/libminisip: include/libminisip/media include/libminisip/media/video source/subsystem_media source/subsystem_media/video source/subsystem_media/vnc
erik at minisip.org
erik at minisip.org
Fri Dec 14 16:02:28 CET 2007
Author: erik
Date: 2007-12-14 16:02:28 +0100 (Fri, 14 Dec 2007)
New Revision: 3559
Modified:
trunk/libminisip/include/libminisip/media/AudioMedia.h
trunk/libminisip/include/libminisip/media/Media.h
trunk/libminisip/include/libminisip/media/MediaStream.h
trunk/libminisip/include/libminisip/media/RealtimeMedia.h
trunk/libminisip/include/libminisip/media/video/VideoMedia.h
trunk/libminisip/source/subsystem_media/AudioMedia.cxx
trunk/libminisip/source/subsystem_media/Media.cxx
trunk/libminisip/source/subsystem_media/MediaHandler.cxx
trunk/libminisip/source/subsystem_media/MediaHandler.h
trunk/libminisip/source/subsystem_media/MediaStream.cxx
trunk/libminisip/source/subsystem_media/video/VideoMedia.cxx
trunk/libminisip/source/subsystem_media/vnc/MediaSharedWorkspace.cxx
Log:
* Made it possible for CSD team7 to forward packets from a video stream.
It's implemented the simplest way possible - the packets are forwarded
without modification.
* Moved forwarding flag from AudioMedia to Media so that any type
that supports it can be used by a "conference" minisip.
* Very minor fixes to vnc "plugin" (RFB code not in yet).
(this&their code is of the experimental kind)
Modified: trunk/libminisip/include/libminisip/media/AudioMedia.h
===================================================================
--- trunk/libminisip/include/libminisip/media/AudioMedia.h 2007-12-14 14:16:06 UTC (rev 3558)
+++ trunk/libminisip/include/libminisip/media/AudioMedia.h 2007-12-14 15:02:28 UTC (rev 3559)
@@ -71,8 +71,6 @@
virtual std::string getSdpMediaType();
- void setAudioForwarding(bool);
-
/**
* Play the given RTP packet on this medium. This includes
* decoding if relevant.
@@ -177,8 +175,6 @@
#endif
std::list< MRef<AudioCodec *> > codecs;
std::list< MRef<AudioMediaSource *> > sources;
- bool audioForwarding;
-
};
class LIBMINISIP_API AudioMediaSource : public BasicSoundSource{
Modified: trunk/libminisip/include/libminisip/media/Media.h
===================================================================
--- trunk/libminisip/include/libminisip/media/Media.h 2007-12-14 14:16:06 UTC (rev 3558)
+++ trunk/libminisip/include/libminisip/media/Media.h 2007-12-14 15:02:28 UTC (rev 3559)
@@ -42,46 +42,49 @@
* example video or audio.
*/
class LIBMINISIP_API Media : public MObject{
- public:
+public:
- ~Media();
+ ~Media();
- /**
- * Returns the media type as used in the SDP (audio or video).
- * @returns the media type as a string
- */
- virtual std::string getSdpMediaType()=0;
+ /**
+ * Returns the media type as used in the SDP (audio or video).
+ * @returns the media type as a string
+ */
+ virtual std::string getSdpMediaType()=0;
-
- /**
- * Used to query media specific attributes to add in the
- * session description (e.g. framesize).
- * @returns a list of attributes (as string) to add in
- * a: headers in the session description
- */
- std::list<std::string> getSdpAttributes();
- /**
- * Add a media attribute to use in session descriptions (SDP).
- * @attribute the attribute as a string, as it will appear
- * in a: headers in the SDP
- */
- void addSdpAttribute( std::string attribute );
-
- /**
- * Used to adapt the medium to a received session description
- * (e.g. change the framesize). This is likely to
- * be a problem with multiple calls and should
- * be called carefully.
- * @param m a reference to the received m: SDP header
- * on which the media should be tweaked
- */
- virtual void handleMHeader( MRef<SdpHeaderM *> m );
+ void setMediaForwarding(bool);
- protected:
- Media();
-
- std::list<std::string> sdpAttributes;
+ /**
+ * Used to query media specific attributes to add in the
+ * session description (e.g. framesize).
+ * @returns a list of attributes (as string) to add in
+ * a: headers in the session description
+ */
+ std::list<std::string> getSdpAttributes();
+
+ /**
+ * Add a media attribute to use in session descriptions (SDP).
+ * @attribute the attribute as a string, as it will appear
+ * in a: headers in the SDP
+ */
+ void addSdpAttribute( std::string attribute );
+
+ /**
+ * Used to adapt the medium to a received session description
+ * (e.g. change the framesize). This is likely to
+ * be a problem with multiple calls and should
+ * be called carefully.
+ * @param m a reference to the received m: SDP header
+ * on which the media should be tweaked
+ */
+ virtual void handleMHeader( MRef<SdpHeaderM *> m );
+
+protected:
+ Media();
+
+ std::list<std::string> sdpAttributes;
+ bool mediaForwarding;
};
Modified: trunk/libminisip/include/libminisip/media/MediaStream.h
===================================================================
--- trunk/libminisip/include/libminisip/media/MediaStream.h 2007-12-14 14:16:06 UTC (rev 3558)
+++ trunk/libminisip/include/libminisip/media/MediaStream.h 2007-12-14 15:02:28 UTC (rev 3559)
@@ -125,12 +125,12 @@
*/
virtual std::string getMediaFormats()=0;
- virtual void start(){}
+/* virtual void start(){}
virtual void stop(){}
+*/
+// virtual uint16_t getPort();
+ virtual uint16_t getPort(std::string type)=0;
- virtual uint16_t getPort();
- virtual uint16_t getPort(std::string type);
-
protected:
uint16_t port;
std::string mediaFormats;
@@ -451,6 +451,7 @@
void sendZrtp(unsigned char* data, int length,
unsigned char* payload, int payLen);
+
/**
* Get the current Seq number of this packet
*
@@ -460,6 +461,8 @@
uint16_t getSeqNo() { return seqNo; };
#endif
+ void sendRtpPacket(MRef<RtpPacket*> rtp);
+
/**
* Used by the Session to specify the IP address
* on which the data should be sent to the peer. This
Modified: trunk/libminisip/include/libminisip/media/RealtimeMedia.h
===================================================================
--- trunk/libminisip/include/libminisip/media/RealtimeMedia.h 2007-12-14 14:16:06 UTC (rev 3558)
+++ trunk/libminisip/include/libminisip/media/RealtimeMedia.h 2007-12-14 15:02:28 UTC (rev 3559)
@@ -139,6 +139,8 @@
*/
MRef<CodecState *> createCodecInstance( uint8_t payloadType );
+ //std::list< MRef<RealtimeMediaStreamSender *> > getMediaSenders(){return senders;}
+
protected:
RealtimeMedia( MRef<Codec *> defaultCodec );
Modified: trunk/libminisip/include/libminisip/media/video/VideoMedia.h
===================================================================
--- trunk/libminisip/include/libminisip/media/video/VideoMedia.h 2007-12-14 14:16:06 UTC (rev 3558)
+++ trunk/libminisip/include/libminisip/media/video/VideoMedia.h 2007-12-14 15:02:28 UTC (rev 3559)
@@ -52,6 +52,7 @@
public:
VideoMedia( MRef<Codec *> codec, MRef<VideoDisplay *> display, MRef<ImageMixer *> mixer, MRef<Grabber *> = NULL, uint32_t receivingWidth = 176, uint32_t receivingHeight=144 );
+
virtual std::string getMemObjectType() const {return "VideoMedia";}
virtual std::string getSdpMediaType();
Modified: trunk/libminisip/source/subsystem_media/AudioMedia.cxx
===================================================================
--- trunk/libminisip/source/subsystem_media/AudioMedia.cxx 2007-12-14 14:16:06 UTC (rev 3558)
+++ trunk/libminisip/source/subsystem_media/AudioMedia.cxx 2007-12-14 15:02:28 UTC (rev 3559)
@@ -81,8 +81,6 @@
receive = true;
send = true;
- audioForwarding=false;
-
// pn430 Changed for multicodec
//MRef<AudioCodec *> acodec = ((AudioCodec *)*codec);
@@ -99,10 +97,6 @@
return "audio";
}
-void AudioMedia::setAudioForwarding(bool b){
- audioForwarding=b;
-}
-
void AudioMedia::registerRealtimeMediaSender( MRef<RealtimeMediaStreamSender *> sender ){
sendersLock.lock();
if( senders.empty() ){
@@ -239,7 +233,7 @@
// TODO: Copying the last received audio is not the
// optimal thing to do. We should have a jitter
// buffer that handled re-ordered packets and such.
- if (audioForwarding){
+ if (mediaForwarding){
std::list< MRef<AudioMediaSource *> >::iterator iSource;
for( iSource = sources.begin(); iSource != sources.end(); iSource ++ ){
if ( (*iSource)->getCallId()!= (*i)->getCallId() ){
Modified: trunk/libminisip/source/subsystem_media/Media.cxx
===================================================================
--- trunk/libminisip/source/subsystem_media/Media.cxx 2007-12-14 14:16:06 UTC (rev 3558)
+++ trunk/libminisip/source/subsystem_media/Media.cxx 2007-12-14 15:02:28 UTC (rev 3559)
@@ -49,12 +49,17 @@
using namespace std;
Media::Media(){
+ mediaForwarding=false;
}
Media::~Media(){
}
+void Media::setMediaForwarding(bool forw){
+ mediaForwarding=forw;
+}
+
list<string> Media::getSdpAttributes(){
return sdpAttributes;
}
Modified: trunk/libminisip/source/subsystem_media/MediaHandler.cxx
===================================================================
--- trunk/libminisip/source/subsystem_media/MediaHandler.cxx 2007-12-14 14:16:06 UTC (rev 3558)
+++ trunk/libminisip/source/subsystem_media/MediaHandler.cxx 2007-12-14 15:02:28 UTC (rev 3559)
@@ -89,6 +89,7 @@
if( !audioMedia && audio ){
audioMedia = audio;
}
+
}
}
@@ -241,15 +242,26 @@
}
if( command.getOp() == MediaCommandString::audio_forwarding_enable){
- audioMedia->setAudioForwarding(true);
+ getMedia("audio")->setMediaForwarding(true);
return;
}
if( command.getOp() == MediaCommandString::audio_forwarding_disable){
- audioMedia->setAudioForwarding(false);
+ getMedia("audio")->setMediaForwarding(false);
return;
}
+ if( command.getOp() == MediaCommandString::video_forwarding_enable){
+ getMedia("video")->setMediaForwarding(true);
+ return;
+ }
+
+ if( command.getOp() == MediaCommandString::video_forwarding_disable){
+ getMedia("video")->setMediaForwarding(false);
+ return;
+ }
+
+
if( command.getOp() == MediaCommandString::send_dtmf){
MRef<Session *> session = Session::registry->getSession( command.getDestinationId() );
if( session ){
@@ -346,6 +358,15 @@
sessionsLock.unlock();
}
+MRef<Media*> MediaHandler::getMedia(std::string sdpType){
+ list<MRef<Media*> >::iterator i;
+ for (i=media.begin(); i!=media.end(); i++){
+ if ((*i)->getSdpMediaType()==sdpType){
+ return *i;
+ }
+ }
+ return NULL;
+}
#ifdef DEBUG_OUTPUT
Modified: trunk/libminisip/source/subsystem_media/MediaHandler.h
===================================================================
--- trunk/libminisip/source/subsystem_media/MediaHandler.h 2007-12-14 14:16:06 UTC (rev 3558)
+++ trunk/libminisip/source/subsystem_media/MediaHandler.h 2007-12-14 15:02:28 UTC (rev 3559)
@@ -125,6 +125,8 @@
bool muteAllButOne;
#endif
+ MRef<Media*> getMedia(std::string sdpType);
+
private:
void init();
Modified: trunk/libminisip/source/subsystem_media/MediaStream.cxx
===================================================================
--- trunk/libminisip/source/subsystem_media/MediaStream.cxx 2007-12-14 14:16:06 UTC (rev 3558)
+++ trunk/libminisip/source/subsystem_media/MediaStream.cxx 2007-12-14 15:02:28 UTC (rev 3559)
@@ -159,6 +159,7 @@
}
+/*
uint16_t ReliableMediaStream::getPort(){
return 33333; //FIXME: Fixed when RFB source is commited... blame Erik
}
@@ -166,9 +167,9 @@
uint16_t ReliableMediaStream::getPort(std::string type){
return 33333;
}
+*/
-
MRef<CryptoContext *> RealtimeMediaStream::initCrypto( uint32_t ssrc, uint16_t seq_no ){
MRef<CryptoContext *> cryptoContext;
@@ -622,6 +623,13 @@
}
+void RealtimeMediaStreamSender::sendRtpPacket(MRef<RtpPacket*> rtp){
+ if( remoteAddress->getAddressFamily() == AF_INET && senderSock )
+ rtp->sendTo( **senderSock, **remoteAddress, remotePort );
+ else if( remoteAddress->getAddressFamily() == AF_INET6 && sender6Sock )
+ rtp->sendTo( **sender6Sock, **remoteAddress, remotePort );
+}
+
void RealtimeMediaStreamSender::setRemoteAddress( MRef<IPAddress *> ra){
mdbg("media") << "RealtimeMediaStreamSender::setRemoteAddress: " <<
ra->getString() << endl;
Modified: trunk/libminisip/source/subsystem_media/video/VideoMedia.cxx
===================================================================
--- trunk/libminisip/source/subsystem_media/video/VideoMedia.cxx 2007-12-14 14:16:06 UTC (rev 3558)
+++ trunk/libminisip/source/subsystem_media/video/VideoMedia.cxx 2007-12-14 15:02:28 UTC (rev 3559)
@@ -86,8 +86,6 @@
}
}
-
-
void VideoMedia::playData( MRef<RtpPacket *> packet ){
MRef<VideoMediaSource *> source = getSource( packet->getHeader().SSRC );
@@ -95,6 +93,18 @@
if( source ){
source->playData( packet );
}
+
+/// VIDEO FORWARD CODE BEGIN
+ if (mediaForwarding){
+ list< MRef<RealtimeMediaStreamSender *> >::iterator i;
+ sendersLock.lock();
+ for( i = senders.begin(); i != senders.end(); i++ ){
+ (*i)->sendRtpPacket( packet );
+ }
+ sendersLock.unlock();
+ }
+/// VIDEO FORWARD CODE END
+
}
@@ -345,7 +355,8 @@
else{
expectedSeqNo = seqNo + 1;
}
-
+
+
}
void VideoMediaSource::addPacketToFrame( MRef<RtpPacket *> packet ){
@@ -364,3 +375,4 @@
packetLoss = false;
}
}
+
Modified: trunk/libminisip/source/subsystem_media/vnc/MediaSharedWorkspace.cxx
===================================================================
--- trunk/libminisip/source/subsystem_media/vnc/MediaSharedWorkspace.cxx 2007-12-14 14:16:06 UTC (rev 3558)
+++ trunk/libminisip/source/subsystem_media/vnc/MediaSharedWorkspace.cxx 2007-12-14 15:02:28 UTC (rev 3559)
@@ -10,6 +10,11 @@
public:
SWSMediaStream( std::string callId, MRef<ReliableMedia*> m );
std::string getMediaFormats();
+
+ void start();
+ void stop();
+ virtual uint16_t getPort();
+ virtual uint16_t getPort(string transport);
};
SWSMediaStream::SWSMediaStream( std::string callId, MRef<ReliableMedia*> m ) : ReliableMediaStream(callId,m) {
@@ -20,13 +25,34 @@
return "vnc";
}
-string MediaSharedWorkspace::getSdpMediaType(){
- return "application";
+void SWSMediaStream::start(){
+
}
+void SWSMediaStream::stop(){
+}
+
+uint16_t SWSMediaStream::getPort(){
+ return 0;
+}
+
+uint16_t SWSMediaStream::getPort(string transport){
+ return 0;
+}
+
+
+///////
+///////
+
MediaSharedWorkspace::MediaSharedWorkspace() : ReliableMedia("application", true,true) {
+ addSdpAttribute("recvonly");
+ addSdpAttribute("setup:active");
}
+string MediaSharedWorkspace::getSdpMediaType(){
+ return "application";
+}
+
MRef<ReliableMediaStream*> MediaSharedWorkspace::createMediaStream(string callId){
MRef<ReliableMediaStream*> m = new SWSMediaStream(callId, this);
return m;
More information about the Minisip-devel
mailing list