Skip to content

Conversation

@Kiyoung-Kim-57
Copy link
Member

🤔 배경

Mic Mute 버튼만 있고 로직은 없었습니다

📃 작업 내역

내 음성 입력 AudioTrack에서 꺼주기

✅ 리뷰 노트

  1. AudioTrack의 입출력 옵션 추가
  • .defaultToSpeaker 기존에 유일하게 있던 옵션 -> 그래서 아무리 이어폰을 연결해도 하단 스피커로만 음성 출력됨
  • .allowBluetooth 블루투스 기기의 음성 입출력을 지원해줌 -> 이제 에어팟 연결하면 에어팟으로 들리고 에어팟 마이크 사용 가능
  • .allowAirPlay -> AirPlay 기기로 음성 출력 지원 -> 혹시 몰라 지원
  • .allowBluetoothA2DP -> 블루투스 기기 음성의 고품질 스테레오 출력을 지원 -> 우리 앱에는 굳이 필요없는 옵션이라 생각해서 뺌
  1. AudioTrack의 isEnabled 속성 값으로 오디오 송출을 조절합니다.
// WebRTCServiceImpl.swift
func changeLocalAudioState(_ isEnabled: Bool) {
    self.localAudioTrack.isEnabled = isEnabled
}
  1. 기존에 toggle방식으로 변경되던 PTGMicButton의 on/off 기능을 AudioTrack의 송출 상태를 반영할 수 있도록 변경했습니다.
//PTGMicButton.swift
public func changeMicState(_ isOn: Bool) {
    micState = isOn ? .on : .off
    
    buttonImage.image = UIImage(systemName: micState.image)
    buttonImage.tintColor = micState.color
}
  1. ConnectionRepositoryImpl는 CurrentValueSubject로 현재 isEnabled 값을 갖고 있습니다.
  • 변경 요청이 오면 현재 저장되는 값의 반대 되는 Bool 값을 isEnabled에 할당하고 CurrentValueSubject에 send 합니다.
// ConnectionRepositoryImpl.swift
private let didChangeLocalAudioTrackStateSubject = CurrentValueSubject<Bool, Never>(true)
public var didChangeLocalAudioTrackStatePublisher: AnyPublisher<Bool, Never> {
    didChangeLocalAudioTrackStateSubject
        .eraseToAnyPublisher()
}

public func switchLocalAudioTrackState() {
    let presentAudioState = didChangeLocalAudioTrackStateSubject.value
    clients.forEach {
        $0.switchLocalAudioTrackState(isEnable: !presentAudioState)
    }
    didChangeLocalAudioTrackStateSubject.send(!presentAudioState)
}

🎨 스크린샷

iPhone SE(2세대) iPhone 14 iPhone 16 Pro Max
스샷 스샷

🚀 테스트 방법

기기 두개를 연결하고 한 쪽의 마이크 버튼을 눌러서 소리의 입출력을 확인합니다.

Kiyoung-Kim-57 and others added 8 commits December 2, 2024 18:40
- allowBluetooth 옵션으로 블루투스 기기의 입출력을 지원합니다.
- allowAirplay 옵션으로 에어 플레이 기기의 출력을 지원합니다.

Co-Authored-By: Youngkyu Song <[email protected]>
- AudioTrack의 isEnabled가 오디오 송출을 결정하는 속성인데 해당 부분을 바꿔주는 방식으로 메서드를 설정했습니다.
- 기존에 audioTrack을 생성해서 PeerConnection에 add해주고 따로 WebRTCService가 audioTrack을 가지고 있진 않았는데 마이크 음소거를 위해 가지고 있을 수 있게 했습니다.
- ConnectionClient에 WebRTC의 AudioTrack 설정을 바꿀 수 있는 메서드를 생성했습니다.
…변경 메서드 구현

- ConnectionRepository에서 ConnectionClients의 AudioTrack 상태 변경 메서드 구현했습니다.
- 변경 후 AudioTrack isEnabled 값을 Publisher를 통해 보내고 있습니다.
- didChangeLocalAudioTrackStateSubject는 현재 isEnabled 값을 보관하고 있습니다.
- 뷰모델에서 마이크 버튼 input을 받고 수행할 메서드를 구현
- UseCase에서 오는 MicState Bool 값을 가지고 마이크 버튼 형태를 바꿀 수 있도록 리팩토링, 실제 isEnable 값에 따라 마이크 상태가 변경되는 것이 좀 더 안정적이라고 판단
- toggle -> change로 네이밍 변경
- WebScoket -> WebSocket 오타 수정
- Lcoal -> Local 오타 수정
- photoRoomViewModel에 의존성 주입
@Kiyoung-Kim-57 Kiyoung-Kim-57 added the ✨ feat 새로운 기능 추가 label Dec 2, 2024
@Kiyoung-Kim-57 Kiyoung-Kim-57 self-assigned this Dec 2, 2024
@Kiyoung-Kim-57 Kiyoung-Kim-57 linked an issue Dec 2, 2024 that may be closed by this pull request
Copy link
Member

@youn9k youn9k left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!! 이렇게 빨리 만드시다니..

Copy link
Collaborator

@0Hooni 0Hooni left a comment

Choose a reason for hiding this comment

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

LGTML 👍

수고 많으셨습니다!!

Copy link
Collaborator

@hsw1920 hsw1920 left a comment

Choose a reason for hiding this comment

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

LGTM!

@Kiyoung-Kim-57 Kiyoung-Kim-57 merged commit 92b5e78 into develop Dec 3, 2024
1 check passed
@0Hooni 0Hooni linked an issue Dec 4, 2024 that may be closed by this pull request
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ feat 새로운 기능 추가

Projects

None yet

Development

Successfully merging this pull request may close these issues.

마이크 상태를 변경할 수 있다 마이크 뮤트 기능을 추가합니다.

5 participants