1+ import Gst from '@girs/node-gst-1.0' ;
12import { describe , expect , it } from 'vitest' ;
23import {
4+ dePacketizeRtpPackets ,
5+ deserializeAudioLevelIndication ,
6+ serializeAudioLevelIndication ,
7+ } from 'werift' ;
8+
9+ import {
10+ MediaStreamTrackFactory ,
311 RemoteVideoStream ,
12+ RoomPublication ,
413 RtpPacket ,
514 SkyWayContext ,
615 SkyWayRoom ,
7- MediaStreamTrackFactory ,
816 SkyWayStreamFactory ,
9- RoomPublication ,
1017} from '../../packages/room/src' ;
11-
12- import Gst from '@girs/node-gst-1.0' ;
1318import { testTokenString } from './fixture' ;
14- import {
15- dePacketizeRtpPackets ,
16- deserializeAudioLevelIndication ,
17- serializeAudioLevelIndication ,
18- } from 'werift' ;
1919
2020const gst = require ( 'node-gtk' ) . require ( 'Gst' , '1.0' ) as typeof Gst ;
2121gst . init ( [ ] ) ;
@@ -26,15 +26,15 @@ describe('loopback', () => {
2626 const context = await SkyWayContext . Create ( testTokenString , {
2727 codecCapabilities : [ { mimeType : 'audio/opus' } ] ,
2828 } ) ;
29+ SkyWayStreamFactory . registerNodeGtkGst ( gst ) ;
2930 const room = await SkyWayRoom . Create ( context , {
3031 type : 'sfu' ,
3132 } ) ;
3233 console . log ( 'roomId' , room . id ) ;
3334 const sender = await room . join ( ) ;
3435
35- const [ track , port , disposer ] = await MediaStreamTrackFactory . rtpSource ( {
36- kind : 'audio' ,
37- cb : ( buf ) => {
36+ const disposer = await SkyWayStreamFactory . registerGstAudio ( {
37+ rtpProcessor : ( buf ) => {
3838 const rtp = RtpPacket . deSerialize ( buf ) ;
3939 rtp . header . extension = true ;
4040 rtp . header . extensions . push ( {
@@ -44,11 +44,6 @@ describe('loopback', () => {
4444 return rtp . serialize ( ) ;
4545 } ,
4646 } ) ;
47- const launch = gst . parseLaunch (
48- `audiotestsrc wave=ticks ! audioconvert ! audioresample ! queue ! opusenc ! rtpopuspay ! udpsink host=127.0.0.1 port=${ port } `
49- ) ;
50- launch . setState ( gst . State . PLAYING ) ;
51- SkyWayStreamFactory . registerMediaDevices ( { audio : track } ) ;
5247
5348 const publication = await sender . publish (
5449 await SkyWayStreamFactory . createMicrophoneAudioStream ( )
@@ -69,7 +64,6 @@ describe('loopback', () => {
6964 console . log ( 'audioLevel' , p ) ;
7065 await room . close ( ) ;
7166 context . dispose ( ) ;
72- launch . setState ( gst . State . NULL ) ;
7367 disposer ( ) ;
7468 done ( ) ;
7569 }
@@ -157,21 +151,15 @@ describe('loopback', () => {
157151 ] ,
158152 rtcConfig : { turnPolicy : 'disable' } ,
159153 } ) ;
154+ SkyWayStreamFactory . registerNodeGtkGst ( gst ) ;
155+
160156 const room = await SkyWayRoom . Create ( context , {
161157 type : 'sfu' ,
162158 } ) ;
163159 console . log ( 'roomId' , room . id ) ;
164160 const sender = await room . join ( ) ;
165161
166- const [ track , port , disposer ] = await MediaStreamTrackFactory . rtpSource ( {
167- kind : 'video' ,
168- } ) ;
169- const launch = gst . parseLaunch (
170- `videotestsrc ! video/x-raw,width=640,height=480,format=I420 ! x264enc key-int-max=60 ! rtph264pay ! udpsink host=127.0.0.1 port=${ port } `
171- ) ;
172- launch . setState ( gst . State . PLAYING ) ;
173- SkyWayStreamFactory . registerMediaDevices ( { video : track } ) ;
174-
162+ const disposer = await SkyWayStreamFactory . registerGstVideo ( ) ;
175163 const publication = await sender . publish (
176164 await SkyWayStreamFactory . createCameraVideoStream ( )
177165 ) ;
@@ -191,7 +179,6 @@ describe('loopback', () => {
191179
192180 await room . close ( ) ;
193181 context . dispose ( ) ;
194- launch . setState ( gst . State . NULL ) ;
195182 disposer ( ) ;
196183 done ( ) ;
197184 }
0 commit comments