- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我编写了一个在线程上创建 RTSP 服务器的程序。我认为通过简单地退出 RTSP 服务器正在运行的循环(即 g_main_loop_quit(loop)
),服务器将自行关闭并终止任何现有连接,但事实并非如此.
我使用 VLC 播放器预览 RTSP 流,我注意到当服务器线程退出时(当 main 仍在运行时),VLC 播放器仍然能够接收来自服务器的传输。如果我关闭播放器,我将无法再次连接到服务器。我没有“取消引用”或释放什么来保持服务器的事件?
#include <gst/gst.h>
#include <gst/rtsp-server/rtsp-server.h>
#include <stdlib.h>
#include <string>
#include <pthread.h>
#include <iostream>
using namespace std;
int thread_running = 1;
struct ThreadArgs {
GMainLoop *loop;
};
void *ServerThreadFunction(void *args) {
g_print("Starting server.\n");
ThreadArgs *ta = (ThreadArgs *)args;
GstRTSPServer *server;
GstRTSPMediaFactory *factory;
GstRTSPMountPoints *mounts;
gst_init(NULL, NULL);
server = gst_rtsp_server_new();
gst_rtsp_server_attach(server, NULL);
factory = gst_rtsp_media_factory_new();
gst_rtsp_media_factory_set_launch(factory, "( videotestsrc ! x264enc ! rtph264pay pt=96 name=pay0 )");
mounts = gst_rtsp_server_get_mount_points(server);
gst_rtsp_mount_points_add_factory(mounts, "/test", factory);
g_object_unref(mounts);
g_main_loop_run(ta->loop);
g_object_unref(server);
g_print("Terminating server.\n");
thread_running = 0;
pthread_exit(NULL);
}
void *KillServerFunction(void *args) {
ThreadArgs *ta = (ThreadArgs *)args;
cout << "Is the loop running? " << g_main_loop_is_running(ta->loop) << endl;
g_main_loop_quit(ta->loop);
pthread_exit(NULL);
}
int main (int argc, char *argv[]) {
ThreadArgs *ta = new ThreadArgs;
ta->loop = g_main_loop_new(NULL, FALSE);
pthread_t server_thread;
int rc = pthread_create(&server_thread, NULL, ServerThreadFunction, (void *)ta);
// Start VLC player here e.g. vlc rtsp://127.0.0.1/test
sleep(1);
cout << "Killing server in 3" << endl;
sleep(1);
cout << "Killing server in 2" << endl;
sleep(1);
cout << "Killing server in 1" << endl;
sleep(1);
pthread_t kill_server_thread;
pthread_create(&kill_server_thread, NULL, KillServerFunction, (void *)ta);
while (thread_running == 1) {}
cout << "Program continues to run but stream is still viewable on VLC player..." << endl;
sleep(100);
return 0;
}
最佳答案
请尝试以下操作:
需要调用g_source_remove();
创建服务器:
if ((gst_server_id=gst_rtsp_server_attach (gst_server, NULL)) == 0)
goto failed;
停止服务器:
g_source_remove (gst_server_id);
此外,来自 gstreamer-rtsp-server docs :
Note that if context is not the default main context as returned by g_main_context_default() (or NULL), g_source_remove() cannot be used to destroy the source. In that case it is recommended to use gst_rtsp_server_create_source() and attach it to context manually.
关于c++ - 关闭在线程上运行的 GStreamer RTSP 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33600762/
是否有人尝试将 Gstreamer SDK 教程移植到 http://docs.gstreamer.com/display/GstSDK/Tutorials到 gstreamer 1.0? 我尝试将
我正在尝试构建和安装 gst-plugin-bad-1.4.0,但在为我的硬件目标运行配置脚本时出现以下错误。我正在我的 Ubuntu 上安装的目标 SDK/linux-devkit/中运行构建,并且
我想制作某种流媒体服务器。我希望它通过网络从实时流(例如网络摄像头、ipcam 等)接收 RTSP 流,然后使用不同的 URL 在我的本地网络上广播相同的流。我知道 gstreamer 可以做得很好,
在将解复用的 h264 解码输出发送到 gstreamer 管道中的 autovideosink 之前,是否可以在两者之间提供一些延迟。如果是这样,任何人都可以发布示例管道来做到这一点。 我使用的管道
我需要捕获第二个显示器的屏幕并在主显示器中的一个窗口内“监视”它(以 x0.5 缩放并使用相邻插值,因为我更喜欢性能与质量)。从这里 link ,我有这个截屏命令: gst-launch ximage
与 stagefright 相比,使用 gstreamer 有哪些优势?谁能指出其中的区别。 最佳答案 一开始,一个非常笼统的评论。如果GStreamer 是非常值得商榷的。优于 Stagefrigh
我确定我已经让这个管道在我设置的早期 Ubuntu 系统上运行(为了便于阅读而格式化): playbin uri=rtspt://user:pswd@192.168.xxx.yyy/ch1/m
我创建了一个管道,如下所示: v4l2src -> tee -> queue -> encoder -> avimux -> filesink tee -> queue -> v
在执行以下命令时, gst-launch-1.0 filesrc location=Wildlife.wmv ! decodebin ! queue ! ffmpegcolorspace ! auto
我想将二进制数据直接写入 gstreamer 管道,但我无法这样做。 我试过 rawaudioparse 插件。我已将二进制数据写入 .raw 文件并尝试使用此命令播放此二进制数据。 gst-laun
如何查看 GST_CAT_INFO、GST_DEBUG 等函数的输出? 我需要使用调试级别设置自己编译 gstreamer 还是可以在应用程序级别完成? 最佳答案 可以使用 GST_DEBUG 环境变
我想编写(但首先我想了解如何做)基于 GStreamer 框架的应用程序(不止一个),这些应用程序将同时共享相同的硬件资源。 例如:有硬件加速的视频解码。我想使用硬件加速同时启动两个能够解码不同视频流
我有一个 gstreamer 管道,它可以完美地工作并获取相机流,将其编码为 H.264 视频,将其保存到文件中并按如下方式在屏幕上显示: gst-launch-1.0 -v autovideosrc
我正在开发 C 程序来执行自适应流,但我无法使用 g_object_set() 函数更改 x264enc 元素的“比特率”属性。我该如何更改它? 谢谢。 最佳答案 安装git版本的gstreamer丑
我有一个 gstreamer 管道,它可以完美地工作并获取相机流,将其编码为 H.264 视频,将其保存到文件中并按如下方式在屏幕上显示: gst-launch-1.0 -v autovideosrc
我跑 ./autogen.sh在克隆的 repo 中,它没有说以下内容: configure: No package 'gstreamer-plugins-base-1.0' found config
引用http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/section-dynamic-pipelines.htm
我有一个项目,我们正在使用 gstreamer、x264 等通过本地网络将视频流多播到多个接收器(连接到监视器的专用计算机)。我们在视频源(相机)系统和显示器上都使用了 gstreamer。 我们使用
我正在尝试使用 GStreamer 作为我们正在内部开发的软电话的视频后端。我们的软电话不是基于 GLib 的,有自己的事件循环。是否可以在没有 GMainLoop 的情况下设置 gst 管道并进入各
关于 gstreamer 元素的一些信息,我必须发出一个查询,比如 gst_element_query_position(data.playbin,GST_FORMAT_TIME,¤t)
我是一名优秀的程序员,十分优秀!