diff options
Diffstat (limited to 'Swiften/ScreenSharing/VP8Encoder.cpp')
-rw-r--r-- | Swiften/ScreenSharing/VP8Encoder.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/Swiften/ScreenSharing/VP8Encoder.cpp b/Swiften/ScreenSharing/VP8Encoder.cpp index e48d6d9..a7f5a69 100644 --- a/Swiften/ScreenSharing/VP8Encoder.cpp +++ b/Swiften/ScreenSharing/VP8Encoder.cpp @@ -14,7 +14,7 @@ namespace Swift { VP8Encoder::VP8Encoder(VP8RTPPacketizer* packetizer, unsigned int width, unsigned int height) : VideoEncoder(), - packetizer(packetizer), codecInterface(vpx_codec_vp8_cx()), imageBuffer(0), codecFlags(0), frameFlags(0), frameNumber(0), pictureID(0), rpsiReceived(true) + packetizer(packetizer), codecInterface(vpx_codec_vp8_cx()), imageBuffer(0), codecFlags(0), frameFlags(0), frameNumber(0), pictureID(0) { SWIFT_LOG(debug) << "VP8 Encoder:" << vpx_codec_iface_name(codecInterface) << std::endl; @@ -63,7 +63,6 @@ void VP8Encoder::updateCodecConfig() frameNumber = 0; pictureID = rand() % 128; - rpsiReceived = true; } void VP8Encoder::encodeImage(const Image& frame) @@ -74,13 +73,16 @@ void VP8Encoder::encodeImage(const Image& frame) return; } + /* vpx_enc_frame_flags_t localFrameFlags = frameFlags; if (!rpsiReceived && frameNumber > 1) { SWIFT_LOG(error) << "VP8 Encoder: RPSI not received, do not ref last frame" << std::endl; localFrameFlags |= VP8_EFLAG_NO_REF_LAST; // VP8_EFLAG_FORCE_GF; // TODO: VP8_EFLAG_NO_REF_LAST; } + */ - vpx_codec_err_t err = vpx_codec_encode(&codecContext, imageBuffer, frameNumber, 1, localFrameFlags, VPX_DL_REALTIME); + vpx_enc_frame_flags_t flags = rps.encodeFlags(pictureID); + vpx_codec_err_t err = vpx_codec_encode(&codecContext, imageBuffer, frameNumber, 1, flags, VPX_DL_REALTIME); if (err) { SWIFT_LOG(error) << "VP8 Encoder: Failed to encode frame, " << vpx_codec_err_to_string(err) << std::endl; // TODO: exception ? @@ -89,9 +91,15 @@ void VP8Encoder::encodeImage(const Image& frame) const vpx_codec_cx_pkt_t* pkt; vpx_codec_iter_t iter = NULL; + int vp8Flags; while ((pkt = vpx_codec_get_cx_data(&codecContext, &iter))) { switch (pkt->kind) { case VPX_CODEC_CX_FRAME_PKT: + vp8Flags = pkt->data.frame.flags >> 16; + SWIFT_LOG(debug) << "vp8Flags: " << vp8Flags << ", len: " << pkt->data.frame.sz << std::endl; + if ((vp8Flags & VP8_ALTR_FRAME) || (vp8Flags & VP8_GOLD_FRAME)) { + rps.refFrameSent(pictureID); + } packetizer->packetizeFrame(pkt, pictureID); break; default: @@ -101,12 +109,16 @@ void VP8Encoder::encodeImage(const Image& frame) ++frameNumber; pictureID = (pictureID + 1) % 128; - rpsiReceived = false; } -void VP8Encoder::handleRPSIFeedback(int /*pictureID*/) +void VP8Encoder::handleRPSIFeedback(int pictureID) { - rpsiReceived = true; + rps.receivedRPSI(pictureID); +} + +void VP8Encoder::handleSLIFeedback(int /*pictureID*/) +{ + rps.receivedSLI(); } bool VP8Encoder::convertRGB24toYV12inBuffer(const Image& frame) |