Skip to content
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
6 changes: 2 additions & 4 deletions endpoint/programs/stream_testing/echo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include <privmx/endpoint/core/Config.hpp>
#include <privmx/endpoint/core/Connection.hpp>
#include <privmx/endpoint/event/EventApi.hpp>
#include <privmx/endpoint/stream/StreamApi.hpp>
#include <privmx/utils/PrivmxException.hpp>

Expand Down Expand Up @@ -43,9 +42,8 @@ int main(int argc, char** argv) {
privKey,
solutionId,
bridgeUrl
);
event::EventApi eventApi = event::EventApi::create(connection);
stream::StreamApi streamApi = stream::StreamApi::create(connection, eventApi);
);
stream::StreamApi streamApi = stream::StreamApi::create(connection);
std::string streamRoomId;
auto contextUsersInfo = connection.listContextUsers(contextId, {0, 100, "asc"});
std::vector<core::UserWithPubKey> usersWithPubKey = {};
Expand Down
6 changes: 2 additions & 4 deletions endpoint/programs/stream_testing/single_video_receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <privmx/endpoint/core/Config.hpp>
#include <privmx/endpoint/core/Connection.hpp>
#include <privmx/endpoint/core/EventQueue.hpp>
#include <privmx/endpoint/event/EventApi.hpp>
#include <privmx/endpoint/stream/StreamApi.hpp>
#include <privmx/endpoint/stream/Events.hpp>
#include <privmx/endpoint/stream/Types.hpp>
Expand Down Expand Up @@ -198,9 +197,8 @@ int main(int argc, char** argv) {
privKey,
solutionId,
bridgeUrl
);
event::EventApi eventApi = event::EventApi::create(connection);
stream::StreamApi streamApi = stream::StreamApi::create(connection, eventApi);
);
stream::StreamApi streamApi = stream::StreamApi::create(connection);
std::string streamRoomId;
if(streamRoomIdOpt.has_value()) {
streamRoomId = streamRoomIdOpt.has_value();
Expand Down
4 changes: 1 addition & 3 deletions endpoint/programs/stream_testing/single_video_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <privmx/endpoint/core/Config.hpp>
#include <privmx/endpoint/core/Connection.hpp>
#include <privmx/endpoint/core/EventQueue.hpp>
#include <privmx/endpoint/event/EventApi.hpp>
#include <privmx/endpoint/stream/StreamApi.hpp>
#include <privmx/endpoint/stream/StreamVarSerializer.hpp>
#include <privmx/endpoint/stream/Types.hpp>
Expand Down Expand Up @@ -53,8 +52,7 @@ int main(int argc, char** argv) {
auto eventHolder = eventQueue.waitEvent();
}
});
event::EventApi eventApi = event::EventApi::create(connection);
stream::StreamApi streamApi = stream::StreamApi::create(connection, eventApi);
stream::StreamApi streamApi = stream::StreamApi::create(connection);
std::string streamRoomId;
if(streamRoomIdOpt.has_value()) {
streamRoomId = streamRoomIdOpt.has_value();
Expand Down
6 changes: 1 addition & 5 deletions endpoint/programs/stream_testing/streams_program_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include <privmx/endpoint/core/Events.hpp>
#include <privmx/endpoint/core/EventQueue.hpp>
#include <privmx/endpoint/crypto/CryptoApi.hpp>
#include <privmx/endpoint/event/EventApi.hpp>
#include <privmx/endpoint/event/Events.hpp>
#include <privmx/endpoint/thread/ThreadApi.hpp>
#include <privmx/endpoint/thread/Events.hpp>
#include <privmx/endpoint/store/StoreApi.hpp>
Expand Down Expand Up @@ -168,7 +166,6 @@ class MyFrame : public wxFrame
wxBitmap bmp = wxBitmap(MAX_VIDEO_W, MAX_VIDEO_H, 32);
int tmp = 0;
std::shared_ptr<core::Connection> connection;
std::shared_ptr<event::EventApi> eventApi;
std::shared_ptr<stream::StreamApi> streamApi;
std::thread _event_chandler;
};
Expand Down Expand Up @@ -297,8 +294,7 @@ MyFrame::MyFrame()

