Advertisement
Guest User

gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegprotocol.c#365

a guest
Aug 17th, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. static int
  2. gst_ffmpeg_pipe_read (URLContext * h, unsigned char *buf, int size)
  3. {
  4.   GstFFMpegPipe *ffpipe;
  5.   const guint8 *data;
  6.   guint available;
  7.  
  8.   ffpipe = (GstFFMpegPipe *) h->priv_data;
  9.  
  10.   GST_LOG ("requested size %d", size);
  11.  
  12.   GST_FFMPEG_PIPE_MUTEX_LOCK (ffpipe);
  13.  
  14.   GST_LOG ("requested size %d", size);
  15.  
  16.   while ((available = gst_adapter_available (ffpipe->adapter)) < size
  17.       && !ffpipe->eos) {
  18.     GST_DEBUG ("Available:%d, requested:%d", available, size);
  19.     ffpipe->needed = size;
  20.     GST_FFMPEG_PIPE_SIGNAL (ffpipe);
  21.     GST_FFMPEG_PIPE_WAIT (ffpipe);
  22.   }
  23.  
  24.   size = MIN (available, size);
  25.   if (size) {
  26.     GST_LOG ("Getting %d bytes", size);
  27.     data = gst_adapter_peek (ffpipe->adapter, size);
  28.     memcpy (buf, data, size);
  29.     gst_adapter_flush (ffpipe->adapter, size);
  30.     GST_LOG ("%d bytes left in adapter",
  31.         gst_adapter_available (ffpipe->adapter));
  32.     ffpipe->needed = 0;
  33.   }
  34.   GST_FFMPEG_PIPE_MUTEX_UNLOCK (ffpipe);
  35.  
  36.   return size;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement