Blocking the tees?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Blocking the tees?

killerrats
Administrator
This post was updated on .
<http://gstreamer-devel.966125.n4.nabble.com/file/t377034/GstreamerRecordPipeline.jpg
I have two tees one for audio and one for video. I will asynchronous switch
between two branches to record a file. If I stop a branch in one thread and
start a new branch in one branch it won't let me block one of the pads on
the start branch. If I synchronous the process it works fine. Any ideas?

Stop Branch:
 Block Tees
Eos Through the queues
Unlink each element
null each element
remove probe
release pad

Start Branch:
wait for EOS through Stop branch.
Request pads from tees
block pads
link the pads with the queues
unblock each pad



-----
------------------------------
Gstreamer 1.12.4
------------------------------
Windows
--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
------------------------------
Gstreamer 1.16.2
------------------------------
Windows
Reply | Threaded
Open this post in threaded view
|

Re: Blocking the tees?

killerrats
Administrator
figure out I can use the approach GST_PAD_PROBE_TYPE_IDLE through the video
then from video call back block probe GST_PAD_PROBE_TYPE_IDLE into audio
side.

The only draw back is that for some reason didn't send the block through the
audio side. You start from calling the method StoppingTheBranch(); then down
to each method below.

bool RtspPipeline::StoppingTheBranch(const std::string teePadName)
{
        gErrorStoppingBranch = false;
        bool result = true;
        GstElement* vtee = nullptr;
        GstPad* vteePad = nullptr;
        unsigned __int16 count = 0;
        GstPadProbeType BlockType = GST_PAD_PROBE_TYPE_IDLE;

        this->aStopBranchPad = teePadName;
        vtee = this->GetElementFromBin(this->srcPipeline, RTSP_V_TEE_NAME);
        vteePad = GetStaticPad(vtee, teePadName);
        this->aBlockVideoId1 = gst_pad_add_probe(vteePad, BlockType,
video_block_cb, this->pRtspPipeline, nullptr);
        if (this->aBlockVideoId1 == 0)
                result = false;

        End:
        {
                this->UnrefPointerObject(vteePad, vtee, nullptr);
        }

        return result;
}
GstPadProbeReturn RtspPipeline::video_block_cb(GstPad * pad, GstPadProbeInfo
* info, gpointer user_data)
{
        GstPadProbeType BlockType = GST_PAD_PROBE_TYPE_IDLE;
        GstElement* atee = nullptr;
        RtspPipeline* pPipe = static_cast<RtspPipeline*>(user_data);
        GstPadProbeReturn result = GST_PAD_PROBE_OK;
        try
        {
                pPipe->aBlockAudioId1 =
gst_pad_add_probe(GetStaticPad(atee,pPipe->aStopBranchPad),
BlockType,audio_block_cb,user_data, nullptr);
                if (pPipe->aBlockAudioId1 == 0)
                {
                        gErrorStoppingBranch = true;
                        result = GST_PAD_PROBE_DROP;
                }
                gst_object_unref(atee);
        }
        catch (...)
        {
                gErrorStoppingBranch = true;
        }

        return result;
}
GstPadProbeReturn RtspPipeline::audio_block_cb(GstPad * pad, GstPadProbeInfo
* info, gpointer user_data)
{
        GstPadProbeType BlockType = GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM;
        GstElement* appsink = nullptr, *queue1 = nullptr, *queue2 = nullptr;
        GstPad* sinkPad = nullptr;
        RtspPipeline* pPipe = static_cast<RtspPipeline*>(user_data);
        PipelineElements pipe;
        GstPadProbeReturn result = GST_PAD_PROBE_OK;

        try
        {
                ReturnBranchElementNames(pPipe->aStopBranchPad, pipe.appsinkName,
pipe.avimuxName, pipe.queue1Name, pipe.queue2Name);

                appsink = gst_bin_get_by_name(GST_BIN(pPipe->srcPipeline),
pipe.appsinkName.c_str());
                queue1 = gst_bin_get_by_name(GST_BIN(pPipe->srcPipeline),
pipe.queue1Name.c_str());
                queue2 = gst_bin_get_by_name(GST_BIN(pPipe->srcPipeline),
pipe.queue2Name.c_str());

                sinkPad = gst_element_get_static_pad(appsink, "sink");
                const unsigned long probeId = gst_pad_add_probe(sinkPad, BlockType,
RtspEventProbe, user_data, nullptr);
               
                if(probeId == 0)
                {
                        gErrorStoppingBranch = true;
                        result = GST_PAD_PROBE_DROP;
                        goto End;
                }
                gboolean queue1Event = gst_element_send_event(queue1, gst_event_new_eos())
                ,queue2Event = gst_element_send_event(queue2, gst_event_new_eos());
                if( (queue1Event == FALSE) && (queue2Event == FALSE))
                {
                        gErrorStoppingBranch = true;
                        result = GST_PAD_PROBE_DROP;
                        goto End;
                }
               
                if(pPipe->WaitForAppsinkEos())
                {
                        pPipe->StopBranch(pPipe->aStopBranchPad);
                }
        }
        catch (...)
        {
                gErrorStoppingBranch = true;
        }

        End:
        {
                gst_object_unref(appsink);
                gst_object_unref(queue1);
                gst_object_unref(queue2);
        }

        return result;
}
GstPadProbeReturn RtspPipeline::RtspEventProbe(GstPad * pad, GstPadProbeInfo
* info, gpointer user_data)
{
        if (GST_EVENT_TYPE(GST_PAD_PROBE_INFO_DATA(info)) != GST_EVENT_EOS)
        {
                return GST_PAD_PROBE_PASS;
        }

        RtspPipeline* pPipe = static_cast<RtspPipeline*>(user_data);
        gst_pad_remove_probe(pad, GST_PAD_PROBE_INFO_ID(info));
        std::cout << "\nGot Eos through " << GST_ELEMENT_NAME(GST_PAD_PARENT(pad))
<< "\n";
        pPipe->AppsinkEos = true;

        return GST_PAD_PROBE_DROP;
}



-----
------------------------------
Gstreamer 1.12.4
------------------------------
Windows
--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
------------------------------
Gstreamer 1.16.2
------------------------------
Windows