我正在尝试使用GStreamer从文件中播放MP4视频.我已设法使用playbin2播放该文件,并使用以下命令提示符:
gst-launch filesrc location=bbb.mp4 ! decodebin2 ! autovideosink
Run Code Online (Sandbox Code Playgroud)
我期待将来我需要创建更复杂的管道,以及为什么我试图"编程"管道.在我的程序中,我试图复制上面的管道,但是我有一个问题,我怀疑与将decodebin2的动态或"有时"源板连接到autovideo接收器有关.我使用这些元素只是为了让事情尽可能简单.
static void on_new_decoded_pad(GstElement* object,
GstPad* arg0,
gboolean arg1,
gpointer user_data)
{
// dynamically connect decoderbin2 src pad to autovideosink sink pad
}
static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{
// handle bus messages
}
int main(int argc, char *argv[])
{
GMainLoop *loop;
GstElement *pipeline, *source, *decodebin, *videosink;
GstBus *bus;
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
pipeline = gst_pipeline_new ("pipeline");
source = gst_element_factory_make("filesrc", "source");
decodebin = gst_element_factory_make("decodebin2", …Run Code Online (Sandbox Code Playgroud) 我有一个Ubuntu虚拟机侦听由主机生成的UDP广播数据包.如果我使用python的socket.bind方法绑定到我的任何一个网络接口eth1或lo(本地环回),我就不会收到任何数据包.但是,如果我使用''(所有接口的符号)进行绑定,那么一切都很好.我希望有可能只绑定eth1的地址,但似乎并非如此.有人可以解释为什么需要'?是否有一些时髦的事情,因为我正在使用虚拟机?我正在使用桥接网络设置,因此虚拟机看起来像我的LAN上的另一台机器.这是代码:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
# using the '' address works
sock.bind(('', UDP_PORT))
# using the address of eth1 doesn't
#sock.bind(('192.168.2.123', UDP_PORT))
# and neither does using the local loopback
#sock.bind(('127.0.0.1', UDP_PORT))
while True:
data, addr = sock.recv(2048)
print data
Run Code Online (Sandbox Code Playgroud) 前几天我遇到了一个实例,我有一个函数,它指向一个基类型,然后我需要向上转换为派生类型以访问一些额外的功能.然而,dynamic_cast失败了,这很奇怪,因为我的类型肯定继承了基类型.
为了了解正在发生的事情的底部,我创建了以下测试程序,我认为它复制了我所看到的:
void cast(TestClass *baseType)
{
if (dynamic_cast<Derived *>(baseType))
TRACE("cast was sucessful");
else
TRACE("cast failed");
}
int main(int argc, char *argv[])
{
Derived *test1 = new Derived();
TestClass *test2 = new TestClass();
TestClass test3;
test1->identify(); // prints: this is a Derived class
test2->identify(); // prints: this is a TestClass
cast(test1); // succesful
cast(test2); // fail - expected
// reassign test2 to test1
test2 = test1;
test2->identify(); // prints: this is a Derived class
cast(test2); // succesful
// the …Run Code Online (Sandbox Code Playgroud) broadcast ×1
c++ ×1
callback ×1
dynamic-cast ×1
gstreamer ×1
networking ×1
python ×1
reference ×1
ubuntu ×1
virtualbox ×1