diff --git a/RingD.cpp b/RingD.cpp index 477a27bb2e81ee76e9e5cd86aa496dd8de4c7984..2a8bf86ca634be1b94a49ceff4f0c07bfcb5efc8 100644 --- a/RingD.cpp +++ b/RingD.cpp @@ -454,7 +454,7 @@ RingD::registerCallbacks() const std::string& callId, bool state) { - // why this cllaback exist ? why are we not using stateChange ? + // why does this callback exist ? why are we not using stateChange ? MSG_("<PeerHold>"); MSG_("callId = " + callId); MSG_("state = " + Utils::toString(state.ToString())); @@ -472,7 +472,7 @@ RingD::registerCallbacks() const std::string& callId, bool state) { - // why this cllaback exist ? why are we not using stateChange ? + // why does this callback exist ? why are we not using stateChange ? MSG_("<AudioMuted>"); MSG_("callId = " + callId); MSG_("state = " + Utils::toString(state.ToString())); @@ -536,7 +536,8 @@ RingD::registerCallbacks() ringtone_->Stop(); } - if (state3 == CallStatus::ENDED) { + if (state3 == CallStatus::ENDED || + (state3 == CallStatus::NONE && code == 106) ) { DRing::hangUp(callId); // solve a bug in the daemon API. ringtone_->Stop(); } @@ -581,6 +582,8 @@ RingD::registerCallbacks() auto callId2 = toPlatformString(callId); auto from2 = toPlatformString(from); + from2 = Utils::TrimRingId2(from2); + auto item = SmartPanelItemsViewModel::instance->findItem(callId2); Contact^ contact; if (item) @@ -680,7 +683,7 @@ RingD::registerCallbacks() getAppPathHandler = { DRing::exportable_callback<DRing::ConfigurationSignal::GetAppDataPath> - ([this](std::vector<std::string>* paths) { + ([this](const std::string& name, std::vector<std::string>* paths) { paths->emplace_back(localFolder_); }) }; @@ -731,40 +734,21 @@ RingD::registerCallbacks() using namespace Video; outgoingVideoHandlers = { - DRing::exportable_callback<DRing::VideoSignal::GetCameraInfo> - ([this](const std::string& device, - std::vector<std::string> *formats, - std::vector<unsigned> *sizes, - std::vector<unsigned> *rates) { - MSG_("<GetCameraInfo>"); - auto device_list = VideoManager::instance->captureManager()->deviceList; - - for (unsigned int i = 0; i < device_list->Size; i++) { - auto dev = device_list->GetAt(i); - if (device == Utils::toString(dev->name())) { - Vector<Video::Resolution^>^ resolutions = dev->resolutionList(); - for (auto res : resolutions) { - formats->emplace_back(Utils::toString(res->activeRate()->format())); - sizes->emplace_back(res->width()); - sizes->emplace_back(res->height()); - for (auto rate : res->rateList()) { - rates->emplace_back(rate->value()); - } - } - } - } + DRing::exportable_callback<DRing::VideoSignal::DeviceAdded> + ([this](const std::string& device) { + MSG_("<DeviceAdded>"); }), - DRing::exportable_callback<DRing::VideoSignal::SetParameters> - ([&](const std::string& device, - std::string format, - const int width, - const int height, - const int rate) { + DRing::exportable_callback<DRing::VideoSignal::ParametersChanged> + ([&](const std::string& device) { dispatcher->RunAsync(CoreDispatcherPriority::High, ref new DispatchedHandler([=]() { - MSG_("<SetParameters>"); + MSG_("<ParametersChanged>"); + auto settings = DRing::getDeviceParams(device); VideoManager::instance->captureManager()->activeDevice->SetDeviceProperties( - Utils::toPlatformString(format),width,height,rate); + Utils::toPlatformString(settings["format"]), + stoi(settings["width"]), + stoi(settings["height"]), + stoi(settings["rate"])); })); }), DRing::exportable_callback<DRing::VideoSignal::StartCapture> diff --git a/VideoCaptureManager.cpp b/VideoCaptureManager.cpp index 2e91f6e39790bee126332706db07405db07fb24b..e8202276c53be1c12ddb5440ef46bb10a43af2a4 100644 --- a/VideoCaptureManager.cpp +++ b/VideoCaptureManager.cpp @@ -351,7 +351,25 @@ VideoCaptureManager::AddVideoDeviceAsync(uint8_t index) this->deviceList->Append(device); this->activeDevice = deviceList->GetAt(0); MSG_("GetDeviceCaps DONE"); - DRing::addVideoDevice(Utils::toString(device->name())); + + std::vector<std::map<std::string, std::string>> devInfo; + Vector<Video::Resolution^>^ resolutions = device->resolutionList(); + for (auto& res : resolutions) { + for (auto& rate : res->rateList()) { + std::map<std::string, std::string> setting; + setting["format"] = Utils::toString(rate->format()); + setting["width"] = Utils::toString(res->width().ToString()); + setting["height"] = Utils::toString(res->height().ToString()); + setting["rate"] = Utils::toString(rate->value().ToString()); + devInfo.emplace_back(std::move(setting)); + MSG_("<DeviceAdded> : info - " + + rate->format() + + ":" + res->width().ToString() + + "x" + res->height().ToString() + " " + rate->value().ToString() + ); + } + } + DRing::addVideoDevice(Utils::toString(device->name()), &devInfo); } catch (Platform::Exception^ e) { WriteException(e); @@ -413,7 +431,6 @@ VideoCaptureManager::CopyFrameAsync() MediaProperties::VideoEncodingProperties^ vidprops = static_cast<VideoEncodingProperties^>(allprops->GetAt(0)); String^ format = vidprops->Subtype; - // for now, only bgra auto videoFrame = ref new VideoFrame(BitmapPixelFormat::Bgra8, videoFrameWidth, videoFrameHeight); try { @@ -428,23 +445,22 @@ VideoCaptureManager::CopyFrameAsync() isRendering = true; auto bitmap = currentFrame->SoftwareBitmap; if (bitmap->BitmapPixelFormat == BitmapPixelFormat::Bgra8) { - const int BYTES_PER_PIXEL = 4; BitmapBuffer^ buffer = bitmap->LockBuffer(BitmapBufferAccessMode::ReadWrite); IMemoryBufferReference^ reference = buffer->CreateReference(); - Microsoft::WRL::ComPtr<IMemoryBufferByteAccess> byteAccess; + if (SUCCEEDED(reinterpret_cast<IUnknown*>(reference)->QueryInterface( IID_PPV_ARGS(&byteAccess)))) { byte* data; unsigned capacity; byteAccess->GetBuffer(&data, &capacity); - auto desc = buffer->GetPlaneDescription(0); byte* buf = (byte*)DRing::obtainFrame(capacity); if (buf) std::memcpy(buf, data, static_cast<size_t>(capacity)); DRing::releaseFrame((void*)buf); } + delete reference; delete buffer; }