How to get duration and implement seeking for a rtsp source on GStreamer Android

51 views Asked by At

I had implemented a rtsp server using GStreamer. I followed this sample rtsp-server. I managed to make this project work and serve a mp4 video file and I could stream the rtsp source using VLC app. The server launch pipeline looks like this:

str = g_strdup_printf("( "
                          "filesrc location=\"%s\" ! qtdemux name=d "
                          "d. ! queue ! rtph264pay pt=96 name=pay0 "
                          "d. ! queue ! rtpmp4apay pt=97 name=pay1 " ")",
                          data->src_location);

    /* make a media factory for a test stream. The default media factory can use
     * gst-launch syntax to create pipelines.
     * any launch line works as long as it contains elements named pay%d. Each
     * element with pay%d names will be a stream */
    factory = gst_rtsp_media_factory_new ();

    gst_rtsp_media_factory_set_launch (factory, str);

Now I want to build a rtsp player. Currently the simple client is to use a playbin GstBin and set the rtsp address as its uri. But how can I get the stream duration and implement the seeking to a position for a rtsp source?

I’ve tried the sample from tutorial4 for android, the player could play/pause the rtsp stream, but it could not get the stream duration nor seeking to a position. Meanwhile the VLC app can do it. The player's launch pipeline currently is like this:

/* Build pipeline */ data->pipeline = gst_parse_launch ("playbin", &error);

The code to query the duration is as followed:

  /* If we didn't know it yet, query the stream duration */
  if (!GST_CLOCK_TIME_IS_VALID (data->duration)) {
    if (!gst_element_query_duration (data->pipeline, GST_FORMAT_TIME,
            &data->duration)) {
      GST_WARNING ("Could not query current duration");
    }
  }

When run, the warning message was printed.

Could someone give me some orientations, please?

0

There are 0 answers