saperasrc: run gst-indent
This commit is contained in:
parent
d7851d627f
commit
9a971a9fb3
@ -47,12 +47,15 @@ gboolean gst_saperasrc_destroy_objects (GstSaperaSrc * src);
|
||||
class SapMyProcessing : public SapProcessing
|
||||
{
|
||||
public:
|
||||
SapMyProcessing (SapBuffer *pBuffers, SapProCallback pCallback, void *pContext)
|
||||
: SapProcessing (pBuffers, pCallback, pContext) {
|
||||
src = (GstSaperaSrc*)pContext;
|
||||
SapMyProcessing (SapBuffer * pBuffers, SapProCallback pCallback,
|
||||
void *pContext)
|
||||
: SapProcessing (pBuffers, pCallback, pContext)
|
||||
{
|
||||
src = (GstSaperaSrc *) pContext;
|
||||
}
|
||||
|
||||
virtual ~SapMyProcessing () {
|
||||
virtual ~ SapMyProcessing ()
|
||||
{
|
||||
if (m_bInitOK)
|
||||
Destroy ();
|
||||
}
|
||||
@ -69,7 +72,8 @@ protected:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean push_buffer () {
|
||||
gboolean push_buffer ()
|
||||
{
|
||||
void *pData;
|
||||
GstMapInfo minfo;
|
||||
|
||||
@ -83,11 +87,12 @@ protected:
|
||||
/* create a new buffer assign to it the clock time as timestamp */
|
||||
buf = gst_buffer_new_and_alloc (size);
|
||||
|
||||
gst_buffer_set_size(buf, size);
|
||||
gst_buffer_set_size (buf, size);
|
||||
|
||||
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_CLOCK_DIFF (gst_element_get_base_time (GST_ELEMENT (src)),
|
||||
gst_clock_get_time (clock));
|
||||
gst_object_unref (clock);
|
||||
|
||||
// TODO: define duration?
|
||||
@ -98,22 +103,22 @@ protected:
|
||||
GST_ERROR_OBJECT (src, "Failed to map buffer");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// TODO: optimize this
|
||||
if (pitch == src->gst_stride) {
|
||||
memcpy (minfo.data, pData, size);
|
||||
} else {
|
||||
for (int line = 0; line < src->height; line++) {
|
||||
memcpy (minfo.data + (line * src->gst_stride),
|
||||
(guint8*)pData + (line * pitch), pitch);
|
||||
(guint8 *) pData + (line * pitch), pitch);
|
||||
}
|
||||
}
|
||||
|
||||
src->sap_buffers->ReleaseAddress(pData);
|
||||
src->sap_buffers->ReleaseAddress (pData);
|
||||
|
||||
gst_buffer_unmap(buf, &minfo);
|
||||
gst_buffer_unmap (buf, &minfo);
|
||||
|
||||
GST_DEBUG ("push_buffer => pts %" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
|
||||
GST_DEBUG ("push_buffer => pts %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
|
||||
|
||||
g_mutex_lock (&src->buffer_mutex);
|
||||
if (src->buffer != NULL)
|
||||
@ -126,12 +131,13 @@ protected:
|
||||
}
|
||||
|
||||
protected:
|
||||
GstSaperaSrc* src;
|
||||
GstSaperaSrc * src;
|
||||
};
|
||||
|
||||
void gst_saperasrc_xfer_callback (SapXferCallbackInfo *pInfo)
|
||||
void
|
||||
gst_saperasrc_xfer_callback (SapXferCallbackInfo * pInfo)
|
||||
{
|
||||
GstSaperaSrc * src = (GstSaperaSrc*) pInfo->GetContext ();
|
||||
GstSaperaSrc *src = (GstSaperaSrc *) pInfo->GetContext ();
|
||||
|
||||
if (pInfo->IsTrash ()) {
|
||||
/* TODO: update dropped buffer count */
|
||||
@ -141,32 +147,39 @@ void gst_saperasrc_xfer_callback (SapXferCallbackInfo *pInfo)
|
||||
}
|
||||
}
|
||||
|
||||
void gst_saperasrc_pro_callback (SapProCallbackInfo *pInfo)
|
||||
void
|
||||
gst_saperasrc_pro_callback (SapProCallbackInfo * pInfo)
|
||||
{
|
||||
GstSaperaSrc * src = (GstSaperaSrc*) pInfo->GetContext ();
|
||||
GstSaperaSrc *src = (GstSaperaSrc *) pInfo->GetContext ();
|
||||
|
||||
/* TODO: handle buffer */
|
||||
}
|
||||
|
||||
void gst_saperasrc_init_objects (GstSaperaSrc * src)
|
||||
void
|
||||
gst_saperasrc_init_objects (GstSaperaSrc * src)
|
||||
{
|
||||
GST_DEBUG_OBJECT (src, "Resource count: %d", SapManager::GetResourceCount(1, SapManager::ResourceAcq));
|
||||
SapLocation loc(1, 0);
|
||||
GST_DEBUG_OBJECT (src, "Resource count: %d", SapManager::GetResourceCount (1,
|
||||
SapManager::ResourceAcq));
|
||||
SapLocation loc (1, 0);
|
||||
src->sap_acq = new SapAcquisition (loc, src->format_file);
|
||||
/* TODO: allow configuring buffer count? */
|
||||
src->sap_buffers = new SapBufferWithTrash (3, src->sap_acq);
|
||||
src->sap_xfer = new SapAcqToBuf(src->sap_acq, src->sap_buffers, gst_saperasrc_xfer_callback, src);
|
||||
src->sap_xfer =
|
||||
new SapAcqToBuf (src->sap_acq, src->sap_buffers,
|
||||
gst_saperasrc_xfer_callback, src);
|
||||
// TODO: handle bayer
|
||||
//src->sap_bayer = new SapBayer(m_Acq, m_Buffers);
|
||||
src->sap_pro = new SapMyProcessing (src->sap_buffers, gst_saperasrc_pro_callback, src);
|
||||
src->sap_pro =
|
||||
new SapMyProcessing (src->sap_buffers, gst_saperasrc_pro_callback, src);
|
||||
}
|
||||
|
||||
gboolean gst_saperasrc_create_objects (GstSaperaSrc * src)
|
||||
gboolean
|
||||
gst_saperasrc_create_objects (GstSaperaSrc * src)
|
||||
{
|
||||
UINT32 video_type = 0;
|
||||
|
||||
/* Create acquisition object */
|
||||
if (src->sap_acq && !*src->sap_acq && !src->sap_acq->Create()) {
|
||||
if (src->sap_acq && !*src->sap_acq && !src->sap_acq->Create ()) {
|
||||
gst_saperasrc_destroy_objects (src);
|
||||
return FALSE;
|
||||
}
|
||||
@ -218,7 +231,7 @@ gboolean gst_saperasrc_create_objects (GstSaperaSrc * src)
|
||||
|
||||
/* Create processing object */
|
||||
if (src->sap_pro && !*src->sap_pro) {
|
||||
if (!src->sap_pro->Create()) {
|
||||
if (!src->sap_pro->Create ()) {
|
||||
gst_saperasrc_destroy_objects (src);
|
||||
return FALSE;
|
||||
}
|
||||
@ -229,24 +242,27 @@ gboolean gst_saperasrc_create_objects (GstSaperaSrc * src)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean gst_saperasrc_destroy_objects (GstSaperaSrc * src)
|
||||
gboolean
|
||||
gst_saperasrc_destroy_objects (GstSaperaSrc * src)
|
||||
{
|
||||
if (src->sap_xfer && *src->sap_xfer) src->sap_xfer->Destroy ();
|
||||
if (src->sap_xfer && *src->sap_xfer)
|
||||
src->sap_xfer->Destroy ();
|
||||
|
||||
if (src->sap_pro && *src->sap_pro) src->sap_pro->Destroy ();
|
||||
if (src->sap_pro && *src->sap_pro)
|
||||
src->sap_pro->Destroy ();
|
||||
|
||||
// TODO: handle bayer
|
||||
//if (src->sap_bayer && *src->sap_bayer) src->sap_bayer->Destroy ();
|
||||
|
||||
if (src->sap_buffers && *src->sap_buffers) src->sap_buffers->Destroy ();
|
||||
if (src->sap_buffers && *src->sap_buffers)
|
||||
src->sap_buffers->Destroy ();
|
||||
|
||||
if (src->sap_acq && *src->sap_acq) src->sap_acq->Destroy ();
|
||||
if (src->sap_acq && *src->sap_acq)
|
||||
src->sap_acq->Destroy ();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* prototypes */
|
||||
static void gst_saperasrc_set_property (GObject * object,
|
||||
guint property_id, const GValue * value, GParamSpec * pspec);
|
||||
@ -260,13 +276,10 @@ static gboolean gst_saperasrc_stop (GstBaseSrc * src);
|
||||
static GstCaps *gst_saperasrc_get_caps (GstBaseSrc * src, GstCaps * filter);
|
||||
static gboolean gst_saperasrc_set_caps (GstBaseSrc * src, GstCaps * caps);
|
||||
|
||||
static GstFlowReturn gst_saperasrc_create (GstPushSrc * src,
|
||||
GstBuffer ** buf);
|
||||
static GstFlowReturn gst_saperasrc_create (GstPushSrc * src, GstBuffer ** buf);
|
||||
|
||||
static GstCaps *gst_saperasrc_create_caps (GstSaperaSrc * src);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
@ -525,7 +538,7 @@ gst_saperasrc_start (GstBaseSrc * bsrc)
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (src, "Creating caps from Sapera buffer format");
|
||||
sap_format = src->sap_buffers->GetFormat();
|
||||
sap_format = src->sap_buffers->GetFormat ();
|
||||
switch (sap_format) {
|
||||
case SapFormatMono8:
|
||||
gst_format = GST_VIDEO_FORMAT_GRAY8;
|
||||
@ -568,7 +581,7 @@ gst_saperasrc_stop (GstBaseSrc * bsrc)
|
||||
|
||||
GST_DEBUG_OBJECT (src, "stop");
|
||||
|
||||
if (!src->sap_xfer->Freeze()) {
|
||||
if (!src->sap_xfer->Freeze ()) {
|
||||
GST_ERROR_OBJECT (src, "Failed to stop camera acquisition");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user