~ubuntu-branches/ubuntu/trusty/liblivemedia/trusty

« back to all changes in this revision

Viewing changes to liveMedia/MediaSession.cpp

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2012-03-02 08:01:26 UTC
  • mfrom: (1.4.10)
  • Revision ID: package-import@ubuntu.com-20120302080126-enkd2pz1h8zcfdkw
Tags: 2012.02.29-1
* Team upload.
* New upstream release.
* Bump Standards.

Show diffs side-by-side

added added

removed removed

Lines of Context:
590
590
 
591
591
    if (fClientPortNum != 0) {
592
592
      // The sockets' port numbers were specified for us.  Use these:
593
 
      fClientPortNum = fClientPortNum&~1; // even
 
593
      Boolean const protocolIsRTP = strcmp(fProtocolName, "RTP") == 0;
 
594
      if (protocolIsRTP) {
 
595
        fClientPortNum = fClientPortNum&~1; // use an even-numbered port for RTP, and the next (odd-numbered) port for RTCP
 
596
      }
594
597
      if (isSSM()) {
595
598
        fRTPSocket = new Groupsock(env(), tempAddr, fSourceFilterAddr, fClientPortNum);
596
599
      } else {
601
604
        break;
602
605
      }
603
606
      
604
 
      // Set our RTCP port to be the RTP port +1
605
 
      portNumBits const rtcpPortNum = fClientPortNum|1;
606
 
      if (isSSM()) {
607
 
        fRTCPSocket = new Groupsock(env(), tempAddr, fSourceFilterAddr, rtcpPortNum);
608
 
      } else {
609
 
        fRTCPSocket = new Groupsock(env(), tempAddr, rtcpPortNum, 255);
610
 
      }
611
 
      if (fRTCPSocket == NULL) {
612
 
        char tmpBuf[100];
613
 
        sprintf(tmpBuf, "Failed to create RTCP socket (port %d)", rtcpPortNum);
614
 
        env().setResultMsg(tmpBuf);
615
 
        break;
 
607
      if (protocolIsRTP) {
 
608
        // Set our RTCP port to be the RTP port +1
 
609
        portNumBits const rtcpPortNum = fClientPortNum|1;
 
610
        if (isSSM()) {
 
611
          fRTCPSocket = new Groupsock(env(), tempAddr, fSourceFilterAddr, rtcpPortNum);
 
612
        } else {
 
613
          fRTCPSocket = new Groupsock(env(), tempAddr, rtcpPortNum, 255);
 
614
        }
616
615
      }
617
616
    } else {
618
617
      // Port numbers were not specified in advance, so we use ephemeral port numbers.
690
689
      rtpBufSize = 50 * 1024;
691
690
    increaseReceiveBufferTo(env(), fRTPSocket->socketNum(), rtpBufSize);
692
691
 
693
 
    // ASSERT: fRTPSocket != NULL && fRTCPSocket != NULL
694
 
    if (isSSM()) {
 
692
    if (isSSM() && fRTCPSocket != NULL) {
695
693
      // Special case for RTCP SSM: Send RTCP packets back to the source via unicast:
696
694
      fRTCPSocket->changeDestinationParameters(fSourceFilterAddr,0,~0);
697
695
    }
705
703
    }
706
704
 
707
705
    // Finally, create our RTCP instance. (It starts running automatically)
708
 
    if (fRTPSource != NULL) {
 
706
    if (fRTPSource != NULL && fRTCPSocket != NULL) {
709
707
      // If bandwidth is specified, use it and add 5% for RTCP overhead.
710
708
      // Otherwise make a guess at 500 kbps.
711
709
      unsigned totSessionBandwidth
791
789
  if (fRTCPSocket != NULL && !isSSM()) {
792
790
    // Note: For SSM sessions, the dest address for RTCP was already set.
793
791
    Port destPort(serverPortNum+1);
794
 
    fRTCPSocket->
795
 
      changeDestinationParameters(destAddr, destPort, destTTL);
 
792
    fRTCPSocket->changeDestinationParameters(destAddr, destPort, destTTL);
796
793
  }
797
794
}
798
795