Commit df0a067a authored by Nicolas Jager's avatar Nicolas Jager
Browse files

video : add video debug output to video.log

Change-Id: I266b8519aceba214803789a6b1f23876a974a1f8
Tuleap: #1226
parent e30847e6
......@@ -51,6 +51,9 @@ MainPage::MainPage()
{
InitializeComponent();
Window::Current->SizeChanged += ref new WindowSizeChangedEventHandler(this, &MainPage::OnResize);
_welcomeFrame_->Navigate(TypeName(RingClientUWP::Views::WelcomePage::typeid));
......@@ -73,11 +76,11 @@ MainPage::MainPage()
Platform::Object^>(this, &MainPage::DisplayProperties_DpiChanged));
visibilityChangedEventToken = Window::Current->VisibilityChanged +=
ref new WindowVisibilityChangedEventHandler(this, &MainPage::Application_VisibilityChanged);
ref new WindowVisibilityChangedEventHandler(this, &MainPage::Application_VisibilityChanged);
applicationSuspendingEventToken = Application::Current->Suspending +=
ref new SuspendingEventHandler(this, &MainPage::Application_Suspending);
ref new SuspendingEventHandler(this, &MainPage::Application_Suspending);
applicationResumingEventToken = Application::Current->Resuming +=
ref new EventHandler<Object^>(this, &MainPage::Application_Resuming);
ref new EventHandler<Object^>(this, &MainPage::Application_Resuming);
}
void
......@@ -123,6 +126,7 @@ RingClientUWP::MainPage::OnNavigatedTo(NavigationEventArgs ^ e)
{
RingD::instance->startDaemon();
showLoadingOverlay(true, false);
}
void
......@@ -263,27 +267,27 @@ void RingClientUWP::MainPage::OnstateChange(Platform::String ^callId, RingClient
void
MainPage::Application_Suspending(Object^, Windows::ApplicationModel::SuspendingEventArgs^ e)
{
WriteLine("Application_Suspending");
RingDebug::instance->WriteLine("Application_Suspending");
if (Frame->CurrentSourcePageType.Name ==
Interop::TypeName(MainPage::typeid).Name) {
auto deferral = e->SuspendingOperation->GetDeferral();
BeginExtendedExecution()
.then([=](task<void> previousTask) {
.then([=](task<void> previousTask) {
try {
previousTask.get();
}
catch (Exception^ e) {
WriteLine("Exception: Extended Execution Begin");
RingDebug::instance->WriteLine("Exception: Extended Execution Begin");
}
})
.then([this, deferral](task<void> previousTask) {
.then([this, deferral](task<void> previousTask) {
try {
previousTask.get();
WriteLine("deferral->Complete()");
RingDebug::instance->WriteLine("deferral->Complete()");
deferral->Complete();
}
catch (Exception^ e) {
WriteLine("Exception: Extended Execution");
RingDebug::instance->WriteLine("Exception: Extended Execution");
deferral->Complete();
}
});
......@@ -294,7 +298,7 @@ void
MainPage::Application_VisibilityChanged(Object^ sender, VisibilityChangedEventArgs^ e)
{
if (e->Visible) {
WriteLine("->Visible");
RingDebug::instance->WriteLine("->Visible");
auto isPreviewing = Video::VideoManager::instance->captureManager()->isPreviewing;
bool isInCall = false;
for (auto item : SmartPanelItemsViewModel::instance->itemsList) {
......@@ -311,7 +315,7 @@ MainPage::Application_VisibilityChanged(Object^ sender, VisibilityChangedEventAr
}
}
else {
WriteLine("->Invisible");
RingDebug::instance->WriteLine("->Invisible");
auto isPreviewing = Video::VideoManager::instance->captureManager()->isPreviewing;
bool isInCall = false;
for (auto item : SmartPanelItemsViewModel::instance->itemsList) {
......@@ -338,7 +342,7 @@ MainPage::Application_VisibilityChanged(Object^ sender, VisibilityChangedEventAr
void MainPage::Application_Resuming(Object^, Object^)
{
WriteLine("Application_Resuming");
RingDebug::instance->WriteLine("Application_Resuming");
}
void
......@@ -353,7 +357,7 @@ void
MainPage::ClearExtendedExecution()
{
if (session != nullptr) {
WriteLine("End Extended Execution");
RingDebug::instance->WriteLine("End Extended Execution");
session->Revoked -= sessionRevokedToken;
}
}
......@@ -367,31 +371,31 @@ MainPage::BeginExtendedExecution()
newSession->Reason = ExtendedExecutionReason::SavingData;
newSession->Description = "Extended Execution";
sessionRevokedToken = (newSession->Revoked += ref new TypedEventHandler<Object^,
ExtendedExecutionRevokedEventArgs^>(this, &MainPage::SessionRevoked));
ExtendedExecutionRevokedEventArgs^>(this, &MainPage::SessionRevoked));
return create_task(newSession->RequestExtensionAsync())
.then([=](ExtendedExecutionResult result){
.then([=](ExtendedExecutionResult result) {
try {
switch (result)
{
case ExtendedExecutionResult::Allowed:
session = newSession;
WriteLine("Request Extended Execution Allowed");
WriteLine("Clean up camera...");
RingDebug::instance->WriteLine("Request Extended Execution Allowed");
RingDebug::instance->WriteLine("Clean up camera...");
Video::VideoManager::instance->captureManager()->CleanupCameraAsync()
.then([](){
WriteLine("Hang up calls...");
.then([]() {
RingDebug::instance->WriteLine("Hang up calls...");
DRing::fini();
});
break;
default:
default:
case ExtendedExecutionResult::Denied:
WriteLine("Request Extended Execution Denied");
RingDebug::instance->WriteLine("Request Extended Execution Denied");
break;
}
}
catch (Exception^ e) {
WriteLine("Exception: Extended Execution Request");
RingDebug::instance->WriteLine("Exception: Extended Execution Request");
}
});
}
\ No newline at end of file
......@@ -56,7 +56,18 @@ RingDebug::print(const std::string& message,
/* fire the event. */
auto line = ref new String(wString.c_str(), wString.length());
messageToScreen(line);
FileIO::AppendTextAsync(_logFile, line+"\n");
FileIO::AppendTextAsync(_logFile, line + "\n");
}
void RingClientUWP::RingDebug::WriteLine(String^ str)
{
/* save in file */
FileIO::AppendTextAsync(_videoFile, str + "\n");
/* screen in visual studio console */
std::wstringstream wStringstream;
wStringstream << str->Data() << "\n";
OutputDebugString(wStringstream.str().c_str());
}
RingClientUWP::RingDebug::RingDebug()
......@@ -70,5 +81,10 @@ RingClientUWP::RingDebug::RingDebug()
this->_logFile = file;
});
task<StorageFile^>(storageFolder->CreateFileAsync("video.log", CreationCollisionOption::ReplaceExisting)).then([this](StorageFile^ file)
{
this->_videoFile = file;
});
}
......@@ -43,6 +43,7 @@ public:
}
property StorageFile^ _logFile;
property StorageFile^ _videoFile;
/* properties */
......@@ -51,6 +52,8 @@ internal:
enum class Type { MSG, WNG, ERR };
void print(const std::string& message, const Type& type = Type::MSG);
void WriteLine(String^ str);
/* event */
event debugMessageToScreen^ messageToScreen;
......
......@@ -145,7 +145,7 @@ Resolution::Resolution(Video::Size^ size):
String^
Resolution::name()
{
return size()->width().ToString() + "x" + size()->height().ToString();
return size()->width().ToString() + "x" + size()->height().ToString();
}
Rate^
......@@ -193,12 +193,12 @@ Resolution::setFormat(String^ format)
bool
Resolution::setActiveRate(Rate^ rate)
{
if (m_currentRate == rate)
return false;
if (m_currentRate == rate)
return false;
m_currentRate = rate;
// set camera device rate here
return true;
m_currentRate = rate;
// set camera device rate here
return true;
}
/************************************************************
......@@ -222,7 +222,7 @@ Device::id()
Vector<Channel^>^
Device::channelList()
{
return m_channels;
return m_channels;
}
String^
......@@ -261,7 +261,7 @@ bool
Device::isActive()
{
return false;
//return Video::DeviceModel::instance().activeDevice() == this;
//return Video::DeviceModel::instance().activeDevice() == this;
}
void
......@@ -270,12 +270,12 @@ Device::SetDeviceProperties(String^ format, int width, int height, int rate)
auto rl = m_currentChannel->resolutionList();
for (auto res : rl) {
if (res->format() == format &&
res->size()->width() == width &&
res->size()->height() == height &&
res->activeRate()->value() == rate)
res->size()->width() == width &&
res->size()->height() == height &&
res->activeRate()->value() == rate)
{
m_currentChannel->setCurrentResolution(res);
WriteLine("SetDeviceProperties");
RingDebug::instance->WriteLine("SetDeviceProperties");
return;
}
}
......
......@@ -42,7 +42,9 @@ VideoCaptureManager::VideoCaptureManager():
, mirroringPreview(false)
, displayOrientation(DisplayOrientations::Portrait)
, displayRequest(ref new Windows::System::Display::DisplayRequest())
, RotationKey({ 0xC380465D, 0x2271, 0x428C,{ 0x9B, 0x83, 0xEC, 0xEA, 0x3B, 0x4A, 0x85, 0xC1 } })
, RotationKey( {
0xC380465D, 0x2271, 0x428C, { 0x9B, 0x83, 0xEC, 0xEA, 0x3B, 0x4A, 0x85, 0xC1 }
})
{
deviceList = ref new Vector<Device^>();
InitializeCopyFrameDispatcher();
......@@ -58,10 +60,10 @@ VideoCaptureManager::getSettings(String^ device)
void
VideoCaptureManager::MediaCapture_Failed(Capture::MediaCapture^, Capture::MediaCaptureFailedEventArgs^ errorEventArgs)
{
WriteLine("MediaCapture_Failed");
RingDebug::instance->WriteLine("MediaCapture_Failed");
std::wstringstream ss;
ss << "MediaCapture_Failed: 0x" << errorEventArgs->Code << ": " << errorEventArgs->Message->Data();
WriteLine(ref new String(ss.str().c_str()));
RingDebug::instance->WriteLine(ref new String(ss.str().c_str()));
if (captureTaskTokenSource)
captureTaskTokenSource->cancel();
......@@ -71,7 +73,7 @@ VideoCaptureManager::MediaCapture_Failed(Capture::MediaCapture^, Capture::MediaC
task<void>
VideoCaptureManager::CleanupCameraAsync()
{
WriteLine("CleanupCameraAsync");
RingDebug::instance->WriteLine("CleanupCameraAsync");
std::vector<task<void>> taskList;
......@@ -87,7 +89,7 @@ VideoCaptureManager::CleanupCameraAsync()
}
return when_all(taskList.begin(), taskList.end())
.then([this]()
.then([this]()
{
if (mediaCapture.Get() != nullptr)
{
......@@ -105,18 +107,18 @@ VideoCaptureManager::EnumerateWebcamsAsync()
deviceList->Clear();
return create_task(DeviceInformation::FindAllAsync(DeviceClass::VideoCapture))
.then([this](task<DeviceInformationCollection^> findTask)
.then([this](task<DeviceInformationCollection^> findTask)
{
try {
devInfoCollection = findTask.get();
if (devInfoCollection == nullptr || devInfoCollection->Size == 0) {
WriteLine("No WebCams found.");
RingDebug::instance->WriteLine("No WebCams found.");
}
else {
for (unsigned int i = 0; i < devInfoCollection->Size; i++) {
AddVideoDevice(i);
}
WriteLine("Enumerating Webcams completed successfully.");
RingDebug::instance->WriteLine("Enumerating Webcams completed successfully.");
}
}
catch (Platform::Exception^ e) {
......@@ -128,20 +130,20 @@ VideoCaptureManager::EnumerateWebcamsAsync()
task<void>
VideoCaptureManager::StartPreviewAsync()
{
WriteLine("StartPreviewAsync");
RingDebug::instance->RingDebug::instance->WriteLine("StartPreviewAsync");
displayRequest->RequestActive();
auto sink = getSink();
sink->Source = mediaCapture.Get();
return create_task(mediaCapture->StartPreviewAsync())
.then([this](task<void> previewTask)
.then([this](task<void> previewTask)
{
try {
previewTask.get();
isPreviewing = true;
startPreviewing();
WriteLine("StartPreviewAsync DONE");
RingDebug::instance->WriteLine("StartPreviewAsync DONE");
}
catch (Exception ^e) {
WriteException(e);
......@@ -152,21 +154,21 @@ VideoCaptureManager::StartPreviewAsync()
task<void>
VideoCaptureManager::StopPreviewAsync()
{
WriteLine("StopPreviewAsync");
RingDebug::instance->WriteLine("StopPreviewAsync");
if (captureTaskTokenSource)
captureTaskTokenSource->cancel();
if (mediaCapture.Get()) {
return create_task(mediaCapture->StopPreviewAsync())
.then([this](task<void> stopTask)
.then([this](task<void> stopTask)
{
try {
stopTask.get();
isPreviewing = false;
stopPreviewing();
displayRequest->RequestRelease();
WriteLine("StopPreviewAsync DONE");
RingDebug::instance->WriteLine("StopPreviewAsync DONE");
}
catch (Exception ^e) {
WriteException(e);
......@@ -174,14 +176,14 @@ VideoCaptureManager::StopPreviewAsync()
});
}
else {
return create_task([](){});
return create_task([]() {});
}
}
task<void>
VideoCaptureManager::InitializeCameraAsync()
{
WriteLine("InitializeCameraAsync");
RingDebug::instance->WriteLine("InitializeCameraAsync");
if (captureTaskTokenSource)
captureTaskTokenSource->cancel();
......@@ -191,27 +193,27 @@ VideoCaptureManager::InitializeCameraAsync()
auto devInfo = devInfoCollection->GetAt(0); //preferences - video capture device
mediaCaptureFailedEventToken = mediaCapture->Failed +=
ref new Capture::MediaCaptureFailedEventHandler(this, &VideoCaptureManager::MediaCapture_Failed);
ref new Capture::MediaCaptureFailedEventHandler(this, &VideoCaptureManager::MediaCapture_Failed);
if (devInfo == nullptr)
return create_task([](){});
return create_task([]() {});
auto settings = ref new MediaCaptureInitializationSettings();
settings->VideoDeviceId = devInfo->Id;
return create_task(mediaCapture->InitializeAsync(settings))
.then([this](task<void> initTask)
.then([this](task<void> initTask)
{
try {
initTask.get();
SetCaptureSettings();
isInitialized = true;
WriteLine("InitializeCameraAsync DONE");
RingDebug::instance->WriteLine("InitializeCameraAsync DONE");
return StartPreviewAsync();
}
catch (Exception ^e) {
WriteException(e);
return create_task([](){});
return create_task([]() {});
}
});
}
......@@ -219,7 +221,7 @@ VideoCaptureManager::InitializeCameraAsync()
void
VideoCaptureManager::AddVideoDevice(uint8_t index)
{
WriteLine("GetDeviceCaps " + index.ToString());
RingDebug::instance->WriteLine("GetDeviceCaps " + index.ToString());
Platform::Agile<Windows::Media::Capture::MediaCapture^> mc;
mc = ref new MediaCapture();
......@@ -232,7 +234,7 @@ VideoCaptureManager::AddVideoDevice(uint8_t index)
settings->VideoDeviceId = devInfo->Id;
create_task(mc->InitializeAsync(settings))
.then([=](task<void> initTask)
.then([=](task<void> initTask)
{
try {
initTask.get();
......@@ -254,9 +256,9 @@ VideoCaptureManager::AddVideoDevice(uint8_t index)
String^ format = vidprops->Subtype;
resolution->setFormat(format);
channel->resolutionList()->Append(resolution);
WriteLine(devInfo->Name + " "
+ width.ToString() + "x" + height.ToString()
+ " " + frame_rate.ToString() + "FPS" + " " + format);
RingDebug::instance->WriteLine(devInfo->Name + " "
+ width.ToString() + "x" + height.ToString()
+ " " + frame_rate.ToString() + "FPS" + " " + format);
}
device->channelList()->Append(channel);
device->setCurrentChannel(device->channelList()->GetAt(0));
......@@ -277,7 +279,7 @@ VideoCaptureManager::AddVideoDevice(uint8_t index)
}
this->deviceList->Append(device);
this->activeDevice = deviceList->GetAt(0);
WriteLine("GetDeviceCaps DONE");
RingDebug::instance->WriteLine("GetDeviceCaps DONE");
DRing::addVideoDevice(Utils::toString(device->name()));
}
catch (Platform::Exception^ e) {
......@@ -302,7 +304,7 @@ VideoCaptureManager::InitializeCopyFrameDispatcher()
isRendering = false;
}
catch (Exception^ e) {
WriteLine(e->ToString());
RingDebug::instance->WriteLine(e->ToString());
}
}
......@@ -314,7 +316,7 @@ VideoCaptureManager::CopyFrame(Object^ sender, Object^ e)
create_task(VideoCaptureManager::CopyFrameAsync());
}
catch(Platform::COMException^ e) {
WriteLine(e->ToString());
RingDebug::instance->WriteLine(e->ToString());
}
}
}
......@@ -334,7 +336,7 @@ VideoCaptureManager::CopyFrameAsync()
captureTaskTokenSource = new cancellation_token_source();
}
return create_task(mediaCapture->GetPreviewFrameAsync(videoFrame), captureTaskTokenSource->get_token())
.then([this](VideoFrame^ currentFrame)
.then([this](VideoFrame^ currentFrame)
{
try {
isRendering = true;
......@@ -347,7 +349,7 @@ VideoCaptureManager::CopyFrameAsync()
Microsoft::WRL::ComPtr<IMemoryBufferByteAccess> byteAccess;
if (SUCCEEDED(reinterpret_cast<IUnknown*>(reference)->QueryInterface(
IID_PPV_ARGS(&byteAccess)))) {
IID_PPV_ARGS(&byteAccess)))) {
byte* data;
unsigned capacity;
byteAccess->GetBuffer(&data, &capacity);
......@@ -360,7 +362,7 @@ VideoCaptureManager::CopyFrameAsync()
for (int row = 0; row < desc.Height; row++) {
for (int col = 0; col < desc.Width; col++) {
auto currPixel = desc.StartIndex + desc.Stride * row
+ BYTES_PER_PIXEL * col;
+ BYTES_PER_PIXEL * col;
buf[currPixel + 0] = data[currPixel + 0];
buf[currPixel + 1] = data[currPixel + 1];
buf[currPixel + 2] = data[currPixel + 2];
......@@ -377,7 +379,7 @@ VideoCaptureManager::CopyFrameAsync()
}
catch (Exception^ e) {
WriteLine("failed to copy frame to daemon's buffer");
RingDebug::instance->WriteLine("failed to copy frame to daemon's buffer");
}
}).then([=](task<void> previousTask) {
try {
......@@ -385,7 +387,7 @@ VideoCaptureManager::CopyFrameAsync()
isRendering = false;
}
catch (Platform::Exception^ e) {
WriteLine( "Caught exception from previous task.\n" );
RingDebug::instance->WriteLine( "Caught exception from previous task.\n" );
}
});
}
......@@ -407,5 +409,5 @@ VideoCaptureManager::SetCaptureSettings()
vp->Subtype = res->format();
auto encodingProperties = static_cast<IMediaEncodingProperties^>(vp);
create_task(mediaCapture->VideoDeviceController->SetMediaStreamPropertiesAsync(
MediaStreamType::VideoPreview, encodingProperties));
MediaStreamType::VideoPreview, encodingProperties));
}
\ No newline at end of file
......@@ -73,12 +73,12 @@ VideoPage::VideoPage()
previousTask.get();
}
catch (Platform::Exception^ e) {
WriteLine( "Caught exception from previous task.\n" );
RingDebug::instance->WriteLine( "Caught exception from previous task.\n" );
}
});
}
catch(Platform::COMException^ e) {
WriteLine(e->ToString());
RingDebug::instance->WriteLine(e->ToString());
}
}));
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment