@@ -693,4 +693,63 @@ describe('Call', function() {
693693 expect ( supportsMatrixCall ( ) ) . toBe ( false ) ;
694694 } ) ;
695695 } ) ;
696+
697+ describe ( "should ignore streams with ids for which we already have a feed" , ( ) => {
698+ const STREAM_ID = "stream_id" ;
699+ const FEEDS_CHANGED_CALLBACK = jest . fn ( ) ;
700+
701+ beforeEach ( async ( ) => {
702+ await startVoiceCall ( client , call ) ;
703+ call . on ( CallEvent . FeedsChanged , FEEDS_CHANGED_CALLBACK ) ;
704+ jest . spyOn ( call , "pushLocalFeed" ) ;
705+ } ) ;
706+
707+ afterEach ( ( ) => {
708+ FEEDS_CHANGED_CALLBACK . mockReset ( ) ;
709+ } ) ;
710+
711+ it ( "pushRemoteFeed()" , async ( ) => {
712+ await call . onAnswerReceived ( {
713+ getContent : ( ) => {
714+ return {
715+ version : 1 ,
716+ call_id : call . callId ,
717+ party_id : 'party_id' ,
718+ answer : {
719+ sdp : DUMMY_SDP ,
720+ } ,
721+ [ SDPStreamMetadataKey ] : {
722+ [ STREAM_ID ] : {
723+ purpose : SDPStreamMetadataPurpose . Usermedia ,
724+ } ,
725+ } ,
726+ } ;
727+ } ,
728+ } ) ;
729+
730+ call . pushRemoteFeed ( new MockMediaStream ( STREAM_ID ) ) ;
731+ call . pushRemoteFeed ( new MockMediaStream ( STREAM_ID ) ) ;
732+
733+ expect ( call . getRemoteFeeds ( ) . length ) . toBe ( 1 ) ;
734+ expect ( FEEDS_CHANGED_CALLBACK ) . toHaveBeenCalledTimes ( 1 ) ;
735+ } ) ;
736+
737+ it ( "pushRemoteFeedWithoutMetadata()" , async ( ) => {
738+ call . pushRemoteFeedWithoutMetadata ( new MockMediaStream ( STREAM_ID ) ) ;
739+ call . pushRemoteFeedWithoutMetadata ( new MockMediaStream ( STREAM_ID ) ) ;
740+
741+ expect ( call . getRemoteFeeds ( ) . length ) . toBe ( 1 ) ;
742+ expect ( FEEDS_CHANGED_CALLBACK ) . toHaveBeenCalledTimes ( 1 ) ;
743+ } ) ;
744+
745+ it ( "pushNewLocalFeed()" , async ( ) => {
746+ call . pushNewLocalFeed ( new MockMediaStream ( STREAM_ID ) , SDPStreamMetadataPurpose . Screenshare ) ;
747+ call . pushNewLocalFeed ( new MockMediaStream ( STREAM_ID ) , SDPStreamMetadataPurpose . Screenshare ) ;
748+
749+ // We already have one local feed from placeVoiceCall()
750+ expect ( call . getLocalFeeds ( ) . length ) . toBe ( 2 ) ;
751+ expect ( FEEDS_CHANGED_CALLBACK ) . toHaveBeenCalledTimes ( 1 ) ;
752+ expect ( call . pushLocalFeed ) . toHaveBeenCalled ( ) ;
753+ } ) ;
754+ } ) ;
696755} ) ;
0 commit comments