Module: qdmvideoout.cpp

class QDMVideoOut
.h

constructorQDMVideoOut()

: QDMObject()

destructor~QDMVideoOut()
AddConsumerParamsvoid AddConsumerParams(QDMBPool *pool)

Get necessary params to use this input object

RegisterPoolvoid RegisterPool(QDMBPool *pool)
GetFDint GetFD()
GetSizevoid GetSize(int *w,int *h)
GetTransferSizeint GetTransferSize()
SetSizevoid SetSize(int w,int h)
SetZoomSizevoid SetZoomSize(int w,int h)
SetOffsetvoid SetOffset(int x,int y)
SetOriginvoid SetOrigin(int x,int y)
SetLayoutvoid SetLayout(int n)
SetFormatvoid SetFormat(int n)
SetPackingvoid SetPacking(int n)
SetCaptureTypevoid SetCaptureType(int n)
SetTimingvoid SetTiming(int n)
SetGenlockvoid SetGenlock(bool b)
Startvoid Start()

Start transferring

GetEventvoid GetEvent(VLEvent *event)

This is actually not advised to use under USE_VL_65
Use QVideoServer's event handling functions; this function
will return events for ANY video path, not just the video out path (!)

Sendvoid Send(DMbuffer buf)


/*
 * QDMVideoOut - definition/implementation
 * 13-11-99: Support for VL65 interface
 * NOTES:
 * - Generated by mkclass
 * BUGS:
 * - Same bugs apply as for QDMVideoIn; event handling of VL was changed
 * to generate events for all paths in one place. Need to demultiplex.
 * (C) 01-01-98 MarketGraph/RVG
 */

#include <qlib/dmvideoout.h>
#include <qlib/dmbpool.h>
#include <qlib/app.h>
#include <qlib/debug.h>
DEBUG_ENABLE

#undef  DBG_CLASS
#define DBG_CLASS "QDMVideoOut"

QDMVideoOut::QDMVideoOut()
  : QDMObject()
{
  QVideoServer *vs;
  int x,y;

  DBG_C("ctor")
  vs=app->GetVideoServer();
  // Nodes from video to memory
  srcNode=new QVideoNode(vs,VL_SRC,VL_MEM,VL_ANY);
  drnNode=new QVideoNode(vs,VL_DRN,VL_VIDEO,VL_ANY);
  // Create path
  pathOut=new QVideoPath(vs,VL_ANY,srcNode,drnNode);

  // Setup hardware
  if(!pathOut->Setup(VL_SHARE,VL_SHARE))
  { qerr("QDMVideoOut: can't setup input path");
  }

  // Default control values
  SetTiming(VL_TIMING_625_CCIR601);
  //SetPacking(VL_PACKING_YVYU_422_8);
  SetPacking(VL_PACKING_ABGR_8);
  //drnNode->SetControl(VL_CAP_TYPE,VL_CAPTURE_NONINTERLEAVED);
  //srcNode->SetControl(VL_CAP_TYPE,VL_CAPTURE_INTERLEAVED);
  SetCaptureType(VL_CAPTURE_INTERLEAVED);
  SetFormat(VL_FORMAT_RGB);
  //srcNode->SetControl(VL_FORMAT,VL_FORMAT_RGB);
  drnNode->SetControl(VL_SYNC,VL_SYNC_INTERNAL);
  //srcNode->GetXYControl(VL_SIZE,&x,&y);
  //SetZoomSize(x,y);

  //drnNode->SetControl(VL_ORIGIN,0,16);		// ??
  //drnNode->SetControl(VL_ZOOM,1,1);
  //srcNode->SetControl(VL_TIMING,VL_TIMING_625_CCIR601);
  //drnNode->SetControl(VL_CAP_TYPE,VL_CAPTURE_INTERLEAVED);
  SetLayout(VL_LAYOUT_GRAPHICS);

  // Debug
  //qdbg("  video in transfer size=%d\n",pathOut->GetTransferSize());
  drnNode->GetXYControl(VL_SIZE,&x,&y);
  //qdbg("  video in size: %dx%d\n",x,y);
}

QDMVideoOut::~QDMVideoOut()
{
  delete pathOut;
  delete drnNode;
  delete srcNode;
}

/*******
* POOL *
*******/
void QDMVideoOut::AddConsumerParams(QDMBPool *pool)
// Get necessary params to use this input object
{
#ifdef USE_VL_65
  vlDMGetParams(app->GetVideoServer()->GetSGIServer(),
    pathOut->GetSGIPath(),drnNode->GetSGINode(),
    pool->GetCreateParams()->GetDMparams());
#else
  vlDMPoolGetParams(app->GetVideoServer()->GetSGIServer(),
    pathOut->GetSGIPath(),drnNode->GetSGINode(),
    pool->GetCreateParams()->GetDMparams());
#endif
  qdbg("QDMVideoOut:GetPoolParams; buffersize=%d\n",
    pool->GetCreateParams()->GetInt(DM_BUFFER_SIZE));
}
void QDMVideoOut::RegisterPool(QDMBPool *pool)
{
  if(vlDMPoolRegister(app->GetVideoServer()->GetSGIServer(),
    pathOut->GetSGIPath(),drnNode->GetSGINode(),pool->GetDMbufferpool())<0)
    qerr("QDMVideoOut: can't register pool");
}

