Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

webrtc-sendrecv.py TypeError : 'Structure' object is not subscriptable #42

Closed
dhirajdhule opened this issue Aug 23, 2018 · 5 comments
Closed

Comments

@dhirajdhule
Copy link

dhirajdhule commented Aug 23, 2018

I am able to successfully test out the stream from C version, but not the python version. I have modified this docker file to setup gstreamer 1.14.2.

root@bcc8369cc4db:/gstwebrtc-demos# python3 sendrecv/gst/webrtc-sendrecv.py 7729
Traceback (most recent call last):

File "sendrecv/gst/webrtc-sendrecv.py", line 53, in on_offer_created

offer = reply['offer']

TypeError: 'Structure' object is not subscriptable

Thanks.

@mohammadbhuyan
Copy link

I am facing the same error in running the demo.

What I have:

NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.1 LTS"
VERSION_ID="18.04"

I have built GStreamer 1.1.4.2 using the sources obtained from:
https://gstreamer.freedesktop.org/news/

$ gst-inspect-1.0 --version
gst-inspect-1.0 version 1.14.2
GStreamer 1.14.2
Unknown package origin

In order to ensure that I have all the elements required for the pipeline, I ran the following:

$ gst-launch-1.0 videotestsrc pattern=ball ! videoconvert ! queue ! vp8enc deadline=1 ! rtpvp8pay ! queue ! application/x-rtp,media=video,encoding-name=VP8,payload=97 ! webrtcbin
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:10.467436577
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

Then I cloned the demo repo and built the C version of the send recv. I used https://webrtc.nirbheek.in/ for signalling.

It worked!!! So the conclusion is the GStreamer 1.14.2 was working and I had the webrtcbin working.

But my objective is to get the python version working.

First failure was: Namespace GstWebRTC not available

I found the following: https://github.com/centricular/gstwebrtc-demos/issues/37

But to build with --enable-introspection I endedn up using:
sudo apt-get install gobject-introspection
sudo apt-get install libgirepository1.0-dev

The build was successfull and I copied the typelib file. If you are curious, my variation was:

./autogen.sh --prefix /usr/ --libdir /usr/lib/x86_64-linux-gnu/ --enable-introspection
sudo cp ./gst-libs/gst/webrtc/GstWebRTC-1.0.typelib /usr/lib/girepository-1.0/
sudo cp ./gst-libs/gst/webrtc/GstWebRTC-1.0.typelib /usr/lib/x86_64-linux-gnu-1.0/girepository-1.0

PS: I don't know what I am doing and shooting blind.

Then I ran the python version and got:

File "webrtc-sendrecv.py", line 53, in on_offer_created
    offer = reply['offer']
TypeError: 'Structure' object is not subscriptable

I had the shot at building gst-python but that did not chnage anyhting.

I had checked for null or print the reply structure:

I get:

python3 webrtc-sendrecv.py 1917
<Gst.Structure object at 0x7fdb19bc91c8 (GstStructure at 0x7fdb080b0160)>
Traceback (most recent call last):
  File "webrtc-sendrecv.py", line 58, in on_offer_created
    offer = reply['offer']
TypeError: 'Structure' object is not subscriptable

Any suggestion?

Since the C version works - Its python binding land issue?

@notedit
Copy link

notedit commented Sep 9, 2018

please use

offer = reply.get_value('offer')

to replace

offer = reply['offer']

@mohammadbhuyan
Copy link

@notedit Much thanks for the response. Your fix got the python example starting to work for me but then the bouncing ball freezes after few seconds in the browser and the python end shows assertion error. I will open a new issue for that. I will appreciate if you have a look at that.

@mohammadbhuyan
Copy link

Finally, I have got the python demo working based on the solution provided in #45

@dhirajdhule
Copy link
Author

Thanks @notedit . Your suggestion works.

hexray-newbee added a commit to hexray-newbee/gstwebrtc-demos that referenced this issue Apr 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants