mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
commit
0f4e6a447e
9 changed files with 28 additions and 11 deletions
|
@ -6,9 +6,13 @@
|
|||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
|
||||
#include "AvatarAudioRingBuffer.h"
|
||||
|
||||
AvatarAudioRingBuffer::AvatarAudioRingBuffer() : _freeVerbs() {
|
||||
AvatarAudioRingBuffer::AvatarAudioRingBuffer() :
|
||||
_freeVerbs(),
|
||||
_shouldLoopbackForAgent(false) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -17,4 +21,9 @@ AvatarAudioRingBuffer::~AvatarAudioRingBuffer() {
|
|||
for (FreeVerbAgentMap::iterator verbIterator = _freeVerbs.begin(); verbIterator != _freeVerbs.end(); verbIterator++) {
|
||||
delete verbIterator->second;
|
||||
}
|
||||
}
|
||||
|
||||
int AvatarAudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||
_shouldLoopbackForAgent = (sourceBuffer[0] == PACKET_HEADER_MICROPHONE_AUDIO_WITH_ECHO);
|
||||
return PositionalAudioRingBuffer::parseData(sourceBuffer, numBytes);
|
||||
}
|
|
@ -21,13 +21,17 @@ public:
|
|||
AvatarAudioRingBuffer();
|
||||
~AvatarAudioRingBuffer();
|
||||
|
||||
int parseData(unsigned char* sourceBuffer, int numBytes);
|
||||
|
||||
FreeVerbAgentMap& getFreeVerbs() { return _freeVerbs; }
|
||||
bool shouldLoopbackForAgent() const { return _shouldLoopbackForAgent; }
|
||||
private:
|
||||
// disallow copying of AvatarAudioRingBuffer objects
|
||||
AvatarAudioRingBuffer(const AvatarAudioRingBuffer&);
|
||||
AvatarAudioRingBuffer& operator= (const AvatarAudioRingBuffer&);
|
||||
|
||||
FreeVerbAgentMap _freeVerbs;
|
||||
bool _shouldLoopbackForAgent;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__AvatarAudioRingBuffer__) */
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
|
||||
#include "InjectedAudioRingBuffer.h"
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
|
||||
#include "PositionalAudioRingBuffer.h"
|
||||
|
@ -14,7 +16,6 @@ PositionalAudioRingBuffer::PositionalAudioRingBuffer() :
|
|||
AudioRingBuffer(false),
|
||||
_position(0.0f, 0.0f, 0.0f),
|
||||
_orientation(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
_shouldLoopbackForAgent(false),
|
||||
_willBeAddedToMix(false)
|
||||
{
|
||||
|
||||
|
|
|
@ -28,8 +28,6 @@ public:
|
|||
const glm::vec3& getPosition() const { return _position; }
|
||||
const glm::quat& getOrientation() const { return _orientation; }
|
||||
|
||||
bool shouldLoopbackForAgent() const { return _shouldLoopbackForAgent; }
|
||||
|
||||
protected:
|
||||
// disallow copying of PositionalAudioRingBuffer objects
|
||||
PositionalAudioRingBuffer(const PositionalAudioRingBuffer&);
|
||||
|
@ -37,7 +35,6 @@ protected:
|
|||
|
||||
glm::vec3 _position;
|
||||
glm::quat _orientation;
|
||||
bool _shouldLoopbackForAgent;
|
||||
bool _willBeAddedToMix;
|
||||
};
|
||||
|
||||
|
|
|
@ -324,7 +324,8 @@ int main(int argc, const char* argv[]) {
|
|||
|
||||
// pull any new audio data from agents off of the network stack
|
||||
while (agentList->getAgentSocket()->receive(agentAddress, packetData, &receivedBytes)) {
|
||||
if (packetData[0] == PACKET_HEADER_MICROPHONE_AUDIO) {
|
||||
if (packetData[0] == PACKET_HEADER_MICROPHONE_AUDIO_NO_ECHO ||
|
||||
packetData[0] == PACKET_HEADER_MICROPHONE_AUDIO_WITH_ECHO) {
|
||||
Agent* avatarAgent = agentList->addOrUpdateAgent(agentAddress,
|
||||
agentAddress,
|
||||
AGENT_TYPE_AVATAR,
|
||||
|
|
|
@ -135,7 +135,9 @@ int audioCallback (const void* inputBuffer,
|
|||
// + 12 for 3 floats for position + float for bearing + 1 attenuation byte
|
||||
unsigned char dataPacket[BUFFER_LENGTH_BYTES_PER_CHANNEL + leadingBytes];
|
||||
|
||||
dataPacket[0] = PACKET_HEADER_MICROPHONE_AUDIO;
|
||||
dataPacket[0] = (Application::getInstance()->shouldEchoAudio())
|
||||
? PACKET_HEADER_MICROPHONE_AUDIO_WITH_ECHO
|
||||
: PACKET_HEADER_MICROPHONE_AUDIO_NO_ECHO;
|
||||
unsigned char *currentPacketPtr = dataPacket + 1;
|
||||
|
||||
// memcpy the three float positions
|
||||
|
|
|
@ -119,7 +119,7 @@ void Agent::recordBytesReceived(int bytesReceived) {
|
|||
}
|
||||
|
||||
float Agent::getAveragePacketsPerSecond() {
|
||||
if (_bytesReceivedMovingAverage != NULL) {
|
||||
if (_bytesReceivedMovingAverage) {
|
||||
return (1 / _bytesReceivedMovingAverage->getEventDeltaAverage());
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -127,7 +127,7 @@ float Agent::getAveragePacketsPerSecond() {
|
|||
}
|
||||
|
||||
float Agent::getAverageKilobitsPerSecond() {
|
||||
if (_bytesReceivedMovingAverage != NULL) {
|
||||
if (_bytesReceivedMovingAverage) {
|
||||
return (_bytesReceivedMovingAverage->getAverageSampleValuePerSecond() * (8.0f / 1000));
|
||||
} else {
|
||||
return 0;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// hifi
|
||||
//
|
||||
// Created by Stephen Birarda on 4/8/13.
|
||||
//
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
// The packet headers below refer to the first byte of a received UDP packet transmitted between
|
||||
// any two Hifi components. For example, a packet whose first byte is 'P' is always a ping packet.
|
||||
|
@ -20,7 +20,8 @@ const PACKET_HEADER PACKET_HEADER_HEAD_DATA = 'H';
|
|||
const PACKET_HEADER PACKET_HEADER_Z_COMMAND = 'Z';
|
||||
const PACKET_HEADER PACKET_HEADER_INJECT_AUDIO = 'I';
|
||||
const PACKET_HEADER PACKET_HEADER_MIXED_AUDIO = 'A';
|
||||
const PACKET_HEADER PACKET_HEADER_MICROPHONE_AUDIO = 'M';
|
||||
const PACKET_HEADER PACKET_HEADER_MICROPHONE_AUDIO_NO_ECHO = 'M';
|
||||
const PACKET_HEADER PACKET_HEADER_MICROPHONE_AUDIO_WITH_ECHO = 'm';
|
||||
const PACKET_HEADER PACKET_HEADER_SET_VOXEL = 'S';
|
||||
const PACKET_HEADER PACKET_HEADER_SET_VOXEL_DESTRUCTIVE = 'O';
|
||||
const PACKET_HEADER PACKET_HEADER_ERASE_VOXEL = 'E';
|
||||
|
|
Loading…
Reference in a new issue