diff options
| author | dknn <yoann.blein@free.fr> | 2012-07-14 08:00:24 (GMT) |
|---|---|---|
| committer | dknn <yoann.blein@free.fr> | 2012-09-22 09:01:48 (GMT) |
| commit | 51958a50e31b483aa932aac8d696b229ba66b5cb (patch) | |
| tree | 559c19451c2d53a1ee72113154aa187060680f3c | |
| parent | ce9a3d75677f08af0a226bb3d2bf02c28c938c33 (diff) | |
| download | swift-contrib-51958a50e31b483aa932aac8d696b229ba66b5cb.zip swift-contrib-51958a50e31b483aa932aac8d696b229ba66b5cb.tar.bz2 | |
Fixes to make classes working together
| -rw-r--r-- | Swiften/ScreenSharing/Image.cpp | 2 | ||||
| -rw-r--r-- | Swiften/ScreenSharing/Image.h | 2 | ||||
| -rw-r--r-- | Swiften/ScreenSharing/IncomingScreenSharing.cpp | 36 | ||||
| -rw-r--r-- | Swiften/ScreenSharing/IncomingScreenSharing.h | 17 | ||||
| -rw-r--r-- | Swiften/ScreenSharing/OutgoingScreenSharing.cpp | 40 | ||||
| -rw-r--r-- | Swiften/ScreenSharing/OutgoingScreenSharing.h | 24 | ||||
| -rw-r--r-- | Swiften/ScreenSharing/RTPSessionImpl.cpp | 9 | ||||
| -rw-r--r-- | Swiften/ScreenSharing/RTPSessionImpl.h | 2 | ||||
| -rw-r--r-- | Swiften/ScreenSharing/ScreenSharing.cpp | 38 | ||||
| -rw-r--r-- | Swiften/ScreenSharing/ScreenSharing.h | 10 | ||||
| -rw-r--r-- | Swiften/ScreenSharing/VP8Encoder.cpp | 16 | ||||
| -rw-r--r-- | Swiften/ScreenSharing/VP8RTPParser.cpp | 2 | ||||
| -rw-r--r-- | Swiften/ScreenSharing/VP8RTPParser.h | 6 |
13 files changed, 160 insertions, 44 deletions
diff --git a/Swiften/ScreenSharing/Image.cpp b/Swiften/ScreenSharing/Image.cpp index c3acd69..d807c58 100644 --- a/Swiften/ScreenSharing/Image.cpp +++ b/Swiften/ScreenSharing/Image.cpp @@ -7,9 +7,9 @@ #include <Swiften/ScreenSharing/Image.h> namespace Swift { -Image::Image(int width, int height, uint8_t* rgb24data) +Image::Image(int width, int height, const uint8_t* rgb24data) : width(width), height(height) { int len = width * height * 3; if (rgb24data) { diff --git a/Swiften/ScreenSharing/Image.h b/Swiften/ScreenSharing/Image.h index 5cdf043..0e0151d 100644 --- a/Swiften/ScreenSharing/Image.h +++ b/Swiften/ScreenSharing/Image.h @@ -14,9 +14,9 @@ namespace Swift { class Image { public: typedef boost::shared_ptr<Image> ref; - Image(int width, int height, uint8_t* rgb24data = 0); + Image(int width, int height, const uint8_t* rgb24data = 0); int width; int height; std::vector<uint8_t> data; diff --git a/Swiften/ScreenSharing/IncomingScreenSharing.cpp b/Swiften/ScreenSharing/IncomingScreenSharing.cpp index d5ee56e..2ddfab9 100644 --- a/Swiften/ScreenSharing/IncomingScreenSharing.cpp +++ b/Swiften/ScreenSharing/IncomingScreenSharing.cpp @@ -7,51 +7,79 @@ #include <Swiften/ScreenSharing/IncomingScreenSharing.h> #include <Swiften/Jingle/JingleSession.h> #include <Swiften/Elements/JingleRawUDPTransportPayload.h> +#include <Swiften/Elements/JingleRTPDescription.h> #include <Swiften/Network/UDPSocketFactory.h> #include <Swiften/Network/UDPSocket.h> +#include <Swiften/ScreenSharing/RTPSessionImpl.h> +#include <Swiften/ScreenSharing/VP8Decoder.h> +#include <Swiften/ScreenSharing/VP8RTPParser.h> + +#include <boost/bind.hpp> namespace Swift { IncomingScreenSharing::IncomingScreenSharing(boost::shared_ptr<JingleSession> session, UDPSocketFactory* udpSocketFactory, boost::shared_ptr<JingleContentPayload> content) : ScreenSharing(session, udpSocketFactory), - initialContent(content) + initialContent(content), parser(0), decoder(0) { onStateChange(ScreenSharing::WaitingForAccept); } IncomingScreenSharing::~IncomingScreenSharing() { + delete rtpSession; + delete parser; + delete decoder; } void IncomingScreenSharing::cancel() { - session->sendTerminate(JinglePayload::Reason::Cancel); - clientSocket->close(); + jingleSession->sendTerminate(JinglePayload::Reason::Cancel); + if (rtpSession) + rtpSession->stop(); onStateChange(ScreenSharing::Canceled); } void IncomingScreenSharing::accept() { JingleRawUDPTransportPayload::ref transport = boost::make_shared<JingleRawUDPTransportPayload>(); addBestCandidate(transport); + JingleRTPDescription::ref desc = initialContent->getDescription<JingleRTPDescription>(); + if (!desc->getPayloadTypes().empty()) + payloadTypeUsed = desc->getPayloadTypes().front(); + // TODO: create a valid description instead of copying the initator's one - session->sendAccept(getContentID(), initialContent->getDescriptions().front(), transport); + jingleSession->sendAccept(getContentID(), desc, transport); JingleRawUDPTransportPayload::ref initialTransport = initialContent->getTransport<JingleRawUDPTransportPayload>(); clientSocket = udpSocketFactory->createUDPSocket(); clientSocket->connect(initialTransport->getCandidates().front().hostAddressPort); // Send a empty packet to let the server know about us SafeByteArray data(1, 0); clientSocket->send(data); + rtpSession = new RTPSessionImpl(clientSocket, payloadTypeUsed); + + if (payloadTypeUsed.getID() == 98 && payloadTypeUsed.getName() == "VP8") { + decoder = new VP8Decoder; + parser = new VP8RTPParser(decoder); + rtpSession->onIncomingPacket.connect(boost::bind(&VP8RTPParser::newPayloadReceived, parser, _1, _2, _3)); + decoder->onNewImageDecoded.connect(boost::bind(&IncomingScreenSharing::hangleNewImageDecoded, this, _1)); + } + onStateChange(ScreenSharing::Connecting); } JingleContentID IncomingScreenSharing::getContentID() const { return JingleContentID(initialContent->getName(), initialContent->getCreator()); } +void IncomingScreenSharing::hangleNewImageDecoded(const Image& image) +{ + onNewImageReceived(image); +} + } diff --git a/Swiften/ScreenSharing/IncomingScreenSharing.h b/Swiften/ScreenSharing/IncomingScreenSharing.h index a9850fd..f6d9b62 100644 --- a/Swiften/ScreenSharing/IncomingScreenSharing.h +++ b/Swiften/ScreenSharing/IncomingScreenSharing.h @@ -7,29 +7,40 @@ #pragma once #include <Swiften/ScreenSharing/ScreenSharing.h> #include <Swiften/Jingle/JingleContentID.h> +#include <Swiften/Elements/RTPPayloadType.h> +#include <Swiften/Base/boost_bsignals.h> namespace Swift { class JingleContentPayload; + class VP8RTPParser; + class VideoDecoder; + class Image; - class IncomingScreenSharing : public ScreenSharing - { + class IncomingScreenSharing : public ScreenSharing { public: typedef boost::shared_ptr<IncomingScreenSharing> ref; public: - IncomingScreenSharing(boost::shared_ptr<JingleSession> session, UDPSocketFactory* udpSocketFactory, + IncomingScreenSharing(boost::shared_ptr<JingleSession> jingleSession, UDPSocketFactory* udpSocketFactory, boost::shared_ptr<JingleContentPayload> content); virtual ~IncomingScreenSharing(); virtual void cancel(); void accept(); + public: + boost::signal<void (const Image&)> onNewImageReceived; + private: JingleContentID getContentID() const; + void hangleNewImageDecoded(const Image& image); private: boost::shared_ptr<JingleContentPayload> initialContent; + RTPPayloadType payloadTypeUsed; + VP8RTPParser* parser; + VideoDecoder* decoder; }; } diff --git a/Swiften/ScreenSharing/OutgoingScreenSharing.cpp b/Swiften/ScreenSharing/OutgoingScreenSharing.cpp index da7eb3e..77226c5 100644 --- a/Swiften/ScreenSharing/OutgoingScreenSharing.cpp +++ b/Swiften/ScreenSharing/OutgoingScreenSharing.cpp @@ -5,60 +5,75 @@ */ #include <Swiften/ScreenSharing/OutgoingScreenSharing.h> +#include <Swiften/Base/Algorithm.h> #include <Swiften/Elements/JinglePayload.h> #include <Swiften/Elements/JingleRawUDPTransportPayload.h> #include <Swiften/Elements/JingleRTPDescription.h> #include <Swiften/Jingle/JingleSession.h> #include <Swiften/Network/UDPSocket.h> #include <Swiften/Network/TimerFactory.h> #include <Swiften/Network/Timer.h> #include <Swiften/ScreenSharing/RTPSessionImpl.h> +#include <Swiften/ScreenSharing/VP8Encoder.h> +#include <Swiften/ScreenSharing/VP8RTPPacketizer.h> +#include <Swiften/ScreenSharing/Image.h> #include <boost/bind.hpp> namespace Swift { OutgoingScreenSharing::OutgoingScreenSharing(boost::shared_ptr<JingleSession> session, UDPSocketFactory* udpSocketFactory, TimerFactory* timerFactory) : ScreenSharing(session, udpSocketFactory), - contentID(JingleContentID(idGenerator.generateID(), JingleContentPayload::InitiatorCreator)), canceled(false), - sessionAccepted(false), socketConnected(false), rtpSession(0), timerFactory(timerFactory) + timerFactory(timerFactory), contentID(JingleContentID(idGenerator.generateID(), JingleContentPayload::InitiatorCreator)), + canceled(false), sessionAccepted(false), socketConnected(false), encoder(0), packetizer(0) { session->onSessionAcceptReceived.connect(boost::bind(&OutgoingScreenSharing::handleSessionAcceptReceived, this, _1, _2, _3)); } OutgoingScreenSharing::~OutgoingScreenSharing() { + delete rtpSession; + delete encoder; + delete packetizer; } void OutgoingScreenSharing::cancel() { canceled = true; - session->sendTerminate(JinglePayload::Reason::Cancel); + jingleSession->sendTerminate(JinglePayload::Reason::Cancel); onStateChange(ScreenSharing::Canceled); } -void OutgoingScreenSharing::start() +void OutgoingScreenSharing::start(unsigned int width, unsigned int height) { //onStateChange(ScreenSharing::WaitingForStart); SWIFT_LOG(debug) << "Screen sharing: start" << std::endl; + this->width = width; + this->height = height; + JingleRTPDescription::ref desc = boost::make_shared<JingleRTPDescription>(JingleRTPDescription::Video); payloadTypeUsed = RTPPayloadType(98, "VP8", 90000); desc->addPayloadType(payloadTypeUsed); JingleRawUDPTransportPayload::ref transport = boost::make_shared<JingleRawUDPTransportPayload>(); addBestCandidate(transport); - session->sendInitiate(contentID, desc, transport); + jingleSession->sendInitiate(contentID, desc, transport); onStateChange(ScreenSharing::WaitingForAccept); serverSocket->onConnected.connect(boost::bind(&OutgoingScreenSharing::handleSocketConnected, this)); serverSocket->connectToFirstIncoming(); } +void OutgoingScreenSharing::addImage(const Image &image) +{ + encoder->encodeImage(image); +} + void OutgoingScreenSharing::handleSocketConnected() { if (canceled) return; @@ -91,9 +106,9 @@ void OutgoingScreenSharing::handleSessionAcceptReceived(const JingleContentID& / void OutgoingScreenSharing::handleConnectionFailed() { SWIFT_LOG(debug) << "Screen sharing: unable to connect" << std::endl; - session->sendTerminate(JinglePayload::Reason::ConnectivityError); + jingleSession->sendTerminate(JinglePayload::Reason::ConnectivityError); canceled = true; onStateChange(ScreenSharing::Failed); } @@ -103,7 +118,20 @@ void OutgoingScreenSharing::startRTPSession() SWIFT_LOG(debug) << "Screen sharing: accepted and connected, start sharing" << std::endl; // Session accepted and socket connected, we can start the rtp session rtpSession = new RTPSessionImpl(serverSocket, payloadTypeUsed); + + if (payloadTypeUsed.getID() == 98 && payloadTypeUsed.getName() == "VP8") { + packetizer = new VP8RTPPacketizer; + encoder = new VP8Encoder(packetizer, width, height); + packetizer->onNewPayloadReady.connect(boost::bind(&OutgoingScreenSharing::handleNewPayloadReady, this, _1, _2)); + onReady(); + } +} + +void OutgoingScreenSharing::handleNewPayloadReady(const std::vector<uint8_t>& data, bool marker) +{ + SafeByteArray sba(data.begin(), data.end()); + rtpSession->sendPacket(sba, 500, marker); } } diff --git a/Swiften/ScreenSharing/OutgoingScreenSharing.h b/Swiften/ScreenSharing/OutgoingScreenSharing.h index c00d11e..cacc715 100644 --- a/Swiften/ScreenSharing/OutgoingScreenSharing.h +++ b/Swiften/ScreenSharing/OutgoingScreenSharing.h @@ -9,42 +9,54 @@ #include <Swiften/ScreenSharing/ScreenSharing.h> #include <Swiften/Jingle/JingleContentID.h> #include <Swiften/Elements/RTPPayloadType.h> +#include <stdint.h> +#include <vector> + namespace Swift { class ConnectivityManager; class JingleDescription; class JingleTransportPayload; class TimerFactory; class Timer; - class RTPSession; + class VideoEncoder; + class VP8RTPPacketizer; + class Image; class OutgoingScreenSharing : public ScreenSharing { public: typedef boost::shared_ptr<OutgoingScreenSharing> ref; public: - OutgoingScreenSharing(boost::shared_ptr<JingleSession> session, UDPSocketFactory* udpSocketFactory, TimerFactory* timerFactory); + OutgoingScreenSharing(boost::shared_ptr<JingleSession> jingleSession, UDPSocketFactory* udpSocketFactory, TimerFactory* timerFactory); virtual ~OutgoingScreenSharing(); virtual void cancel(); - void start(); + void start(unsigned int width, unsigned int height); + void addImage(const Image& image); + + public: + boost::signal<void ()> onReady; private: void handleSocketConnected(); void handleSessionAcceptReceived(const JingleContentID& /*id*/, boost::shared_ptr<JingleDescription> /*desc*/, boost::shared_ptr<JingleTransportPayload> /*transport*/); void handleConnectionFailed(); void startRTPSession(); + void handleNewPayloadReady(const std::vector<uint8_t>& data, bool marker); private: + TimerFactory* timerFactory; JingleContentID contentID; bool canceled; bool sessionAccepted; bool socketConnected; - RTPSession* rtpSession; RTPPayloadType payloadTypeUsed; - - TimerFactory* timerFactory; + VideoEncoder* encoder; + VP8RTPPacketizer* packetizer; + unsigned int width; + unsigned int height; boost::shared_ptr<Timer> connectionTimer; }; } diff --git a/Swiften/ScreenSharing/RTPSessionImpl.cpp b/Swiften/ScreenSharing/RTPSessionImpl.cpp index 62b05d5..94641ff 100644 --- a/Swiften/ScreenSharing/RTPSessionImpl.cpp +++ b/Swiften/ScreenSharing/RTPSessionImpl.cpp @@ -22,8 +22,12 @@ #include <rtpsessionparams.h> namespace Swift { +Sender::Sender(boost::shared_ptr<UDPSocket> udpSocket) + : udpSocket(udpSocket) { +} + bool Sender::SendRTP(const void *data, size_t len) { send(data, len); return true; } @@ -37,9 +41,9 @@ bool Sender::ComesFromThisSender (const jrtplib::RTPAddress* address) { return RTPSessionImpl::nativeAddressToJRTPAddress(udpSocket->getLocalAddress()).IsSameAddress(address); } void Sender::send(const void* data, size_t len) { - unsigned char *uint8Data = (unsigned char*)data; + uint8_t* uint8Data = (uint8_t*)data; udpSocket->send(SafeByteArray(uint8Data, uint8Data + len)); } RTPSessionImpl::RTPSessionImpl(boost::shared_ptr<UDPSocket> udpSocket, const RTPPayloadType &payloadType) @@ -54,8 +58,9 @@ RTPSessionImpl::RTPSessionImpl(boost::shared_ptr<UDPSocket> udpSocket, const RTP packetInjecter = static_cast<jrtplib::RTPExternalTransmissionInfo*>(session.GetTransmissionInfo())->GetPacketInjector(); udpSocket->onDataRead.connect(boost::bind(&RTPSessionImpl::handleDataRead, this, _1)); + udpSocket->listen(); } RTPSessionImpl::~RTPSessionImpl() { @@ -96,9 +101,9 @@ void RTPSessionImpl::injectData(const SafeByteArray& data) void RTPSessionImpl::stop(int maxWaitMs) { session.BYEDestroy(jrtplib::RTPTime(0, maxWaitMs * 1000), "", 0); - // TODO: shutdown socket + udpSocket->close(); } void RTPSessionImpl::checkError(int rtperr) const { diff --git a/Swiften/ScreenSharing/RTPSessionImpl.h b/Swiften/ScreenSharing/RTPSessionImpl.h index 9bf08e5..231ec1e 100644 --- a/Swiften/ScreenSharing/RTPSessionImpl.h +++ b/Swiften/ScreenSharing/RTPSessionImpl.h @@ -18,9 +18,9 @@ namespace Swift { class Sender : public jrtplib::RTPExternalSender { public: - Sender(boost::shared_ptr<UDPSocket> udpSocket) : udpSocket(udpSocket) {} + Sender(boost::shared_ptr<UDPSocket> udpSocket); virtual bool SendRTP(const void* data, size_t len); virtual bool SendRTCP(const void* data, size_t len); virtual bool ComesFromThisSender (const jrtplib::RTPAddress* address); diff --git a/Swiften/ScreenSharing/ScreenSharing.cpp b/Swiften/ScreenSharing/ScreenSharing.cpp index 532b73d..d5ab921 100644 --- a/Swiften/ScreenSharing/ScreenSharing.cpp +++ b/Swiften/ScreenSharing/ScreenSharing.cpp @@ -5,26 +5,37 @@ */ #include <Swiften/ScreenSharing/ScreenSharing.h> -#include <Swiften/Network/PlatformNetworkEnvironment.h> -#include <Swiften/Elements/JingleRawUDPTransportPayload.h> #include <Swiften/Base/foreach.h> - -#include <Swiften/Network/UDPSocketFactory.h> +#include <Swiften/Elements/JingleRawUDPTransportPayload.h> +#include <Swiften/Network/PlatformNetworkEnvironment.h> #include <Swiften/Network/UDPSocket.h> +#include <Swiften/Network/UDPSocketFactory.h> +#include <Swiften/ScreenSharing/RTPSession.h> +#include <Swiften/Jingle/JingleSession.h> + +#include <boost/bind.hpp> namespace Swift { ScreenSharing::ScreenSharing(boost::shared_ptr<JingleSession> session, UDPSocketFactory* udpSocketFactory) - : session(session), udpSocketFactory(udpSocketFactory) + : rtpSession(0), jingleSession(session), udpSocketFactory(udpSocketFactory) { + session->onSessionTerminateReceived.connect(boost::bind(&ScreenSharing::handleSessionTerminateReceived, this, _1)); } ScreenSharing::~ScreenSharing() { } +void ScreenSharing::stop() +{ + jingleSession->sendTerminate(JinglePayload::Reason::Success); + if (rtpSession) + rtpSession->stop(); +} + bool ScreenSharing::addBestCandidate(boost::shared_ptr<JingleRawUDPTransportPayload> transport) { // TODO: NAT traversal @@ -64,5 +75,22 @@ bool ScreenSharing::addBestCandidate(boost::shared_ptr<JingleRawUDPTransportPayl return false; } +void ScreenSharing::handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason) +{ + if (rtpSession) + rtpSession->stop(); + + if (reason.is_initialized() && reason.get().type == JinglePayload::Reason::Cancel) { + onStateChange(ScreenSharing::Canceled); + //onFinished(FileTransferError(FileTransferError::PeerError)); + } else if (reason.is_initialized() && reason.get().type == JinglePayload::Reason::Success) { + onStateChange(ScreenSharing::Finished); + //onFinished(boost::optional<FileTransferError>()); + } else { + onStateChange(ScreenSharing::Failed); + //onFinished(FileTransferError(FileTransferError::PeerError)); + } +} + } diff --git a/Swiften/ScreenSharing/ScreenSharing.h b/Swiften/ScreenSharing/ScreenSharing.h index b1756b9..5289d3c 100644 --- a/Swiften/ScreenSharing/ScreenSharing.h +++ b/Swiften/ScreenSharing/ScreenSharing.h @@ -7,16 +7,18 @@ #pragma once #include <Swiften/Base/boost_bsignals.h> #include <Swiften/Base/IDGenerator.h> +#include <Swiften/Elements/JinglePayload.h> #include <boost/shared_ptr.hpp> namespace Swift { class JingleSession; class JingleRawUDPTransportPayload; class UDPSocketFactory; class UDPSocket; + class RTPSession; class ScreenSharing { public: typedef boost::shared_ptr<ScreenSharing> ref; @@ -33,25 +35,27 @@ namespace Swift { WaitingForAccept, }; public: - ScreenSharing(boost::shared_ptr<JingleSession> session, UDPSocketFactory* udpSocketFactory); + ScreenSharing(boost::shared_ptr<JingleSession> jingleSession, UDPSocketFactory* udpSocketFactory); virtual ~ScreenSharing(); virtual void cancel() = 0; + void stop(); public: boost::signal<void (SCState)> onStateChange; protected: bool addBestCandidate(boost::shared_ptr<JingleRawUDPTransportPayload> transport); + void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason); protected: IDGenerator idGenerator; boost::shared_ptr<UDPSocket> serverSocket; boost::shared_ptr<UDPSocket> clientSocket; + RTPSession* rtpSession; - boost::shared_ptr<JingleSession> session; + boost::shared_ptr<JingleSession> jingleSession; UDPSocketFactory* udpSocketFactory; - }; } diff --git a/Swiften/ScreenSharing/VP8Encoder.cpp b/Swiften/ScreenSharing/VP8Encoder.cpp index ed4d3de..7a88418 100644 --- a/Swiften/ScreenSharing/VP8Encoder.cpp +++ b/Swiften/ScreenSharing/VP8Encoder.cpp @@ -20,9 +20,9 @@ VP8Encoder::VP8Encoder(VP8RTPPacketizer* packetizer, unsigned int width, unsign // Populate encoder configuration vpx_codec_err_t err = vpx_codec_enc_config_default(codecInterface, &codecConfig, 0); if (err) { - SWIFT_LOG(debug) << "VP8 Encoder: Failed to get config, " << vpx_codec_err_to_string(err) << std::endl; + SWIFT_LOG(error) << "VP8 Encoder: Failed to get config, " << vpx_codec_err_to_string(err) << std::endl; // TODO: exception } // Update the default configuration with our settings @@ -49,31 +49,31 @@ void VP8Encoder::updateCodecConfig() vpx_img_free(imageBuffer); vpx_codec_err_t err = vpx_codec_enc_init(&codecContext, codecInterface, &codecConfig, codecFlags); if (err) { - SWIFT_LOG(debug) << "VP8 Encoder: Failed to initialize encoder, " << vpx_codec_err_to_string(err) << std::endl; + SWIFT_LOG(error) << "VP8 Encoder: Failed to initialize encoder, " << vpx_codec_err_to_string(err) << std::endl; // TODO: exception return; } imageBuffer = vpx_img_alloc(0, VPX_IMG_FMT_YV12, codecConfig.g_w, codecConfig.g_h, 1); if (!imageBuffer) { - SWIFT_LOG(debug) << "VP8 Encoder: Failed to allocate image" << std::endl; + SWIFT_LOG(error) << "VP8 Encoder: Failed to allocate image" << std::endl; // TODO: exception } } -void VP8Encoder::encodeImage(const Image &frame) +void VP8Encoder::encodeImage(const Image& frame) { if (!convertRGB24toYV12inBuffer(frame)) { - SWIFT_LOG(debug) << "VP8 Encoder: Failed to convert frame: Image buffer not initialized" << std::endl; + SWIFT_LOG(error) << "VP8 Encoder: Failed to convert frame: Image buffer not initialized" << std::endl; // TODO: exception ? return; } vpx_codec_err_t err = vpx_codec_encode(&codecContext, imageBuffer, frameNumber, 1, frameFlags, VPX_DL_REALTIME); if (err) { - SWIFT_LOG(debug) << "VP8 Encoder: Failed to encode frame, " << vpx_codec_err_to_string(err) << std::endl; + SWIFT_LOG(error) << "VP8 Encoder: Failed to encode frame, " << vpx_codec_err_to_string(err) << std::endl; // TODO: exception ? return; } @@ -91,9 +91,9 @@ void VP8Encoder::encodeImage(const Image &frame) ++frameNumber; } -bool VP8Encoder::convertRGB24toYV12inBuffer(const Image &frame) +bool VP8Encoder::convertRGB24toYV12inBuffer(const Image& frame) { if (!imageBuffer) return false; @@ -103,9 +103,9 @@ bool VP8Encoder::convertRGB24toYV12inBuffer(const Image &frame) unsigned int width = frame.width; unsigned int height = frame.height; unsigned int len = width * height; - const std::vector<uint8_t> &data = frame.data; + const std::vector<uint8_t>& data = frame.data; for (unsigned int i = 0; i < len; ++i) { const uint8_t* p = &data[3 * i]; yPlane[i] = ((66 * p[0] + 129 * p[1] + 25 * p[2] + 128) >> 8) + 16; diff --git a/Swiften/ScreenSharing/VP8RTPParser.cpp b/Swiften/ScreenSharing/VP8RTPParser.cpp index 5a725ea..053a50a 100644 --- a/Swiften/ScreenSharing/VP8RTPParser.cpp +++ b/Swiften/ScreenSharing/VP8RTPParser.cpp @@ -9,9 +9,9 @@ #include <Swiften/ScreenSharing/VP8Decoder.h> namespace Swift { -VP8RTPParser::VP8RTPParser(VP8Decoder* decoder) +VP8RTPParser::VP8RTPParser(VideoDecoder* decoder) : decoder(decoder), firstPacket(true) { } diff --git a/Swiften/ScreenSharing/VP8RTPParser.h b/Swiften/ScreenSharing/VP8RTPParser.h index c88e2a6..1594c66 100644 --- a/Swiften/ScreenSharing/VP8RTPParser.h +++ b/Swiften/ScreenSharing/VP8RTPParser.h @@ -10,22 +10,22 @@ #include <stdint.h> #include <stddef.h> namespace Swift { - class VP8Decoder; + class VideoDecoder; class VP8RTPParser { public: - VP8RTPParser(VP8Decoder* decoder); + VP8RTPParser(VideoDecoder* decoder); void newPayloadReceived(const uint8_t* data, size_t len, bool hasMarker); private: static const uint8_t SBit = 1 << 4; static const uint8_t HBit = 1 << 4; static const uint8_t Size0BitShift = 5; - VP8Decoder* decoder; + VideoDecoder* decoder; std::vector<uint8_t> buffer; bool firstPacket; size_t frameSize; |
Swift