void FBTestPluginAPI::getURLCallback(const FB::JSObjectPtr& callback, bool success, const FB::HeaderMap& headers, const boost::shared_array<uint8_t>& data, const size_t size) { FB::VariantMap outHeaders; for (FB::HeaderMap::const_iterator it = headers.begin(); it != headers.end(); ++it) { if (headers.count(it->first) > 1) { if (outHeaders.find(it->first) != outHeaders.end()) { outHeaders[it->first].cast<FB::VariantList>().push_back(it->second); } else { outHeaders[it->first] = FB::VariantList(FB::variant_list_of(it->second)); } } else { outHeaders[it->first] = it->second; } } if (success) { std::string dstr(reinterpret_cast<const char*>(data.get()), size); callback->InvokeAsync("", FB::variant_list_of (true) (outHeaders) (dstr) ); } else { callback->InvokeAsync("", FB::variant_list_of(false)); } }
bool BlabbleCall::Transfer(const FB::VariantMap ¶ms) { std::string destination; pj_str_t desturi; BlabbleAccountPtr p = parent_.lock(); if (!p) return false; if (call_id_ == INVALID_CALL) return false; FB::VariantMap::const_iterator iter = params.find("destination"); if (iter == params.end()) { throw FB::script_error("No destination given!"); } else { destination = iter->second.cast<std::string>(); if (destination.size() <= 4 || destination.substr(0, 4) != "sip:") destination = "sip:" + destination + "@" + p->server(); if (p->use_tls() && destination.find("transport=TLS") == std::string::npos) destination += ";transport=TLS"; } if ((iter = params.find("onStatusChange")) != params.end() && iter->second.is_of_type<FB::JSObjectPtr>()) { set_on_transfer_status(iter->second.cast<FB::JSObjectPtr>()); } desturi.ptr = const_cast<char*>(destination.c_str()); desturi.slen = destination.length(); return pjsua_call_xfer(call_id_, &desturi, NULL) == PJ_SUCCESS; }
void btlauncherAPI::gotajax(const FB::JSObjectPtr& callback, bool success, const FB::HeaderMap& headers, const boost::shared_array<uint8_t>& data, const size_t size) { FBLOG_INFO("gotajax()", "START"); FB::VariantMap response; response["allowed"] = true; response["success"] = success; if(!success) { FBLOG_INFO("gotajax()", "unsuccessful"); callback->InvokeAsync("", FB::variant_list_of(response)); FBLOG_INFO("gotajax()", "END"); return; } FB::VariantMap outHeaders; for (FB::HeaderMap::const_iterator it = headers.begin(); it != headers.end(); ++it) { if (headers.count(it->first) > 1) { if (outHeaders.find(it->first) != outHeaders.end()) { outHeaders[it->first].cast<FB::VariantList>().push_back(it->second); } else { outHeaders[it->first] = FB::VariantList(FB::variant_list_of(it->second)); } } else { outHeaders[it->first] = it->second; } } response["headers"] = outHeaders; response["size"] = size; std::string result = std::string((const char*) data.get(), size); response["data"] = result; callback->InvokeAsync("", FB::variant_list_of(response)); FBLOG_INFO("gotajax()", "END"); }
FB::VariantMap LocalVideoTrack::GetVideoDevices() { static int deviceCount = 0; const size_t kMaxDeviceNameLength = 128; const size_t kMaxUniqueIdLength = 256; char deviceName[kMaxDeviceNameLength]; char deviceUniqueId[kMaxUniqueIdLength]; webrtc::VideoCaptureModule::DeviceInfo* pDevInfo; FB::VariantMap devices; std::string key; std::string val; pDevInfo = webrtc::VideoCaptureFactory::CreateDeviceInfo(0); for(size_t i=0; i<pDevInfo->NumberOfDevices(); i++) { pDevInfo->GetDeviceName(i, deviceName, kMaxDeviceNameLength, deviceUniqueId, kMaxUniqueIdLength); key = deviceUniqueId; val = deviceName; devices[key] = val; if(videoDevices.end() == videoDevices.find(key)) { videoDevices[key] = webrtc::VideoCaptureFactory::Create(deviceCount++, deviceUniqueId); std::string msg("Capture device ["); std::stringstream devIdxStr; msg += deviceUniqueId; msg += "][idx = "; devIdxStr << (deviceCount-1); msg += (devIdxStr.str() + "]"); if(NULL == videoDevices[key]) { devices.erase(key); videoDevices.erase(key); msg += " (failed to open)"; FBLOG_ERROR_CUSTOM("LocalVideoTrack::GetVideoDevices", msg); } else { msg += "..."; FBLOG_INFO_CUSTOM("LocalVideoTrack::GetVideoDevices", msg); } } if((0 == i) && (videoDevices.end() != videoDevices.find(key))) { devices["default"] = key; } } std::stringstream offlineDevices; for(VideoDeviceList::iterator it = videoDevices.begin(); it != videoDevices.end(); it++) { if(devices.end() == devices.find(it->first)) { offlineDevices << (it->first); } } while(offlineDevices) { std::string deviceId; offlineDevices >> deviceId; if("" != deviceId) { videoDevices.erase(deviceId); std::string msg = "Deleting offline device ["; msg += (deviceId + "]..."); FBLOG_INFO_CUSTOM("LocalVideTrack::GetVideoDevices", msg); } } delete pDevInfo; return devices; }