[server] / trunk / server / src / ipmdevice.cxx Repository:
ViewVC logotype

Diff of /trunk/server/src/ipmdevice.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1217, Fri Apr 20 09:55:38 2012 UTC revision 1218, Wed Jun 6 13:16:07 2012 UTC
# Line 462  Line 462 
462   * Get local RTP info.   * Get local RTP info.
463   */   */
464  bool IpmDevice::getLocalMediaInfo( eIPM_MEDIA_TYPE type,  bool IpmDevice::getLocalMediaInfo( eIPM_MEDIA_TYPE type,
465                                     IpInfo& rtp_media ) const                                     RtpIpInfo& rtp_media ) const
466  {  {
467          switch ( type )          switch ( type )
468          {          {
# Line 493  Line 493 
493   * Save the remote params, the RTCP port is assumed to be media + 1.   * Save the remote params, the RTCP port is assumed to be media + 1.
494   */   */
495  void IpmDevice::setRemoteMediaInfo( eIPM_MEDIA_TYPE type,  void IpmDevice::setRemoteMediaInfo( eIPM_MEDIA_TYPE type,
496                                      const IpInfo& rtp_info )                                      const RtpIpInfo& rtp_info )
497  {  {
498          if ( type == MEDIATYPE_AUDIO_REMOTE_RTP_INFO )          if ( type == MEDIATYPE_AUDIO_REMOTE_RTP_INFO )
499          {          {
# Line 520  Line 520 
520   * Get remote Rtp info.   * Get remote Rtp info.
521   */   */
522  bool IpmDevice::getRemoteMediaInfo( eIPM_MEDIA_TYPE type,  bool IpmDevice::getRemoteMediaInfo( eIPM_MEDIA_TYPE type,
523                                      IpInfo& rtp_media ) const                                      RtpIpInfo& rtp_media ) const
524  {  {
525          switch ( type )          switch ( type )
526          {          {
# Line 603  Line 603 
603  /*  /*
604   * Start RTP streaming: audio and video.   * Start RTP streaming: audio and video.
605   */   */
606  bool IpmDevice::startMedia( const IpInfo& remote_audio_rtp,  bool IpmDevice::startMedia( const RtpIpInfo& remote_audio_rtp,
607                              const IpInfo& remote_audio_rtcp,                              const RtpIpInfo& remote_audio_rtcp,
608                              const IpInfo& remote_video_rtp,                              const RtpIpInfo& remote_video_rtp,
609                              const IpInfo& remote_video_rtcp )                              const RtpIpInfo& remote_video_rtcp )
610  {  {
611          if ( busy_ )          if ( busy_ )
612          {          {
# Line 622  Line 622 
622                  return true;                  return true;
623          }          }
624    
         eIPM_DATA_DIRECTION direction = DATA_IP_TDM_BIDIRECTIONAL;  
         if ( !remote_audio_rtp.isValid() && !remote_video_rtp.isValid() )  
         {  
                 LOGDEBUG("IpmDevice::startMedia() recvonly for device: " <<  
                          getDeviceName());  
                 direction = DATA_IP_RECEIVEONLY;  
         }  
   
625          if ( ipt_ )          if ( ipt_ )
626          {          {
627                  setDtmfMode(dtmfMode_);                  setDtmfMode(dtmfMode_);
# Line 799  Line 791 
791                  mediaCnt++;                  mediaCnt++;
792          }          }
793    
794          /* Done.          if ( mediaCnt == 0 )
795           */          {
796                    LOGERROR("IpmDevice::startMedia() no media for device: " << getDeviceName());
797                    return false;
798            }
799          mediaInfo.unCount = mediaCnt;          mediaInfo.unCount = mediaCnt;
800    
801            /* Use the remote rtp's direction to control whether or not media
802             * should be transmitted.
803             */
804            eIPM_DATA_DIRECTION audio_direction;
805            eIPM_DATA_DIRECTION video_direction;
806    
807            if ( remote_audio_rtp.getDirection() == RtpIpInfo::INACTIVE )
808            {
809                    audio_direction = DATA_IP_INACTIVE;
810            }
811            else if ( remote_audio_rtp.getDirection() == RtpIpInfo::SENDONLY )
812            {
813                    audio_direction = DATA_IP_RECEIVEONLY;
814            }
815            else if ( remote_audio_rtp.getDirection() == RtpIpInfo::RECVONLY )
816            {
817                    audio_direction = DATA_IP_SENDONLY;
818            }
819            else /* RtpIpInfo::SENDRECV */
820            {
821                    audio_direction = DATA_IP_TDM_BIDIRECTIONAL;
822            }
823    
824            if ( remote_video_rtp.getDirection() == RtpIpInfo::INACTIVE )
825            {
826                    video_direction = DATA_IP_INACTIVE;
827            }
828            else if ( remote_video_rtp.getDirection() == RtpIpInfo::SENDONLY )
829            {
830                    video_direction = DATA_IP_RECEIVEONLY;
831            }
832            else if ( remote_video_rtp.getDirection() == RtpIpInfo::RECVONLY )
833            {
834                    video_direction = DATA_IP_SENDONLY;
835            }
836            else /* RtpIpInfo::SENDRECV */
837            {
838                    video_direction = DATA_IP_TDM_BIDIRECTIONAL;
839            }
840    
841            eIPM_DATA_DIRECTION direction = DATA_IP_TDM_BIDIRECTIONAL;
842            if ( (audio_direction == DATA_IP_INACTIVE) && (video_direction == DATA_IP_INACTIVE) )
843            {
844                    LOGDEBUG("IpmDevice::startMedia() DATA_IP_INACTIVE for device: " <<
845                             getDeviceName());
846                    direction = DATA_IP_INACTIVE;
847            }
848            else if ( (audio_direction == DATA_IP_RECEIVEONLY) && (video_direction == DATA_IP_RECEIVEONLY) )
849            {
850                    LOGDEBUG("IpmDevice::startMedia() DATA_IP_RECEIVEONLY for device: " <<
851                             getDeviceName());
852                    direction = DATA_IP_RECEIVEONLY;
853            }
854            else
855            {
856                    LOGDEBUG("IpmDevice::startMedia() DATA_IP_TDM_BIDIRECTIONAL for device: " <<
857                             getDeviceName());
858            }
859    
860            /* Start streaming...
861             */
862          if ( remote_audio_rtp.isValid() )          if ( remote_audio_rtp.isValid() )
863          {          {
864                  LOGDEBUG("IpmDevice::startMedia() starting audio on device: " <<                  LOGDEBUG("IpmDevice::startMedia() starting audio on device: " <<
# Line 1059  Line 1115 
1115          const Coders::audio_coders_t& local_audio_coders = ipt_->getAudioCoders();          const Coders::audio_coders_t& local_audio_coders = ipt_->getAudioCoders();
1116          const Coders::video_coders_t& local_video_coders = ipt_->getVideoCoders();          const Coders::video_coders_t& local_video_coders = ipt_->getVideoCoders();
1117    
1118          IpInfo local_rtp_audio;          RtpIpInfo local_rtp_audio;
1119          getLocalMediaInfo(MEDIATYPE_AUDIO_LOCAL_RTP_INFO, local_rtp_audio);          getLocalMediaInfo(MEDIATYPE_AUDIO_LOCAL_RTP_INFO, local_rtp_audio);
1120    
1121          IpInfo local_rtp_video;          RtpIpInfo local_rtp_video;
1122          getLocalMediaInfo(MEDIATYPE_VIDEO_LOCAL_RTP_INFO, local_rtp_video);          getLocalMediaInfo(MEDIATYPE_VIDEO_LOCAL_RTP_INFO, local_rtp_video);
1123    
1124          /* v= */          /* v= */
# Line 1368  Line 1424 
1424          const Coders::audio_coders_t& local_audio_coders = ipt_->getAudioCoders();          const Coders::audio_coders_t& local_audio_coders = ipt_->getAudioCoders();
1425          const Coders::video_coders_t& local_video_coders = ipt_->getVideoCoders();          const Coders::video_coders_t& local_video_coders = ipt_->getVideoCoders();
1426    
1427          IpInfo local_rtp_audio;          RtpIpInfo local_rtp_audio;
1428          getLocalMediaInfo(MEDIATYPE_AUDIO_LOCAL_RTP_INFO, local_rtp_audio);          getLocalMediaInfo(MEDIATYPE_AUDIO_LOCAL_RTP_INFO, local_rtp_audio);
1429    
1430          IpInfo local_rtp_video;          RtpIpInfo local_rtp_video;
1431          getLocalMediaInfo(MEDIATYPE_VIDEO_LOCAL_RTP_INFO, local_rtp_video);          getLocalMediaInfo(MEDIATYPE_VIDEO_LOCAL_RTP_INFO, local_rtp_video);
1432    
1433          /* v= */          /* v= */
# Line 1499  Line 1555 
1555                                                  audio_attribute->setPropertyValue(fmtp.c_str());                                                  audio_attribute->setPropertyValue(fmtp.c_str());
1556                                          }                                          }
1557                                          audio_attribute = audio_attr_list->addItem();                                          audio_attribute = audio_attr_list->addItem();
1558                                          audio_attribute->setProperty(localMedia_.audioDirection.c_str());                                          audio_attribute->setProperty(localMedia_.audioRtp.getDirectionText().c_str());
1559                                          audio_attribute->setPropertyValue("");                                          audio_attribute->setPropertyValue("");
1560                                  }                                  }
1561                                  if ( (*i).rfc2833 )                                  if ( (*i).rfc2833 )
# Line 1695  Line 1751 
1751                                          }                                          }
1752    
1753                                          video_attribute = video_attr_list->addItem();                                          video_attribute = video_attr_list->addItem();
1754                                          video_attribute->setProperty(localMedia_.videoDirection .c_str());                                          video_attribute->setProperty(localMedia_.videoRtp.getDirectionText().c_str());
1755                                          video_attribute->setPropertyValue("");                                          video_attribute->setPropertyValue("");
1756                                  }                                  }
1757                          }                          }
# Line 1731  Line 1787 
1787           */           */
1788          localMedia_.audioCoder.encoding.clear();          localMedia_.audioCoder.encoding.clear();
1789          remoteMedia_.audioCoder.encoding.clear();          remoteMedia_.audioCoder.encoding.clear();
1790          setRemoteMediaInfo(MEDIATYPE_AUDIO_REMOTE_RTP_INFO, IpInfo());  /* clear */          setRemoteMediaInfo(MEDIATYPE_AUDIO_REMOTE_RTP_INFO, RtpIpInfo());  /* clear */
1791          offer_.chosen_audio_mline = -1;          offer_.chosen_audio_mline = -1;
1792    
1793          const Coders::audio_coders_t& audio_coders = ipt_->getAudioCoders();          const Coders::audio_coders_t& audio_coders = ipt_->getAudioCoders();
# Line 1748  Line 1804 
1804                                  {                                  {
1805                                          remoteMedia_.audioCoder = (*j).audioCoder;                                          remoteMedia_.audioCoder = (*j).audioCoder;
1806                                          setRemoteMediaInfo(MEDIATYPE_AUDIO_REMOTE_RTP_INFO, (*j).rtp);                                          setRemoteMediaInfo(MEDIATYPE_AUDIO_REMOTE_RTP_INFO, (*j).rtp);
                                         remoteMedia_.audioDirection = (*j).direction;  
1807    
1808                                          LOGDEBUG("IpmDevice::onSdp() chose: \"" << remoteMedia_.audioCoder.encoding << "\" for audio");                                          LOGDEBUG("IpmDevice::processSdp() chose: \"" << remoteMedia_.audioCoder.encoding << "\" for audio");
1809    
1810                                          /* The remoteMedia_.audioCoder preserves the encoding name from                                          /* The remoteMedia_.audioCoder preserves the encoding name from
1811                                           * the remote party, which may differ from the name defined in the                                           * the remote party, which may differ from the name defined in the
# Line 1760  Line 1815 
1815                                          localMedia_.audioCoder = remoteMedia_.audioCoder;                                          localMedia_.audioCoder = remoteMedia_.audioCoder;
1816                                          localMedia_.audioCoder.encoding = (*i).encoding;                                          localMedia_.audioCoder.encoding = (*i).encoding;
1817    
1818                                          if ( remoteMedia_.audioDirection == "inactive" )                                          if ( remoteMedia_.audioRtp.getDirection() == RtpIpInfo::INACTIVE )
1819                                          {                                          {
1820                                                  localMedia_.audioDirection = "inactive";                                                  localMedia_.audioRtp.setDirection(RtpIpInfo::INACTIVE);
1821                                          }                                          }
1822                                          else if ( remoteMedia_.audioDirection == "sendonly" )                                          else if ( remoteMedia_.audioRtp.getDirection() == RtpIpInfo::SENDONLY )
1823                                          {                                          {
1824                                                  localMedia_.audioDirection = "recvonly";                                                  localMedia_.audioRtp.setDirection(RtpIpInfo::RECVONLY);
1825                                          }                                          }
1826                                          else if ( remoteMedia_.audioDirection == "recvonly" )                                          else if ( remoteMedia_.audioRtp.getDirection() == RtpIpInfo::RECVONLY )
1827                                          {                                          {
1828                                                  localMedia_.audioDirection = "sendonly";                                                  localMedia_.audioRtp.setDirection(RtpIpInfo::SENDONLY);
1829                                          }                                          }
1830                                          else /* "sendrecv" */                                          else /* "sendrecv" */
1831                                          {                                          {
1832                                                  localMedia_.audioDirection = "sendrecv";                                                  localMedia_.audioRtp.setDirection(RtpIpInfo::SENDRECV);
1833                                          }                                          }
1834    
1835                                          offer_.chosen_audio_mline = (*j).mline;                                          offer_.chosen_audio_mline = (*j).mline;
# Line 1792  Line 1847 
1847           */           */
1848          localMedia_.videoCoder.encoding.clear();          localMedia_.videoCoder.encoding.clear();
1849          remoteMedia_.videoCoder.encoding.clear();          remoteMedia_.videoCoder.encoding.clear();
1850          setRemoteMediaInfo(MEDIATYPE_VIDEO_REMOTE_RTP_INFO, IpInfo());  /* clear */          setRemoteMediaInfo(MEDIATYPE_VIDEO_REMOTE_RTP_INFO, RtpIpInfo());  /* clear */
1851          offer_.chosen_video_mline = -1;          offer_.chosen_video_mline = -1;
1852    
1853          const Coders::video_coders_t& video_coders = ipt_->getVideoCoders();          const Coders::video_coders_t& video_coders = ipt_->getVideoCoders();
# Line 1810  Line 1865 
1865                                          remoteMedia_.videoCoder = (*l).videoCoder;                                          remoteMedia_.videoCoder = (*l).videoCoder;
1866                                          /* Use the first fmt offered, there is always at least one. */                                          /* Use the first fmt offered, there is always at least one. */
1867                                          remoteMedia_.videoCoder.active_fmt = (*l).videoCoder.available_fmts[0];                                          remoteMedia_.videoCoder.active_fmt = (*l).videoCoder.available_fmts[0];
1868                                          LOGDEBUG("IpmDevice::onSdp() chose: \"" << remoteMedia_.videoCoder.encoding << "\" for video");                                          LOGDEBUG("IpmDevice::processSdp() chose: \"" << remoteMedia_.videoCoder.encoding << "\" for video");
1869    
1870                                          setRemoteMediaInfo(MEDIATYPE_VIDEO_REMOTE_RTP_INFO, (*l).rtp);                                          setRemoteMediaInfo(MEDIATYPE_VIDEO_REMOTE_RTP_INFO, (*l).rtp);
                                         remoteMedia_.videoDirection = (*l).direction;  
1871    
1872                                          /* The remoteMedia_.videoCoder preserves the encoding name from                                          /* The remoteMedia_.videoCoder preserves the encoding name from
1873                                           * the remote party, which may differ from the name defined in the                                           * the remote party, which may differ from the name defined in the
# Line 1823  Line 1877 
1877                                          localMedia_.videoCoder = remoteMedia_.videoCoder;                                          localMedia_.videoCoder = remoteMedia_.videoCoder;
1878                                          localMedia_.videoCoder.encoding = (*k).encoding;                                          localMedia_.videoCoder.encoding = (*k).encoding;
1879    
1880                                          if ( remoteMedia_.videoDirection == "inactive" )                                          if ( remoteMedia_.videoRtp.getDirection() == RtpIpInfo::INACTIVE )
1881                                          {                                          {
1882                                                  localMedia_.videoDirection = "inactive";                                                  localMedia_.videoRtp.setDirection(RtpIpInfo::INACTIVE);
1883                                          }                                          }
1884                                          else if ( remoteMedia_.videoDirection == "sendonly" )                                          else if ( remoteMedia_.videoRtp.getDirection() == RtpIpInfo::SENDONLY )
1885                                          {                                          {
1886                                                  localMedia_.videoDirection = "recvonly";                                                  localMedia_.videoRtp.setDirection(RtpIpInfo::RECVONLY);
1887                                          }                                          }
1888                                          else if ( remoteMedia_.videoDirection == "recvonly" )                                          else if ( remoteMedia_.videoRtp.getDirection() == RtpIpInfo::RECVONLY )
1889                                          {                                          {
1890                                                  localMedia_.videoDirection = "sendonly";                                                  localMedia_.videoRtp.setDirection(RtpIpInfo::SENDONLY);
1891                                          }                                          }
1892                                          else /* "sendrecv" */                                          else /* "sendrecv" */
1893                                          {                                          {
1894                                                  localMedia_.videoDirection = "sendrecv";                                                  localMedia_.videoRtp.setDirection(RtpIpInfo::SENDRECV);
1895                                          }                                          }
1896    
1897                                          offer_.chosen_video_mline = (*l).mline;                                          offer_.chosen_video_mline = (*l).mline;
# Line 1911  Line 1965 
1965          offer_.session.origin.address = sdp_desc.origin()->getAddress();          offer_.session.origin.address = sdp_desc.origin()->getAddress();
1966    
1967          /* a= */          /* a= */
1968            offer_.session.direction = "sendrecv";  /* Default, RFC 3264 */
1969    
1970          SdpAttributeList* attribute_list = sdp_desc.attributeList();          SdpAttributeList* attribute_list = sdp_desc.attributeList();
         offer_.session.direction = "sendrecv";  
1971          getSdpDirection(attribute_list, offer_.session.direction);          getSdpDirection(attribute_list, offer_.session.direction);
1972    
1973            /* If the connection address is "0.0.0.0" neither RTP nor RTCP can be sent
1974             * to the remote party. It _could_ indicate hold (RFC 2543), and the remote
1975             * party may still send(only) media.
1976             */
1977            if ( offer_.session.conn_address == "0.0.0.0" )
1978            {
1979                    if ( offer_.session.direction != "sendonly" )
1980                    {
1981                            offer_.session.direction = "inactive";
1982                    }
1983            }
1984    
1985          offer_.media.clear();          offer_.media.clear();
1986    
1987          const int num_media = sdp_desc.mediaDescriptionList()->numItem();          const int num_media = sdp_desc.mediaDescriptionList()->numItem();
# Line 1933  Line 2000 
2000                       (strcmp(sdp_media->getTransport(), "RTP/AVP") == 0) &&                       (strcmp(sdp_media->getTransport(), "RTP/AVP") == 0) &&
2001                       (sdp_media->getPort() != 0) )                       (sdp_media->getPort() != 0) )
2002                  {                  {
                         IpInfo rtp(media_addr, sdp_media->getPort());  
   
2003                          std::string media_direction = offer_.session.direction;                          std::string media_direction = offer_.session.direction;
2004                          getSdpDirection(md->attributeList(), media_direction);                          getSdpDirection(md->attributeList(), media_direction);
2005                            if ( offer_.session.conn_address == "0.0.0.0" )
2006                            {
2007                                    if ( media_direction != "sendonly" )
2008                                    {
2009                                            media_direction = "inactive";
2010                                    }
2011                            }
2012                            RtpIpInfo rtp(media_addr, sdp_media->getPort(), RtpIpInfo::INACTIVE);
2013                            rtp.setDirection(media_direction);
2014    
2015                          const int num_format = sdp_media->getNumFormat();                          const int num_format = sdp_media->getNumFormat();
2016                          for ( int f = 0; f < num_format; f++ )                          for ( int f = 0; f < num_format; f++ )
# Line 1946  Line 2020 
2020                                  remote_media.transport = sdp_media->getTransport();                                  remote_media.transport = sdp_media->getTransport();
2021                                  remote_media.mline = m;                                  remote_media.mline = m;
2022                                  remote_media.rtp = rtp;                                  remote_media.rtp = rtp;
                                 remote_media.direction = media_direction;  
2023                                  remote_media.rfc2833 = false;                                  remote_media.rfc2833 = false;
2024                                  remote_media.audioCoder.coderPayloadType = atoi(sdp_media->getFormat(f));                                  remote_media.audioCoder.coderPayloadType = atoi(sdp_media->getFormat(f));
2025                                  remote_media.audioCoder.coderType = CODER_TYPE_NONSTANDARD;                                  remote_media.audioCoder.coderType = CODER_TYPE_NONSTANDARD;
# Line 2103  Line 2176 
2176                            (strcmp(sdp_media->getTransport(), "RTP/AVP") == 0) &&                            (strcmp(sdp_media->getTransport(), "RTP/AVP") == 0) &&
2177                            (sdp_media->getPort() != 0) )                            (sdp_media->getPort() != 0) )
2178                  {                  {
                         IpInfo rtp(media_addr, sdp_media->getPort());  
   
2179                          std::string media_direction = offer_.session.direction;                          std::string media_direction = offer_.session.direction;
2180                          getSdpDirection(md->attributeList(), media_direction);                          getSdpDirection(md->attributeList(), media_direction);
2181                            if ( offer_.session.conn_address == "0.0.0.0" )
2182                            {
2183                                    if ( media_direction != "sendonly" )
2184                                    {
2185                                            media_direction = "inactive";
2186                                    }
2187                            }
2188                            RtpIpInfo rtp(media_addr, sdp_media->getPort(), RtpIpInfo::INACTIVE);
2189                            rtp.setDirection(media_direction);
2190    
2191                          unsigned int bandwidth = offer_.session.bandwidth;                          unsigned int bandwidth = offer_.session.bandwidth;
2192                          std::string modifier = md->bandwidth()->getModifier();                          std::string modifier = md->bandwidth()->getModifier();
# Line 2123  Line 2203 
2203                                  remote_media.transport = sdp_media->getTransport();                                  remote_media.transport = sdp_media->getTransport();
2204                                  remote_media.mline = m;                                  remote_media.mline = m;
2205                                  remote_media.rtp = rtp;                                  remote_media.rtp = rtp;
                                 remote_media.direction = media_direction;  
2206                                  remote_media.videoCoder.coderPayloadType = atoi(sdp_media->getFormat(f));                                  remote_media.videoCoder.coderPayloadType = atoi(sdp_media->getFormat(f));
2207                                  remote_media.videoCoder.coderType = CODER_TYPE_NONSTANDARD;                                  remote_media.videoCoder.coderType = CODER_TYPE_NONSTANDARD;
2208                                  remote_media.videoCoder.maxBitRate = bandwidth;                                  remote_media.videoCoder.maxBitRate = bandwidth;

Legend:
Removed from v.1217  
changed lines
  Added in v.1218

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.8