<div dir="ltr">Hi, I've been trying to get the code below to work. In the past I've been able to have my python code make an offer and the browser answer, but now I want to make the relationship the other way for a couple of reasons<br><br><div style="color:rgb(204,204,204);background-color:rgb(31,31,31);font-family:"Droid Sans Mono","monospace",monospace;font-size:14px;line-height:19px;white-space:pre"><div><span style="color:rgb(197,134,192)">import</span> <span style="color:rgb(78,201,176)">boto3</span></div><div><span style="color:rgb(197,134,192)">import</span> <span style="color:rgb(78,201,176)">websocket</span></div><div><span style="color:rgb(197,134,192)">import</span> <span style="color:rgb(78,201,176)">ssl</span></div><div><span style="color:rgb(197,134,192)">import</span> <span style="color:rgb(78,201,176)">threading</span></div><div><span style="color:rgb(197,134,192)">import</span> <span style="color:rgb(78,201,176)">queue</span></div><div><span style="color:rgb(197,134,192)">import</span> <span style="color:rgb(78,201,176)">enum</span></div><div><span style="color:rgb(197,134,192)">import</span> <span style="color:rgb(78,201,176)">gi</span></div><div><span style="color:rgb(197,134,192)">import</span> <span style="color:rgb(78,201,176)">json</span></div><div><span style="color:rgb(197,134,192)">import</span> <span style="color:rgb(78,201,176)">base64</span></div><br><div><span style="color:rgb(197,134,192)">from</span> <span style="color:rgb(78,201,176)">sign_url</span> <span style="color:rgb(197,134,192)">import</span> <span style="color:rgb(78,201,176)">SigV4RequestSigner</span></div><br><div><span style="color:rgb(78,201,176)">gi</span>.<span style="color:rgb(220,220,170)">require_version</span>(<span style="color:rgb(206,145,120)">"Gst"</span>, <span style="color:rgb(206,145,120)">"1.0"</span>)</div><div><span style="color:rgb(197,134,192)">from</span> <span style="color:rgb(78,201,176)">gi</span>.<span style="color:rgb(78,201,176)">repository</span> <span style="color:rgb(197,134,192)">import</span> Gst</div><br><div><span style="color:rgb(78,201,176)">gi</span>.<span style="color:rgb(220,220,170)">require_version</span>(<span style="color:rgb(206,145,120)">"GstWebRTC"</span>, <span style="color:rgb(206,145,120)">"1.0"</span>)</div><div><span style="color:rgb(197,134,192)">from</span> <span style="color:rgb(78,201,176)">gi</span>.<span style="color:rgb(78,201,176)">repository</span> <span style="color:rgb(197,134,192)">import</span> GstWebRTC</div><br><div><span style="color:rgb(78,201,176)">gi</span>.<span style="color:rgb(220,220,170)">require_version</span>(<span style="color:rgb(206,145,120)">"GstSdp"</span>, <span style="color:rgb(206,145,120)">"1.0"</span>)</div><div><span style="color:rgb(197,134,192)">from</span> <span style="color:rgb(78,201,176)">gi</span>.<span style="color:rgb(78,201,176)">repository</span> <span style="color:rgb(197,134,192)">import</span> GstSdp</div><br><br><div><span style="color:rgb(86,156,214)">class</span> <span style="color:rgb(78,201,176)">EventType</span>(<span style="color:rgb(78,201,176)">enum</span>.<span style="color:rgb(78,201,176)">Enum</span>):</div><div> <span style="color:rgb(79,193,255)">UNKNOWN</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(206,145,120)">"UNKNOWN"</span></div><div> <span style="color:rgb(79,193,255)">INIT</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(206,145,120)">"INIT"</span></div><div> <span style="color:rgb(79,193,255)">CONNECT_SIGNAL_CHANNEL</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(206,145,120)">"CONNECT_SIGNAL_CHANNEL"</span></div><div> <span style="color:rgb(79,193,255)">SIGNAL_MESSAGE_SDP_OFFER</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(206,145,120)">"SIGNAL_MESSAGE_SDP_OFFER"</span></div><div> <span style="color:rgb(79,193,255)">SIGNAL_ERROR</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(206,145,120)">"SIGNAL_ERROR"</span></div><div> <span style="color:rgb(79,193,255)">SIGNAL_CLOSE</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(206,145,120)">"SIGNAL_CLOSE"</span></div><div> <span style="color:rgb(79,193,255)">SIGNAL_OPEN</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(206,145,120)">"SIGNAL_OPEN"</span></div><div> <span style="color:rgb(79,193,255)">ANSWER_CREATED</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(206,145,120)">"ANSWER_CREATED"</span></div><div> <span style="color:rgb(79,193,255)">SEND_ICE_CANDIDATE</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(206,145,120)">"SEND_ICE_CANDIDATE"</span></div><div> <span style="color:rgb(79,193,255)">NEGOTIATION_NEEDED</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(206,145,120)">"NEGOTIATION_NEEDED"</span></div><br><br><div><span style="color:rgb(86,156,214)">class</span> <span style="color:rgb(78,201,176)">VideoService</span>:</div><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">__init__</span>(<span style="color:rgb(156,220,254)">self</span>, <span style="color:rgb(156,220,254)">region</span>, <span style="color:rgb(156,220,254)">channel_arn</span>, <span style="color:rgb(156,220,254)">pipeline_description</span>):</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">event_queue</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(78,201,176)">queue</span>.<span style="color:rgb(78,201,176)">Queue</span>()</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">client_id</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(86,156,214)">None</span></div><br><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">region</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">region</span></div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">channel_arn</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">channel_arn</span></div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">pipeline_description</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">pipeline_description</span></div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">pipeline</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(86,156,214)">None</span></div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">appsrc</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(86,156,214)">None</span></div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">webrtc</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(86,156,214)">None</span></div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">connect_signal_channel</span>(<span style="color:rgb(156,220,254)">self</span>):</div><div> <span style="color:rgb(156,220,254)">client</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(78,201,176)">boto3</span>.<span style="color:rgb(220,220,170)">client</span>(<span style="color:rgb(206,145,120)">"kinesisvideo"</span>, <span style="color:rgb(156,220,254)">region_name</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">region</span>)</div><br><div> <span style="color:rgb(106,153,85)"># Browser should be viewer, we will be master</span></div><div> <span style="color:rgb(156,220,254)">response</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">client</span>.get_signaling_channel_endpoint(</div><div> <span style="color:rgb(156,220,254)">ChannelARN</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">channel_arn</span>,</div><div> <span style="color:rgb(156,220,254)">SingleMasterChannelEndpointConfiguration</span><span style="color:rgb(212,212,212)">=</span>{</div><div> <span style="color:rgb(206,145,120)">"Protocols"</span>: [</div><div> <span style="color:rgb(206,145,120)">"WSS"</span>,</div><div> ],</div><div> <span style="color:rgb(206,145,120)">"Role"</span>: <span style="color:rgb(206,145,120)">"MASTER"</span>,</div><div> },</div><div> )</div><br><div> <span style="color:rgb(156,220,254)">endpoints</span> <span style="color:rgb(212,212,212)">=</span> []</div><br><div> <span style="color:rgb(197,134,192)">for</span> <span style="color:rgb(156,220,254)">e</span> <span style="color:rgb(197,134,192)">in</span> <span style="color:rgb(156,220,254)">response</span>[<span style="color:rgb(206,145,120)">"ResourceEndpointList"</span>]:</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(156,220,254)">e</span>[<span style="color:rgb(206,145,120)">"Protocol"</span>])</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(156,220,254)">e</span>[<span style="color:rgb(206,145,120)">"ResourceEndpoint"</span>])</div><br><div> <span style="color:rgb(156,220,254)">endpoints</span>.<span style="color:rgb(220,220,170)">append</span>(<span style="color:rgb(156,220,254)">e</span>[<span style="color:rgb(206,145,120)">"ResourceEndpoint"</span>])</div><br><div> <span style="color:rgb(156,220,254)">query_params</span> <span style="color:rgb(212,212,212)">=</span> {</div><div> <span style="color:rgb(206,145,120)">"X-Amz-ChannelARN"</span>: <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">channel_arn</span>,</div><div> }</div><br><div> <span style="color:rgb(156,220,254)">credentials</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(78,201,176)">boto3</span>.<span style="color:rgb(78,201,176)">Session</span>().<span style="color:rgb(220,220,170)">get_credentials</span>()</div><div> <span style="color:rgb(156,220,254)">signer</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(78,201,176)">SigV4RequestSigner</span>(<span style="color:rgb(156,220,254)">credentials</span>, <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">region</span>, <span style="color:rgb(206,145,120)">"kinesisvideo"</span>)</div><div> <span style="color:rgb(156,220,254)">signed_url</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">signer</span>.<span style="color:rgb(220,220,170)">get_signed_url</span>(</div><div> <span style="color:rgb(156,220,254)">endpoints</span>[<span style="color:rgb(181,206,168)">0</span>],</div><div> <span style="color:rgb(156,220,254)">query_params</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">query_params</span>,</div><div> )</div><br><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">ws</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(78,201,176)">websocket</span>.<span style="color:rgb(78,201,176)">WebSocketApp</span>(</div><div> <span style="color:rgb(156,220,254)">signed_url</span>,</div><div> <span style="color:rgb(156,220,254)">on_message</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">on_message</span>,</div><div> <span style="color:rgb(156,220,254)">on_error</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">on_error</span>,</div><div> <span style="color:rgb(156,220,254)">on_close</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">on_close</span>,</div><div> <span style="color:rgb(156,220,254)">on_open</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">on_open</span>,</div><div> )</div><br><div> <span style="color:rgb(106,153,85)"># </span><span style="color:rgb(86,156,214)">TODO</span><span style="color:rgb(106,153,85)"> do SSL</span></div><br><div> <span style="color:rgb(106,153,85)"># Start ws.run_forever() in a separate thread</span></div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">ws_thread</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(78,201,176)">threading</span>.<span style="color:rgb(78,201,176)">Thread</span>(</div><div> <span style="color:rgb(156,220,254)">target</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">ws</span>.<span style="color:rgb(220,220,170)">run_forever</span>, <span style="color:rgb(156,220,254)">kwargs</span><span style="color:rgb(212,212,212)">=</span>{<span style="color:rgb(206,145,120)">"sslopt"</span>: {<span style="color:rgb(206,145,120)">"cert_reqs"</span>: <span style="color:rgb(78,201,176)">ssl</span>.<span style="color:rgb(156,220,254)">CERT_NONE</span>, <span style="color:rgb(206,145,120)">"check_hostname"</span>: <span style="color:rgb(86,156,214)">False</span>}}</div><div> )</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">ws_thread</span>.<span style="color:rgb(220,220,170)">start</span>()</div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">on_message</span>(<span style="color:rgb(156,220,254)">self</span>, <span style="color:rgb(156,220,254)">ws</span>, <span style="color:rgb(156,220,254)">message</span>):</div><div> <span style="color:rgb(197,134,192)">if</span> <span style="color:rgb(156,220,254)">message</span>:</div><div> <span style="color:rgb(156,220,254)">received</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(78,201,176)">json</span>.<span style="color:rgb(220,220,170)">loads</span>(<span style="color:rgb(156,220,254)">message</span>)</div><br><div> <span style="color:rgb(197,134,192)">if</span> <span style="color:rgb(206,145,120)">"messagePayload"</span> <span style="color:rgb(86,156,214)">in</span> <span style="color:rgb(156,220,254)">received</span> <span style="color:rgb(86,156,214)">and</span> <span style="color:rgb(206,145,120)">"messageType"</span> <span style="color:rgb(86,156,214)">in</span> <span style="color:rgb(156,220,254)">received</span>:</div><div> <span style="color:rgb(156,220,254)">payload</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(78,201,176)">base64</span>.<span style="color:rgb(220,220,170)">b64decode</span>(<span style="color:rgb(156,220,254)">received</span>[<span style="color:rgb(206,145,120)">"messagePayload"</span>]).<span style="color:rgb(220,220,170)">decode</span>(<span style="color:rgb(206,145,120)">"utf-8"</span>)</div><div> <span style="color:rgb(156,220,254)">payload</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(78,201,176)">json</span>.<span style="color:rgb(220,220,170)">loads</span>(<span style="color:rgb(156,220,254)">payload</span>)</div><br><div> <span style="color:rgb(197,134,192)">if</span> <span style="color:rgb(156,220,254)">received</span>[<span style="color:rgb(206,145,120)">"messageType"</span>] <span style="color:rgb(212,212,212)">==</span> <span style="color:rgb(206,145,120)">"SDP_OFFER"</span>:</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(206,145,120)">"Received SDP_OFFER"</span>)</div><div> <span style="color:rgb(156,220,254)">client_id</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">received</span>[<span style="color:rgb(206,145,120)">"senderClientId"</span>]</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">event_queue</span>.<span style="color:rgb(220,220,170)">put</span>(</div><div> (<span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">SIGNAL_MESSAGE_SDP_OFFER</span>, {<span style="color:rgb(206,145,120)">"client_id"</span>: <span style="color:rgb(156,220,254)">client_id</span>, <span style="color:rgb(206,145,120)">"payload"</span>: <span style="color:rgb(156,220,254)">payload</span>})</div><div> )</div><br><div> <span style="color:rgb(197,134,192)">else</span>:</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(156,220,254)">received</span>[<span style="color:rgb(206,145,120)">"messageType"</span>])</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(156,220,254)">payload</span>)</div><div> <span style="color:rgb(197,134,192)">elif</span> <span style="color:rgb(206,145,120)">"message"</span> <span style="color:rgb(86,156,214)">in</span> <span style="color:rgb(156,220,254)">received</span>:</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(156,220,254)">received</span>[<span style="color:rgb(206,145,120)">"message"</span>])</div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">on_error</span>(<span style="color:rgb(156,220,254)">self</span>, <span style="color:rgb(156,220,254)">ws</span>, <span style="color:rgb(156,220,254)">error</span>):</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">event_queue</span>.<span style="color:rgb(220,220,170)">put</span>((<span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">SIGNAL_ERROR</span>, <span style="color:rgb(156,220,254)">error</span>))</div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">on_close</span>(<span style="color:rgb(156,220,254)">self</span>, <span style="color:rgb(156,220,254)">ws</span>, <span style="color:rgb(156,220,254)">close_status_code</span>, <span style="color:rgb(156,220,254)">close_msg</span>):</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">event_queue</span>.<span style="color:rgb(220,220,170)">put</span>((<span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">SIGNAL_CLOSE</span>, <span style="color:rgb(86,156,214)">None</span>))</div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">on_open</span>(<span style="color:rgb(156,220,254)">self</span>, <span style="color:rgb(156,220,254)">ws</span>):</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">event_queue</span>.<span style="color:rgb(220,220,170)">put</span>((<span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">SIGNAL_OPEN</span>, <span style="color:rgb(86,156,214)">None</span>))</div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">on_negotiation_needed</span>(<span style="color:rgb(156,220,254)">self</span>, <span style="color:rgb(156,220,254)">element</span>, <span style="color:rgb(156,220,254)">user_data</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(86,156,214)">None</span>):</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(206,145,120)">"on_negotiation_needed"</span>)</div><br><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">event_queue</span>.<span style="color:rgb(220,220,170)">put</span>((<span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">NEGOTIATION_NEEDED</span>, <span style="color:rgb(86,156,214)">None</span>))</div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">on_ice_gathering_state_notify</span>(<span style="color:rgb(156,220,254)">self</span>, <span style="color:rgb(156,220,254)">element</span>, <span style="color:rgb(156,220,254)">pspec</span>):</div><div> <span style="color:rgb(106,153,85)"># </span><span style="color:rgb(86,156,214)">TODO</span></div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(206,145,120)">"on_ice_gathering_state_notify"</span>)</div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">on_incoming_stream</span>(<span style="color:rgb(156,220,254)">self</span>, <span style="color:rgb(156,220,254)">webrtc</span>, <span style="color:rgb(156,220,254)">pad</span>, <span style="color:rgb(156,220,254)">pipe</span>):</div><div> <span style="color:rgb(106,153,85)"># </span><span style="color:rgb(86,156,214)">TODO</span><span style="color:rgb(106,153,85)"> Do we need to handle incoming streams?</span></div><br><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(206,145,120)">"on_incoming_stream"</span>)</div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">send_ice_candidate_message</span>(<span style="color:rgb(156,220,254)">self</span>, <span style="color:rgb(156,220,254)">element</span>, <span style="color:rgb(156,220,254)">mlineindex</span>, <span style="color:rgb(156,220,254)">candidate</span>):</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(206,145,120)">"send_ice_candidate_message"</span>)</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">event_queue</span>.<span style="color:rgb(220,220,170)">put</span>(</div><div> (</div><div> <span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">SEND_ICE_CANDIDATE</span>,</div><div> {</div><div> <span style="color:rgb(206,145,120)">"sdpMLineIndex"</span>: <span style="color:rgb(156,220,254)">mlineindex</span>,</div><div> <span style="color:rgb(206,145,120)">"candidate"</span>: <span style="color:rgb(156,220,254)">candidate</span>,</div><div> },</div><div> )</div><div> )</div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">get_ice_candidates</span>(<span style="color:rgb(156,220,254)">self</span>):</div><div> <span style="color:rgb(106,153,85)"># </span><span style="color:rgb(86,156,214)">TODO</span></div><div> <span style="color:rgb(197,134,192)">pass</span></div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">setup_gstreamer</span>(<span style="color:rgb(156,220,254)">self</span>):</div><div> <span style="color:rgb(197,134,192)">try</span>:</div><div> <span style="color:rgb(106,153,85)"># Create a new pipeline</span></div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">pipeline</span> <span style="color:rgb(212,212,212)">=</span> Gst.parse_launch(<span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">pipeline_description</span>)</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">webrtc</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">pipeline</span>.get_by_name(<span style="color:rgb(206,145,120)">"sink"</span>)</div><br><div> <span style="color:rgb(106,153,85)"># Attach signals</span></div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">webrtc</span>.connect(<span style="color:rgb(206,145,120)">"on-negotiation-needed"</span>, <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">on_negotiation_needed</span>)</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">webrtc</span>.connect(<span style="color:rgb(206,145,120)">"on-ice-candidate"</span>, <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">send_ice_candidate_message</span>)</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">webrtc</span>.connect(<span style="color:rgb(206,145,120)">"notify::ice-gathering-state"</span>, <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">on_ice_gathering_state_notify</span>)</div><br><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">pipeline</span>.set_state(Gst.State.READY)</div><br><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">webrtc</span>.connect(<span style="color:rgb(206,145,120)">"pad-added"</span>, <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">on_incoming_stream</span>, <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">pipeline</span>)</div><br><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">get_ice_candidates</span>()</div><br><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(206,145,120)">"Starting pipeline"</span>)</div><br><div> <span style="color:rgb(197,134,192)">except</span> <span style="color:rgb(78,201,176)">Exception</span> <span style="color:rgb(197,134,192)">as</span> <span style="color:rgb(156,220,254)">ex</span>:</div><div> <span style="color:rgb(197,134,192)">raise</span> <span style="color:rgb(78,201,176)">Exception</span>(<span style="color:rgb(206,145,120)">"Failed to start pipeline"</span>, <span style="color:rgb(156,220,254)">ex</span>)</div><br><div> <span style="color:rgb(156,220,254)">ret</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">pipeline</span>.set_state(Gst.State.PLAYING)</div><div> <span style="color:rgb(197,134,192)">if</span> <span style="color:rgb(156,220,254)">ret</span> <span style="color:rgb(212,212,212)">==</span> Gst.StateChangeReturn.FAILURE:</div><div> <span style="color:rgb(197,134,192)">raise</span> <span style="color:rgb(78,201,176)">Exception</span>(<span style="color:rgb(206,145,120)">"Failed to start pipeline"</span>)</div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">send_sdp_ice_candidate</span>(<span style="color:rgb(156,220,254)">self</span>, <span style="color:rgb(156,220,254)">ice_candidate</span>):</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(206,145,120)">"send_sdp_ice_candidate"</span>)</div><br><div> <span style="color:rgb(156,220,254)">msg</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(78,201,176)">json</span>.<span style="color:rgb(220,220,170)">dumps</span>(<span style="color:rgb(156,220,254)">ice_candidate</span>)</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(156,220,254)">msg</span>)</div><br><div> <span style="color:rgb(156,220,254)">base64_str</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(78,201,176)">base64</span>.<span style="color:rgb(220,220,170)">b64encode</span>(<span style="color:rgb(156,220,254)">msg</span>.<span style="color:rgb(220,220,170)">encode</span>(<span style="color:rgb(206,145,120)">"utf-8"</span>))</div><br><div> <span style="color:rgb(156,220,254)">payload</span> <span style="color:rgb(212,212,212)">=</span> {</div><div> <span style="color:rgb(206,145,120)">"action"</span>: <span style="color:rgb(206,145,120)">"ICE_CANDIDATE"</span>,</div><div> <span style="color:rgb(206,145,120)">"recipientClientId"</span>: <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">client_id</span>,</div><div> <span style="color:rgb(206,145,120)">"messagePayload"</span>: <span style="color:rgb(156,220,254)">base64_str</span>.<span style="color:rgb(220,220,170)">decode</span>(<span style="color:rgb(206,145,120)">"utf-8"</span>),</div><div> }</div><br><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">ws</span>.<span style="color:rgb(220,220,170)">send</span>(<span style="color:rgb(78,201,176)">json</span>.<span style="color:rgb(220,220,170)">dumps</span>(<span style="color:rgb(156,220,254)">payload</span>))</div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">set_offer_on_gstreamer</span>(<span style="color:rgb(156,220,254)">self</span>, <span style="color:rgb(156,220,254)">sdp</span>):</div><div> <span style="color:rgb(156,220,254)">res</span>, <span style="color:rgb(156,220,254)">sdpmsg</span> <span style="color:rgb(212,212,212)">=</span> GstSdp.SDPMessage.new()</div><div> GstSdp.sdp_message_parse_buffer(<span style="color:rgb(78,201,176)">bytes</span>(<span style="color:rgb(156,220,254)">sdp</span>.encode()), <span style="color:rgb(156,220,254)">sdpmsg</span>)</div><div> <span style="color:rgb(156,220,254)">offer</span> <span style="color:rgb(212,212,212)">=</span> GstWebRTC.WebRTCSessionDescription.new(GstWebRTC.WebRTCSDPType.OFFER, <span style="color:rgb(156,220,254)">sdpmsg</span>)</div><div> <span style="color:rgb(156,220,254)">promise</span> <span style="color:rgb(212,212,212)">=</span> Gst.Promise.new()</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">webrtc</span>.emit(<span style="color:rgb(206,145,120)">"set-remote-description"</span>, <span style="color:rgb(156,220,254)">offer</span>, <span style="color:rgb(156,220,254)">promise</span>)</div><div> <span style="color:rgb(156,220,254)">promise</span>.wait()</div><br><div> <span style="color:rgb(156,220,254)">promise</span> <span style="color:rgb(212,212,212)">=</span> Gst.Promise.new_with_change_func(<span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">on_answer_created</span>, <span style="color:rgb(86,156,214)">None</span>, <span style="color:rgb(86,156,214)">None</span>)</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">webrtc</span>.emit(<span style="color:rgb(206,145,120)">"create-answer"</span>, <span style="color:rgb(86,156,214)">None</span>, <span style="color:rgb(156,220,254)">promise</span>)</div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">on_answer_created</span>(<span style="color:rgb(156,220,254)">self</span>, <span style="color:rgb(156,220,254)">promise</span>, <span style="color:rgb(156,220,254)">_</span>, <span style="color:rgb(156,220,254)">__</span>):</div><div> <span style="color:rgb(156,220,254)">reply</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">promise</span>.get_reply()</div><div> <span style="color:rgb(156,220,254)">answer</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">reply</span>.get_value(<span style="color:rgb(206,145,120)">"answer"</span>)</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">webrtc</span>.emit(<span style="color:rgb(206,145,120)">"set-local-description"</span>, <span style="color:rgb(156,220,254)">answer</span>, <span style="color:rgb(86,156,214)">None</span>)</div><br><div> <span style="color:rgb(156,220,254)">answer_text</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">answer</span>.sdp.as_text()</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">event_queue</span>.<span style="color:rgb(220,220,170)">put</span>((<span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">ANSWER_CREATED</span>, <span style="color:rgb(156,220,254)">answer_text</span>))</div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">send_sdp_answer</span>(<span style="color:rgb(156,220,254)">self</span>, <span style="color:rgb(156,220,254)">answer</span>):</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(206,145,120)">"send_sdp_answer"</span>)</div><br><div> <span style="color:rgb(156,220,254)">msg</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(78,201,176)">json</span>.<span style="color:rgb(220,220,170)">dumps</span>({<span style="color:rgb(206,145,120)">"type"</span>: <span style="color:rgb(206,145,120)">"answer"</span>, <span style="color:rgb(206,145,120)">"sdp"</span>: <span style="color:rgb(156,220,254)">answer</span>})</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(156,220,254)">msg</span>)</div><br><div> <span style="color:rgb(156,220,254)">base64_str</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(78,201,176)">base64</span>.<span style="color:rgb(220,220,170)">b64encode</span>(<span style="color:rgb(156,220,254)">msg</span>.<span style="color:rgb(220,220,170)">encode</span>(<span style="color:rgb(206,145,120)">"utf-8"</span>))</div><br><div> <span style="color:rgb(156,220,254)">payload</span> <span style="color:rgb(212,212,212)">=</span> {</div><div> <span style="color:rgb(206,145,120)">"action"</span>: <span style="color:rgb(206,145,120)">"SDP_ANSWER"</span>,</div><div> <span style="color:rgb(206,145,120)">"recipientClientId"</span>: <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">client_id</span>,</div><div> <span style="color:rgb(206,145,120)">"messagePayload"</span>: <span style="color:rgb(156,220,254)">base64_str</span>.<span style="color:rgb(220,220,170)">decode</span>(<span style="color:rgb(206,145,120)">"utf-8"</span>),</div><div> }</div><br><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">ws</span>.<span style="color:rgb(220,220,170)">send</span>(<span style="color:rgb(78,201,176)">json</span>.<span style="color:rgb(220,220,170)">dumps</span>(<span style="color:rgb(156,220,254)">payload</span>))</div><br><div> <span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">run</span>(<span style="color:rgb(156,220,254)">self</span>):</div><div> <span style="color:rgb(106,153,85)"># Start the queue with a request to connect</span></div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">event_queue</span>.<span style="color:rgb(220,220,170)">put</span>((<span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">INIT</span>, <span style="color:rgb(86,156,214)">None</span>))</div><br><div> <span style="color:rgb(156,220,254)">running</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(86,156,214)">True</span></div><br><div> <span style="color:rgb(156,220,254)">sdp_offer</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(86,156,214)">None</span></div><br><div> <span style="color:rgb(197,134,192)">while</span> <span style="color:rgb(156,220,254)">running</span>:</div><div> <span style="color:rgb(106,153,85)"># Get the next event from the queue</span></div><div> <span style="color:rgb(156,220,254)">event_type</span>, <span style="color:rgb(156,220,254)">event_data</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">event_queue</span>.<span style="color:rgb(220,220,170)">get</span>()</div><br><div> <span style="color:rgb(197,134,192)">if</span> <span style="color:rgb(156,220,254)">event_type</span> <span style="color:rgb(212,212,212)">==</span> <span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">INIT</span>:</div><div> <span style="color:rgb(156,220,254)">sdp_offer</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(86,156,214)">None</span></div><div> Gst.init(<span style="color:rgb(86,156,214)">None</span>)</div><br><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">event_queue</span>.<span style="color:rgb(220,220,170)">put</span>((<span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">CONNECT_SIGNAL_CHANNEL</span>, <span style="color:rgb(86,156,214)">None</span>))</div><br><div> <span style="color:rgb(197,134,192)">elif</span> <span style="color:rgb(156,220,254)">event_type</span> <span style="color:rgb(212,212,212)">==</span> <span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">CONNECT_SIGNAL_CHANNEL</span>:</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">connect_signal_channel</span>()</div><br><div> <span style="color:rgb(197,134,192)">elif</span> <span style="color:rgb(156,220,254)">event_type</span> <span style="color:rgb(212,212,212)">==</span> <span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">SIGNAL_OPEN</span>:</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(206,145,120)">"Waiting for peers"</span>)</div><br><div> <span style="color:rgb(197,134,192)">elif</span> <span style="color:rgb(156,220,254)">event_type</span> <span style="color:rgb(212,212,212)">==</span> <span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">SIGNAL_MESSAGE_SDP_OFFER</span>:</div><div> <span style="color:rgb(156,220,254)">sdp_offer</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">event_data</span>[<span style="color:rgb(206,145,120)">"payload"</span>][<span style="color:rgb(206,145,120)">"sdp"</span>]</div><div> <span style="color:rgb(156,220,254)">client_id</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">event_data</span>[<span style="color:rgb(206,145,120)">"client_id"</span>]</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(156,220,254)">client_id</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(156,220,254)">client_id</span></div><br><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">setup_gstreamer</span>()</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">set_offer_on_gstreamer</span>(<span style="color:rgb(156,220,254)">sdp_offer</span>)</div><br><div> <span style="color:rgb(197,134,192)">elif</span> <span style="color:rgb(156,220,254)">event_type</span> <span style="color:rgb(212,212,212)">==</span> <span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">NEGOTIATION_NEEDED</span>:</div><div> <span style="color:rgb(106,153,85)"># </span><span style="color:rgb(86,156,214)">TODO</span></div><div> <span style="color:rgb(197,134,192)">pass</span></div><br><div> <span style="color:rgb(197,134,192)">elif</span> <span style="color:rgb(156,220,254)">event_type</span> <span style="color:rgb(212,212,212)">==</span> <span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">ANSWER_CREATED</span>:</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">send_sdp_answer</span>(<span style="color:rgb(156,220,254)">event_data</span>)</div><br><div> <span style="color:rgb(197,134,192)">elif</span> <span style="color:rgb(156,220,254)">event_type</span> <span style="color:rgb(212,212,212)">==</span> <span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">SEND_ICE_CANDIDATE</span>:</div><div> <span style="color:rgb(156,220,254)">self</span>.<span style="color:rgb(220,220,170)">send_sdp_ice_candidate</span>(<span style="color:rgb(156,220,254)">event_data</span>)</div><br><div> <span style="color:rgb(197,134,192)">elif</span> <span style="color:rgb(156,220,254)">event_type</span> <span style="color:rgb(212,212,212)">==</span> <span style="color:rgb(78,201,176)">EventType</span>.<span style="color:rgb(79,193,255)">SIGNAL_CLOSE</span>:</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(206,145,120)">"Signal channel closed"</span>)</div><br><div> <span style="color:rgb(197,134,192)">else</span>:</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(86,156,214)">f</span><span style="color:rgb(206,145,120)">"Unexpected event: </span><span style="color:rgb(86,156,214)">{</span><span style="color:rgb(156,220,254)">event_type</span><span style="color:rgb(86,156,214)">}</span><span style="color:rgb(206,145,120)">"</span>)</div><div> <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(156,220,254)">event_data</span>)</div><div> <span style="color:rgb(106,153,85)"># </span><span style="color:rgb(86,156,214)">TODO</span><span style="color:rgb(106,153,85)"> shutdown self.ws_thread and self.pipeline</span></div><div> <span style="color:rgb(156,220,254)">running</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(86,156,214)">False</span></div><br><br><div><span style="color:rgb(197,134,192)">if</span> <span style="color:rgb(156,220,254)">__name__</span> <span style="color:rgb(212,212,212)">==</span> <span style="color:rgb(206,145,120)">"__main__"</span>:</div><div> <span style="color:rgb(156,220,254)">video_parameters</span> <span style="color:rgb(212,212,212)">=</span> {</div><div> <span style="color:rgb(206,145,120)">"region"</span>: <span style="color:rgb(206,145,120)">"us-west-2"</span>,</div><div> <span style="color:rgb(206,145,120)">"channel_arn"</span>: <span style="color:rgb(206,145,120)">"..."</span>,</div><div> <span style="color:rgb(206,145,120)">"pipeline_description"</span>: <span style="color:rgb(206,145,120)">"webrtcbin bundle-policy=max-bundle name=sink stun-server=stun://<a href="http://stun.kinesisvideo.us-west-2.amazonaws.com:443">stun.kinesisvideo.us-west-2.amazonaws.com:443</a></span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">videotestsrc pattern=ball ! videoconvert ! videoscale ! video/x-raw,width=1280,height=720 ! videorate ! video/x-raw,framerate=25/1 ! queue ! x264enc speed-preset=ultrafast tune=zerolatency bframes=0 key-int-max=25 ! video/x-h264,profile=baseline ! rtph264pay !</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">queue ! application/x-rtp,media=video,encoding-name=H264 ! sink."</span>,</div><div> }</div><div> <span style="color:rgb(156,220,254)">vs</span> <span style="color:rgb(212,212,212)">=</span> <span style="color:rgb(78,201,176)">VideoService</span>(<span style="color:rgb(212,212,212)">**</span><span style="color:rgb(156,220,254)">video_parameters</span>)</div><div> <span style="color:rgb(156,220,254)">vs</span>.<span style="color:rgb(220,220,170)">run</span>()</div><br></div><br>My browser code will send an offer:<br><br>{"type":"offer","sdp":"v=0\r\no=- 6426415272463828937 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 63 9 0 8 13 110 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:e9Aj\r\na=ice-pwd:o//T9KUkuruDaBLI4lUrt4Pt\r\na=ice-options:trickle\r\na=fingerprint:sha-256 9B:54:6D:8E:DF:AD:5E:A1:B6:5B:A2:CD:C5:67:22:9D:5F:90:0F:EF:5B:9B:FD:C9:0E:45:CF:3C:4A:B7:43:1D\r\na=setup:actpass\r\na=mid:0\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2 <a href="http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:3">http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:3</a> <a href="http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:4">http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:4</a> urn:ietf:params:rtp-hdrext:sdes:mid\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1\r\na=rtpmap:63 red/48000/2\r\na=fmtp:63 111/111\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:126 telephone-event/8000\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 35 36 37 38 102 103 104 105 106 107 108 109 127 125 39 40 41 42 43 44 45 46 47 48 112 113 114 115 116 117 118 49\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:e9Aj\r\na=ice-pwd:o//T9KUkuruDaBLI4lUrt4Pt\r\na=ice-options:trickle\r\na=fingerprint:sha-256 9B:54:6D:8E:DF:AD:5E:A1:B6:5B:A2:CD:C5:67:22:9D:5F:90:0F:EF:5B:9B:FD:C9:0E:45:CF:3C:4A:B7:43:1D\r\na=setup:actpass\r\na=mid:1\r\na=extmap:14 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:2 <a href="http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:13">http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:13</a> urn:3gpp:video-orientation\r\na=extmap:3 <a href="http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:5">http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:5</a> <a href="http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:6">http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:6</a> <a href="http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:7">http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:7</a> <a href="http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:8">http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:8</a> <a href="http://www.webrtc.org/experiments/rtp-hdrext/color-space\r\na=extmap:4">http://www.webrtc.org/experiments/rtp-hdrext/color-space\r\na=extmap:4</a> urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:10 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id\r\na=extmap:11 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id\r\na=recvonly\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:35 VP9/90000\r\na=rtcp-fb:35 goog-remb\r\na=rtcp-fb:35 transport-cc\r\na=rtcp-fb:35 ccm fir\r\na=rtcp-fb:35 nack\r\na=rtcp-fb:35 nack pli\r\na=fmtp:35 profile-id=1\r\na=rtpmap:36 rtx/90000\r\na=fmtp:36 apt=35\r\na=rtpmap:37 VP9/90000\r\na=rtcp-fb:37 goog-remb\r\na=rtcp-fb:37 transport-cc\r\na=rtcp-fb:37 ccm fir\r\na=rtcp-fb:37 nack\r\na=rtcp-fb:37 nack pli\r\na=fmtp:37 profile-id=3\r\na=rtpmap:38 rtx/90000\r\na=fmtp:38 apt=37\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:103 rtx/90000\r\na=fmtp:103 apt=102\r\na=rtpmap:104 H264/90000\r\na=rtcp-fb:104 goog-remb\r\na=rtcp-fb:104 transport-cc\r\na=rtcp-fb:104 ccm fir\r\na=rtcp-fb:104 nack\r\na=rtcp-fb:104 nack pli\r\na=fmtp:104 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f\r\na=rtpmap:105 rtx/90000\r\na=fmtp:105 apt=104\r\na=rtpmap:106 H264/90000\r\na=rtcp-fb:106 goog-remb\r\na=rtcp-fb:106 transport-cc\r\na=rtcp-fb:106 ccm fir\r\na=rtcp-fb:106 nack\r\na=rtcp-fb:106 nack pli\r\na=fmtp:106 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=106\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: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=1;profile-level-id=4d001f\r\na=rtpmap:125 rtx/90000\r\na=fmtp:125 apt=127\r\na=rtpmap:39 H264/90000\r\na=rtcp-fb:39 goog-remb\r\na=rtcp-fb:39 transport-cc\r\na=rtcp-fb:39 ccm fir\r\na=rtcp-fb:39 nack\r\na=rtcp-fb:39 nack pli\r\na=fmtp:39 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=4d001f\r\na=rtpmap:40 rtx/90000\r\na=fmtp:40 apt=39\r\na=rtpmap:41 H264/90000\r\na=rtcp-fb:41 goog-remb\r\na=rtcp-fb:41 transport-cc\r\na=rtcp-fb:41 ccm fir\r\na=rtcp-fb:41 nack\r\na=rtcp-fb:41 nack pli\r\na=fmtp:41 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=f4001f\r\na=rtpmap:42 rtx/90000\r\na=fmtp:42 apt=41\r\na=rtpmap:43 H264/90000\r\na=rtcp-fb:43 goog-remb\r\na=rtcp-fb:43 transport-cc\r\na=rtcp-fb:43 ccm fir\r\na=rtcp-fb:43 nack\r\na=rtcp-fb:43 nack pli\r\na=fmtp:43 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=f4001f\r\na=rtpmap:44 rtx/90000\r\na=fmtp:44 apt=43\r\na=rtpmap:45 AV1/90000\r\na=rtcp-fb:45 goog-remb\r\na=rtcp-fb:45 transport-cc\r\na=rtcp-fb:45 ccm fir\r\na=rtcp-fb:45 nack\r\na=rtcp-fb:45 nack pli\r\na=rtpmap:46 rtx/90000\r\na=fmtp:46 apt=45\r\na=rtpmap:47 AV1/90000\r\na=rtcp-fb:47 goog-remb\r\na=rtcp-fb:47 transport-cc\r\na=rtcp-fb:47 ccm fir\r\na=rtcp-fb:47 nack\r\na=rtcp-fb:47 nack pli\r\na=fmtp:47 profile=1\r\na=rtpmap:48 rtx/90000\r\na=fmtp:48 apt=47\r\na=rtpmap:112 H264/90000\r\na=rtcp-fb:112 goog-remb\r\na=rtcp-fb:112 transport-cc\r\na=rtcp-fb:112 ccm fir\r\na=rtcp-fb:112 nack\r\na=rtcp-fb:112 nack pli\r\na=fmtp:112 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f\r\na=rtpmap:113 rtx/90000\r\na=fmtp:113 apt=112\r\na=rtpmap:114 H264/90000\r\na=rtcp-fb:114 goog-remb\r\na=rtcp-fb:114 transport-cc\r\na=rtcp-fb:114 ccm fir\r\na=rtcp-fb:114 nack\r\na=rtcp-fb:114 nack pli\r\na=fmtp:114 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=64001f\r\na=rtpmap:115 rtx/90000\r\na=fmtp:115 apt=114\r\na=rtpmap:116 red/90000\r\na=rtpmap:117 rtx/90000\r\na=fmtp:117 apt=116\r\na=rtpmap:118 ulpfec/90000\r\na=rtpmap:49 flexfec-03/90000\r\na=rtcp-fb:49 goog-remb\r\na=rtcp-fb:49 transport-cc\r\na=fmtp:49 repair-window=10000000\r\n"}<br><br>and I am able to send a answer from Python:<br><br>{"type":"answer","sdp":"v=0\r\no=- 6426415272463828937 2 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:B1FuRGQ3FL4KnNY7C/h8BygmBRYbAEol\r\na=ice-pwd:3YJMhXnjRkWEC/ZMruapjMIRAOXWjcBd\r\na=mid:0\r\na=rtcp-mux\r\na=setup:active\r\na=rtpmap:111 OPUS/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1\r\na=inactive\r\na=fingerprint:sha-256 2E:6D:EE:5F:5B:0F:91:35:6A:B0:7C:D1:7D:D2:37:8B:68:73:E0:0D:A7:65:E1:5D:A1:6F:5F:3E:8A:44:15:85\r\nm=video 9 UDP/TLS/RTP/SAVPF 96\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:B1FuRGQ3FL4KnNY7C/h8BygmBRYbAEol\r\na=ice-pwd:3YJMhXnjRkWEC/ZMruapjMIRAOXWjcBd\r\na=mid:1\r\na=rtcp-mux\r\na=setup:active\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 nack pli\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 transport-cc\r\na=inactive\r\na=fingerprint:sha-256 2E:6D:EE:5F:5B:0F:91:35:6A:B0:7C:D1:7D:D2:37:8B:68:73:E0:0D:A7:65:E1:5D:A1:6F:5F:3E:8A:44:15:85\r\n"}<br><br>But the connection is not made, note the answer is VP8 and my pipeline is H.264:<br><br><div style="background-color:rgb(31,31,31);font-family:"Droid Sans Mono","monospace",monospace;font-size:14px;line-height:19px;white-space:pre"><div style="">webrtcbin<font color="#ce9178"> bundle-policy=max-bundle name=sink stun-server=stun://<a href="http://stun.kinesisvideo.us-west-2.amazonaws.com:443">stun.kinesisvideo.us-west-2.amazonaws.com:443</a></font><font color="#d7ba7d">
</font><font color="#ce9178">videotestsrc pattern=ball ! videoconvert ! videoscale ! video/x-raw,width=1280,height=720 ! videorate ! video/x-raw,framerate=25/1 ! queue ! x264enc speed-preset=ultrafast tune=zerolatency bframes=0 key-int-max=25 ! video/x-h264,profile=baseline ! rtph264pay !</font><font color="#d7ba7d">
</font><span style="color:rgb(206,145,120)">queue ! application/x-rtp,media=video,encoding-name=H264 ! sink.</span></div></div><br>Any help would be most appreciatedĀ here. <br><br>Thanks, C</div>