Seek support in GstCurlBaseSink

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Seek support in GstCurlBaseSink

Gst-Geek
All,

This question in specific to curl but some one familiar with curl can help me here.

I am trying to add seek support in GstCurlBaseSink plugin for mp4 file fragment push.

Curl has APIs for SEEK operation. One API to register the SEEK function and other for private data. But I don't know how to trigger the seek event. Below links have   API details.
https://curl.haxx.se/libcurl/c/CURLOPT_SEEKDATA.html
https://curl.haxx.se/libcurl/c/CURLOPT_SEEKFUNCTION.html

Can any one help me to understand how to use these APIs ?
API doc describes only about the input seek. Does curl SEEK API support output file seek also ?
----------------------------------------------------------------------------------

I tried to implement seek operation similar to file sink through lseek() using the fd(Curl file descriptor). But seek operation is failing. errno returned is invalid argument.

What wrong here ??

Seek code function.
static gboolean
gst_curl_sink_do_seek (GstCurlBaseSink * sink, guint64 new_offset)
{
  GST_DEBUG_OBJECT (sink, "Seeking to offset %" G_GUINT64_FORMAT
      " using " __GST_STDIO_SEEK_FUNCTION, new_offset);
  if(sink->fd.fd == -1)
      return TRUE;
  if (fsync(sink->fd.fd) < 0)
    goto flush_failed;
#if defined (G_OS_UNIX) || defined (G_OS_WIN32)
  if (lseek (sink->fd.fd, (off_t) new_offset,
          SEEK_SET) == (off_t) - 1)
    goto seek_failed;
#else
    goto seek_failed;
#endif

  return TRUE;

  /* ERRORS */
flush_failed:
  {
    GST_DEBUG_OBJECT (sink, "Flush failed: %s", g_strerror (errno));
    return FALSE;
  }
seek_failed:
  {
    GST_DEBUG_OBJECT (sink, "Seeking failed: %s", g_strerror (errno));
    return FALSE;
  }
}