jikjoo / Bangul_webOS

"차량용 스마트 펫케어 서비스 : 방울이가타고있어요"의 차량용 소프트웨어입니다
MIT License
2 stars 1 forks source link

webOS 마이크 입력, 스피커 출력 #21

Closed jikjoo closed 4 years ago

jikjoo commented 4 years ago

https://forum.webosose.org/t/how-to-get-the-microphone-raw-data/1154

마이크 사용하는 API는 따로 없고, parecord 사용하면 된다는데 확인필요

We don't have any API to record audio data via mic. Instead, you can use below pulseaudio utility to record audio data through mic. parecord /tmp/rec_file.wav --device=precord Thanks!


에뮬레이터 테스트 결과 입력 잘 됬음

jikjoo commented 4 years ago

마이크 입력이 잘 된다는 가정하에, https://www.webosose.org/docs/tutorials/native-services/developing-external-native-services/ 여기서 LS2 API com.bangul.microphone.service 만들어서 프런트에 적용시켜보기

jikjoo commented 4 years ago

C언어로 parecord 실행시키고 .wav 파일 읽어서 음성파일 결과 반환해주기

https://www.raspberrypi.org/forums/viewtopic.php?t=177612

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <dirent.h>
...
        int ppid;
        int status;
        FILE *fptr;
        char c;
 if ((ppid=fork())==0)
      {
         printf("Child process\n");
         execlp("bash","bash","./your_shell_script.sh","",NULL);
         return; //terminates child process
      }

      //does this block? YES!
//      printf("Parent process %d\n",ppid);
      wait(&status);

해보고 안되면, system() or popen() 사용해보기

jikjoo commented 4 years ago

native-service 환경설정이 리눅스가 필요한 관계로 복잡해서,

https://www.webosose.org/docs/reference/ls2-api/com-webos-service-audio/#example-23

luna://com.webos.service.audio/state/pulse/sinkStatus '{"sink" : "pmedia"}'

로 음성 스트리밍 가능한지 확인해보기

jikjoo commented 4 years ago

에뮬레이터에서 appr.tc로 확인해본 결과, 특별한 설정을 하지 않아도

내 목소리가 아이패드로 가는 것을 확인함. 화면은 가지 않음. 카메라 설정이 안 되어있어서 그런거같음

반대로 아이패드에서 에뮬레이터로 화면과 함께 목소리가 가는것도 확인함.

따라서, 우선 webRTC 지원하는 코드를 만들어서 확인해보는 것이 필요.

// AppRTC 내부 코드 일부
    var loadingParams = {
      errorMessages: [],
      isLoopback: false,
      warningMessages: [],

      roomId: '713631343',
      roomLink: 'https://appr.tc/r/713631343',

      mediaConstraints: {"audio": true, "video": {"optional": [{"minWidth": "1280"}, {"minHeight": "720"}], "mandatory": {}}},
      offerOptions: {},
      peerConnectionConfig: {"rtcpMuxPolicy": "require", "bundlePolicy": "max-bundle", "iceServers": []},
      peerConnectionConstraints: {"optional": []},
      iceServerRequestUrl: 'https://networktraversal.googleapis.com/v1alpha/iceconfig?key=AIzaSyArJnQRd2kEen3RoVrsQOLxP1TnJJ-y8d8',
      iceServerTransports: '',
      wssUrl: 'wss://apprtc-ws.webrtc.org:443/ws',
      wssPostUrl: 'https://apprtc-ws.webrtc.org:443',
      bypassJoinConfirmation: false,
      versionInfo: {"gitHash": "462e24600a071c55cb8ff34f1a596b54d0927c70", "branch": "master", "time": "Thu Jun 18 10:29:32 2020 +0200"},
    };

    var appController;

    function initialize() {
      // We don't want to continue if this is triggered from Chrome prerendering,
      // since it will register the user to GAE without cleaning it up, causing
      // the real navigation to get a "full room" error. Instead we'll initialize
      // once the visibility state changes to non-prerender.
      if (document.visibilityState === 'prerender') {
        document.addEventListener('visibilitychange', onVisibilityChange);
        return;
      }
      appController = new AppController(loadingParams);
    }

    function onVisibilityChange() {
      if (document.visibilityState === 'prerender') {
        return;
      }
      document.removeEventListener('visibilitychange', onVisibilityChange);
      initialize();
    }

    initialize();
jikjoo commented 4 years ago

web RTC 마이크 입력 문제

getUserMedia 'not found' 에러

https://github.com/webosose/test-apps/blob/master/com.webos.app.test.webrtc/appinfo.json

com.webos.app.test.webrtc (Test Web RTC)에서 찾은건데,

"allowVideoCapture": true,
"allowAudioCapture": true

다른 test app과는 달리 appinfo.json에 있었음. web browser app에서는 마찬가지로 마이크 인식 못함.

appinfo.json 바꿔서 시도해봤는데 결과는 똑같았음. ares-package의 문제일 수 있을거같아서 찾아보는 중

jikjoo commented 4 years ago

webrtc test app 똑같이 깔아서 음성테스트해봤는데, 이미 깔려있는 버전처럼 마이크 입력이 안 들어오는 거 같음.

CLI를 업데이트 해봐야겠음

jikjoo commented 4 years ago

ares-cli 1.12버전으로 업데이트 하니,

{
  "id": "com.bangul.app.webos",
  "version": "1.0.0",
  "vendor": "LGE-SVL",
  "type": "web",
  "main": "index.html",
  "title": "방울이가 타고있어요",
  "icon": "icon.png",
  "miniicon": "icon-mini.png",
  "largeIcon": "icon-large.png",
  "uiRevision": 2,
  "allowAudioCapture": true,
  "allowVideoCapture": true
}

allowAudioCapture가 먹혀서 마이크까지 작동함.