我正在尝试获取桌面屏幕并将其传输到笔记本电脑。 为此,我写了以下代码。但似乎他们没有连接或没有发送数据。
这是我的代码
在发件人方面
#!/usr/bin/env python
# coding: latin-1
import sys
import os
import gtk
import time
import datetime
import gobject, pygst
pygst.require("0.10")
import gst
pipeline = gst.Pipeline("client")
source = gst.element_factory_make("ximagesrc", "source")
source.set_property("use-damage", "false")
pipeline.add(source)
def new_mux_pad(mux, pad, islast):
pad.link(mux.get_pad("mpeg"))
mux = gst.element_factory_make("dvddemux", "mux")
mux.connect("new-muxed-pad", new_mux_pad)
pipeline.add(mux)
src.link(mux)
def new_mpeg_pad(mpg, pad, islast):
pad.link(mpeg.get_pad("theora"))
mpeg = gst.element_factory_make("mpeg2dec", "mpeg")
mpeg.connect("new-mpeged-pad", new_mpeg_pad)
pipeline.add(mpeg)
mux.link(mpeg)
def new_theoraenc_pad(thr, pad, islast):
pad.link(theora.get_pad("ogg"))
theora = gst.element_factory_make("theoraenc", "theora")
theora.connect("new-theoraenced-pad", new_theoraenc_pad)
pipeline.add(theora)
mpeg.link(theora)
def new_ogg_pad(og, pad, islast):
ogg = gst.element_factory_make("oggmux", "ogg")
ogg.connect("new-ogged-pad", new_ogg_pad)
pipeline.add(ogg)
theora.link(ogg)
client = gst.element_factory_make("tcpclientsink", "client")
pipeline.add(client)
client.set_property("host", "10.3.100.207")
client.set_property("port", 8080)
ogg.link(client)
pipeline.set_state(gst.STATE_PLAYING)
loop = gobject.MainLoop()
loop.run()
接收器的代码是:
#!/usr/bin/env python
# coding: latin-1
import gobject, pygst
pygst.require("0.10")
import gst
def new_decode_pad(dbin, pad, islast):
pad.link(decode.get_pad("xvimagesink"))
pipeline = gst.Pipeline("server")
tcpsrc = gst.element_factory_make("tcpserversrc", "source")
pipeline.add(tcpsrc)
tcpsrc.set_property("host", "10.3.100.207")
tcpsrc.set_property("port", 8080)
decode = gst.element_factory_make("decodebin", "decode")
decode.connect("new-decoded-pad", new_decode_pad)
pipeline.add(decode)
tcpsrc.link(decode)
def new_xvimage_pad(ximg, pad, islast):
xvimage = gst.element_factory_make("xvimagesink", "imagesink")
xvimage.connect("new-xvimaged-pad", new_xvimage_pad)
pipeline.add(xvimage)
decode.link(xvimage)
pipeline.set_state(gst.STATE_PLAYING)
loop = gobject.MainLoop()
loop.run()
当我运行此代码时,我无法获得任何输出。