Publish audio only and publish video only

hi
i have two function that one of them publish audio only and one of them publish video only
but i get this errors when i call both of them

jsonrpcclient.js:173 ERROR:org.kurento.client.internal.server.KurentoServerException:Endpoint already negotiated (Code:40208, Type:null, Data: {“type”:“SDP_END_POINT_ALREADY_NEGOTIATED”}) in Request: method:publishVideo params:{“doLoopback”:false,“hasAudio”:false,“hasVideo”:true,“videoActive”:true,“typeOfVideo”:“CAMERA”,“frameRate”:-1,“videoDimensions”:"{“width”:640,“height”:480}",“sdpOffer”:“v=0\r\no=- 2856961965171772600 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=msid-semantic: WMS TPF8x5CIhfKNMs57A2nxhTApBpkCwUpWqSlS\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125 107 108 109 124 120 123 119 114 115 116\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:M4HG\r\na=ice-pwd:Lrb24v8mo5LZAlNwQGgTRU5v\r\na=ice-options:trickle\r\na=fingerprint:sha-256 F5:76:4C:A7:60:89:D1:12:EA:A0:1D:DC:F8:6F:33:63:50:EA:BC:16:F1:16:84:01:4F:13:F3:CE:AD:6F:DE:BC\r\na=setup:actpass\r\na=mid:0\r\na=extmap:14 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:13 urn:3gpp:video-orientation\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:12 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:11 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:8 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07\r\na=extmap:9 http://www.webrtc.org/experiments/rtp-hdrext/color-space\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id\r\na=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id\r\na=sendonly\r\na=msid:TPF8x5CIhfKNMs57A2nxhTApBpkCwUpWqSlS 655ccdfd-b10e-4be0-99f7-83190293a3f7\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 profile-id=0\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98\r\na=rtpmap:100 VP9/90000\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=fmtp:100 profile-id=2\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\r\na=rtcp-fb:102 transport-cc\r\na=rtcp-fb:102 ccm fir\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f\r\na=rtpmap:122 rtx/90000\r\na=fmtp:122 apt=102\r\na=rtpmap:127 H264/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f\r\na=rtpmap:121 rtx/90000\r\na=fmtp:121 apt=127\r\na=rtpmap:125 H264/90000\r\na=rtcp-fb:125 goog-remb\r\na=rtcp-fb:125 transport-cc\r\na=rtcp-fb:125 ccm fir\r\na=rtcp-fb:125 nack\r\na=rtcp-fb:125 nack pli\r\na=fmtp:125 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=125\r\na=rtpmap:108 H264/90000\r\na=rtcp-fb:108 goog-remb\r\na=rtcp-fb:108 transport-cc\r\na=rtcp-fb:108 ccm fir\r\na=rtcp-fb:108 nack\r\na=rtcp-fb:108 nack pli\r\na=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f\r\na=rtpmap:109 rtx/90000\r\na=fmtp:109 apt=108\r\na=rtpmap:124 H264/90000\r\na=rtcp-fb:124 goog-remb\r\na=rtcp-fb:124 transport-cc\r\na=rtcp-fb:124 ccm fir\r\na=rtcp-fb:124 nack\r\na=rtcp-fb:124 nack pli\r\na=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d001f\r\na=rtpmap:120 rtx/90000\r\na=fmtp:120 apt=124\r\na=rtpmap:123 H264/90000\r\na=rtcp-fb:123 goog-remb\r\na=rtcp-fb:123 transport-cc\r\na=rtcp-fb:123 ccm fir\r\na=rtcp-fb:123 nack\r\na=rtcp-fb:123 nack pli\r\na=fmtp:123 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f\r\na=rtpmap:119 rtx/90000\r\na=fmtp:119 apt=123\r\na=rtpmap:114 red/90000\r\na=rtpmap:115 rtx/90000\r\na=fmtp:115 apt=114\r\na=rtpmap:116 ulpfec/90000\r\na=ssrc-group:FID 1794402681 3294728228\r\na=ssrc:1794402681 cname:s5J9A7JdVqF7bBYw\r\na=ssrc:1794402681 msid:TPF8x5CIhfKNMs57A2nxhTApBpkCwUpWqSlS 655ccdfd-b10e-4be0-99f7-83190293a3f7\r\na=ssrc:1794402681 mslabel:TPF8x5CIhfKNMs57A2nxhTApBpkCwUpWqSlS\r\na=ssrc:1794402681 label:655ccdfd-b10e-4be0-99f7-83190293a3f7\r\na=ssrc:3294728228 cname:s5J9A7JdVqF7bBYw\r\na=ssrc:3294728228 msid:TPF8x5CIhfKNMs57A2nxhTApBpkCwUpWqSlS 655ccdfd-b10e-4be0-99f7-83190293a3f7\r\na=ssrc:3294728228 mslabel:TPF8x5CIhfKNMs57A2nxhTApBpkCwUpWqSlS\r\na=ssrc:3294728228 label:655ccdfd-b10e-4be0-99f7-83190293a3f7\r\n”} request:undefined
(anonymous) @ jsonrpcclient.js:173
dispatchCallback @ index.js:614
processResponse @ index.js:745
RpcBuilder.decode @ index.js:806
transportMessage @ index.js:225
jsonrpcclient.js:177 ERROR DATA:“org.kurento.client.internal.server.KurentoServerException: Endpoint already negotiated (Code:40208, Type:null, Data: {“type”:“SDP_END_POINT_ALREADY_NEGOTIATED”})\n\tat org.kurento.client.internal.transport.jsonrpc.RomClientJsonRpcClient.sendRequest(RomClientJsonRpcClient.java:264)\n\tat org.kurento.client.internal.transport.jsonrpc.RomClientJsonRpcClient.invoke(RomClientJsonRpcClient.java:117)\n\tat org.kurento.client.internal.transport.jsonrpc.RomClientJsonRpcClient.invoke(RomClientJsonRpcClient.java:99)\n\tat org.kurento.client.internal.client.RomManager.invoke(RomManager.java:162)\n\tat org.kurento.client.internal.client.RemoteObject.invoke(RemoteObject.java:186)\n\tat org.kurento.client.internal.client.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:182)\n\tat org.kurento.client.internal.client.RemoteObjectInvocationHandler.internalInvoke(RemoteObjectInvocationHandler.java:142)\n\tat org.kurento.client.internal.client.DefaultInvocationHandler.invoke(DefaultInvocationHandler.java:39)\n\tat com.sun.proxy.$Proxy83.processOffer(Unknown Source)\n\tat io.openvidu.server.kurento.endpoint.MediaEndpoint.processOffer(MediaEndpoint.java:481)\n\tat io.openvidu.server.kurento.endpoint.PublisherEndpoint.publish(PublisherEndpoint.java:207)\n\tat io.openvidu.server.kurento.core.KurentoParticipant.publishToRoom(KurentoParticipant.java:177)\n\tat io.openvidu.server.kurento.core.KurentoSessionManager.publishVideo(KurentoSessionManager.java:398)\n\tat io.openvidu.server.rpc.RpcHandler.publishVideo(RpcHandler.java:328)\n\tat io.openvidu.server.rpc.RpcHandler.handleRequest(RpcHandler.java:124)\n\tat org.kurento.jsonrpc.internal.JsonRpcHandlerManager.handleRequest(JsonRpcHandlerManager.java:142)\n\tat org.kurento.jsonrpc.internal.server.ProtocolManager$3.run(ProtocolManager.java:218)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\n”
(anonymous) @ jsonrpcclient.js:177
dispatchCallback @ index.js:614
processResponse @ index.js:745
RpcBuilder.decode @ index.js:806
transportMessage @ index.js:225
Session.ts:383 Uncaught (in promise) Error on publishVideo: {“code”:-1,“message”:“org.kurento.client.internal.server.KurentoServerException:Endpoint already negotiated (Code:40208, Type:null, Data: {“type”:“SDP_END_POINT_ALREADY_NEGOTIATED”})”,“data”:“org.kurento.client.internal.server.KurentoServerException: Endpoint already negotiated (Code:40208, Type:null, Data: {“type”:“SDP_END_POINT_ALREADY_NEGOTIATED”})\n\tat org.kurento.client.internal.transport.jsonrpc.RomClientJsonRpcClient.sendRequest(RomClientJsonRpcClient.java:264)\n\tat org.kurento.client.internal.transport.jsonrpc.RomClientJsonRpcClient.invoke(RomClientJsonRpcClient.java:117)\n\tat org.kurento.client.internal.transport.jsonrpc.RomClientJsonRpcClient.invoke(RomClientJsonRpcClient.java:99)\n\tat org.kurento.client.internal.client.RomManager.invoke(RomManager.java:162)\n\tat org.kurento.client.internal.client.RemoteObject.invoke(RemoteObject.java:186)\n\tat org.kurento.client.internal.client.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:182)\n\tat org.kurento.client.internal.client.RemoteObjectInvocationHandler.internalInvoke(RemoteObjectInvocationHandler.java:142)\n\tat org.kurento.client.internal.client.DefaultInvocationHandler.invoke(DefaultInvocationHandler.java:39)\n\tat com.sun.proxy.$Proxy83.processOffer(Unknown Source)\n\tat io.openvidu.server.kurento.endpoint.MediaEndpoint.processOffer(MediaEndpoint.java:481)\n\tat io.openvidu.server.kurento.endpoint.PublisherEndpoint.publish(PublisherEndpoint.java:207)\n\tat io.openvidu.server.kurento.core.KurentoParticipant.publishToRoom(KurentoParticipant.java:177)\n\tat io.openvidu.server.kurento.core.KurentoSessionManager.publishVideo(KurentoSessionManager.java:398)\n\tat io.openvidu.server.rpc.RpcHandler.publishVideo(RpcHandler.java:328)\n\tat io.openvidu.server.rpc.RpcHandler.handleRequest(RpcHandler.java:124)\n\tat org.kurento.jsonrpc.internal.JsonRpcHandlerManager.handleRequest(JsonRpcHandlerManager.java:142)\n\tat org.kurento.jsonrpc.internal.server.ProtocolManager$3.run(ProtocolManager.java:218)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\n”,“requestTime”:1599025084516}

I think the error is pretty clear. You can’t republish a stream track.

How are you publishing the audio and video?

i copied the code here.
https://js.do/code/sdcksjcn

Please, copy your code well formatted. It’s difficult to read.

Before publish a new publisher, you have to unpublish the publisher published.

Please, read the docs https://docs.openvidu.io/en/2.15.0/cheatsheet/publish-unpublish/

but i want the publisher could publish many media
for example the screen and the audio and the webcam

You can. But you must initialize a new Connection for the same client: each Publisher requires its own connection. Genreate a new token to be used to call a second time Session.connect(TOKEN), and then call Session.publish() for the new Publisher.

i want the user can publish three time and you said i should take token for each publish
and i should get three token for each user?

If you want each final user to be able to publish 3 times, then you will need to establish 3 different connections to OpenVidu for the same browser. That requires 3 different tokens, yes. OpenVidu Call application works in this way to be able to publish both webcam and screenshare at the same time: https://demos.openvidu.io/openvidu-call/#/

1 Like