dshowsrcwrapper: cleanup push buffer callback

This commit is contained in:
Julien Isorce 2009-10-28 17:37:44 +01:00
parent 29fe6205ca
commit db3bd777e8
4 changed files with 29 additions and 25 deletions

View file

@ -94,8 +94,8 @@ static void gst_dshowaudiosrc_reset (GstAudioSrc * asrc);
/* utils */
static GstCaps *gst_dshowaudiosrc_getcaps_from_streamcaps (GstDshowAudioSrc *
src, IPin * pin, IAMStreamConfig * streamcaps);
static gboolean gst_dshowaudiosrc_push_buffer (byte * buffer, long size,
gpointer src_object, UINT64 start, UINT64 stop);
static gboolean gst_dshowaudiosrc_push_buffer (guint8 * buffer, guint size,
gpointer src_object, GstClockTime duration);
static void
gst_dshowaudiosrc_init_interfaces (GType type)
@ -830,8 +830,8 @@ gst_dshowaudiosrc_getcaps_from_streamcaps (GstDshowAudioSrc * src, IPin * pin,
}
static gboolean
gst_dshowaudiosrc_push_buffer (byte * buffer, long size, gpointer src_object,
UINT64 start, UINT64 stop)
gst_dshowaudiosrc_push_buffer (guint8 * buffer, guint size, gpointer src_object,
GstClockTime duration)
{
GstDshowAudioSrc *src = GST_DSHOWAUDIOSRC (src_object);
@ -840,7 +840,7 @@ gst_dshowaudiosrc_push_buffer (byte * buffer, long size, gpointer src_object,
}
g_mutex_lock (src->gbarray_lock);
g_byte_array_prepend (src->gbarray, (guint8 *) buffer, size);
g_byte_array_prepend (src->gbarray, buffer, size);
g_mutex_unlock (src->gbarray_lock);
return TRUE;

View file

@ -57,17 +57,17 @@ HRESULT CDshowFakeSink::CheckMediaType (const CMediaType * pmt)
HRESULT CDshowFakeSink::DoRenderSample (IMediaSample * pMediaSample)
{
if (pMediaSample && m_callback) {
BYTE *
pBuffer = NULL;
LONGLONG
lStart = 0, lStop = 0;
guint8 *pBuffer = NULL;
pMediaSample->GetPointer (&pBuffer);
long
size = pMediaSample->GetActualDataLength ();
guint size = pMediaSample->GetActualDataLength ();
GstClockTimeDiff lStart = 0;
GstClockTimeDiff lStop = 0;
pMediaSample->GetTime (&lStart, &lStop);
lStart *= 100;
lStop *= 100;
m_callback (pBuffer, size, m_data, lStart, lStop);
GstClockTime duration = (lStop - lStart) * 100;
m_callback (pBuffer, size, m_data, duration);
}
return S_OK;

View file

@ -30,8 +30,8 @@ static const GUID CLSID_DshowFakeSink =
0x73}
};
typedef bool (*push_buffer_func) (byte * buffer, long size, gpointer src_object,
UINT64 start, UINT64 stop);
typedef bool (*push_buffer_func) (guint8 * buffer, guint size, gpointer src_object,
GstClockTime duration);
class CDshowFakeSink:public CBaseRenderer
{

View file

@ -101,8 +101,8 @@ static GstCaps *gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc *
src, IPin * pin);
static GstCaps *gst_dshowvideosrc_getcaps_from_enum_mediatypes (GstDshowVideoSrc *
src, IPin * pin);
static gboolean gst_dshowvideosrc_push_buffer (byte * buffer, long size,
gpointer src_object, UINT64 start, UINT64 stop);
static gboolean gst_dshowvideosrc_push_buffer (guint8 * buffer, guint size,
gpointer src_object, GstClockTime duration);
static void
gst_dshowvideosrc_init_interfaces (GType type)
@ -1005,11 +1005,11 @@ gst_dshowvideosrc_getcaps_from_enum_mediatypes (GstDshowVideoSrc * src, IPin * p
}
static gboolean
gst_dshowvideosrc_push_buffer (byte * buffer, long size, gpointer src_object,
UINT64 start, UINT64 stop)
gst_dshowvideosrc_push_buffer (guint8 * buffer, guint size, gpointer src_object,
GstClockTime duration)
{
GstDshowVideoSrc *src = GST_DSHOWVIDEOSRC (src_object);
GstBuffer *buf;
GstBuffer *buf = NULL;
IPin *pPin = NULL;
HRESULT hres = S_FALSE;
AM_MEDIA_TYPE *pMediaType = NULL;
@ -1022,9 +1022,13 @@ gst_dshowvideosrc_push_buffer (byte * buffer, long size, gpointer src_object,
buf = gst_buffer_new_and_alloc (size);
GST_BUFFER_SIZE (buf) = size;
GST_BUFFER_TIMESTAMP (buf) = gst_clock_get_time (GST_ELEMENT (src)->clock);
GST_BUFFER_TIMESTAMP (buf) -= GST_ELEMENT (src)->base_time;
GST_BUFFER_DURATION (buf) = stop - start;
GstClock *clock = gst_element_get_clock (GST_ELEMENT (src));
GST_BUFFER_TIMESTAMP (buf) =
GST_CLOCK_DIFF (gst_element_get_base_time (GST_ELEMENT (src)), gst_clock_get_time (clock));
gst_object_unref (clock);
GST_BUFFER_DURATION (buf) = duration;
if (src->is_rgb) {
/* FOR RGB directshow decoder will return bottom-up BITMAP
@ -1044,7 +1048,7 @@ gst_dshowvideosrc_push_buffer (byte * buffer, long size, gpointer src_object,
GST_DEBUG ("push_buffer => pts %" GST_TIME_FORMAT "duration %"
GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
GST_TIME_ARGS (stop - start));
GST_TIME_ARGS (duration));
/* the negotiate() method already set caps on the source pad */
gst_buffer_set_caps (buf, GST_PAD_CAPS (GST_BASE_SRC_PAD (src)));