void MyFrame::Connect(std::string privKey, std::string solutionId, std::string url) {
connection = std::make_shared<core::Connection>(core::Connection::connect(privKey, solutionId, url));
eventApi = std::make_shared<event::EventApi>(event::EventApi::create(*connection));
streamApi = std::make_shared<stream::StreamApi>(stream::StreamApi::create(*connection, *eventApi));
streamApi = std::make_shared<stream::StreamApi>(stream::StreamApi::create(*connection));
crypto::CryptoApi cryptoApi = crypto::CryptoApi::create();
auto context = connection->listContexts({.skip=0, .limit=1, .sortOrder="asc"}).readItems[0];
auto streamRoomList = streamApi->listStreamRooms(context.contextId, {.skip=0, .limit=1, .sortOrder="asc"});
Expand Down
8 changes: 2 additions & 6 deletions endpoint/programs/stream_testing/streams_program_5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include <privmx/endpoint/core/Events.hpp>
#include <privmx/endpoint/core/EventQueue.hpp>
#include <privmx/endpoint/crypto/CryptoApi.hpp>
#include <privmx/endpoint/event/EventApi.hpp>
#include <privmx/endpoint/event/Events.hpp>
#include <privmx/endpoint/thread/ThreadApi.hpp>
#include <privmx/endpoint/thread/Events.hpp>
#include <privmx/endpoint/store/StoreApi.hpp>
Expand Down Expand Up @@ -179,7 +177,6 @@ class MyFrame : public wxFrame
wxBitmap bmp = wxBitmap(MAX_VIDEO_W, MAX_VIDEO_H, 32);
int tmp = 0;
std::shared_ptr<core::Connection> connection;
std::shared_ptr<event::EventApi> eventApi;
std::shared_ptr<stream::StreamApi> streamApi;
std::thread _event_handler;
std::thread _renderer_handler;
Expand Down Expand Up @@ -434,8 +431,7 @@ void MyFrame::Connect(std::string login, std::string password, std::string url)
PRIVMX_DEBUG("StreamProgram wx", "Connect", "Connected with Application Server")
try {
connection = std::make_shared<core::Connection>(core::Connection::connect(privKey, solutionId, bridgeUrl));
eventApi = std::make_shared<event::EventApi>(event::EventApi::create(*connection));
streamApi = std::make_shared<stream::StreamApi>(stream::StreamApi::create(*connection, *eventApi));
streamApi = std::make_shared<stream::StreamApi>(stream::StreamApi::create(*connection));
} catch (const privmx::endpoint::core::Exception& e) {
PRIVMX_DEBUG("StreamProgram wx", "Connect", "Connection To bridge failed")
}
Expand All @@ -446,7 +442,7 @@ void MyFrame::Connect(std::string login, std::string password, std::string url)
} catch (const privmx::endpoint::core::Exception& e) {
PRIVMX_DEBUG("StreamProgram wx", "Connect", "User not added to StreamRoom")
auto admin_connection = std::make_shared<core::Connection>(core::Connection::connect(adminUserPrivKey, solutionId, bridgeUrl));
auto admin_streamApi = std::make_shared<stream::StreamApi>(stream::StreamApi::create(*admin_connection, *eventApi));
auto admin_streamApi = std::make_shared<stream::StreamApi>(stream::StreamApi::create(*admin_connection));
bool stop = false;
for (size_t i = 0;!stop;i++) {
PRIVMX_DEBUG("StreamProgram wx", "Connect", "Admin: Getting StreamRoomInfo")
Expand Down
2 changes: 1 addition & 1 deletion endpoint/stream/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else()
add_library(privmxendpointstream STATIC)
endif()
target_compile_options(privmxendpointstream PRIVATE -Wall -Wextra -fPIC)
target_link_libraries(privmxendpointstream PRIVATE Poco::Foundation privmx privmxendpointcore privmxendpointevent PUBLIC privmxendpointstream_stream ${LIBS})
target_link_libraries(privmxendpointstream PRIVATE Poco::Foundation privmx privmxendpointcore PUBLIC privmxendpointstream_stream ${LIBS})
if(BUILD_SHARED_LIBS)
set_target_properties(privmxendpointstream PROPERTIES POSITION_INDEPENDENT_CODE True)
endif()
Expand Down
2 changes: 1 addition & 1 deletion endpoint/stream/stream/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ add_library(privmxendpointstream_stream OBJECT ${SOURCES})

target_include_directories(privmxendpointstream_stream PUBLIC ${INCLUDE_DIRS} PUBLIC ${INCLUDE_PUB_DIRS})
target_compile_options(privmxendpointstream_stream PRIVATE -Wall -Wextra -fPIC)
target_link_libraries(privmxendpointstream_stream PRIVATE Poco::Foundation privmx privmxendpointcore privmxendpointevent)
target_link_libraries(privmxendpointstream_stream PRIVATE Poco::Foundation privmx privmxendpointcore)
if(BUILD_SHARED_LIBS)
set_target_properties(privmxendpointstream_stream PROPERTIES POSITION_INDEPENDENT_CODE True)
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ limitations under the License.
#include <privmx/endpoint/core/ModuleBaseApi.hpp>
#include <privmx/endpoint/core/Types.hpp>
#include <privmx/endpoint/core/encryptors/module/ModuleDataEncryptorV5.hpp>
#include <privmx/endpoint/event/EventApiImpl.hpp>
#include <string>
#include <unordered_map>
#include <vector>

#include "ThreadSafeQueue.hpp"
#include "privmx/endpoint/stream/Constants.hpp"
#include "privmx/endpoint/stream/ServerApi.hpp"
#include "privmx/endpoint/stream/StreamKeyManager.hpp"
#include "privmx/endpoint/stream/SubscriberImpl.hpp"
#include "privmx/endpoint/stream/Types.hpp"
#include "privmx/endpoint/stream/WebRTCInterface.hpp"
Expand All @@ -40,14 +38,12 @@ namespace stream {
class StreamApiLowImpl : public privmx::utils::ManualManagedClass<StreamApiLowImpl>, protected core::ModuleBaseApi {
public:
StreamApiLowImpl(
const std::shared_ptr<event::EventApiImpl>& eventApi,
const core::Connection& connection,
const privfs::RpcGateway::Ptr& gateway,
const privmx::crypto::PrivateKey& userPrivKey,
const std::shared_ptr<core::KeyProvider>& keyProvider,
const std::string& host,
const std::shared_ptr<core::EventMiddleware>& eventMiddleware,
StreamEncryptionMode streamEncryptionMode = StreamEncryptionMode::SINGLE_KEY
const std::shared_ptr<core::EventMiddleware>& eventMiddleware
);
~StreamApiLowImpl();

Expand Down Expand Up @@ -98,7 +94,6 @@ class StreamApiLowImpl : public privmx::utils::ManualManagedClass<StreamApiLowIm
void unsubscribeFrom(const std::vector<std::string>& subscriptionIds);
std::string buildSubscriptionQuery(EventType eventType, EventSelectorType selectorType, const std::string& selectorId);

void keyManagement(const std::string& streamRoomId, bool disable);
void trickle(const int64_t sessionId, const std::string& candidateAsJson);
void acceptOfferOnReconfigure(const int64_t sessionId, const SdpWithTypeModel& sdp);
void setNewOfferOnReconfigure(const int64_t sessionId, const SdpWithTypeModel& sdp);
Expand All @@ -110,24 +105,16 @@ class StreamApiLowImpl : public privmx::utils::ManualManagedClass<StreamApiLowIm
std::optional<StreamHandle> streamHandle;
};
struct StreamRoomData {
StreamRoomData(std::shared_ptr<StreamKeyManager> _streamKeyManager, const std::string _streamRoomId, std::shared_ptr<WebRTCInterface> _webRtc, const std::vector<std::string>& _subscriptionsIds, StreamEncryptionMode streamEncryptionMode, const std::string& _encryptionKeyId = ""):
streamKeyManager(_streamKeyManager), streamRoomId(_streamRoomId), webRtc(_webRtc), subscriptionsIds(_subscriptionsIds), encryptionKeyId(_encryptionKeyId)
{
if(streamEncryptionMode == StreamEncryptionMode::MULTIPLE_KEY) {
keyUpdateCallbackId = streamKeyManager->addKeyUpdateCallback([_webRtc, _streamRoomId](const std::vector<privmx::endpoint::stream::Key> keys) {
_webRtc->updateKeys(_streamRoomId, keys);
});
}
}
StreamRoomData(const std::string _streamRoomId, std::shared_ptr<WebRTCInterface> _webRtc, const std::vector<std::string>& _subscriptionsIds, const std::string& _encryptionKeyId = ""):
streamRoomId(_streamRoomId), webRtc(_webRtc), subscriptionsIds(_subscriptionsIds), encryptionKeyId(_encryptionKeyId)
{}
std::shared_ptr<StreamData> publisherStream;
std::shared_ptr<StreamData> subscriberStream;
std::shared_ptr<StreamKeyManager> streamKeyManager;
std::string streamRoomId;
std::shared_ptr<WebRTCInterface> webRtc;
int64_t keyUpdateCallbackId;
std::vector<std::string> subscriptionsIds;
std::string encryptionKeyId;
};
};
// if streamMap is empty after leave, unpublish StreamRoomData should, be removed.

void onNotificationEvent(const std::string& type, const core::NotificationEvent& notification);
Expand Down Expand Up @@ -165,15 +152,12 @@ class StreamApiLowImpl : public privmx::utils::ManualManagedClass<StreamApiLowIm
core::ModuleKeys streamRoomToModuleKeys(server::StreamRoomInfo streamRoom);
void assertTurnServerUri(const std::string& uri);

void sendStreamKeyRequest(std::shared_ptr<privmx::endpoint::stream::StreamApiLowImpl::StreamRoomData> room, const std::set<RemoteStreamId>& streamIds);

static int32_t nextIdCounter;
static int32_t nextId() {
return nextIdCounter++;
}


std::shared_ptr<event::EventApiImpl> _eventApi;
std::shared_ptr<core::ConnectionImpl> _connection;
privmx::crypto::PrivateKey _userPrivKey;
std::shared_ptr<core::KeyProvider> _keyProvider;
Expand All @@ -188,8 +172,6 @@ class StreamApiLowImpl : public privmx::utils::ManualManagedClass<StreamApiLowIm
privmx::utils::ThreadSaveMap<std::string, std::shared_ptr<StreamRoomData>> _streamRoomMap;
privmx::utils::ThreadSaveMap<StreamHandle, std::string> _streamHandleToRoomId;
int _notificationListenerId, _connectedListenerId, _disconnectedListenerId;
std::vector<std::string> _internalSubscriptionIds;
StreamEncryptionMode _streamEncryptionMode;
};

} // namespace stream
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ limitations under the License.
#include "privmx/endpoint/stream/StreamVarSerializer.hpp"
#include <privmx/endpoint/core/VarDeserializer.hpp>
#include <privmx/endpoint/stream/StreamVarDeserializer.hpp>
#include <privmx/endpoint/event/EventApi.hpp>
#include <mutex>
#include <shared_mutex>
namespace privmx {
Expand Down Expand Up @@ -60,8 +59,8 @@ class StreamApiLowVarInterface {
JoinStreamRoomEx = 25,
};

StreamApiLowVarInterface(core::Connection connection, event::EventApi eventApi, const core::VarSerializer& serializer)
: _connection(std::move(connection)), _eventApi(std::move(eventApi)), _serializer(serializer) {}
StreamApiLowVarInterface(core::Connection connection, const core::VarSerializer& serializer)
: _connection(std::move(connection)), _serializer(serializer) {}

Poco::Dynamic::Var create(const Poco::Dynamic::Var& args);
Poco::Dynamic::Var getTurnCredentials(const Poco::Dynamic::Var& args);
Expand Down Expand Up @@ -94,8 +93,6 @@ class StreamApiLowVarInterface {
Poco::Dynamic::Var trickle(const Poco::Dynamic::Var& args);
Poco::Dynamic::Var acceptOfferOnReconfigure(const Poco::Dynamic::Var& args);
Poco::Dynamic::Var setNewOfferOnReconfigure(const Poco::Dynamic::Var& args);
Poco::Dynamic::Var keyManagement(const Poco::Dynamic::Var& args);

Poco::Dynamic::Var exec(METHOD method, const Poco::Dynamic::Var& args);

std::shared_ptr<WebRTCInterface> getWebRtcInterface();
Expand All @@ -105,7 +102,6 @@ class StreamApiLowVarInterface {
static std::map<METHOD, Poco::Dynamic::Var (StreamApiLowVarInterface::*)(const Poco::Dynamic::Var&)> methodMap;

core::Connection _connection;
event::EventApi _eventApi;
StreamApiLow _streamApi;
core::VarSerializer _serializer;
core::VarDeserializer _deserializer;
Expand Down
Loading
Loading