diff --git a/MixedRemoteViewCompositor/Samples/LowLatencyMRC/UWP/Viewer/Capture.xaml b/MixedRemoteViewCompositor/Samples/LowLatencyMRC/UWP/Viewer/Capture.xaml
index f1b74f57..6890ed0e 100644
--- a/MixedRemoteViewCompositor/Samples/LowLatencyMRC/UWP/Viewer/Capture.xaml
+++ b/MixedRemoteViewCompositor/Samples/LowLatencyMRC/UWP/Viewer/Capture.xaml
@@ -17,6 +17,7 @@
+
diff --git a/MixedRemoteViewCompositor/Samples/LowLatencyMRC/UWP/Viewer/Capture.xaml.cs b/MixedRemoteViewCompositor/Samples/LowLatencyMRC/UWP/Viewer/Capture.xaml.cs
index 19ea8992..06037a29 100644
--- a/MixedRemoteViewCompositor/Samples/LowLatencyMRC/UWP/Viewer/Capture.xaml.cs
+++ b/MixedRemoteViewCompositor/Samples/LowLatencyMRC/UWP/Viewer/Capture.xaml.cs
@@ -41,14 +41,14 @@ private async void bnListen_Click(object sender, RoutedEventArgs e)
this.connection.Disconnected += Connection_Disconnected;
this.connection.Received += Connection_Received;
- StartCapture();
+ StartCapture(cbEnableAudio.IsChecked.GetValueOrDefault(false));
}
}
}
- private async void StartCapture()
+ private async void StartCapture(bool enableAudio)
{
- captureEngine = await CaptureEngine.CreateAsync(false);
+ captureEngine = await CaptureEngine.CreateAsync(enableAudio);
if (this.captureEngine != null)
{
await this.captureEngine.StartAsync(false, this.connection);
diff --git a/MixedRemoteViewCompositor/Samples/LowLatencyMRC/UWP/Viewer/Package.appxmanifest b/MixedRemoteViewCompositor/Samples/LowLatencyMRC/UWP/Viewer/Package.appxmanifest
index 7e492e20..a9218524 100644
--- a/MixedRemoteViewCompositor/Samples/LowLatencyMRC/UWP/Viewer/Package.appxmanifest
+++ b/MixedRemoteViewCompositor/Samples/LowLatencyMRC/UWP/Viewer/Package.appxmanifest
@@ -27,5 +27,6 @@
+
\ No newline at end of file
diff --git a/MixedRemoteViewCompositor/Source/Shared/Media/CaptureEngine.cpp b/MixedRemoteViewCompositor/Source/Shared/Media/CaptureEngine.cpp
index cfb8f5bf..3975f66c 100644
--- a/MixedRemoteViewCompositor/Source/Shared/Media/CaptureEngine.cpp
+++ b/MixedRemoteViewCompositor/Source/Shared/Media/CaptureEngine.cpp
@@ -458,7 +458,7 @@ HRESULT CaptureEngineImpl::StartAsync(
ComPtr mrcAudioEffectDefinition;
MakeAndInitialize(&mrcAudioEffectDefinition);
- IFR(mrcAudioEffectDefinition->put_MixerMode(AudioMixerMode_Mic));
+ IFR(mrcAudioEffectDefinition->put_MixerMode(AudioMixerMode_MicAndLoopback));
ComPtr audioEffectDefinition;
IFR(mrcAudioEffectDefinition.As(&audioEffectDefinition));
diff --git a/MixedRemoteViewCompositor/Source/Shared/Media/PlaybackEngine.cpp b/MixedRemoteViewCompositor/Source/Shared/Media/PlaybackEngine.cpp
index 25e51dcd..ae2c3021 100644
--- a/MixedRemoteViewCompositor/Source/Shared/Media/PlaybackEngine.cpp
+++ b/MixedRemoteViewCompositor/Source/Shared/Media/PlaybackEngine.cpp
@@ -411,7 +411,8 @@ HRESULT PlaybackEngineImpl::StartPlayback()
NULL_CHK_HR(_sourceReader, E_NOT_SET);
- IFR(RequestNextSampleAsync(MF_SOURCE_READER_FIRST_VIDEO_STREAM));
+ IFR(RequestNextSampleAsync(MF_SOURCE_READER_ANY_STREAM));
+ //IFR(RequestNextSampleAsync(MF_SOURCE_READER_FIRST_VIDEO_STREAM));
//IFR(RequestNextSampleAsync(MF_SOURCE_READER_FIRST_AUDIO_STREAM));
diff --git a/MixedRemoteViewCompositor/Source/Shared/Network/Connection.cpp b/MixedRemoteViewCompositor/Source/Shared/Network/Connection.cpp
index 7f10342d..e6249904 100644
--- a/MixedRemoteViewCompositor/Source/Shared/Network/Connection.cpp
+++ b/MixedRemoteViewCompositor/Source/Shared/Network/Connection.cpp
@@ -327,111 +327,117 @@ HRESULT ConnectionImpl::SendBundle(
_Use_decl_annotations_
HRESULT ConnectionImpl::SendBundleAsync(
- IDataBundle *dataBundle,
- IAsyncAction **sendAction)
+ IDataBundle *dataBundle,
+ IAsyncAction **sendAction)
{
- Log(Log_Level_Info, L"ConnectionImpl::SendBundleAsync\n");
+ Log(Log_Level_Info, L"ConnectionImpl::SendBundleAsyncSequenced\n");
- NULL_CHK(dataBundle);
- NULL_CHK(sendAction);
+ NULL_CHK(dataBundle);
+ NULL_CHK(sendAction);
- {
- auto lock = _lock.Lock();
+ {
+ auto lock = _lock.Lock();
- IFR(CheckClosed());
- }
+ IFR(CheckClosed());
+ }
- UINT32 bufferCount = 0;
- IFR(dataBundle->get_BufferCount(&bufferCount));
+ ComPtr spWriteAction;
+ IFR(MakeAndInitialize(&spWriteAction, 1));
- ComPtr spWriteAction;
- IFR(MakeAndInitialize(&spWriteAction, bufferCount));
+ // define workitem
+ ComPtr spDataBundle(dataBundle);
+ ComPtr spThis(this);
+ auto workItem =
+ Microsoft::WRL::Callback(
+ [this, spThis, spDataBundle, spWriteAction](IAsyncAction* asyncAction) -> HRESULT
+ {
+ ComPtr spOutputStream;
+ DataBundleImpl::Container buffers;
+ DataBundleImpl::Iterator iter;
- // define workitem
- ComPtr spDataBundle(dataBundle);
- ComPtr spThis(this);
- auto workItem =
- Microsoft::WRL::Callback(
- [this, spThis, spDataBundle, spWriteAction](IAsyncAction* asyncAction) -> HRESULT
- {
- ComPtr spOutputStream;
- DataBundleImpl::Container buffers;
- DataBundleImpl::Iterator iter;
+ ComPtr writeOperation;
+ ComPtr rawBuffer;
+ ComPtr singleBuffer;
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- {
- auto lock = _lock.Lock();
-
- IFC(CheckClosed());
-
- // get the output stream for socket
- if (nullptr != _streamSocket)
- {
- IFC(_streamSocket->get_OutputStream(&spOutputStream));
- }
- else
- {
- IFC(E_UNEXPECTED);
- }
- }
+ {
+ auto lock = _lock.Lock();
- DataBundleImpl* bundleImpl = static_cast(spDataBundle.Get());
- if (nullptr == bundleImpl)
- {
- IFC(E_INVALIDARG);
- }
+ IFC(CheckClosed());
- // send one buffer at a time syncronously
- IFC(bundleImpl->get_Buffers(&buffers));
- iter = buffers.begin();
- for (; iter != buffers.end(); ++iter)
- {
- ComPtr spWriteOperation;
- ComPtr rawBuffer;
- IFC((*iter).As(&rawBuffer));
+ // get the output stream for socket
+ if (nullptr != _streamSocket)
+ {
+ IFC(_streamSocket->get_OutputStream(&spOutputStream));
+ }
+ else
+ {
+ IFC(E_UNEXPECTED);
+ }
+ }
- IFC(spOutputStream->WriteAsync(rawBuffer.Get(), &spWriteOperation));
+ DataBundleImpl* bundleImpl = static_cast(spDataBundle.Get());
+ if (nullptr == bundleImpl)
+ {
+ IFC(E_INVALIDARG);
+ }
- // start async write operation
- IFC(StartAsyncThen(
- spWriteOperation.Get(),
- [this, spThis, spWriteAction](_In_ HRESULT hr, _In_ IStreamWriteOperation *asyncResult, _In_ AsyncStatus asyncStatus) -> HRESULT
- {
- LOG_RESULT(hr);
+ //make a single big buffer
+ ULONG totalSize;
+ IFC(bundleImpl->get_TotalSize(&totalSize));
- spWriteAction->SignalCompleted(hr);
+ IFC(MakeAndInitialize(&singleBuffer, totalSize));
- return S_OK;
- }));
- }
+ DataBufferImpl * bufferImpl = static_cast(singleBuffer.Get());
- done:
- if (FAILED(hr))
- {
- spWriteAction->SignalCompleted(hr);
- }
+ if (nullptr == bufferImpl)
+ {
+ IFC(E_INVALIDARG);
+ }
- return S_OK;
- });
+ BYTE* rawSingleBuffer;
+ IFC(bufferImpl->get_Buffer(&rawSingleBuffer));
- ComPtr workerAsync;
- IFR(_threadPoolStatics->RunAsync(workItem.Get(), &workerAsync));
+ DWORD copied;
+ IFC(bundleImpl->CopyTo(0, totalSize, &rawSingleBuffer[0], &copied));
- IFR(StartAsyncThen(
- workerAsync.Get(),
- [this, spThis, spWriteAction](_In_ HRESULT hr, _In_ IAsyncAction *asyncResult, _In_ AsyncStatus asyncStatus) -> HRESULT
- {
- if (FAILED(hr))
- {
- spWriteAction->SignalCompleted(hr);
- }
+ IFC(bufferImpl->put_CurrentLength(copied));
- return S_OK;
- }));
+ IFC(singleBuffer.As(&rawBuffer));
+
+ IFC(spOutputStream->WriteAsync(rawBuffer.Get(), &writeOperation));
+
+ hr = SyncWait(writeOperation.Get(), 1);
+
+ spWriteAction->SignalCompleted(hr);
+
+ done:
+ if (FAILED(hr))
+ {
+ spWriteAction->SignalCompleted(hr);
+ }
+
+ return S_OK;
+ });
+
+ ComPtr workerAsync;
+ IFR(_threadPoolStatics->RunAsync(workItem.Get(), &workerAsync));
+
+ IFR(StartAsyncThen(
+ workerAsync.Get(),
+ [this, spThis, spWriteAction](_In_ HRESULT hr, _In_ IAsyncAction *asyncResult, _In_ AsyncStatus asyncStatus) -> HRESULT
+ {
+ if (FAILED(hr))
+ {
+ spWriteAction->SignalCompleted(hr);
+ }
+
+ return S_OK;
+ }));
- // hand off async op
- return spWriteAction.CopyTo(sendAction);
+ // hand off async op
+ return spWriteAction.CopyTo(sendAction);
}
// IConnectionInternal