Mert Can Ergün
Mert Can Ergün

Reputation: 399

Controlling the state of appsink pipeline depending on its RTSP appsrc clients

I have a hierarchy like below:

SourcePipeline

GstRTSPServer

My caps on both appsink and appsrc are

caps = "video/x-raw,width=640,height=512,format=GRAY8" 

So, on media factories I listen for media-constructed signals and register appsrc pointers to source pipeline. Also when their media changes state to GST_STATE_NULL i remove the pointer from appsrc array in SourcePipeline.

On the source pipeline, appsink pushes the samples to appsrc one by one. When there are no appsrcs left on the array, pipeline's state is changed to GST_STATE_NULL until the first appsrc joins again.

I have some questions and problems:

  1. When 1st client connects to RTSP, the client instantly gets the stream. When the 2nd one joins on he 2nd mountpoint, stream pauses when GstRTSPMedia changes its state to GST_STATE_PLAYING, and after 5 - 6 seconds stream resumes again. This sometimes doesn't happen, though. The stream fails and I can't get it up again before restarting the program.

  2. Is my approach of controlling SourcePipeline correct? How should I do it on an RTSP server?

  3. I set appsrc's block property on TRUE. If I don't set it to true, It uses all the memory, until system becomes unresponsive. Again, what is the right approach here?

  4. I am currently using push_sample to push buffers to appsrcs. What is the difference between push_sample and push_buffer? Which is more effective?

  5. When 2 clients on different mountpoints are watching the stream, it breaks the stream down when 1 of them disconnects or stops the stream. I check new-state signal on GstRTSPMedia to know RTSP pipeline's states. Clearly this approach doesn't work, what is the correct one here?

Upvotes: 3

Views: 854

Answers (1)

Mert Can Ergün
Mert Can Ergün

Reputation: 399

I didn't need to do any synchronization between appsink and appsrc after I got time-stamps solved with

GST_BUFFER_TIMESTAMP(buf) = timestamps[i];
GST_BUFFER_DURATION(buf) = bufferDuration;
timestamps[i] += GST_BUFFER_DURATION(buf);

I already had suspicions about buffer time-stamps but couldn't figure out how to solve them. These 3 lines easily handle the problem, as long as the same clock is used between source pipeline and sink pipelines.

Upvotes: 1

Related Questions