Skip to content

Commit

Permalink
implemented mic streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
mai authored and mai committed Aug 23, 2019
1 parent d1af966 commit 33c0808
Show file tree
Hide file tree
Showing 17 changed files with 618 additions and 811 deletions.
2 changes: 2 additions & 0 deletions ALVR-common/packet_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ struct AudioFrame {
struct MicAudioFrame {
uint32_t type; // ALVR_PACKET_TYPE_MIC_AUDIO_FRAME
size_t outputBufferNumElements;
size_t completeSize;
int packetIndex;
int16_t micBuffer[100];
};

Expand Down
12 changes: 0 additions & 12 deletions ALVR.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest", "test\gtest\gtest.v
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AMF", "AMF\AMF.vcxproj", "{B040F09F-3DE1-4E72-AC89-F45DC4ECDE76}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AudioTestApp", "AudioTestApp\AudioTestApp.vcxproj", "{FC47282D-B7AA-418F-85F1-42031BE026B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -95,16 +93,6 @@ Global
{B040F09F-3DE1-4E72-AC89-F45DC4ECDE76}.Release|x64.Build.0 = Release|x64
{B040F09F-3DE1-4E72-AC89-F45DC4ECDE76}.Release|x86.ActiveCfg = Release|Win32
{B040F09F-3DE1-4E72-AC89-F45DC4ECDE76}.Release|x86.Build.0 = Release|Win32
{FC47282D-B7AA-418F-85F1-42031BE026B1}.Debug|Any CPU.ActiveCfg = Debug|Win32
{FC47282D-B7AA-418F-85F1-42031BE026B1}.Debug|x64.ActiveCfg = Debug|x64
{FC47282D-B7AA-418F-85F1-42031BE026B1}.Debug|x64.Build.0 = Debug|x64
{FC47282D-B7AA-418F-85F1-42031BE026B1}.Debug|x86.ActiveCfg = Debug|Win32
{FC47282D-B7AA-418F-85F1-42031BE026B1}.Debug|x86.Build.0 = Debug|Win32
{FC47282D-B7AA-418F-85F1-42031BE026B1}.Release|Any CPU.ActiveCfg = Release|Win32
{FC47282D-B7AA-418F-85F1-42031BE026B1}.Release|x64.ActiveCfg = Release|x64
{FC47282D-B7AA-418F-85F1-42031BE026B1}.Release|x64.Build.0 = Release|x64
{FC47282D-B7AA-418F-85F1-42031BE026B1}.Release|x86.ActiveCfg = Release|Win32
{FC47282D-B7AA-418F-85F1-42031BE026B1}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
9 changes: 6 additions & 3 deletions ALVR/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,18 @@
<setting name="force60Hz" serializeAs="String">
<value>False</value>
</setting>
<setting name="resolutionScale" serializeAs="String">
<value>1</value>
</setting>
<setting name="disableThrottling" serializeAs="String">
<value>False</value>
</setting>
<setting name="controllerPoseOffset" serializeAs="String">
<value>0.01</value>
</setting>
<setting name="resolutionScale" serializeAs="String">
<value>1</value>
</setting>
<setting name="streamMic" serializeAs="String">
<value>False</value>
</setting>
</ALVR.Properties.Settings>
</userSettings>
</configuration>
844 changes: 385 additions & 459 deletions ALVR/Launcher.Designer.cs

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion ALVR/Launcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ private void SaveSettings()
c.autoConnectList = clientList.Serialize();

c.codec = codecComboBox.SelectedIndex;
c.streamMic = streamMic.Checked;

if (soundDevices.Count > 0)
{
Expand Down Expand Up @@ -693,7 +694,8 @@ private void Launcher_FormClosed(object sender, FormClosedEventArgs e)
SaveSettings();
}

async private void autoConnectCheckBox_CheckedChanged(object sender, EventArgs e)
async private void
autoConnectCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (autoConnectCheckBox.Checked)
{
Expand Down Expand Up @@ -805,5 +807,10 @@ private void controllerPoseOffset_Click(object sender, EventArgs e)
{

}

private void metroCheckBox4_CheckedChanged(object sender, EventArgs e)
{
SaveSettings();
}
}
}
36 changes: 24 additions & 12 deletions ALVR/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions ALVR/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,17 @@
<Setting Name="eyeFov" Type="System.Double[]" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="resolutionScale" Type="System.Int32" Scope="User">
<Value Profile="(Default)">100</Value>
</Setting>
<Setting Name="disableThrottling" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="controllerPoseOffset" Type="System.String" Scope="User">
<Value Profile="(Default)">0.01</Value>
</Setting>
<Setting Name="resolutionScale" Type="System.Int32" Scope="User">
<Value Profile="(Default)">1</Value>
</Setting>
<Setting Name="streamMic" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
1 change: 1 addition & 0 deletions ALVR/ServerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public bool Save(DeviceDescriptor device)

driverConfig.enableSound = c.enableSound && c.soundDevice != "";
driverConfig.soundDevice = c.soundDevice;
driverConfig.streamMic = c.streamMic;

driverConfig.debugOutputDir = Utils.GetOutputPath();
driverConfig.debugLog = c.debugLog;
Expand Down
159 changes: 0 additions & 159 deletions AudioTestApp/AudioTestApp.vcxproj

This file was deleted.

14 changes: 0 additions & 14 deletions AudioTestApp/pch.h

This file was deleted.

16 changes: 5 additions & 11 deletions alvr_server/ClientConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ ClientConnection::ClientConnection()
, m_Enabled(false)
, m_Connected(false)
, m_Streaming(false)
, m_LastSeen(0)
, outfile("C:\\tmp\\mic.raw", std::ios::out | std::ios::binary | std::ofstream::app){
, m_LastSeen(0) {
memset(&m_TrackingInfo, 0, sizeof(m_TrackingInfo));
InitializeCriticalSection(&m_CS);

m_Statistics = std::make_shared<Statistics>();
m_MicPlayer = std::make_shared<MicPlayer>();

m_Settings.type = ALVR_PACKET_TYPE_CHANGE_SETTINGS;
m_Settings.debugFlags = 0;
Expand All @@ -24,12 +24,10 @@ ClientConnection::ClientConnection()
m_Streaming = false;

reed_solomon_init();


}

ClientConnection::~ClientConnection() {
outfile.close();
DeleteCriticalSection(&m_CS);
}

Expand Down Expand Up @@ -431,14 +429,9 @@ void ClientConnection::ProcessRecv(char *buf, int len, sockaddr_in *addr) {
return;
}
auto *frame = (MicAudioFrame *)buf;
Log(L"Got MicAudio Frame with length - %zu", frame->outputBufferNumElements);


outfile.write(reinterpret_cast<const char*>(frame->micBuffer), sizeof frame->outputBufferNumElements);
outfile.flush();
Log(L"Got MicAudio Frame with length - %zu %zu index: %i", frame->outputBufferNumElements, frame->completeSize, frame->packetIndex);



m_MicPlayer->playAudio( (char*)frame->micBuffer , sizeof(int16_t) * frame->outputBufferNumElements);

}
}
Expand Down Expand Up @@ -721,6 +714,7 @@ void ClientConnection::Connect(const sockaddr_in *addr) {
message.bufferSize = Settings::Instance().m_clientRecvBufferSize;
message.frameQueueSize = Settings::Instance().m_frameQueueSize;
message.refreshRate = Settings::Instance().m_refreshRate;
message.streamMic = Settings::Instance().m_streamMic && m_MicPlayer->getCableHWID() != -1;

m_Socket->Send((char *)&message, sizeof(message), 0);
}
Expand Down
Loading

1 comment on commit 33c0808

@amg-12
Copy link

@amg-12 amg-12 commented on 33c0808 Aug 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work, can't wait for the next release!

Please sign in to comment.