/*******
* INFO *
*******/
int QDMVideoOut::GetFD()
{
#ifdef USE_VL_65
  //return drnNode->GetFD();
  return srcNode->GetFD();
#else
  return pathOut->GetFD();
#endif
}
void QDMVideoOut::GetSize(int *w,int *h)
{
  drnNode->GetXYControl(VL_SIZE,w,h);
}
int QDMVideoOut::GetTransferSize()
{
  if(!pathOut)return 0;
  return pathOut->GetTransferSize();
}

void QDMVideoOut::SetSize(int w,int h)
{
  //drnNode->SetControl(VL_SIZE,w,h);
  srcNode->SetControl(VL_SIZE,w,h);
}
void QDMVideoOut::SetZoomSize(int w,int h)
{
  drnNode->SetControl(VL_MVP_ZOOMSIZE,w,h);
}
void QDMVideoOut::SetOffset(int x,int y)
{
  drnNode->SetControl(VL_SIZE,x,y);
}
void QDMVideoOut::SetOrigin(int x,int y)
{
  drnNode->SetControl(VL_ORIGIN,x,y);
}

void QDMVideoOut::SetLayout(int n)
{ srcNode->SetControl(VL_LAYOUT,n);
}
void QDMVideoOut::SetFormat(int n)
{ srcNode->SetControl(VL_FORMAT,n);
}
void QDMVideoOut::SetPacking(int n)
{ srcNode->SetControl(VL_PACKING,n);
}
void QDMVideoOut::SetCaptureType(int n)
{ srcNode->SetControl(VL_CAP_TYPE,n);
}
void QDMVideoOut::SetTiming(int n)
{ drnNode->SetControl(VL_TIMING,n);
}
void QDMVideoOut::SetGenlock(bool b)
{
  drnNode->SetControl(VL_SYNC,b?VL_SYNC_GENLOCK:VL_SYNC_INTERNAL);
}

void QDMVideoOut::Start()
// Start transferring
{
#ifdef FUTURE
  VLTransferDescriptor xferDesc;
#endif
  pathOut->SelectEvents(
                 VLTransferCompleteMask |
                 VLStreamBusyMask |
                 VLStreamPreemptedMask |
                 VLAdvanceMissedMask |
                 VLStreamAvailableMask |
                 VLSyncLostMask |
                 VLStreamStartedMask |
                 VLStreamStoppedMask |
                 VLSequenceLostMask |
                 VLControlChangedMask |
                 VLTransferCompleteMask |
                 VLTransferFailedMask |
                 //VLEvenVerticalRetraceMask |
                 //VLOddVerticalRetraceMask |
                 //VLFrameVerticalRetraceMask |
                 VLDeviceEventMask |
                 VLDefaultSourceMask |
                 VLControlRangeChangedMask |
                 VLControlPreemptedMask |
                 VLControlAvailableMask |
                 VLDefaultDrainMask |
                 VLStreamChangedMask |
                 VLTransferError);

  /*pathOut->SelectEvents(VLTransferCompleteMask|
                       VLTransferFailedMask|
                       VLStreamPreemptedMask|
                       VLDeviceEventMask);*/
#ifdef FUTURE
  xferDesc.mode=VL_TRANSFER_MODE_CONTINUOUS;
  xferDesc.count=1;
  xferDesc.delay=0;
  xferDesc.trigger=VLTriggerImmediate;
#endif
  pathOut->BeginTransfer();
}

void QDMVideoOut::GetEvent(VLEvent *event)
// This is actually not advised to use under USE_VL_65
// Use QVideoServer's event handling functions; this function
// will return events for ANY video path, not just the video out path (!)
{
#ifdef USE_VL_65
  if(vlPending(app->GetVideoServer()->GetSGIServer())<=0)
    return /*FALSE*/;
  if(vlNextEvent(app->GetVideoServer()->GetSGIServer(),event)!=DM_SUCCESS)
#else
  if(vlEventRecv(app->GetVideoServer()->GetSGIServer(),
    pathOut->GetSGIPath(),event)!=DM_SUCCESS)
#endif
  { qerr("QDMVideoOut:GetEvent failed vlEventRecv");
    return;
  }
}
void QDMVideoOut::Send(DMbuffer buf)
{
#ifdef USE_VL_65
  if(vlDMBufferPutValid(app->GetVideoServer()->GetSGIServer(),
    pathOut->GetSGIPath(),drnNode->GetSGINode(),buf)!=0)
#else
  if(vlDMBufferSend(app->GetVideoServer()->GetSGIServer(),
    pathOut->GetSGIPath(),buf)!=0)
#endif
  { qerr("QDMVideoOut::Send(buf) failed; %s",vlStrError(vlGetErrno()));
  }
}