Skip to content

Commit

Permalink
PeerConnection から情報を取得するように試行錯誤中
Browse files Browse the repository at this point in the history
  • Loading branch information
enm10k committed Feb 8, 2024
1 parent e863d68 commit 0c3329f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/sora.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,4 +1012,60 @@ std::string Sora::GetConnectedSignalingURL() const {
return signaling_->GetConnectedSignalingURL();
}

void Sora::GetTracks() const {
RTC_LOG(LS_INFO) << __func__ << " start";
auto conn = signaling_->GetPeerConnection();
RTC_LOG(LS_INFO) << __func__ << " hoge";

if (conn != nullptr) {
RTC_LOG(LS_INFO) << __func__ << " A";
} else {
RTC_LOG(LS_INFO) << __func__ << " B";
}

auto conf = conn->GetConfiguration();
if (conf.sdp_semantics == webrtc::SdpSemantics::kUnifiedPlan) {
RTC_LOG(LS_INFO) << __func__ << " sdp_semantics: kUnifiedPlan";
} else {
RTC_LOG(LS_INFO) << __func__ << " sdp_semantics: kPlanB";
}

if (conf.sdp_semantics != webrtc::SdpSemantics::kUnifiedPlan) {
auto local_streams = conn->local_streams();
for (int i = 0; i < local_streams->count(); i++) {
auto stream = local_streams->at(i);
RTC_LOG(LS_INFO) << __func__ << " local stream: " << stream->id();
auto audio_tracks = stream->GetAudioTracks();
for (auto track : audio_tracks) {
RTC_LOG(LS_INFO) << __func__ << " local audio track: " << track->id();
}

auto video_tracks = stream->GetAudioTracks();
for (auto track : video_tracks) {
RTC_LOG(LS_INFO) << __func__ << " local video track: " << track->id();
}
}
// auto remote_streams = conn.remote_streams();
} else {
auto transceivers = conn->GetTransceivers();
for (auto transceiver : transceivers) {
auto sender = transceiver->sender();
auto sender_stream_ids = sender->stream_ids();
if (sender_stream_ids.size() != 0) {
RTC_LOG(LS_INFO) << __func__
<< " sender_stream_id=" << sender_stream_ids[0]
<< ", track_id=" << sender->track()->id();
}

auto receiver = transceiver->receiver();
auto receiver_stream_ids = receiver->stream_ids();
if (receiver_stream_ids.size() != 0) {
RTC_LOG(LS_INFO) << __func__
<< " receiver_stream_id=" << receiver_stream_ids[0]
<< ", track_id=" << receiver->track()->id();
}
}
}
}

} // namespace sora_unity_sdk
2 changes: 2 additions & 0 deletions src/sora.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class Sora : public std::enable_shared_from_this<Sora>,
std::string GetSelectedSignalingURL() const;
std::string GetConnectedSignalingURL() const;

void GetTracks() const;

private:
void* GetAndroidApplicationContext(void* env);
static sora_conf::ErrorCode ToErrorCode(sora::SoraSignalingErrorCode ec);
Expand Down
2 changes: 2 additions & 0 deletions src/unity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ void sora_set_on_handle_audio(void* p, handle_audio_cb_t f, void* userdata) {

void sora_get_stats(void* p, stats_cb_t f, void* userdata) {
auto wsora = (SoraWrapper*)p;

wsora->sora->GetTracks();
wsora->sora->GetStats(
[f, userdata](std::string json) { f(json.c_str(), userdata); });
}
Expand Down

0 comments on commit 0c3329f

Please sign in to comment.