From f20ac7f4bc756a76de39579d8541cf938d9314af Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 7 Aug 2013 10:17:04 -0700 Subject: [PATCH 1/2] Include received video data in bandwidth usage, clear webcam bits when it's been turned off. --- interface/src/Application.cpp | 2 ++ interface/src/Webcam.cpp | 7 +++++++ interface/src/avatar/Avatar.cpp | 1 + 3 files changed, 10 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7aa6042dba..407fbdc613 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4053,9 +4053,11 @@ void* Application::networkReceive(void* args) { break; case PACKET_TYPE_AVATAR_VOXEL_URL: processAvatarVoxelURLMessage(app->_incomingPacket, bytesReceived); + getInstance()->_bandwidthMeter.inputStream(BandwidthMeter::AVATARS).updateValue(bytesReceived); break; case PACKET_TYPE_AVATAR_FACE_VIDEO: processAvatarFaceVideoMessage(app->_incomingPacket, bytesReceived); + getInstance()->_bandwidthMeter.inputStream(BandwidthMeter::AVATARS).updateValue(bytesReceived); break; default: NodeList::getInstance()->processNodeData(&senderAddress, app->_incomingPacket, bytesReceived); diff --git a/interface/src/Webcam.cpp b/interface/src/Webcam.cpp index 0deae62e46..789540d2f2 100644 --- a/interface/src/Webcam.cpp +++ b/interface/src/Webcam.cpp @@ -159,6 +159,9 @@ const float METERS_PER_MM = 1.0f / 1000.0f; void Webcam::setFrame(const Mat& color, int format, const Mat& depth, float midFaceDepth, float aspectRatio, const RotatedRect& faceRect, bool sending, const JointVector& joints) { + if (!_enabled) { + return; // was queued before we shut down; ignore + } if (!color.empty()) { IplImage colorImage = color; glPixelStorei(GL_UNPACK_ROW_LENGTH, colorImage.widthStep / 3); @@ -406,6 +409,10 @@ void FrameGrabber::shutdown() { destroyCodecs(); _initialized = false; + // send an empty video message to indicate that we're no longer sending + QMetaObject::invokeMethod(Application::getInstance(), "sendAvatarFaceVideoMessage", + Q_ARG(int, ++_frameCount), Q_ARG(QByteArray, QByteArray())); + thread()->quit(); } diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index d695cb4759..610eabb021 100755 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -308,6 +308,7 @@ void Avatar::updateFromGyrosAndOrWebcam(bool gyroLook, } else { _head.setPitch(pitchFromTouch); + _head.getFace().clearFrame(); return; } if (webcam->isActive()) { From 80481747fa6ae2c4ca29f5847d40aa051f55eb10 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 7 Aug 2013 11:15:37 -0700 Subject: [PATCH 2/2] Fix for enabling depth-only webcam after startup. --- interface/src/Webcam.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/Webcam.cpp b/interface/src/Webcam.cpp index 789540d2f2..349816a4ed 100644 --- a/interface/src/Webcam.cpp +++ b/interface/src/Webcam.cpp @@ -168,8 +168,8 @@ void Webcam::setFrame(const Mat& color, int format, const Mat& depth, float midF if (_colorTextureID == 0) { glGenTextures(1, &_colorTextureID); glBindTexture(GL_TEXTURE_2D, _colorTextureID); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _textureSize.width = colorImage.width, _textureSize.height = colorImage.height, - 0, format, GL_UNSIGNED_BYTE, colorImage.imageData); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _textureSize.width = colorImage.width, + _textureSize.height = colorImage.height, 0, format, GL_UNSIGNED_BYTE, colorImage.imageData); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } else { @@ -195,8 +195,8 @@ void Webcam::setFrame(const Mat& color, int format, const Mat& depth, float midF } else { glBindTexture(GL_TEXTURE_2D, _depthTextureID); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _textureSize.width, _textureSize.height, GL_LUMINANCE, - GL_UNSIGNED_BYTE, depthImage.imageData); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _textureSize.width = depthImage.width, + _textureSize.height = depthImage.height, GL_LUMINANCE, GL_UNSIGNED_BYTE, depthImage.imageData); } } else if (_depthTextureID != 0) { glDeleteTextures(1, &_depthTextureID);