dshowsrcwrapper: cleanup push buffer callback

This commit is contained in:
Julien Isorce 2009-10-22 14:26:30 +02:00
parent 79fe732785
commit 2e4131926f
4 changed files with 29 additions and 25 deletions

View file

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

View file

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

View file

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

View file

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