gpt4 book ai didi

ios - 在iOS 8中播放管道时在Gstreamer中,进入后台并返回前台管道后不起作用:(?

转载 作者:可可西里 更新时间:2023-11-01 05:52:10 28 4
gpt4 key购买 nike

- 实际上,我从链接下载了 gstreamer 的示例教程,

http://cgit.freedesktop.org/~slomo/gst-sdk-tutorials/

git://people.freedesktop.org/~slomo/gst-sdk-tutorials

  • 现在我已经修改了教程 3 中的以下代码,
    -(void) app_function
    {
    GstBus *bus;
    GSource *bus_source;
    GError *error = NULL;

    GST_DEBUG ("Creating pipeline");

    pipeline = gst_pipeline_new ("e-pipeline");


    /* Create our own GLib Main Context and make it the default one */
    context = g_main_context_new ();
    g_main_context_push_thread_default(context);

    /* Build pipeline */
    // pipeline = gst_parse_launch("videotestsrc ! warptv ! videoconvert ! autovideosink", &error);


    source = gst_element_factory_make("udpsrc", "source");

    g_object_set( G_OBJECT ( source), "port", 8001, NULL );

    GstCaps *caps;

    caps = gst_caps_new_simple ("application/x-rtp",
    "encoding-name", G_TYPE_STRING, "H264",
    "payload", G_TYPE_INT, 96,
    "clock-rate", G_TYPE_INT, 90000,
    NULL);

    g_object_set (source, "caps", caps, NULL);




    rtp264depay = gst_element_factory_make ("rtph264depay", "rtph264depay");
    h264parse = gst_element_factory_make ("h264parse", "h264parse");
    vtdec = gst_element_factory_make ("vtdec", "vtdec");
    glimagesink = gst_element_factory_make ("glimagesink", "glimagesink");

    gst_bin_add_many (GST_BIN(pipeline), source, rtp264depay, h264parse, vtdec, glimagesink, NULL);




    if (error) {
    gchar *message = g_strdup_printf("Unable to build pipeline: %s", error->message);
    g_clear_error (&error);
    [self setUIMessage:message];
    g_free (message);
    return;
    }

    /* Set the pipeline to READY, so it can already accept a window handle */
    gst_element_set_state(pipeline, GST_STATE_READY);

    video_sink = gst_bin_get_by_interface(GST_BIN(pipeline), GST_TYPE_VIDEO_OVERLAY);
    if (!video_sink) {
    GST_ERROR ("Could not retrieve video sink");
    return;
    }
    gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(video_sink), (guintptr) (id) ui_video_view);

    /* Instruct the bus to emit signals for each received message, and connect to the interesting signals */
    bus = gst_element_get_bus (pipeline);
    bus_source = gst_bus_create_watch (bus);
    g_source_set_callback (bus_source, (GSourceFunc) gst_bus_async_signal_func, NULL, NULL);
    g_source_attach (bus_source, context);
    g_source_unref (bus_source);
    g_signal_connect (G_OBJECT (bus), "message::error", (GCallback)error_cb, (__bridge void *)self);
    g_signal_connect (G_OBJECT (bus), "message::state-changed", (GCallback)state_changed_cb, (__bridge void *)self);
    gst_object_unref (bus);

    /* Create a GLib Main Loop and set it to run */
    GST_DEBUG ("Entering main loop...");
    main_loop = g_main_loop_new (context, FALSE);
    [self check_initialization_complete];
    g_main_loop_run (main_loop);
    GST_DEBUG ("Exited main loop");
    g_main_loop_unref (main_loop);
    main_loop = NULL;

    /* Free resources */
    g_main_context_pop_thread_default(context);
    g_main_context_unref (context);
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);

    return;

    }

  • -现在正在ipad中运行应用程序,应用程序开始播放。
  • 现在正在进入后台并返回到前台
    Gstreamer 流更新在 UI 中不可见,但在 xcode 的网络使用中,我可以看到接收到的数据包....:(

  • 提前致谢....iOS 极客....

    最佳答案

    更新:让 UDP 工作。

    经过进一步调查,我让 UDP h264 流在 linux (PC x86) 上工作,但原理在 IOS 上应该是相同的(特别是 avdec_h264 (在 PC 上使用)必须替换为 vt1205)。

    TCP 和 UDP 管道之间的主要区别:

    服务器端:

  • IP:让我在 UDP 和 TCP 服务器端之间混淆的第一个元素:在 UDP 服务器 上,在 udpsink _0x10071919 udpsink _0x10707160707045045045 端服务器端指定的服务器地址是gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! udpsink host=$CLIENTIP port=5000

  • 而在 TCP服务器端,IP是服务器端(tcpserversink上的主机参数)之一,即gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=$SERVERIP port=5000
  • 视频流有效载荷/格式:为了让客户端能够检测帧的格式和大小, TCP 服务器 端使用 gdppay gdppay _0x1045679100x104080x1045679 管道中的有效载荷_0x2045679 元素。在 客户端 相对的元素上,使用 de-payloader gdpdepay 以便能够读取接收到的帧。

  • gst-launch-1.0 -v fdsrc ! h264解析! rtph264pay 配置间隔=1 pt=96 ! gdppay ! tcpserversink 主机=$SERVERIP 端口=5000

    UDP 服务器端确实 而不是 使用 gdpay 元素,它让客户端在其 udpsink 上使用 CAPS ,请参见下面的客户端差异。

    客户端
  • IP: UDP 客户端不需要 NOT 需要指定任何IP。
    虽然 TCP 客户端需要 服务器 IP (tcpclientsrc 上的主机参数),即gst-launch-1.0 -v tcpclientsrc host=$SERVERIP port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false enable-last-buffer=false
  • 视频流有效载荷/格式:如上一段所述,TCP 服务器端使用有效载荷器 gdppay 而客户端使用去载荷器来识别帧的格式和大小。

  • 相反, UDP 客户端必须在其 udpsrc 元素上使用 caps 明确指定它,即CAPS='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96'
    gst-launch-1.0 -v udpsrc port=5000 caps=$CAPS ! rtph264depay ! avdec_h264 !视频转换! autovideosink sync=false enable-last-buffer=false`

    如何指定大写字母 :它有点笨拙,但它有效:
    运行您的 UDP 服务器,使用详细选项 -v gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! udpsink host=$CLIENTIP port=5000
    你会得到以下日志:
    Setting pipeline to PAUSED ...
    Pipeline is PREROLLING ...
    /GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:src: caps = video/x-h264, width=(int)1280, height=(int)720, parsed=(boolean)true, stream-format=(string)avc, alignment=(string)au, codec_data=(buffer)01640028ffe1000e27640028ac2b402802dd00f1226a01000428ee1f2c
    /GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0.GstPad:src: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, sprop-parameter-sets=(string)"J2QAKKwrQCgC3QDxImo\=\,KO4fLA\=\=", payload=(int)96, ssrc=(uint)3473549335, timestamp-offset=(uint)257034921, seqnum-offset=(uint)12956
    /GstPipeline:pipeline0/GstUDPSink:udpsink0.GstPad:sink: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, sprop-parameter-sets=(string)"J2QAKKwrQCgC3QDxImo\=\,KO4fLA\=\=", payload=(int)96, ssrc=(uint)3473549335, timestamp-offset=(uint)257034921, seqnum-offset=(uint)12956
    /GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0.GstPad:sink: caps = video/x-h264, width=(int)1280, height=(int)720, parsed=(boolean)true, stream-format=(string)avc, alignment=(string)au, codec_data=(buffer)01640028ffe1000e27640028ac2b402802dd00f1226a01000428ee1f2c
    /GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0: timestamp = 257034921
    /GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0: seqnum = 12956
    Pipeline is PREROLLED ...
    Setting pipeline to PLAYING ...

    现在复制以 caps = application/x-rtp 开头的大写字母
    这是指定 rtp 流格式的一种。据我所知,真正必须让 UDP 客户端识别 rtp 流内容然后初始化播放。

    为了总结并避免混淆,请在下面找到完整的命令行示例,将 raspivid 与 Raspberry pi 结合使用。如果您想尝试一下(在 linux 上)

    UDP
  • 服务器:raspivid -t 0 -w 1280 -h 720 -fps 25 -b 2500000 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! udpsink host=$CLIENTIP port=5000
  • 客户端:CAPS='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96'
    gst-launch-1.0 -v udpsrc port=5000 caps=$CAPS ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false enable-last-buffer=false

  • TCP
  • 服务器:raspivid -t 0 -w 1280 -h 720 -fps 25 -b 2500000 -o - | gst-launch-0.10 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=$SERVERIP port=5000
  • 客户端:gst-launch-1.0 -v tcpclientsrc host=$SERVERIP port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false enable-last-buffer=false

  • 注意:使用 cat cat myfile.h264 | gst-launch... 可以很容易地将 Raspivid 替换为简单的 h264 文件

    关于ios - 在iOS 8中播放管道时在Gstreamer中,进入后台并返回前台管道后不起作用:(?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30897446/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com