Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
- @t-miya
- [ADD] MediaChannel に libwebrtc の統計情報を取得する `getStats` メソッドを追加する
- @t-miya
- [ADD] MediaStream に RTCAudioTrackSink を RTCAudioTrack と関連付ける / 関連付けを解除するためのメソッドを追加する
- 追加したメソッド
- `addAudioTrackSink(_ sink: RTCAudioTrackSink)`
- `removeAudioTrackSink(_ sink: RTCAudioTrackSink)`
- @zztkm

### misc

Expand Down
20 changes: 20 additions & 0 deletions Sora/MediaStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ public protocol MediaStream: AnyObject {
/// このプロパティはロールがサブスクライバーの場合のみ有効です。
var remoteAudioVolume: Double? { get set }

// MARK: 音声データ取得

/// RTCAudioTrackSink を RTCAudioTrack に関連付けます。
/// 追加済みのシンクを再度追加した場合は何もしません。
func addAudioTrackSink(_ sink: RTCAudioTrackSink)

/// RTCAudioTrackSink の関連付けを解除します。
/// 未追加の RTCAudioTrackSink を指定した場合は何もしません。
func removeAudioTrackSink(_ sink: RTCAudioTrackSink)

// MARK: 映像フレームの送信

/// 映像フィルター
Expand Down Expand Up @@ -210,6 +220,16 @@ class BasicMediaStream: MediaStream {
}
}

func addAudioTrackSink(_ sink: RTCAudioTrackSink) {
Logger.debug(type: .mediaStream, message: "add audio track sink \(sink)")
nativeAudioTrack?.add(sink)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RTCAudioTrack の addSink 内で sink の重複チェックをしているので、iOS SDK での重複チェックは不要。

https://github.com/shiguredo-webrtc-build/webrtc-build/blob/7d4b527397a61d200d77a1971de2714ded3b710d/patches/ios_audio_track_sink.patch#L201-L206

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これコードコメントに書いてあったほうが良さそう。

}

func removeAudioTrackSink(_ sink: RTCAudioTrackSink) {
Logger.debug(type: .mediaStream, message: "remove audio track sink \(sink)")
nativeAudioTrack?.remove(sink)
}

init(peerChannel: PeerChannel, nativeStream: RTCMediaStream) {
self.peerChannel = peerChannel
self.nativeStream = nativeStream
Expand Down
9 changes: 5 additions & 4 deletions Sora/Sora.swift
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format しただけです。

Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ public final class Sora {
public func connect(
configuration: Configuration,
webRTCConfiguration: WebRTCConfiguration = WebRTCConfiguration(),
handler: @escaping (
_ mediaChannel: MediaChannel?,
_ error: Error?
) -> Void
handler:
@escaping (
_ mediaChannel: MediaChannel?,
_ error: Error?
) -> Void
) -> ConnectionTask {
let mediaChan = MediaChannel(manager: self, configuration: configuration)
mediaChan.internalHandlers.onDisconnectLegacy = { [weak self, weak mediaChan] error in
Expand Down