Skip to content

Commit

Permalink
misc: windows: remove UWP/store files and code
Browse files Browse the repository at this point in the history
Change-Id: I4875e4d76f5da442eace0204052d536c65545d3f
  • Loading branch information
atraczyk committed Oct 18, 2023
1 parent 5692c1e commit ad3be16
Show file tree
Hide file tree
Showing 20 changed files with 108 additions and 501 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ build-macos*
/extras/tools/check_sed
/extras/tools/libtool-*.tar.xz

# UWP
# Windows native build
/contrib/build/
/contrib/msvc/

Expand Down
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ source_group("Source Files\\media\\video" FILES ${Source_Files__media__video})
source_group("Source Files\\plugin" FILES ${Source_Files__plugin})

if(MSVC)
if(WINDOWS_STORE)
source_group("Source Files\\media\\video\\uwpvideo" FILES ${Source_Files__media__video__uwpvideo})
endif()
source_group("Source Files\\media\\audio\\portaudio" FILES ${Source_Files__media__audio__portaudio})
source_group("Source Files\\media\\video\\winvideo" FILES ${Source_Files__media__video__winvideo})
endif()
Expand Down
10 changes: 0 additions & 10 deletions compat/msvc/dlfcn.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ void *dlopen( const char *file, int mode )
UINT uMode;
current_error = NULL;
/* Do not let Windows display the critical-error-handler message box */
#ifndef RING_UWP
uMode = SetErrorMode( SEM_FAILCRITICALERRORS );
#endif
if( file == 0 )
{
/* POSIX says that if the value of file is 0, a handle on a global
Expand All @@ -149,9 +147,7 @@ void *dlopen( const char *file, int mode )
* symbols only from the original program file. For objects loaded with
* the RTLD_GLOBAL flag, we create our own list later on.
*/
#ifndef RING_UWP
hModule = GetModuleHandle( NULL );
#endif
if( !hModule )
save_err_ptr_str( file );
}
Expand All @@ -175,10 +171,8 @@ else
* to UNIX's search paths (start with system folders instead of current
* folder).
*/
#ifndef RING_UWP
hModule = LoadLibraryEx( (LPSTR) lpFileName, NULL,
LOAD_WITH_ALTERED_SEARCH_PATH );
#endif
/* If the object was loaded with RTLD_GLOBAL, add it to list of global
* objects, so that its symbols may be retrieved even if the handle for
* the original program file is passed. POSIX says that if the same
Expand All @@ -192,9 +186,7 @@ else if( (mode & RTLD_GLOBAL) )
global_add( hModule );
}
/* Return to previous state of the error-mode bit flags. */
#ifndef RING_UWP
SetErrorMode( uMode );
#endif
return (void *) hModule;
}
int dlclose( void *handle )
Expand Down Expand Up @@ -225,9 +217,7 @@ void *dlsym( void *handle, const char *name )
/* If the handle for the original program file is passed, also search
* in all globally loaded objects.
*/
#ifndef RING_UWP
hModule = GetModuleHandle( NULL );
#endif
if( hModule == handle )
{
global_object *pobject;
Expand Down
3 changes: 0 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ set (Source_Files__media__audio__audio_processing ${Source_Files__media__audio__
set (Source_Files__media__audio__webrtc ${Source_Files__media__audio__webrtc} PARENT_SCOPE)
set (Source_Files__media__video ${Source_Files__media__video} PARENT_SCOPE)
if(MSVC)
if(WINDOWS_STORE)
set (Source_Files__media__video__uwpvideo ${Source_Files__media__video__uwpvideo} PARENT_SCOPE)
endif()
set (Source_Files__media__audio__portaudio ${Source_Files__media__audio__portaudio} PARENT_SCOPE)
set (Source_Files__media__video__winvideo ${Source_Files__media__video__winvideo} PARENT_SCOPE)
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/client/ring_signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ getSignalHandlers()
#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
exported_callback<libjami::ConfigurationSignal::GetHardwareAudioFormat>(),
#endif
#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) || defined(RING_UWP)
#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
exported_callback<libjami::ConfigurationSignal::GetAppDataPath>(),
exported_callback<libjami::ConfigurationSignal::GetDeviceName>(),
#endif
Expand Down
8 changes: 5 additions & 3 deletions src/client/videomanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ AudioFrame::mix(const AudioFrame& frame)
{
auto& f = *pointer();
auto& fIn = *frame.pointer();
if (f.ch_layout.nb_channels != fIn.ch_layout.nb_channels || f.format != fIn.format || f.sample_rate != fIn.sample_rate) {
if (f.ch_layout.nb_channels != fIn.ch_layout.nb_channels || f.format != fIn.format
|| f.sample_rate != fIn.sample_rate) {
throw std::invalid_argument("Can't mix frames with different formats");
}
if (f.nb_samples == 0) {
Expand Down Expand Up @@ -185,7 +186,8 @@ AudioFrame::calcRMS() const
double rms = 0.0;
auto fmt = static_cast<AVSampleFormat>(frame_->format);
bool planar = av_sample_fmt_is_planar(fmt);
int perChannel = planar ? frame_->nb_samples : frame_->nb_samples * frame_->ch_layout.nb_channels;
int perChannel = planar ? frame_->nb_samples
: frame_->nb_samples * frame_->ch_layout.nb_channels;
int channels = planar ? frame_->ch_layout.nb_channels : 1;
if (fmt == AV_SAMPLE_FMT_S16 || fmt == AV_SAMPLE_FMT_S16P) {
for (int c = 0; c < channels; ++c) {
Expand Down Expand Up @@ -649,7 +651,7 @@ setEncodingAccelerated(bool state)
}
}

#if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
void
addVideoDevice(const std::string& node,
const std::vector<std::map<std::string, std::string>>& devInfo)
Expand Down
2 changes: 1 addition & 1 deletion src/connectivity/ip_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "ip_utils.h"

#if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
#define JAMI_DEVICE_SIGNAL 1
#endif

Expand Down
70 changes: 14 additions & 56 deletions src/fileutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
#include "compiler_intrinsics.h"
#include <opendht/crypto.h>

#ifdef RING_UWP
#include <io.h> // for access and close
#include "ring_signal.h"
#endif

#ifdef __APPLE__
#include <TargetConditionals.h>
#endif
Expand Down Expand Up @@ -265,7 +260,10 @@ loadTextFile(const std::filesystem::path& path, const std::filesystem::path& def
}

void
saveFile(const std::filesystem::path& path, const uint8_t* data, size_t data_size, mode_t UNUSED mode)
saveFile(const std::filesystem::path& path,
const uint8_t* data,
size_t data_size,
mode_t UNUSED mode)
{
std::ofstream file(path, std::ios::trunc | std::ios::binary);
if (!file.is_open()) {
Expand All @@ -276,8 +274,7 @@ saveFile(const std::filesystem::path& path, const uint8_t* data, size_t data_siz
#ifndef _WIN32
file.close();
if (chmod(path.c_str(), mode) < 0)
JAMI_WARNING("fileutils::saveFile(): chmod() failed on {}, {}",
path, strerror(errno));
JAMI_WARNING("fileutils::saveFile(): chmod() failed on {}, {}", path, strerror(errno));
#endif
}

Expand Down Expand Up @@ -382,7 +379,7 @@ writeArchive(const std::string& archive_str, const std::string& path, const std:
}
}

#if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
#else
static char* program_dir = NULL;
void
Expand All @@ -399,21 +396,7 @@ set_program_dir(char* program_path)
std::filesystem::path
get_cache_dir(const char* pkg)
{
#ifdef RING_UWP
std::string cache_path;
std::vector<std::string> paths;
paths.reserve(1);
emitSignal<libjami::ConfigurationSignal::GetAppDataPath>("", &paths);
if (not paths.empty()) {
cache_path = paths[0] + DIR_SEPARATOR_STR + std::string(".cache");
if (fileutils::recursive_mkdir(cache_path.data(), 0700) != true) {
// If directory creation failed
if (errno != EEXIST)
JAMI_DBG("Cannot create directory: %s!", cache_path.c_str());
}
}
return cache_path;
#elif defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
std::vector<std::string> paths;
paths.reserve(1);
emitSignal<libjami::ConfigurationSignal::GetAppDataPath>("cache", &paths);
Expand Down Expand Up @@ -452,13 +435,6 @@ get_home_dir()
if (not paths.empty())
return paths[0];
return {};
#elif defined RING_UWP
std::vector<std::string> paths;
paths.reserve(1);
emitSignal<libjami::ConfigurationSignal::GetAppDataPath>("", &paths);
if (not paths.empty())
return paths[0];
return {};
#elif defined _WIN32
TCHAR path[MAX_PATH];
if (SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_PROFILE, nullptr, 0, path))) {
Expand Down Expand Up @@ -507,20 +483,6 @@ get_data_dir(const char* pkg)
} else {
return get_home_dir() / "AppData" / "Local" / pkg;
}
#elif defined(RING_UWP)
std::vector<std::string> paths;
paths.reserve(1);
emitSignal<libjami::ConfigurationSignal::GetAppDataPath>("", &paths);
if (not paths.empty()) {
auto files_path = std::filesystem::path(paths[0]) / ".data";
if (fileutils::recursive_mkdir(files_path.data(), 0700) != true) {
// If directory creation failed
if (errno != EEXIST)
JAMI_DBG("Cannot create directory: %s!", files_path.c_str());
}
return files_path;
}
return {};
#else
std::string_view data_home(XDG_DATA_HOME);
if (not data_home.empty())
Expand All @@ -546,11 +508,6 @@ get_config_dir(const char* pkg)
emitSignal<libjami::ConfigurationSignal::GetAppDataPath>("config", &paths);
if (not paths.empty())
configdir = std::filesystem::path(paths[0]);
#elif defined(RING_UWP)
std::vector<std::string> paths;
emitSignal<libjami::ConfigurationSignal::GetAppDataPath>("", &paths);
if (not paths.empty())
configdir = std::filesystem::path(paths[0]) / ".config";
#elif defined(__APPLE__)
configdir = fileutils::get_home_dir() / "Library" / "Application Support" / pkg;
#elif defined(_WIN32)
Expand Down Expand Up @@ -587,8 +544,9 @@ get_config_dir()
bool
eraseFile_win32(const std::string& path, bool dosync)
{
// Note: from https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-deletefilea#remarks
// To delete a read-only file, first you must remove the read-only attribute.
// Note: from
// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-deletefilea#remarks To
// delete a read-only file, first you must remove the read-only attribute.
SetFileAttributesA(path.c_str(), GetFileAttributesA(path.c_str()) & ~FILE_ATTRIBUTE_READONLY);
HANDLE h
= CreateFileA(path.c_str(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
Expand Down Expand Up @@ -656,7 +614,7 @@ eraseFile_posix(const std::string& path, bool dosync)
return false;
}
// Remove read-only flag if possible
chmod(path.c_str(), st.st_mode | (S_IWGRP+S_IWUSR) );
chmod(path.c_str(), st.st_mode | (S_IWGRP + S_IWUSR));

int fd = open(path.c_str(), O_WRONLY);
if (fd == -1) {
Expand Down Expand Up @@ -693,7 +651,7 @@ eraseFile_posix(const std::string& path, bool dosync)

bool
eraseFile(const std::string& path, bool dosync)
{
{
#ifdef _WIN32
return eraseFile_win32(path, dosync);
#else
Expand Down Expand Up @@ -788,8 +746,8 @@ uint64_t
lastWriteTimeInSeconds(const std::filesystem::path& filePath)
{
return std::chrono::duration_cast<std::chrono::seconds>(
std::filesystem::last_write_time(filePath)
.time_since_epoch()).count();
std::filesystem::last_write_time(filePath).time_since_epoch())
.count();
}

} // namespace fileutils
Expand Down
8 changes: 5 additions & 3 deletions src/jami/configurationmanager_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ LIBJAMI_PUBLIC std::map<std::string, std::string> getAccountTemplate(const std::
LIBJAMI_PUBLIC std::string addAccount(const std::map<std::string, std::string>& details,
const std::string& accountID = {});
LIBJAMI_PUBLIC void monitor(bool continuous);
LIBJAMI_PUBLIC std::vector<std::map<std::string, std::string>> getConnectionList(const std::string& accountId, const std::string& conversationId);
LIBJAMI_PUBLIC std::vector<std::map<std::string, std::string>> getChannelList(const std::string& accountId, const std::string& connectionId);
LIBJAMI_PUBLIC std::vector<std::map<std::string, std::string>> getConnectionList(
const std::string& accountId, const std::string& conversationId);
LIBJAMI_PUBLIC std::vector<std::map<std::string, std::string>> getChannelList(
const std::string& accountId, const std::string& connectionId);

LIBJAMI_PUBLIC bool exportOnRing(const std::string& accountID, const std::string& password);
LIBJAMI_PUBLIC bool exportToFile(const std::string& accountID,
Expand Down Expand Up @@ -537,7 +539,7 @@ struct LIBJAMI_PUBLIC ConfigurationSignal
using cb_type = void(std::vector<int32_t>* /* params_ret */);
};
#endif
#if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
struct LIBJAMI_PUBLIC GetAppDataPath
{
constexpr static const char* name = "GetAppDataPath";
Expand Down
12 changes: 7 additions & 5 deletions src/jami/videomanager_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ namespace libjami {
[[deprecated("Replaced by registerSignalHandlers")]] LIBJAMI_PUBLIC void registerVideoHandlers(
const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);

struct LIBJAMI_PUBLIC AVFrame_deleter {
struct LIBJAMI_PUBLIC AVFrame_deleter
{
void operator()(AVFrame* frame) const { av_frame_free(&frame); }
};

typedef std::unique_ptr<AVFrame, AVFrame_deleter> FrameBuffer;

struct LIBJAMI_PUBLIC AVPacket_deleter {
struct LIBJAMI_PUBLIC AVPacket_deleter
{
void operator()(AVPacket* pkt) const { av_packet_free(&pkt); }
};

Expand Down Expand Up @@ -184,7 +186,7 @@ LIBJAMI_PUBLIC std::vector<std::string> getDeviceList();
LIBJAMI_PUBLIC VideoCapabilities getCapabilities(const std::string& deviceId);
LIBJAMI_PUBLIC std::map<std::string, std::string> getSettings(const std::string& deviceId);
LIBJAMI_PUBLIC void applySettings(const std::string& deviceId,
const std::map<std::string, std::string>& settings);
const std::map<std::string, std::string>& settings);
LIBJAMI_PUBLIC void setDefaultDevice(const std::string& deviceId);
LIBJAMI_PUBLIC void setDeviceOrientation(const std::string& deviceId, int angle);
LIBJAMI_PUBLIC std::map<std::string, std::string> getDeviceParams(const std::string& deviceId);
Expand All @@ -209,10 +211,10 @@ LIBJAMI_PUBLIC void startShmSink(const std::string& sinkId, bool value);
LIBJAMI_PUBLIC std::map<std::string, std::string> getRenderer(const std::string& callId);

LIBJAMI_PUBLIC std::string startLocalMediaRecorder(const std::string& videoInputId,
const std::string& filepath);
const std::string& filepath);
LIBJAMI_PUBLIC void stopLocalRecorder(const std::string& filepath);

#if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
LIBJAMI_PUBLIC void addVideoDevice(
const std::string& node, const std::vector<std::map<std::string, std::string>>& devInfo = {});
LIBJAMI_PUBLIC void removeVideoDevice(const std::string& node);
Expand Down
Loading

0 comments on commit ad3be16

Please sign in to comment.