int MediaStream::deliverFeedback_(std::shared_ptr<DataPacket> fb_packet) { RtcpHeader *chead = reinterpret_cast<RtcpHeader*>(fb_packet->data); uint32_t recvSSRC = chead->getSourceSSRC(); if (isVideoSourceSSRC(recvSSRC)) { fb_packet->type = VIDEO_PACKET; sendPacketAsync(fb_packet); } else if (isAudioSourceSSRC(recvSSRC)) { fb_packet->type = AUDIO_PACKET; sendPacketAsync(fb_packet); } else { ELOG_DEBUG("%s deliverFeedback unknownSSRC: %u, localVideoSSRC: %u, localAudioSSRC: %u", toLog(), recvSSRC, this->getVideoSourceSSRC(), this->getAudioSourceSSRC()); } return fb_packet->length; }
int MediaStream::sendPLI() { RtcpHeader thePLI; thePLI.setPacketType(RTCP_PS_Feedback_PT); thePLI.setBlockCount(1); thePLI.setSSRC(this->getVideoSinkSSRC()); thePLI.setSourceSSRC(this->getVideoSourceSSRC()); thePLI.setLength(2); char *buf = reinterpret_cast<char*>(&thePLI); int len = (thePLI.getLength() + 1) * 4; sendPacketAsync(std::make_shared<DataPacket>(0, buf, len, VIDEO_PACKET)); return len; }
int MediaStream::deliverFeedback_(std::shared_ptr<DataPacket> fb_packet) { RtcpHeader *chead = reinterpret_cast<RtcpHeader*>(fb_packet->data); uint32_t recvSSRC = chead->getSourceSSRC(); if (chead->isREMB()) { for (uint8_t index = 0; index < chead->getREMBNumSSRC(); index++) { uint32_t ssrc = chead->getREMBFeedSSRC(index); if (isVideoSourceSSRC(ssrc)) { recvSSRC = ssrc; break; } } } if (isVideoSourceSSRC(recvSSRC)) { fb_packet->type = VIDEO_PACKET; sendPacketAsync(fb_packet); } else if (isAudioSourceSSRC(recvSSRC)) { fb_packet->type = AUDIO_PACKET; sendPacketAsync(fb_packet); } else { ELOG_DEBUG("%s deliverFeedback unknownSSRC: %u, localVideoSSRC: %u, localAudioSSRC: %u", toLog(), recvSSRC, this->getVideoSourceSSRC(), this->getAudioSourceSSRC()); } return fb_packet->length; }
int MediaStream::deliverVideoData_(std::shared_ptr<DataPacket> video_packet) { if (video_enabled_ == true) { sendPacketAsync(std::make_shared<DataPacket>(*video_packet)); } return video_packet->length; }
int MediaStream::deliverAudioData_(std::shared_ptr<DataPacket> audio_packet) { if (audio_enabled_ == true) { sendPacketAsync(std::make_shared<DataPacket>(*audio_packet)); } return audio_packet->length; }