srs.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import {SrsRTC } from './SrsRTC.js';
  2. import { Connection } from './connection.js';
  3. const sdk = new SrsRTC();
  4. const testConfig ={
  5. userId: '11111',
  6. roomId: '111',
  7. }
  8. const connection =new Connection(testConfig);
  9. console.log('sdk',sdk)
  10. console.log('sdk',connection)
  11. connection.socket.emit('pushVideo',{
  12. videoList:['0-1-0'],
  13. videoId: 'mini'
  14. })
  15. connection.socket.on('getVideo',(videoId)=>{
  16. console.log('getVideo',videoId)
  17. if(videoId){
  18. const steamUrl ='webrtc://demo-kms.4dage.com/live/' + videoId
  19. getVideo(steamUrl)
  20. }
  21. })
  22. const getVideo =(videoUrl)=>{
  23. $('#testVideoFeed').prop('srcObject', sdk.stream);
  24. sdk.getVideo(videoUrl).then(function(session){
  25. console.log('session',session.sessionid)
  26. }).catch(function (reason) {
  27. console.error(reason);
  28. })
  29. }
  30. // sdk.pc.ondatachannel = function(ev) {
  31. // console.log('Data channel is created!');
  32. // ev.channel.onopen = function() {
  33. // console.log('Data channel is open and ready to be used.');
  34. // };
  35. // };