diff options
Diffstat (limited to 'Swiften/ScreenSharing/RTPSessionImpl.cpp')
-rw-r--r-- | Swiften/ScreenSharing/RTPSessionImpl.cpp | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/Swiften/ScreenSharing/RTPSessionImpl.cpp b/Swiften/ScreenSharing/RTPSessionImpl.cpp index 33b9c2e..2f90944 100644 --- a/Swiften/ScreenSharing/RTPSessionImpl.cpp +++ b/Swiften/ScreenSharing/RTPSessionImpl.cpp @@ -106,8 +106,8 @@ void RTPSessionImpl::sendPacket(const SafeByteArray& data, int timestampinc, boo void RTPSessionImpl::injectData(const SafeByteArray& data) { packetInjecter->InjectRTPorRTCP((void*)(data.data()), data.size(), *jRTPRemotePeer); - checkIncomingPackets(); poll(); + checkIncomingPackets(); } void RTPSessionImpl::stop(int maxWaitMs) @@ -122,26 +122,22 @@ void RTPSessionImpl::sendSLIFeedback(int pictureID) int first = 0; // 13 bits int number = 0; // 13 bits // TODO : Find the total number of macroblocks per frame - uint32_t data = 0; - data |= first << 19; - data |= (number & 2047) << 6; - data |= (pictureID & 63); + uint8_t data[4] = {0, 0, 0, (pictureID & 63)}; - SendUnknownPacket(false, PSFB, PSFB_SLI, (void*)&data, sizeof(uint32_t)); + SendUnknownPacket(false, PSFB, PSFB_SLI, (void*)data, sizeof(data)); } void RTPSessionImpl::sendRPSIFeedback(int pictureID) { + SWIFT_LOG(debug) << "sendRPSIFeedback, pictureId = " << pictureID << std::endl; + // Send an RPSI as positive feedback. With VP8, it only contains the picture ID (7 bits) - int pb = 9; // trailing padding bits - int pt = payloadType.getID(); // payload type (7 bits) + uint8_t pb = 9; // trailing padding bits + uint8_t pt = payloadType.getID(); // payload type (7 bits) - uint32_t data = 0; - data |= pb << 24; - data |= (pt & 127) << 16; - data |= (pictureID & 127) << 9; + uint8_t data[4] = {pb, pt & 127, (pictureID & 127) << 1, 0}; - SendUnknownPacket(false, PSFB, PSFB_RPSI, (void*)&data, sizeof(uint32_t)); + SendUnknownPacket(false, PSFB, PSFB_RPSI, (void*)data, sizeof(data)); } size_t RTPSessionImpl::getMaxRTPPayloadSize() const @@ -162,13 +158,14 @@ void RTPSessionImpl::OnUnknownPacketType(jrtplib::RTCPPacket* rtcpPack, const jr if (type != PSFB) return; + size_t hdrSize = 8; int subtype = rtcpHdr->count; switch (subtype) { case PSFB_SLI: - parseSLIFeedBack(data + 8, len - 8); + parseSLIFeedBack(data + hdrSize, len - hdrSize); break; case PSFB_RPSI: - parseRPSIFeedBack(data + 8, len - 8); + parseRPSIFeedBack(data + hdrSize, len - hdrSize); break; default: break; @@ -188,24 +185,21 @@ void RTPSessionImpl::handleDataRead(boost::shared_ptr<SafeByteArray> data) void RTPSessionImpl::parseSLIFeedBack(uint8_t* data, size_t len) { - SWIFT_LOG(debug) << "Got SLI feedback (negative)" << std::endl; - if (len < 4) return; - int pictureID = data[len - 1] & 63; // pictureID correspond to the 6 last bits + + int pictureID = (data[3] & 63); // pictureID correspond to the 6 lsb + SWIFT_LOG(debug) << "Got SLI feedback (negative), pictureID = " << pictureID << std::endl; onSLIFeedback(pictureID); } void RTPSessionImpl::parseRPSIFeedBack(uint8_t* data, size_t len) { - SWIFT_LOG(debug) << "Got RPSI feedback (postive)" << std::endl; - if (len < 4) return; - int pb = data[0]; // First byte : trailing padding bits - uint32_t intData = *((uint32_t*)(data)); - intData >>= pb; // remove padding bits - int pictureID = (intData & 127); // pictureID correspond to the 7 last bits + + int pictureID = (data[2] >> 1); + SWIFT_LOG(debug) << "Got RPSI feedback (postive), pictureID = " << pictureID << std::endl; onRPSIFeedback(pictureID); } |