본문 바로가기

프로그래밍/WebRTC

(8)
[WebRTC] peerConnection.statistics() 중 자주 확인하는 데이터 매번 키와 필드를 찾는게 구찮아서 일단 자주사용하는 webrtc 통계 데이터 샘플로 정리해 둠. 연결 관련 데이터 peer-connection id: "RTCPeerConnection" type: "peer-connection" timeStamp: 1655703464253039.0 values: [ "dataChannelsClosed": 0 "dataChannelsOpened": 1 ] data-channel id: "RTCDataChannel_2" type: "data-channel" timeStamp: 1655703464253039.0 values: [ "bytesSent": 12410 "messagesReceived": 9 "messagesSent": 3 "state": open "label": d..
[WebRTC] 안드로이드 I420 Buffer관련 클래스 WebRTC 에서는 VideoFrame을 위해 TextureBuffer와 I420Buffer를 사용. I420Buffer는 Buffer 클래스를 상속받은 클래스이며, Buffer 는 네이티브(jni) 라이브러리에게 버퍼의 크기나 포인터를 알려주는 역할이며, I420Buffer는 YUV 포인터의 위치를 전달하는 역할을 하게된다. TextureBuffer 일반 rgb bitmap 이미지를 VideoFrame으로 변경하려면 대략 아래처럼 처리가 이루어진다. // 텍스처 생성 int[] textures = new int[1]; GLES20.glGenTextures(1, textures, 0); // TextureBuffer 생성 Matrix transform = new Matrix(); YuvConverter ..
[WebRTC] android camera 관련 webrtc의 카메라 캡처러 부분은 아래와 같은 구조로 여러 카메라 api에 대응하도록 설계되어 있다. enumerator 의 createCapturer() 를 호출해 CameraVideoCapturer 를 생성 camera2enumerator 의 경우 Camera2Capturer 를 생성 CameraCapturer 의 startCapture() 를 호출하면 Camera2Capturer의 createCameraSession() 호출 실제 카메라 처리 부분은 CameraSession 에서 이루어지며, 캡처된 데이터는 opengl es 를 통해 렌더링 되어 CameraCapturer 에 구현되어 있는 CameraSession.Events.onFrameCaptured() 콜백으로 VideoFrame을 전달한다..
[WebRTC] 사이멀캐스트? 네이티브를 위한 레거시 simulcast * 개인적으로 simulcast를 위한 iOS, Android 클라이언트를 구성하면서 판단한 경험에 대한 내용이라 실제 표준과 다를 수 있습니다. * 추가) 레거시 planB 는 2021년 12월말에 크롬에서 삭제될 예정 현재 웹 환경(브라우저)에서 지원하는 simulcast의 경우 unified plan기반으로 tranceiver 를 사용해 불필요한 SDP 정의를 최소화하는 것으로 변화되었다. 별다른 설정없이 tranceiver 설정에 encoding parameter만 설정하면, SDP 에 아래와 같은 문자열이 추가된다. a=rid:label1 send a=simulcast:send label1;lable2;label3 webrtc 라이브러리는 로컬, 리모트 SDP가 위와 같이 설정되면 로컬 송출 트..
[WebRTC] iOS Audio 관련 클래스 RTCPeerConnectionFactory sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm webrtc peer connection 객체를 생성하는 factory 클래스, init 시에 비디오 encoder, decoder factory 를 설정하고, audio device module 을 생성한다. 아래 함수를 통해 audio device module을 설정하게 된다. #if defined(WEBRTC_IOS) #import "sdk/objc/native/api/audio_device_module.h" #endif - (rtc::scoped_refptr)audioDevicdeModule { #if defined(WEBRTC_IOS) return we..
[WebRTC] Android SurfaceTextureHelper WebRTC 에서 미디어 스트림 생성시 트랙을 생성하게 되는데, 비디오 트랙의 경우 surface texture helper 를 사용해 VideoFrame 이라는 버퍼를 전달할 수 있도록 되어있다. Camera1Session, Camera2Session 에서 startListening() 으로 카메라 데이터 수신을 위한 루프를 동작시키고, 이 루프에서는 주기적으로 SurfaceTexture의 updateTexImage()를 호출해 새로운 데이터를 가져오도록 한다. 처리순서 1. 텍스처 생성 : oes 타입 텍스처 2. 서피스 텍스처 생성 : 텍스처로부터 surface texture를 생성 3. 해당 서피스 텍스처를 카메라 모듈등의 output으로 전달 4. surface texture 의 onFrameA..
WebRTC iOS 기본 플로우 코드 관련 프로퍼티 // RTCPeerConnection // factory를 생성한 후에 factory에서 peer connection을 생성하는 구조 // factory 생성시에는 인코더, 디코더 필요 var factory:RTCPeerConnectionFactory var peerConnection:RTCPeerConnection // encoder, decoder var encoderFactory:RTCDefaultVideoEncoderFactory var decoderFactory:RTCDefaultVideoDecoderFactory // delegate var delegate:RTCPeerConnectionDelegate // 카메라 캡처 var localVideoCapturer:RTCCameraV..
WebRTC native build https://webrtc.org/native-code/ WebRTC Native Code | WebRTC webrtc.org 공통 git openJDK : openjdk-7-jdk python 2.7 : python2.7 depot tools git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git fetch : gclient 랩퍼 gclient : checkout 도구 git_cl : 코드리뷰 도구 roll-dep : gclient 기반 관리 도구 gn ninja gclient or gclient.bat을 실행하면 git, python등 필요한 패키지들이 설치됨 depot_tools 경로 추가 export PATH=$PATH..