Commit e416629a authored by Ronan's avatar Ronan

in progress

parent 3cfc023c
......@@ -157,9 +157,9 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
content/content.h
content/file-content.h
content/file-transfer-content.h
content/header/header.h
content/header/header-p.h
content/header/header-param.h
content/header/header.h
core/core-accessor.h
core/core-listener.h
core/core-p.h
......@@ -194,6 +194,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
event-log/events.h
hacks/hacks.h
logger/logger.h
media-device-watcher/media-device-watcher.h
nat/ice-agent.h
nat/stun-client.h
object/app-data-container.h
......@@ -365,8 +366,9 @@ elseif (WIN32)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES core/paths/paths-windows.cpp)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-windows.h)
elseif (UNIX)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES core/paths/paths-linux.cpp)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-linux.h)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES core/paths/paths-linux.cpp)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES media-device-watcher/media-device-watcher-linux.cpp)
endif ()
set(LINPHONE_CXX_OBJECTS_INCLUDE_DIRS
......@@ -383,7 +385,7 @@ foreach (header ${LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES})
endforeach ()
set(LINPHONE_PRIVATE_HEADER_FILES ${LINPHONE_PRIVATE_HEADER_FILES} PARENT_SCOPE)
if (ANDROID AND CMAKE_C_COMPILER_ID STREQUAL "GNU")
if (ANDROID AND CMAKE_C_COMPILER_ID STREQUAL "GNU")
list(APPEND STRICT_OPTIONS_CXX "-Wno-attributes")
endif()
bc_apply_compile_flags(LINPHONE_CXX_OBJECTS_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX)
......
......@@ -22,6 +22,8 @@
#include <libudev.h>
#include "core_private.h"
#include "core/core.h"
#include "logger/logger.h"
#include "media-device-watcher.h"
#include "object/object-p.h"
......@@ -32,20 +34,41 @@ LINPHONE_BEGIN_NAMESPACE
class MediaDeviceWatcherPrivate : public ObjectPrivate {
public:
udev *udevContext;
udev_monitor *udevMonitor;
udev *udevContext = nullptr;
udev_monitor *udevMonitor = nullptr;
Core *core = nullptr;
belle_sip_source_t *socketWatcher = nullptr;
void clean ();
static int handleNotification (void *userData, unsigned int) {
MediaDeviceWatcherPrivate *d = static_cast<MediaDeviceWatcherPrivate *>(userData);
udev_device *udevDevice = udev_monitor_receive_device(d->udevMonitor);
const char *subsystem = udev_device_get_subsystem(udevDevice);
if (subsystem) {
if (!strcmp(subsystem, "sound")) {
// TODO:
}
if (!strcmp(subsystem, "video4linux")) {
// TODO:
}
}
udev_device_unref(udevDevice);
}
};
void MediaDeviceWatcherPrivate::clean () {
if (core)
core->getCCore()->sal->destroySocketWatcher(socketWatcher);
if (udevMonitor)
udev_monitor_unref(udevMonitor);
if (udevContext)
udev_unref(udevContext);
}
MediaDeviceWatcher::MediaDeviceWatcher () : Object(*new MediaDeviceWatcherPrivate) {
MediaDeviceWatcher::MediaDeviceWatcher (Core *core) : Object(*new MediaDeviceWatcherPrivate) {
L_D();
if (!(d->udevContext = udev_new())) {
......@@ -72,7 +95,8 @@ MediaDeviceWatcher::MediaDeviceWatcher () : Object(*new MediaDeviceWatcherPrivat
return;
}
// TODO: Deal with fd. Add a socket notifier in core?
d->core = core;
core->getCCore()->sal->createSocketWatcher(&MediaDeviceWatcherPrivate::handleNotification, d, 0, fd, BELLE_SIP_EVENT_READ);
}
MediaDeviceWatcher::~MediaDeviceWatcher () {
......
......@@ -26,11 +26,12 @@
LINPHONE_BEGIN_NAMESPACE
class Core;
class MediaDeviceWatcherPrivate;
class MediaDeviceWatcher : public Object {
public:
MediaDeviceWatcher ();
MediaDeviceWatcher (Core *core);
~MediaDeviceWatcher ();
private:
......
......@@ -801,6 +801,23 @@ void Sal::cancelTimer(belle_sip_source_t *timer) {
belle_sip_main_loop_remove_source(ml, timer);
}
belle_sip_source_t *Sal::createSocketWatcher (
belle_sip_source_func_t func,
void *data,
unsigned int timeoutValueMs,
belle_sip_socket_t fd,
unsigned int events
) {
belle_sip_source_t *socketWatcher = belle_sip_socket_source_new(func, data, fd, events, timeoutValueMs);
belle_sip_main_loop_add_source(belle_sip_stack_get_main_loop(mStack), socketWatcher);
return socketWatcher;
}
void Sal::destroySocketWatcher (belle_sip_source_t *socketWatcher) {
if (socketWatcher)
belle_sip_main_loop_remove_source(belle_sip_stack_get_main_loop(mStack), socketWatcher);
}
belle_sip_response_t *Sal::createResponseFromRequest (belle_sip_request_t *request, int code) {
auto response = belle_sip_response_create_from_request(request, code);
belle_sip_message_add_header(BELLE_SIP_MESSAGE(response), BELLE_SIP_HEADER(mUserAgentHeader));
......
......@@ -240,8 +240,7 @@ public:
const std::string &getDnsUserHostsFile () const;
belle_sip_resolver_context_t *resolveA (const std::string &name, int port, int family, belle_sip_resolver_callback_t cb, void *data);
belle_sip_resolver_context_t *resolve (const std::string &service, const std::string &transport, const std::string &name, int port, int family, belle_sip_resolver_callback_t cb, void *data);
belle_sip_resolver_context_t *resolve (const std::string &service, const std::string &transport, const std::string &name, int port, int family, belle_sip_resolver_callback_t cb, void *data);
// ---------------------------------------------------------------------------
// Timers
......@@ -249,6 +248,17 @@ public:
belle_sip_source_t *createTimer (belle_sip_source_func_t func, void *data, unsigned int timeoutValueMs, const std::string &timerName);
void cancelTimer (belle_sip_source_t *timer);
// ---------------------------------------------------------------------------
// Socket watcher
// ---------------------------------------------------------------------------
belle_sip_source_t *createSocketWatcher (
belle_sip_source_func_t func,
void *data,
unsigned int timeoutValueMs,
belle_sip_socket_t fd,
unsigned int events
);
void destroySocketWatcher (belle_sip_source_t *socketWatcher);
private:
struct SalUuid {
......@@ -337,4 +347,3 @@ int toSipCode (SalReason reason);
LINPHONE_END_NAMESPACE
#endif // ifndef _L_SAL_H_
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