Showing the changes to interface/src/Application.cpp (1 of 41 files). Show all
Unified · Split
| @@ -938,6 +938,36 @@ void Application::sendPingPackets() { · 937 unmodified lines | ||
| 938 | 938 | nodesToPing, sizeof(nodesToPing)); |
| 939 | 939 | } |
| 940 | 940 | |
| 941 | +void Application::sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data) { | |
| 942 | + unsigned char packet[MAX_PACKET_SIZE]; | |
| 943 | + unsigned char* packetPosition = packet; | |
| 944 | + | |
| 945 | + packetPosition += populateTypeAndVersion(packetPosition, PACKET_TYPE_AVATAR_FACE_VIDEO); | |
| 946 | + | |
| 947 | + *(uint16_t*)packetPosition = NodeList::getInstance()->getOwnerID(); | |
| 948 | + packetPosition += sizeof(uint16_t); | |
| 949 | + | |
| 950 | + *(uint32_t*)packetPosition = frameCount; | |
| 951 | + packetPosition += sizeof(uint32_t); | |
| 952 | + | |
| 953 | + *(uint32_t*)packetPosition = data.size(); | |
| 954 | + packetPosition += sizeof(uint32_t); | |
| 955 | + | |
| 956 | + uint32_t* offsetPosition = (uint32_t*)packetPosition; | |
| 957 | + packetPosition += sizeof(uint32_t); | |
| 958 | + | |
| 959 | + int headerSize = packetPosition - packet; | |
| 960 | + | |
| 961 | + // break the data up into submessages of the maximum size | |
| 962 | + *offsetPosition = 0; | |
| 963 | + while (*offsetPosition < data.size()) { | |
| 964 | + int payloadSize = min(data.size() - (int)*offsetPosition, MAX_PACKET_SIZE - headerSize); | |
| 965 | + memcpy(packetPosition, data.constData() + *offsetPosition, payloadSize); | |
| 966 | + getInstance()->controlledBroadcastToNodes(packet, headerSize + payloadSize, &NODE_TYPE_AVATAR_MIXER, 1); | |
| 967 | + *offsetPosition += payloadSize; | |
| 968 | + } | |
| 969 | +} | |
| 970 | + | |
| 941 | 971 | // Every second, check the frame rates and other stuff |
| 942 | 972 | void Application::timer() { |
| 943 | 973 | gettimeofday(&_timerEnd, NULL); |
| @@ -1047,7 +1077,7 @@ void Application::sendAvatarVoxelURLMessage(const QUrl& url) { · 103 unmodified lines | ||
| 1047 | 1077 | controlledBroadcastToNodes((unsigned char*)message.data(), message.size(), & NODE_TYPE_AVATAR_MIXER, 1); |
| 1048 | 1078 | } |
| 1049 | 1079 | |
| 1050 | −void Application::processAvatarVoxelURLMessage(unsigned char *packetData, size_t dataBytes) { | |
| 1080 | +static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { | |
| 1051 | 1081 | // skip the header |
| 1052 | 1082 | int numBytesPacketHeader = numBytesForPacketHeader(packetData); |
| 1053 | 1083 | packetData += numBytesPacketHeader; |
| @@ -1061,18 +1091,31 @@ void Application::processAvatarVoxelURLMessage(unsigned char *packetData, size_t · 7 unmodified lines | ||
| 1061 | 1091 | // make sure the node exists |
| 1062 | 1092 | Node* node = NodeList::getInstance()->nodeWithID(nodeID); |
| 1063 | 1093 | if (!node || !node->getLinkedData()) { |
| 1064 | − return; | |
| 1094 | + return NULL; | |
| 1065 | 1095 | } |
| 1066 | 1096 | Avatar* avatar = static_cast<Avatar*>(node->getLinkedData()); |
| 1067 | − if (!avatar->isInitialized()) { | |
| 1068 | − return; // wait until initialized | |
| 1069 | − } | |
| 1097 | + return avatar->isInitialized() ? avatar : NULL; | |
| 1098 | +} | |
| 1099 | + | |
| 1100 | +void Application::processAvatarVoxelURLMessage(unsigned char* packetData, size_t dataBytes) { | |
| 1101 | + Avatar* avatar = processAvatarMessageHeader(packetData, dataBytes); | |
| 1102 | + if (!avatar) { | |
| 1103 | + return; | |
| 1104 | + } | |
| 1070 | 1105 | QUrl url = QUrl::fromEncoded(QByteArray((char*)packetData, dataBytes)); |
| 1071 | 1106 | |
| 1072 | 1107 | // invoke the set URL function on the simulate/render thread |
| 1073 | 1108 | QMetaObject::invokeMethod(avatar->getVoxels(), "setVoxelURL", Q_ARG(QUrl, url)); |
| 1074 | 1109 | } |
| 1075 | 1110 | |
| 1111 | +void Application::processAvatarFaceVideoMessage(unsigned char* packetData, size_t dataBytes) { | |
| 1112 | + Avatar* avatar = processAvatarMessageHeader(packetData, dataBytes); | |
| 1113 | + if (!avatar) { | |
| 1114 | + return; | |
| 1115 | + } | |
| 1116 | + avatar->getHead().getFace().processVideoMessage(packetData, dataBytes); | |
| 1117 | +} | |
| 1118 | + | |
| 1076 | 1119 | void Application::checkBandwidthMeterClick() { |
| 1077 | 1120 | // ... to be called upon button release |
| 1078 | 1121 | |
| @@ -1682,6 +1725,7 @@ void Application::initMenu() { · 603 unmodified lines | ||
| 1682 | 1725 | (_renderAvatarBalls = renderMenu->addAction("Avatar as Balls"))->setCheckable(true); |
| 1683 | 1726 | _renderAvatarBalls->setChecked(false); |
| 1684 | 1727 | renderMenu->addAction("Cycle Voxel Mode", _myAvatar.getVoxels(), SLOT(cycleMode())); |
| 1728 | + renderMenu->addAction("Cycle Face Mode", &_myAvatar.getHead().getFace(), SLOT(cycleRenderMode())); | |
| 1685 | 1729 | (_renderFrameTimerOn = renderMenu->addAction("Show Timer"))->setCheckable(true); |
| 1686 | 1730 | _renderFrameTimerOn->setChecked(false); |
| 1687 | 1731 | (_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true); |
| @@ -3402,6 +3446,9 @@ void* Application::networkReceive(void* args) { · 1714 unmodified lines | ||
| 3402 | 3446 | case PACKET_TYPE_AVATAR_VOXEL_URL: |
| 3403 | 3447 | processAvatarVoxelURLMessage(app->_incomingPacket, bytesReceived); |
| 3404 | 3448 | break; |
| 3449 | + case PACKET_TYPE_AVATAR_FACE_VIDEO: | |
| 3450 | + processAvatarFaceVideoMessage(app->_incomingPacket, bytesReceived); | |
| 3451 | + break; | |
| 3405 | 3452 | default: |
| 3406 | 3453 | NodeList::getInstance()->processNodeData(&senderAddress, app->_incomingPacket, bytesReceived); |
| 3407 | 3454 | break; |