Skip to content

Commit

Permalink
Merge branch 'release/2023.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Jul 6, 2023
2 parents ae4853f + a77c9eb commit 30c1c10
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 6 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@

## develop

## 2023.3.0

**2023-07-06**

- [CHANGE] Sora.create_connection() が複数のシグナリング URL を受け取れるようにする
- C++ SDK の仕様に合わせるための破壊的な変更
- `signaling_url` は廃止して `signaling_urls` で置き換える
- `signaling_urls``List[str]` を受け取る
- @sile

## 2023.2.0

**2023-07-03**
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "sora_sdk"
authors = [{ name = "Shiguredo Inc.", email = "contact+pypi@shiguredo.jp" }]
version = "2023.2.0"
version = "2023.3.0"
description = "WebRTC SFU Sora Python SDK"
readme = "README.md"
license = { file = "LICENSE" }
Expand Down
25 changes: 23 additions & 2 deletions src/sora.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Sora::~Sora() {
}

std::shared_ptr<SoraConnection> Sora::CreateConnection(
const std::string& signaling_url,
const nb::handle& signaling_urls,
const std::string& role,
const std::string& channel_id,
std::optional<std::string> client_id,
Expand Down Expand Up @@ -59,7 +59,7 @@ std::shared_ptr<SoraConnection> Sora::CreateConnection(
sora::SoraSignalingConfig config;
config.pc_factory = factory_->GetPeerConnectionFactory();
config.observer = conn;
config.signaling_urls.push_back(signaling_url);
config.signaling_urls = ConvertSignalingUrls(signaling_urls);
config.role = role;
config.channel_id = channel_id;
if (client_id) {
Expand Down Expand Up @@ -291,6 +291,27 @@ Sora::ConvertForwardingFilter(const nb::handle value) {
return filter;
}

std::vector<std::string> Sora::ConvertSignalingUrls(const nb::handle value) {
auto signaling_urls_value =
ConvertJsonValue(value, "Invalid JSON value in signaling_urls");
if (!signaling_urls_value.is_array()) {
throw nb::type_error("`signaling_urls` should be a list of strings");
}

std::vector<std::string> signaling_urls;
for (auto signaling_url_value : signaling_urls_value.as_array()) {
if (!signaling_url_value.is_string()) {
throw nb::type_error("`signaling_urls` should be a list of strings");
}
signaling_urls.push_back(boost::json::value_to<std::string>(signaling_url_value));
}

if (signaling_urls.empty()) {
throw nb::type_error("`signaling_urls` should not be empty");
}
return signaling_urls;
}

std::vector<sora::SoraSignalingConfig::DataChannel> Sora::ConvertDataChannels(
const nb::handle value) {
std::vector<sora::SoraSignalingConfig::DataChannel> data_channels;
Expand Down
4 changes: 3 additions & 1 deletion src/sora.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Sora : public DisposePublisher {

std::shared_ptr<SoraConnection> CreateConnection(
// 必須パラメータ
const std::string& signaling_url,
const nb::handle& signaling_urls,
const std::string& role,
const std::string& channel_id,

Expand Down Expand Up @@ -75,6 +75,8 @@ class Sora : public DisposePublisher {
const char* error_message);
std::vector<sora::SoraSignalingConfig::DataChannel> ConvertDataChannels(
const nb::handle value);
std::vector<std::string> ConvertSignalingUrls(const nb::handle value);

boost::optional<sora::SoraSignalingConfig::ForwardingFilter>
ConvertForwardingFilter(const nb::handle value);

Expand Down
2 changes: 1 addition & 1 deletion src/sora_sdk_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ NB_MODULE(sora_sdk_ext, m) {
nb::class_<Sora>(m, "Sora")
.def(nb::init<std::optional<bool>, std::optional<std::string>>(),
"use_hardware_encoder"_a = nb::none(), "openh264"_a = nb::none())
.def("create_connection", &Sora::CreateConnection, "signaling_url"_a,
.def("create_connection", &Sora::CreateConnection, "signaling_urls"_a,
"role"_a, "channel_id"_a, "client_id"_a = nb::none(),
"bundle_id"_a = nb::none(), "metadata"_a = nb::none(),
"signaling_notify_metadata"_a = nb::none(),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_recvonly.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_sendonly():
sora = Sora()

conn = sora.create_connection(
signaling_url=os.environ.get("TEST_SIGNALING_URL"),
signaling_urls=[os.environ.get("TEST_SIGNALING_URL")],
role="recvonly",
channel_id=os.environ.get("TEST_CHANNEL_ID_PREFIX") + "sora-python-sdk-test",
metadata={"access_token": os.environ.get("TEST_SECRET_KEY")}
Expand Down

0 comments on commit 30c1c10

Please sign in to comment.