Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ WDS is a set of libraries for developers who want to build Wi-Fi Display applica
WDS consists of:
* libwds: Main library implements a Wi-Fi Display dialect of RTSP that includes the parser, actual negotiation logic for sink and source, and the related data structures. It is not tied to any specific connection manager, media framework or main loop. This Library is also compatible with MSVC.
* network: Supports integration with GLib main loop and GStreamer
* p2p: Supports integration with Connman Wifi P2P features
* p2p: Supports integration with Connman and IWD Wifi P2P features


The source code includes example implementations:
* _sink:_ Wi-Fi Display sink that depends on Gstreamer, Connman and GLib mainloop
* _desktop_source:_ Wi-Fi Display source that depends on Gstreamer, Connman and GLib mainloop
* _sink:_ Wi-Fi Display sink that depends on Gstreamer, Connman/IWD and GLib mainloop
* _desktop_source:_ Wi-Fi Display source that depends on Gstreamer, Connman/IWD and GLib mainloop

More information can be found on the [mailing list](https://lists.01.org/mailman/listinfo/wysiwidi-dev) and the [wiki](https://github.com/01org/wds/wiki).

### Requirements:

WDS test executables have runtime dependencies on just a few things (mostly GStreamer and GLib), but for successful Wi-Fi Display sessions the following are adviced:
WDS test executables have runtime dependencies on just a few things (mostly GStreamer and GLib), but for successful Wi-Fi Display sessions the following are advised:
* Wifi adapter from Intel 7260-family or Atheros ath9k
* [wpa_supplicant](http://w1.fi/wpa_supplicant/): version 2.4 or later, built with `CONFIG_P2P=y`, `CONFIG_WIFI_DISPLAY=y` and `CONFIG_CTRL_IFACE_DBUS_NEW=y`
* [connman](https://01.org/connman): version 1.28 (released Feb 1st 2015) or later.
* gstreamer: either master branch more recent than Feb 3rd 2015 (commit d0a50be2), or 1.4 branch more recent than
Feb 3rd 2005 (commit 1ce3260a638d or release 1.4.6 or later).
* either: [wpa_supplicant](http://w1.fi/wpa_supplicant/): version 2.4 or later, built with `CONFIG_P2P=y`, `CONFIG_WIFI_DISPLAY=y` and `CONFIG_CTRL_IFACE_DBUS_NEW=y`
* [connman](https://01.org/connman): version 1.28 (released Feb 1st 2015) or later.
* or: [IWD](https://iwd.wiki.kernel.org/) version 1.9+ -- alternative to connman and wpa_supplicant.

Test results with other Wifi adapters are very welcome but be warned that in many cases Wifi-P2P has not had the testing it needs on linux: you may run into problems in surprising places.

Expand All @@ -34,7 +35,7 @@ make

### Testing WDS

#### Pre-requisites
#### Pre-requisites (connman backend)

Make sure wpa_supplicant & connmand are running. Running both of them uninstalled is possible (but in that case make sure the system wpa_supplicant and system connection manager are _not_ running):

Expand Down
27 changes: 9 additions & 18 deletions desktop_source/source-app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
*/

#include <iostream>
#include <netinet/in.h> // htons()

#include "source-app.h"
#include "multi-client.h"

void SourceApp::on_availability_changed(P2P::Client *client)
{
Expand Down Expand Up @@ -85,23 +85,14 @@ void SourceApp::on_availability_changed(P2P::Peer *peer)
SourceApp::SourceApp(int port) :
peer_index_(0)
{
// Create a information element for a simple WFD Source
P2P::InformationElement ie;
auto sub_element = P2P::new_subelement(P2P::DEVICE_INFORMATION);
auto dev_info = (P2P::DeviceInformationSubelement*)sub_element;

// TODO InformationElement could have constructors for this stuff...
dev_info->session_management_control_port = htons(port);
dev_info->maximum_throughput = htons(50);
dev_info->field1.device_type = P2P::SOURCE;
dev_info->field1.session_availability = true;
ie.add_subelement(sub_element);

std::cout << "* Registering Wi-Fi Display Source with IE " << ie.to_string() << std::endl;

// register the P2P service with connman
auto array = ie.serialize ();
p2p_client_.reset(new P2P::Client(array, this));
static struct P2P::Parameters params = {
.source = true,
.session_management_control_port = (uint16_t) port,
};

// register the P2P service with the DBus service in use
std::cout << "* Registering Wi-Fi Display Source" << std::endl;
p2p_client_.reset(new P2P::MultiClient(params, this));

source_.reset(new MiracBrokerSource(port));
}
Expand Down
2 changes: 1 addition & 1 deletion desktop_source/source-app.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <memory>

#include "source.h"
#include "connman-client.h"
#include "client.h"
#include "mirac_broker_source.h"

class SourceApp: public P2P::Client::Observer, public P2P::Peer::Observer {
Expand Down
2 changes: 2 additions & 0 deletions mirac_network/mirac-broker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ std::string MiracBroker::get_peer_address() const
}

MiracBroker::MiracBroker (const std::string& listen_port):
connect_wait_id_(0),
connect_timer_(NULL)
{
network_source_ptr_ = this;
Expand All @@ -193,6 +194,7 @@ MiracBroker::MiracBroker (const std::string& listen_port):
MiracBroker::MiracBroker(const std::string& peer_address, const std::string& peer_port, uint timeout):
peer_address_(peer_address),
peer_port_(peer_port),
connect_wait_id_(0),
connect_timeout_(timeout)
{
network_source_ptr_ = this;
Expand Down
2 changes: 1 addition & 1 deletion p2p/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pkg_check_modules (GIO REQUIRED gio-2.0)
include_directories(${GIO_INCLUDE_DIRS})

add_library(p2p STATIC
connman-peer.cpp connman-client.cpp information-element.cpp
connman-peer.cpp connman-client.cpp information-element.cpp iwd-peer.cpp iwd-client.cpp
)

add_executable(register-peer-service main.cpp)
Expand Down
60 changes: 60 additions & 0 deletions p2p/client.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* This file is part of Wireless Display Software for Linux OS
*
* Copyright (C) 2020 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/

#ifndef CLIENT_H_
#define CLIENT_H_

#include <memory>

#include "peer.h"

namespace P2P {

class Client {
public:
class Observer {
public:
virtual void on_peer_added(Client *client, std::shared_ptr<P2P::Peer> peer) {}
virtual void on_peer_removed(Client *client, std::shared_ptr<P2P::Peer> peer) {}
virtual void on_availability_changed(Client *client) {}

protected:
virtual ~Observer() {}
};

virtual void set_parameters(const Parameters &params) = 0;
virtual void set_observer(Observer* observer) {
observer_ = observer;
}

virtual bool is_available() const = 0;
/* TODO error / finished handling */
virtual void scan() = 0;

protected:
Client(Observer *observer = NULL) : observer_(observer) {}

Observer* observer_;
std::map<std::string, std::shared_ptr<P2P::Peer>> peers_;
};

}
#endif // CLIENT_H_
Loading