Skip to content

Commit 0c3329f

Browse files
committed
PeerConnection から情報を取得するように試行錯誤中
1 parent e863d68 commit 0c3329f

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

src/sora.cpp

+56
Original file line numberDiff line numberDiff line change
@@ -1012,4 +1012,60 @@ std::string Sora::GetConnectedSignalingURL() const {
10121012
return signaling_->GetConnectedSignalingURL();
10131013
}
10141014

1015+
void Sora::GetTracks() const {
1016+
RTC_LOG(LS_INFO) << __func__ << " start";
1017+
auto conn = signaling_->GetPeerConnection();
1018+
RTC_LOG(LS_INFO) << __func__ << " hoge";
1019+
1020+
if (conn != nullptr) {
1021+
RTC_LOG(LS_INFO) << __func__ << " A";
1022+
} else {
1023+
RTC_LOG(LS_INFO) << __func__ << " B";
1024+
}
1025+
1026+
auto conf = conn->GetConfiguration();
1027+
if (conf.sdp_semantics == webrtc::SdpSemantics::kUnifiedPlan) {
1028+
RTC_LOG(LS_INFO) << __func__ << " sdp_semantics: kUnifiedPlan";
1029+
} else {
1030+
RTC_LOG(LS_INFO) << __func__ << " sdp_semantics: kPlanB";
1031+
}
1032+
1033+
if (conf.sdp_semantics != webrtc::SdpSemantics::kUnifiedPlan) {
1034+
auto local_streams = conn->local_streams();
1035+
for (int i = 0; i < local_streams->count(); i++) {
1036+
auto stream = local_streams->at(i);
1037+
RTC_LOG(LS_INFO) << __func__ << " local stream: " << stream->id();
1038+
auto audio_tracks = stream->GetAudioTracks();
1039+
for (auto track : audio_tracks) {
1040+
RTC_LOG(LS_INFO) << __func__ << " local audio track: " << track->id();
1041+
}
1042+
1043+
auto video_tracks = stream->GetAudioTracks();
1044+
for (auto track : video_tracks) {
1045+
RTC_LOG(LS_INFO) << __func__ << " local video track: " << track->id();
1046+
}
1047+
}
1048+
// auto remote_streams = conn.remote_streams();
1049+
} else {
1050+
auto transceivers = conn->GetTransceivers();
1051+
for (auto transceiver : transceivers) {
1052+
auto sender = transceiver->sender();
1053+
auto sender_stream_ids = sender->stream_ids();
1054+
if (sender_stream_ids.size() != 0) {
1055+
RTC_LOG(LS_INFO) << __func__
1056+
<< " sender_stream_id=" << sender_stream_ids[0]
1057+
<< ", track_id=" << sender->track()->id();
1058+
}
1059+
1060+
auto receiver = transceiver->receiver();
1061+
auto receiver_stream_ids = receiver->stream_ids();
1062+
if (receiver_stream_ids.size() != 0) {
1063+
RTC_LOG(LS_INFO) << __func__
1064+
<< " receiver_stream_id=" << receiver_stream_ids[0]
1065+
<< ", track_id=" << receiver->track()->id();
1066+
}
1067+
}
1068+
}
1069+
}
1070+
10151071
} // namespace sora_unity_sdk

src/sora.h

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class Sora : public std::enable_shared_from_this<Sora>,
7676
std::string GetSelectedSignalingURL() const;
7777
std::string GetConnectedSignalingURL() const;
7878

79+
void GetTracks() const;
80+
7981
private:
8082
void* GetAndroidApplicationContext(void* env);
8183
static sora_conf::ErrorCode ToErrorCode(sora::SoraSignalingErrorCode ec);

src/unity.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ void sora_set_on_handle_audio(void* p, handle_audio_cb_t f, void* userdata) {
184184

185185
void sora_get_stats(void* p, stats_cb_t f, void* userdata) {
186186
auto wsora = (SoraWrapper*)p;
187+
188+
wsora->sora->GetTracks();
187189
wsora->sora->GetStats(
188190
[f, userdata](std::string json) { f(json.c_str(), userdata); });
189191
}

0 commit comments

Comments
 (0)