Beispiel #1
0
  int WebRtcConnection::deliverFeedback_(char* buf, int len){
    // Check where to send the feedback
    RtcpHeader *chead = reinterpret_cast<RtcpHeader*> (buf);
//    ELOG_DEBUG("received Feedback type %u ssrc %u, sourcessrc %u", chead->packettype, chead->getSSRC(), chead->getSourceSSRC());
    if (chead->getSourceSSRC() == this->getAudioSourceSSRC()) {
        writeSsrc(buf,len,this->getAudioSinkSSRC());
    } else {
        writeSsrc(buf,len,this->getVideoSinkSSRC());      
    }

    if (videoTransport_ != NULL) {
      this->queueData(0, buf, len, videoTransport_);
    }
    return len;
  }
Beispiel #2
0
  int WebRtcConnection::deliverFeedback(char* buf, int len){
    // Check where to send the feedback
    rtcpheader *chead = (rtcpheader*) buf;
    ELOG_DEBUG("received Feedback type %u ssrc %u, sourcessrc %u", chead->packettype, ntohl(chead->ssrc), ntohl(chead->ssrcsource));
    if (ntohl(chead->ssrcsource) == this->getAudioSourceSSRC()) {
        writeSsrc(buf,len,this->getAudioSinkSSRC());      
    } else {
        writeSsrc(buf,len,this->getVideoSinkSSRC());      
    }

    if (bundle_){
      if (videoTransport_ != NULL) {
        videoTransport_->write(buf, len);
      }
    } else {
      // TODO: Check where to send the feedback
      if (videoTransport_ != NULL) {
        videoTransport_->write(buf, len);
      }
    }
    return len;
  }
Beispiel #3
0
 int WebRtcConnection::deliverAudioData_(char* buf, int len) {
   writeSsrc(buf, len, this->getAudioSinkSSRC());
   if (bundle_){
     if (videoTransport_ != NULL) {
       if (audioEnabled_ == true) {
         this->queueData(0, buf, len, videoTransport_);
       }
     }
   } else if (audioTransport_ != NULL) {
     if (audioEnabled_ == true) {
       this->queueData(0, buf, len, audioTransport_);
     }
   }
   return len;
 }
Beispiel #4
0
 int WebRtcConnection::deliverAudioData(char* buf, int len) {
   boost::mutex::scoped_lock lock(receiveAudioMutex_);
   writeSsrc(buf, len, this->getAudioSinkSSRC());
   if (bundle_){
     if (videoTransport_ != NULL) {
       if (audioEnabled_ == true) {
         videoTransport_->write(buf, len);
       }
     }
   } else if (audioTransport_ != NULL) {
     if (audioEnabled_ == true) {
       audioTransport_->write(buf, len);
     }
   }
   return len;
 }
Beispiel #5
0
  int WebRtcConnection::deliverVideoData(char* buf, int len) {
    boost::mutex::scoped_lock lock(receiveAudioMutex_);
    rtpheader *head = (rtpheader*) buf;

    if (head->payloadtype == RED_90000_PT) {
      int totalLength = 12;

      if (head->extension) {
        totalLength += ntohs(head->extensionlength)*4 + 4; // RTP Extension header
      }
      int rtpHeaderLength = totalLength;
      redheader *redhead = (redheader*) (buf + totalLength);

      //redhead->payloadtype = remoteSdp_.inOutPTMap[redhead->payloadtype];
      if (!remoteSdp_.supportPayloadType(head->payloadtype)) {
        while (redhead->follow) {
          totalLength += redhead->getLength() + 4; // RED header
          redhead = (redheader*) (buf + totalLength);
        }
        // Parse RED packet to VP8 packet.
        // Copy RTP header
        memcpy(deliverMediaBuffer_, buf, rtpHeaderLength);
        // Copy payload data
        memcpy(deliverMediaBuffer_ + totalLength, buf + totalLength + 1, len - totalLength - 1);
        // Copy payload type
        rtpheader *mediahead = (rtpheader*) deliverMediaBuffer_;
        mediahead->payloadtype = redhead->payloadtype;
        buf = deliverMediaBuffer_;
        len = len - 1 - totalLength + rtpHeaderLength;
      }
    }
    writeSsrc(buf, len, this->getVideoSinkSSRC());
    if (videoTransport_ != NULL) {
      if (videoEnabled_ == true) {
        videoTransport_->write(buf, len);
      }
    }
    return len;
  }
Beispiel #6
0
 int WebRtcConnection::deliverVideoData_(char* buf, int len) {
   writeSsrc(buf, len, this->getVideoSinkSSRC());
   if (videoTransport_ != NULL) {
     if (videoEnabled_ == true) {
         RtpHeader* h = reinterpret_cast<RtpHeader*>(buf);
         if (h->getPayloadType() == RED_90000_PT && !remoteSdp_.supportPayloadType(RED_90000_PT)) {
             // This is a RED/FEC payload, but our remote endpoint doesn't support that (most likely because it's firefox :/ )
             // Let's go ahead and run this through our fec receiver to convert it to raw VP8
             webrtc::RTPHeader hackyHeader;
             hackyHeader.headerLength = h->getHeaderLength();
             hackyHeader.sequenceNumber = h->getSeqNumber();
             // FEC copies memory, manages its own memory, including memory passed in callbacks (in the callback, be sure to memcpy out of webrtc's buffers
             if (fec_receiver_.AddReceivedRedPacket(hackyHeader, (const uint8_t*) buf, len, ULP_90000_PT) == 0) {
                 fec_receiver_.ProcessReceivedFec();
             }
           } else {
             this->queueData(0, buf, len, videoTransport_);
         }
     }
   }
   return len;
 }