video: refactor video implementation
- changes the SetParameters signal to ParametersChanged and removes
the use of the GetCameraInfo signal as an alternative usage is
implemented in the daemon API as of commit:
a1b8b13a6f6ad4c7fb6df8d1c7219509c7dc1036
Change-Id: Iba76e6ec8f9d1ceb1068bd58b151ac37b9f72ed1
Tuleap: #790
diff --git a/RingD.cpp b/RingD.cpp
index 477a27b..2a8bf86 100644
--- a/RingD.cpp
+++ b/RingD.cpp
@@ -454,7 +454,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 2e91f6e..e820227 100644
--- a/VideoCaptureManager.cpp
+++ b/VideoCaptureManager.cpp
@@ -351,7 +351,25 @@
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 @@
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 @@
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;
}