AJA NTV2 SDK  17.0.1.1246
NTV2 SDK 17.0.1.1246
ntv2streamplayer.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #include "ntv2streamplayer.h"
9 #include "ntv2debug.h"
10 #include "ntv2devicescanner.h"
11 #include "ntv2testpatterngen.h"
13 #include "ajabase/system/process.h"
17 #include <fstream> // For ifstream
18 
19 using namespace std;
20 
21 #define NTV2_BUFFER_LOCKING // Define this to pre-lock video/audio buffers in kernel
22 
23 // Convenience macros for EZ logging:
24 #define TCFAIL(_expr_) AJA_sERROR (AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_)
25 #define TCWARN(_expr_) AJA_sWARNING(AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_)
26 #define TCNOTE(_expr_) AJA_sNOTICE (AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_)
27 #define TCINFO(_expr_) AJA_sINFO (AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_)
28 #define TCDBG(_expr_) AJA_sDEBUG (AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_)
29 
35 static ULWord gAncMaxSizeBytes (NTV2_ANCSIZE_MAX); // Max per-frame anc buffer size, in bytes
36 
45 static const uint32_t gAudMaxSizeBytes (256 * 1024); // Max per-frame audio buffer size, in bytes
46 
47 static const bool BUFFER_PAGE_ALIGNED (true);
48 
49 // Audio tone generator data
50 static const double gFrequencies [] = {250.0, 500.0, 1000.0, 2000.0};
51 static const ULWord gNumFrequencies (sizeof(gFrequencies) / sizeof(double));
52 static const double gAmplitudes [] = { 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85,
53  0.85, 0.80, 0.75, 0.70, 0.65, 0.60, 0.55, 0.50, 0.45, 0.40, 0.35, 0.30, 0.25, 0.20, 0.15, 0.10};
54 
55 
57  : mConfig (inConfig),
58  mConsumerThread (),
59  mProducerThread (),
60  mDevice (),
61  mDeviceID (DEVICE_ID_INVALID),
62  mSavedTaskMode (NTV2_TASK_MODE_INVALID),
63  mCurrentFrame (0),
64  mCurrentSample (0),
65  mToneFrequency (440.0),
66  mAudioSystem (NTV2_AUDIOSYSTEM_INVALID),
67  mFormatDesc (),
68  mGlobalQuit (false),
69  mTCBurner (),
70  mHostBuffers (),
71  mFrameDataRing (),
72  mTestPatRasters ()
73 {
74 }
75 
76 
78 {
79  // Stop my playout and producer threads, then destroy them...
80  Quit();
81 
82  mDevice.UnsubscribeOutputVerticalEvent(mConfig.fOutputChannel); // Unsubscribe from output VBI event
83 } // destructor
84 
85 
87 {
88  // Set the global 'quit' flag, and wait for the threads to go inactive...
89  mGlobalQuit = true;
90 
91  while (mProducerThread.Active())
92  AJATime::Sleep(10);
93 
94  while (mConsumerThread.Active())
95  AJATime::Sleep(10);
96 
97 #if defined(NTV2_BUFFER_LOCKING)
98  mDevice.DMABufferUnlockAll();
99 #endif // NTV2_BUFFER_LOCKING
100  if (!mConfig.fDoMultiFormat && mDevice.IsOpen())
101  {
103  if (NTV2_IS_VALID_TASK_MODE(mSavedTaskMode))
104  mDevice.SetEveryFrameServices(mSavedTaskMode); // Restore prior task mode
105  }
106 } // Quit
107 
108 
110 {
111  AJAStatus status (AJA_STATUS_SUCCESS);
112 
113  // Open the device...
115  {cerr << "## ERROR: Device '" << mConfig.fDeviceSpec << "' not found" << endl; return AJA_STATUS_OPEN;}
116  mDeviceID = mDevice.GetDeviceID(); // Keep this ID handy -- it's used frequently
117 
118  if (!mDevice.IsDeviceReady(false))
119  {cerr << "## ERROR: Device '" << mDevice.GetDisplayName() << "' not ready" << endl; return AJA_STATUS_INITIALIZE;}
120  if (!::NTV2DeviceCanDoPlayback(mDeviceID))
121  {cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' is capture-only" << endl; return AJA_STATUS_FEATURE;}
122 
123  const UWord maxNumChannels (::NTV2DeviceGetNumFrameStores(mDeviceID));
124 
125  // Beware -- some older devices (e.g. Corvid1) can only output from FrameStore 2...
126  if ((mConfig.fOutputChannel == NTV2_CHANNEL1) && (!::NTV2DeviceCanDoFrameStore1Display(mDeviceID)))
127  mConfig.fOutputChannel = NTV2_CHANNEL2;
128  if (UWord(mConfig.fOutputChannel) >= maxNumChannels)
129  {
130  cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' can't use Ch" << DEC(mConfig.fOutputChannel+1)
131  << " -- only supports Ch1" << (maxNumChannels > 1 ? string("-Ch") + string(1, char(maxNumChannels+'0')) : "") << endl;
132  return AJA_STATUS_UNSUPPORTED;
133  }
134 
135  if (!mConfig.fDoMultiFormat)
136  {
137  mDevice.GetEveryFrameServices(mSavedTaskMode); // Save the current task mode
139  return AJA_STATUS_BUSY; // Device is in use by another app -- fail
140  }
141  mDevice.SetEveryFrameServices(NTV2_OEM_TASKS); // Set OEM service level
142 
143  if (::NTV2DeviceCanDoMultiFormat(mDeviceID))
144  mDevice.SetMultiFormatMode(mConfig.fDoMultiFormat);
145  else
146  mConfig.fDoMultiFormat = false;
147 
148  // Set up the video and audio...
149  status = SetUpVideo();
150  if (AJA_FAILURE(status))
151  return status;
152  status = mConfig.WithAudio() ? SetUpAudio() : AJA_STATUS_SUCCESS;
153  if (AJA_FAILURE(status))
154  return status;
155 
156  // Set up the circular buffers, and the test pattern buffers...
157  status = SetUpHostBuffers();
158  if (AJA_FAILURE(status))
159  return status;
160  status = SetUpTestPatternBuffers();
161  if (AJA_FAILURE(status))
162  return status;
163 
164  // Set up the device signal routing...
165  if (!RouteOutputSignal())
166  return AJA_STATUS_FAIL;
167 
168  // Lastly, prepare my AJATimeCodeBurn instance...
169  if (!mTCBurner.RenderTimeCodeFont (CNTV2DemoCommon::GetAJAPixelFormat(mConfig.fPixelFormat), mFormatDesc.numPixels, mFormatDesc.numLines))
170  {cerr << "## ERROR: RenderTimeCodeFont failed for: " << mFormatDesc << endl; return AJA_STATUS_UNSUPPORTED;}
171 
172  // Ready to go...
173  #if defined(_DEBUG)
174  cerr << mConfig << endl;
175  #endif // defined(_DEBUG)
176  return AJA_STATUS_SUCCESS;
177 
178 } // Init
179 
180 
182 {
183  // Configure the device to output the requested video format...
184  if (mConfig.fVideoFormat == NTV2_FORMAT_UNKNOWN)
185  return AJA_STATUS_BAD_PARAM;
186  if (!::NTV2DeviceCanDoVideoFormat (mDeviceID, mConfig.fVideoFormat))
187  { cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' doesn't support "
188  << ::NTV2VideoFormatToString(mConfig.fVideoFormat) << endl;
189  return AJA_STATUS_UNSUPPORTED;
190  }
191  if (!::NTV2DeviceCanDoFrameBufferFormat (mDeviceID, mConfig.fPixelFormat))
192  { cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' doesn't support "
193  << ::NTV2FrameBufferFormatString(mConfig.fPixelFormat) << endl;
194  return AJA_STATUS_UNSUPPORTED;
195  }
196 
197  // This demo doesn't playout dual-link RGB over SDI -- only YCbCr.
198  // Check that this device has a CSC to convert RGB to YUV...
199  if (::IsRGBFormat(mConfig.fPixelFormat)) // If RGB FBF...
200  if (UWord(mConfig.fOutputChannel) > ::NTV2DeviceGetNumCSCs(mDeviceID)) // No CSC for this channel?
201  {cerr << "## ERROR: No CSC for channel " << DEC(mConfig.fOutputChannel+1) << " to convert RGB pixel format" << endl;
202  return AJA_STATUS_UNSUPPORTED;}
203 
204  if (!::NTV2DeviceCanDo3GLevelConversion(mDeviceID) && mConfig.fDoABConversion && ::IsVideoFormatA(mConfig.fVideoFormat))
205  mConfig.fDoABConversion = false;
206  if (mConfig.fDoABConversion)
208 
209  // Keep the raster description handy...
210  mFormatDesc = NTV2FormatDescriptor(mConfig.fVideoFormat, mConfig.fPixelFormat);
211  if (!mFormatDesc.IsValid())
212  return AJA_STATUS_FAIL;
213 
214  // Turn on the FrameStore (to read frame buffer memory and transmit video)...
215  mDevice.EnableChannel(mConfig.fOutputChannel);
216  mDevice.SetMode(mConfig.fOutputChannel, NTV2_MODE_DISPLAY);
217 
218  // This demo assumes VANC is disabled...
219  mDevice.SetVANCMode(NTV2_VANCMODE_OFF, mConfig.fOutputChannel);
221 
222  // Set the FrameStore video format...
223  mDevice.SetVideoFormat (mConfig.fVideoFormat, false, false, mConfig.fOutputChannel);
224 
225  // Set the frame buffer pixel format for the device FrameStore...
226  mDevice.SetFrameBufferFormat (mConfig.fOutputChannel, mConfig.fPixelFormat);
227 
228  // The output interrupt is Enabled by default, but on some platforms, you must subscribe to it
229  // in order to be able to wait on its event/semaphore...
231 
232  // Check if HDR anc is permissible...
234  {cerr << "## WARNING: HDR Anc requested, but device can't do custom anc" << endl;
236 
237  // Get current per-field maximum Anc buffer size...
240 
241  // Set output clock reference...
243 
244  // At this point, video setup is complete (except for widget signal routing).
245  return AJA_STATUS_SUCCESS;
246 
247 } // SetUpVideo
248 
249 
251 {
252  uint16_t numAudioChannels (::NTV2DeviceGetMaxAudioChannels(mDeviceID));
253 
254  // If there are 2048 pixels on a line instead of 1920, reduce the number of audio channels
255  // This is because HANC is narrower, and has space for only 8 channels
256  if (NTV2_IS_2K_1080_VIDEO_FORMAT(mConfig.fVideoFormat) && numAudioChannels > 8)
257  numAudioChannels = 8;
258 
259  mAudioSystem = NTV2_AUDIOSYSTEM_1; // Use NTV2_AUDIOSYSTEM_1...
260  if (::NTV2DeviceGetNumAudioSystems(mDeviceID) > 1) // ...but if the device has more than one audio system...
261  mAudioSystem = ::NTV2ChannelToAudioSystem(mConfig.fOutputChannel); // ...base it on the channel
262  // However, there are a few older devices that have only 1 audio system,
263  // yet 2 frame stores (or must use channel 2 for playout)...
264  if (!::NTV2DeviceCanDoFrameStore1Display(mDeviceID))
265  mAudioSystem = NTV2_AUDIOSYSTEM_1;
266 
267  mDevice.SetNumberAudioChannels (numAudioChannels, mAudioSystem);
268  mDevice.SetAudioRate (NTV2_AUDIO_48K, mAudioSystem);
269 
270  // How big should the on-device audio buffer be? 1MB? 2MB? 4MB? 8MB?
271  // For this demo, 4MB will work best across all platforms (Windows, Mac & Linux)...
272  mDevice.SetAudioBufferSize (NTV2_AUDIO_BUFFER_BIG, mAudioSystem);
273 
274  // Set the SDI output audio embedders to embed audio samples from the output of mAudioSystem...
275  mDevice.SetSDIOutputAudioSystem (mConfig.fOutputChannel, mAudioSystem);
276  mDevice.SetSDIOutputDS2AudioSystem (mConfig.fOutputChannel, mAudioSystem);
277 
278  // If the last app using the device left it in E-E mode (input passthru), then loopback
279  // must be disabled --- otherwise the output audio will be pass-thru SDI input audio...
280  mDevice.SetAudioLoopBack (NTV2_AUDIO_LOOPBACK_OFF, mAudioSystem);
281 
282  if (!mConfig.fDoMultiFormat && ::NTV2DeviceGetNumHDMIVideoOutputs(mDeviceID))
283  {
287  }
288 
289  return AJA_STATUS_SUCCESS;
290 
291 } // SetUpAudio
292 
293 
295 {
296  CNTV2DemoCommon::SetDefaultPageSize(); // Set host-specific page size
297 
298  // Let my circular buffer know when it's time to quit...
299  mFrameDataRing.SetAbortFlag (&mGlobalQuit);
300 
301  // Allocate and add each in-host NTV2FrameData to my circular buffer member variable...
302  mHostBuffers.reserve(CIRCULAR_BUFFER_SIZE);
303  while (mHostBuffers.size() < CIRCULAR_BUFFER_SIZE)
304  {
305  mHostBuffers.push_back(NTV2FrameData()); // Make a new NTV2FrameData...
306  NTV2FrameData & frameData(mHostBuffers.back()); // ...and get a reference to it
307 
308  // Allocate a page-aligned video buffer
309  if (mConfig.WithVideo())
310  if (!frameData.fVideoBuffer.Allocate (mFormatDesc.GetTotalBytes(), BUFFER_PAGE_ALIGNED))
311  {
312  PLFAIL("Failed to allocate " << xHEX0N(mFormatDesc.GetTotalBytes(),8) << "-byte video buffer");
313  return AJA_STATUS_MEMORY;
314  }
315  if (frameData.fVideoBuffer)
316  {
317  frameData.fVideoBuffer.Fill(ULWord(0));
318  mDevice.DMABufferLock(frameData.fVideoBuffer, true);
319  }
320 
321  // Allocate a page-aligned audio buffer (if transmitting audio)
322  if (mConfig.WithAudio())
324  {
325  PLFAIL("Failed to allocate " << xHEX0N(gAudMaxSizeBytes,8) << "-byte audio buffer");
326  return AJA_STATUS_MEMORY;
327  }
328  if (frameData.fAudioBuffer)
329  {
330  frameData.fAudioBuffer.Fill(ULWord(0));
331  mDevice.DMABufferLock(frameData.fAudioBuffer, /*alsoPreLockSGL*/true);
332  }
333  mFrameDataRing.Add (&frameData);
334  } // for each NTV2FrameData
335 
336  return AJA_STATUS_SUCCESS;
337 
338 } // SetUpHostBuffers
339 
340 
342 {
343  vector<NTV2TestPatternSelect> testPatIDs;
344  testPatIDs.push_back(NTV2_TestPatt_ColorBars100);
345  testPatIDs.push_back(NTV2_TestPatt_ColorBars75);
346  testPatIDs.push_back(NTV2_TestPatt_Ramp);
347  testPatIDs.push_back(NTV2_TestPatt_MultiBurst);
348  testPatIDs.push_back(NTV2_TestPatt_LineSweep);
349  testPatIDs.push_back(NTV2_TestPatt_CheckField);
350  testPatIDs.push_back(NTV2_TestPatt_FlatField);
351  testPatIDs.push_back(NTV2_TestPatt_MultiPattern);
352  testPatIDs.push_back(NTV2_TestPatt_Border);
353 
354  mTestPatRasters.clear();
355  for (size_t tpNdx(0); tpNdx < testPatIDs.size(); tpNdx++)
356  mTestPatRasters.push_back(NTV2Buffer());
357 
358  if (!mFormatDesc.IsValid())
359  {PLFAIL("Bad format descriptor"); return AJA_STATUS_FAIL;}
360  if (mFormatDesc.IsVANC())
361  {PLFAIL("VANC should have been disabled: " << mFormatDesc); return AJA_STATUS_FAIL;}
362 
363  // Set up one video buffer for each test pattern...
364  for (size_t tpNdx(0); tpNdx < testPatIDs.size(); tpNdx++)
365  {
366  // Allocate the buffer memory...
367  if (!mTestPatRasters.at(tpNdx).Allocate (mFormatDesc.GetTotalBytes(), BUFFER_PAGE_ALIGNED))
368  { PLFAIL("Test pattern buffer " << DEC(tpNdx+1) << " of " << DEC(testPatIDs.size()) << ": "
369  << xHEX0N(mFormatDesc.GetTotalBytes(),8) << "-byte page-aligned alloc failed");
370  return AJA_STATUS_MEMORY;
371  }
372 
373  // Fill the buffer with test pattern...
374  NTV2TestPatternGen testPatternGen;
375  if (!testPatternGen.DrawTestPattern (testPatIDs.at(tpNdx), mFormatDesc, mTestPatRasters.at(tpNdx)))
376  {
377  cerr << "## ERROR: DrawTestPattern " << DEC(tpNdx) << " failed: " << mFormatDesc << endl;
378  return AJA_STATUS_FAIL;
379  }
380 
381  #ifdef NTV2_BUFFER_LOCKING
382  // Try to prelock the memory, including its scatter-gather list...
383 // if (!mDevice.DMABufferLock(mTestPatRasters.at(tpNdx), /*alsoLockSegmentMap=*/true))
384 // PLWARN("Test pattern buffer " << DEC(tpNdx+1) << " of " << DEC(testPatIDs.size()) << ": failed to pre-lock");
385  #endif
386  } // loop for each predefined pattern
387 
388  return AJA_STATUS_SUCCESS;
389 
390 } // SetUpTestPatternBuffers
391 
392 
394 {
395  const NTV2Standard outputStandard (::GetNTV2StandardFromVideoFormat(mConfig.fVideoFormat));
396  const UWord numSDIOutputs (::NTV2DeviceGetNumVideoOutputs (mDeviceID));
397  const bool isRGB (::IsRGBFormat(mConfig.fPixelFormat));
398  const bool canVerify (mDevice.HasCanConnectROM());
399  UWord connectFailures (0);
400 
401  const NTV2OutputXptID cscVidOutXpt(::GetCSCOutputXptFromChannel(mConfig.fOutputChannel, false/*isKey*/, !isRGB/*isRGB*/));
402  const NTV2OutputXptID fsVidOutXpt (::GetFrameBufferOutputXptFromChannel(mConfig.fOutputChannel, isRGB/*isRGB*/, false/*is425*/));
403  const NTV2InputXptID cscInputXpt (isRGB ? ::GetCSCInputXptFromChannel(mConfig.fOutputChannel, false/*isKeyInput*/) : NTV2_INPUT_CROSSPOINT_INVALID);
404  if (isRGB)
405  if (!mDevice.Connect (cscInputXpt, fsVidOutXpt, canVerify))
406  connectFailures++;
407 
408  if (mConfig.fDoMultiFormat)
409  {
410  // Multiformat --- We may be sharing the device with other processes, so route only one SDI output...
411  if (::NTV2DeviceHasBiDirectionalSDI(mDeviceID))
412  mDevice.SetSDITransmitEnable(mConfig.fOutputChannel, true);
413 
414  if (!mDevice.Connect (::GetSDIOutputInputXpt (mConfig.fOutputChannel, false/*isDS2*/), isRGB ? cscVidOutXpt : fsVidOutXpt, canVerify))
415  connectFailures++;
416  // NOTE: No need to send VITC2 with VITC1 (for "i" formats) -- firmware does this automatically
417  mDevice.SetSDIOutputStandard (mConfig.fOutputChannel, outputStandard);
418  }
419  else
420  {
421  // Not multiformat: We own the whole device, so connect all possible SDI outputs...
422  const UWord numFrameStores(::NTV2DeviceGetNumFrameStores(mDeviceID));
423  mDevice.ClearRouting(); // Start with clean slate
424 
425  if (isRGB)
426  if (!mDevice.Connect (cscInputXpt, fsVidOutXpt, canVerify))
427  connectFailures++;
428 
429  for (NTV2Channel chan(NTV2_CHANNEL1); ULWord(chan) < numSDIOutputs; chan = NTV2Channel(chan+1))
430  {
431  if (chan != mConfig.fOutputChannel && chan < numFrameStores)
432  mDevice.DisableChannel(chan); // Disable unused FrameStore
433  if (::NTV2DeviceHasBiDirectionalSDI(mDeviceID))
434  mDevice.SetSDITransmitEnable (chan, true); // Make it an output
435 
436  if (!mDevice.Connect (::GetSDIOutputInputXpt (chan, false/*isDS2*/), isRGB ? cscVidOutXpt : fsVidOutXpt, canVerify))
437  connectFailures++;
438  mDevice.SetSDIOutputStandard (chan, outputStandard);
439  // NOTE: No need to send VITC2 with VITC1 (for "i" formats) -- firmware does this automatically
440 
441  if (mConfig.WithAudio())
442  mDevice.SetSDIOutputAudioSystem (chan, mAudioSystem); // Ensure SDIOut embedder gets audio from mAudioSystem
443  } // for each SDI output spigot
444 
445  // And connect analog video output, if the device has one...
446  if (::NTV2DeviceGetNumAnalogVideoOutputs(mDeviceID))
447  if (!mDevice.Connect (::GetOutputDestInputXpt(NTV2_OUTPUTDESTINATION_ANALOG), isRGB ? cscVidOutXpt : fsVidOutXpt, canVerify))
448  connectFailures++;
449 
450  // And connect HDMI video output, if the device has one...
451  if (::NTV2DeviceGetNumHDMIVideoOutputs(mDeviceID))
452  if (!mDevice.Connect (::GetOutputDestInputXpt(NTV2_OUTPUTDESTINATION_HDMI), isRGB ? cscVidOutXpt : fsVidOutXpt, canVerify))
453  connectFailures++;
454  }
455  if (connectFailures)
456  PLWARN(DEC(connectFailures) << " 'Connect' call(s) failed");
457  return connectFailures == 0;
458 
459 } // RouteOutputSignal
460 
461 
463 {
464  // Start my consumer and producer threads...
467  return AJA_STATUS_SUCCESS;
468 
469 } // Run
470 
471 
472 
474 // This is where the play thread starts
475 
477 {
478  // Create and start the playout thread...
479  mConsumerThread.Attach (ConsumerThreadStatic, this);
480  mConsumerThread.SetPriority(AJA_ThreadPriority_High);
481  mConsumerThread.Start();
482 
483 } // StartConsumerThread
484 
485 
486 // The playout thread function
487 void NTV2StreamPlayer::ConsumerThreadStatic (AJAThread * pThread, void * pContext) // static
488 { (void) pThread;
489  // Grab the NTV2StreamPlayer instance pointer from the pContext parameter,
490  // then call its ConsumeFrames method...
491  NTV2StreamPlayer * pApp (reinterpret_cast<NTV2StreamPlayer*>(pContext));
492  if (pApp)
493  pApp->ConsumeFrames();
494 
495 } // ConsumerThreadStatic
496 
497 
499 {
500  NTV2StreamChannel strStatus;
501  NTV2StreamBuffer bfrStatus;
502  ULWord goodQueue(0), badQueue(0), goodRelease(0), starves(0), noRoomWaits(0);
503  ULWord status;
504 
505  // Initialize and claim ownership of the stream
506  status = mDevice.StreamChannelInitialize(mConfig.fOutputChannel);
507  if (status != NTV2_STREAM_STATUS_SUCCESS)
508  {
509  cerr << "## ERROR: Stream initialize failed: " << status << endl;
510  return;
511  }
512  PLNOTE("Thread started");
513 
514  while (!mGlobalQuit)
515  {
516  // Get stream status
517  status = mDevice.StreamChannelStatus(mConfig.fOutputChannel, strStatus);
518  if (status != NTV2_STREAM_STATUS_SUCCESS)
519  {
520  cerr << "## ERROR: Stream status failed: " << status << endl;
521  return;
522  }
523 
524  if (strStatus.GetQueueDepth() < 8)
525  {
526  NTV2FrameData * pFrameData (mFrameDataRing.StartConsumeNextBuffer());
527  if (pFrameData)
528  {
529  // Queue frame to stream
530  NTV2_POINTER buffer(pFrameData->fVideoBuffer.GetHostAddress(0), pFrameData->fVideoBuffer.GetByteCount());
531  status = mDevice.StreamBufferQueue(mConfig.fOutputChannel,
532  buffer,
533  goodQueue,
534  bfrStatus);
535  if (status == NTV2_STREAM_STATUS_SUCCESS)
536  {
537  goodQueue++;
538  }
539  else
540  {
541  badQueue++;
542  cerr << "## ERROR: Stream buffer add failed: " << status << endl;
543  }
544 
545  if (goodQueue == 3)
546  {
547  // Start the stream
548  status = mDevice.StreamChannelStart(mConfig.fOutputChannel, strStatus);
549  if (status != NTV2_STREAM_STATUS_SUCCESS)
550  {
551  cerr << "## ERROR: Stream initialize failed: " << status << endl;
552  return;
553  }
554  }
555  }
556  else
557  {
558  starves++;
559  }
560  continue; // Back to top of while loop
561  }
562  else
563  {
564  noRoomWaits++;
565  }
566 
567  // Look for buffers to release
568  status = mDevice.StreamBufferRelease(mConfig.fOutputChannel, bfrStatus);
569  while (status == NTV2_STREAM_STATUS_SUCCESS)
570  {
571  mFrameDataRing.EndConsumeNextBuffer();
572  goodRelease++;
573  status = mDevice.StreamBufferRelease(mConfig.fOutputChannel, bfrStatus);
574  }
575 
576  // Wait for one or more buffers to become available on the device, which should occur at next VBI...
577  mDevice.StreamChannelWait(mConfig.fOutputChannel, strStatus);
578  } // loop til quit signaled
579 
580  // Stop streaming...
581  status = mDevice.StreamChannelInitialize(mConfig.fOutputChannel);
582  if (status != NTV2_STREAM_STATUS_SUCCESS)
583  {
584  cerr << "## ERROR: Stream initialize failed: " << status << endl;
585  return;
586  }
587 
588  // Release all buffers
589  status = mDevice.StreamBufferRelease(mConfig.fOutputChannel, bfrStatus);
590  while (status == NTV2_STREAM_STATUS_SUCCESS)
591  {
592  mFrameDataRing.EndConsumeNextBuffer();
593  goodRelease++;
594  status = mDevice.StreamBufferRelease(mConfig.fOutputChannel, bfrStatus);
595  }
596 
597  // Release stream ownership
598  status = mDevice.StreamChannelRelease(mConfig.fOutputChannel);
599  if (status != NTV2_STREAM_STATUS_SUCCESS)
600  {
601  cerr << "## ERROR: Stream release failed: " << status << endl;
602  return;
603  }
604 
605  PLNOTE("Thread completed: " << DEC(goodQueue) << " queued, " << DEC(badQueue) << " failed, "
606  << DEC(starves) << " starves, " << DEC(noRoomWaits) << " VBI waits");
607 
608 } // ConsumeFrames
609 
610 
611 
613 // This is where the producer thread starts
614 
616 {
617  // Create and start the producer thread...
618  mProducerThread.Attach(ProducerThreadStatic, this);
619  mProducerThread.SetPriority(AJA_ThreadPriority_High);
620  mProducerThread.Start();
621 
622 } // StartProducerThread
623 
624 
625 void NTV2StreamPlayer::ProducerThreadStatic (AJAThread * pThread, void * pContext) // static
626 { (void) pThread;
627  NTV2StreamPlayer * pApp (reinterpret_cast<NTV2StreamPlayer*>(pContext));
628  if (pApp)
629  pApp->ProduceFrames();
630 
631 } // ProducerThreadStatic
632 
633 
635 {
636  ULWord testPatNdx(0), badTally(0);
637 
640 
641  PLNOTE("Thread started");
642  NTV2FrameData * pFrameData (mFrameDataRing.StartProduceNextBuffer());
643  mFrameDataRing.EndProduceNextBuffer();
644  while (!mGlobalQuit)
645  {
646 #if 0
647  NTV2FrameData * pFrameData (mFrameDataRing.StartProduceNextBuffer());
648  if (!pFrameData)
649  { badTally++; // No frame available!
650  AJATime::Sleep(10); // Wait a bit for the consumer thread to free one up for me...
651  continue; // ...then try again
652  }
653 #endif
654  // Copy fresh, unmodified, pre-rendered test pattern into this frame's video buffer...
655  pFrameData->fVideoBuffer.CopyFrom (mTestPatRasters.at(testPatNdx),
656  /*srcOffset*/ 0,
657  /*dstOffset*/ 0,
658  /*byteCount*/ pFrameData->fVideoBuffer.GetByteCount());
659  testPatNdx = (testPatNdx + 1) % ULWord(mTestPatRasters.size());
660  AJATime::Sleep(5000);
661  } // loop til mGlobalQuit goes true
662  PLNOTE("Thread completed: " << DEC(mCurrentFrame) << " frame(s) produced, " << DEC(badTally) << " failed");
663 
664 } // ProduceFrames
665 
666 
668 {
669  mDevice.StreamChannelStatus(mConfig.fOutputChannel, outStatus);
670 }
671 
NTV2TestPatternGen::DrawTestPattern
virtual bool DrawTestPattern(const std::string &inTPName, const NTV2FormatDescriptor &inFormatDesc, NTV2Buffer &inBuffer)
Renders the given test pattern or color into a host raster buffer.
CNTV2Card::SubscribeOutputVerticalEvent
virtual bool SubscribeOutputVerticalEvent(const NTV2Channel inChannel)
Causes me to be notified when an output vertical blanking interrupt is generated for the given output...
Definition: ntv2subscriptions.cpp:25
CNTV2Card::SetVANCMode
virtual bool SetVANCMode(const NTV2VANCMode inVancMode, const NTV2Channel inChannel=NTV2_CHANNEL1)
Sets the VANC mode for the given FrameStore.
Definition: ntv2register.cpp:2656
CNTV2Card::SetMultiFormatMode
virtual bool SetMultiFormatMode(const bool inEnable)
Enables or disables multi-format (per channel) device operation. If enabled, each device channel can ...
Definition: ntv2register.cpp:4281
GetSDIOutputInputXpt
NTV2InputXptID GetSDIOutputInputXpt(const NTV2Channel inSDIOutput, const bool inIsDS2=false)
Definition: ntv2signalrouter.cpp:942
CNTV2Card::StreamBufferQueue
virtual ULWord StreamBufferQueue(const NTV2Channel inChannel, NTV2_POINTER inBuffer, ULWord64 bufferCookie, NTV2StreamBuffer &status)
Queue a buffer to the stream. The bufferCookie is a user defined identifier of the buffer used by the...
Definition: ntv2stream.cpp:67
NTV2_AUDIO_LOOPBACK_OFF
@ NTV2_AUDIO_LOOPBACK_OFF
Embeds silence (zeroes) into the data stream.
Definition: ntv2enums.h:1971
CNTV2Card::GetAncRegionOffsetFromBottom
virtual bool GetAncRegionOffsetFromBottom(ULWord &outByteOffsetFromBottom, const NTV2AncillaryDataRegion inAncRegion=NTV2_AncRgn_All)
Answers with the byte offset to the start of an ancillary data region within a device frame buffer,...
Definition: ntv2dma.cpp:659
NTV2_TestPatt_CheckField
@ NTV2_TestPatt_CheckField
Definition: ntv2testpatterngen.h:32
ancillarydata_hdr_hlg.h
Declares the AJAAncillaryData_HDR_HLG class.
NTV2_REFERENCE_SFP1_PTP
@ NTV2_REFERENCE_SFP1_PTP
Specifies the PTP source on SFP 1.
Definition: ntv2enums.h:1413
NTV2_IS_VALID_TASK_MODE
#define NTV2_IS_VALID_TASK_MODE(__m__)
Definition: ntv2publicinterface.h:4265
NTV2StreamChannel
Definition: ntv2publicinterface.h:8701
NTV2_CHANNEL2
@ NTV2_CHANNEL2
Specifies channel or Frame Store 2 (or the 2nd item).
Definition: ntv2enums.h:1308
NTV2_VANCDATA_NORMAL
@ NTV2_VANCDATA_NORMAL
Definition: ntv2enums.h:3729
AJA_ThreadPriority_High
@ AJA_ThreadPriority_High
Definition: thread.h:44
AJATimeCodeBurn::RenderTimeCodeFont
AJA_EXPORT bool RenderTimeCodeFont(AJA_PixelFormat pixelFormat, uint32_t numPixels, uint32_t numLines)
Definition: timecodeburn.cpp:447
NTV2_TestPatt_MultiBurst
@ NTV2_TestPatt_MultiBurst
Definition: ntv2testpatterngen.h:30
NTV2_AUDIO_BUFFER_BIG
@ NTV2_AUDIO_BUFFER_BIG
Definition: ntv2enums.h:1864
gAmplitudes
static const double gAmplitudes[]
Definition: ntv2streamplayer.cpp:52
AJAAncDataType_Unknown
@ AJAAncDataType_Unknown
Includes data that is valid, but we don't recognize.
Definition: ancillarydata.h:46
NTV2FormatDescriptor
Describes a video frame for a given video standard or format and pixel format, including the total nu...
Definition: ntv2formatdescriptor.h:41
IS_KNOWN_AJAAncDataType
#define IS_KNOWN_AJAAncDataType(_x_)
Definition: ancillarydata.h:64
NTV2FrameData
I encapsulate the video, audio and anc host buffers used in the AutoCirculate demos....
Definition: ntv2democommon.h:79
NTV2Channel
NTV2Channel
These enum values are mostly used to identify a specific Frame Store. They're also commonly used to i...
Definition: ntv2enums.h:1305
NTV2Buffer
A generic user-space buffer object that has an address and a length. Used most often to share an arbi...
Definition: ntv2publicinterface.h:5967
AJA_STATUS_SUCCESS
@ AJA_STATUS_SUCCESS
Definition: types.h:368
NTV2Buffer::GetByteCount
ULWord GetByteCount(void) const
Definition: ntv2publicinterface.h:6040
NTV2StreamPlayer::SetUpHostBuffers
virtual AJAStatus SetUpHostBuffers(void)
Sets up my host video & audio buffers.
Definition: ntv2streamplayer.cpp:294
GetNTV2FrameRateFromVideoFormat
NTV2FrameRate GetNTV2FrameRateFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Definition: ntv2utils.cpp:3530
AJAThread::Attach
virtual AJAStatus Attach(AJAThreadFunction *pThreadFunction, void *pUserContext)
Definition: thread.cpp:169
NTV2_AUDIO_48K
@ NTV2_AUDIO_48K
Definition: ntv2enums.h:1875
NTV2StreamChannel::GetQueueDepth
ULWord GetQueueDepth(void)
Gets the queue depth.
Definition: ntv2publicinterface.h:8733
AJA_STATUS_BUSY
@ AJA_STATUS_BUSY
Definition: types.h:378
CNTV2DeviceScanner::GetFirstDeviceFromArgument
static bool GetFirstDeviceFromArgument(const std::string &inArgument, CNTV2Card &outDevice)
Rescans the host, and returns an open CNTV2Card instance for the AJA device that matches a command li...
Definition: ntv2devicescanner.cpp:327
NTV2_AUDIOSYSTEM_1
@ NTV2_AUDIOSYSTEM_1
This identifies the first Audio System.
Definition: ntv2enums.h:3811
AJACircularBuffer::StartConsumeNextBuffer
FrameDataPtr StartConsumeNextBuffer(void)
The thread that's responsible for processing incoming frames – the consumer – calls this function to ...
Definition: circularbuffer.h:153
NTV2DeviceCanDoMultiFormat
bool NTV2DeviceCanDoMultiFormat(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:4065
ntv2testpatterngen.h
Declares the NTV2TestPatternGen class.
CNTV2Card::DisableChannel
virtual bool DisableChannel(const NTV2Channel inChannel)
Disables the given FrameStore.
Definition: ntv2register.cpp:2093
NTV2_TestPatt_ColorBars100
@ NTV2_TestPatt_ColorBars100
Definition: ntv2testpatterngen.h:26
NTV2StreamPlayer::Init
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
Definition: ntv2streamplayer.cpp:109
CNTV2Card::ClearRouting
virtual bool ClearRouting(void)
Removes all existing signal path connections between any and all widgets on the AJA device.
Definition: ntv2regroute.cpp:278
CNTV2MacDriverInterface::ReleaseStreamForApplication
virtual bool ReleaseStreamForApplication(ULWord inApplicationType, int32_t inProcessID)
Releases exclusive use of the AJA device for the given process, permitting other processes to acquire...
Definition: ntv2macdriverinterface.cpp:832
NTV2_AncRgn_Field2
@ NTV2_AncRgn_Field2
Identifies the "normal" Field 2 ancillary data region.
Definition: ntv2enums.h:4141
AJA_STATUS_MEMORY
@ AJA_STATUS_MEMORY
Definition: types.h:384
AJACircularBuffer::EndProduceNextBuffer
void EndProduceNextBuffer(void)
The producer thread calls this function to signal that it has finished populating the frame it obtain...
Definition: circularbuffer.h:259
NTV2Buffer::Allocate
bool Allocate(const size_t inByteCount, const bool inPageAligned=false)
Allocates (or re-allocates) my user-space storage using the given byte count. I assume full responsib...
Definition: ntv2publicinterface.cpp:1554
NTV2DeviceGetNumCSCs
UWord NTV2DeviceGetNumCSCs(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:10042
CNTV2Card::StreamChannelRelease
virtual ULWord StreamChannelRelease(const NTV2Channel inChannel)
Release a stream. Releases all buffers remaining in the queue.
Definition: ntv2stream.cpp:19
NTV2_IS_2K_1080_VIDEO_FORMAT
#define NTV2_IS_2K_1080_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:726
NTV2DeviceCanDoFrameStore1Display
bool NTV2DeviceCanDoFrameStore1Display(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:2716
PlayerConfig::fDoMultiFormat
bool fDoMultiFormat
If true, enable device-sharing; otherwise take exclusive control of device.
Definition: ntv2democommon.h:323
NTV2StreamPlayer
I play out SD or HD test pattern (with timecode) to an output of an AJA device with or without audio ...
Definition: ntv2streamplayer.h:24
NTV2InputXptID
enum NTV2InputCrosspointID NTV2InputXptID
NTV2_AUDIO_FORMAT_LPCM
@ NTV2_AUDIO_FORMAT_LPCM
Definition: ntv2enums.h:1894
CNTV2Card::SetAudioLoopBack
virtual bool SetAudioLoopBack(const NTV2AudioLoopBack inMode, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Enables or disables NTV2AudioLoopBack mode for the given NTV2AudioSystem.
Definition: ntv2audio.cpp:303
NTV2DeviceCanDoFrameBufferFormat
bool NTV2DeviceCanDoFrameBufferFormat(const NTV2DeviceID inDeviceID, const NTV2FrameBufferFormat inFBFormat)
Definition: ntv2devicefeatures.hpp:15330
NTV2_CHANNEL1
@ NTV2_CHANNEL1
Specifies channel or Frame Store 1 (or the first item).
Definition: ntv2enums.h:1307
ntv2debug.h
NTV2FrameBufferFormatString
const char * NTV2FrameBufferFormatString(NTV2FrameBufferFormat fmt)
Definition: ntv2debug.cpp:201
CNTV2Card::SetSDITransmitEnable
virtual bool SetSDITransmitEnable(const NTV2Channel inChannel, const bool inEnable)
Sets the specified bidirectional SDI connector to act as an input or an output.
Definition: ntv2register.cpp:3805
CNTV2Card::SetVANCShiftMode
virtual bool SetVANCShiftMode(NTV2Channel inChannel, NTV2VANCDataShiftMode inMode)
Enables or disables the "VANC Shift Mode" feature for the given channel.
Definition: ntv2register.cpp:2816
CNTV2Card::SetVideoFormat
virtual bool SetVideoFormat(const NTV2VideoFormat inVideoFormat, const bool inIsAJARetail=true, const bool inKeepVancSettings=false, const NTV2Channel inChannel=NTV2_CHANNEL1)
Configures the AJA device to handle a specific video format.
Definition: ntv2register.cpp:204
NTV2StreamPlayer::ConsumeFrames
virtual void ConsumeFrames(void)
My consumer thread that repeatedly plays frames using AutoCirculate (until quit).
Definition: ntv2streamplayer.cpp:498
NTV2StreamPlayer::Quit
virtual void Quit(void)
Gracefully stops me from running.
Definition: ntv2streamplayer.cpp:86
NTV2DeviceCanDoVideoFormat
bool NTV2DeviceCanDoVideoFormat(const NTV2DeviceID inDeviceID, const NTV2VideoFormat inVideoFormat)
Definition: ntv2devicefeatures.hpp:18535
PlayerConfig::fTransmitHDRType
AJAAncDataType fTransmitHDRType
Specifies the HDR anc data packet to transmit, if any.
Definition: ntv2democommon.h:321
GetOutputDestInputXpt
NTV2InputXptID GetOutputDestInputXpt(const NTV2OutputDestination inOutputDest, const bool inIsSDI_DS2=false, const UWord inHDMI_Quadrant=99)
Definition: ntv2signalrouter.cpp:928
AJAThread
Definition: thread.h:69
NTV2StreamPlayer::~NTV2StreamPlayer
virtual ~NTV2StreamPlayer(void)
Definition: ntv2streamplayer.cpp:77
AJAThread::Active
virtual bool Active()
Definition: thread.cpp:116
CNTV2Card::DMABufferUnlockAll
virtual bool DMABufferUnlockAll()
Unlocks all previously-locked buffers used for DMA transfers.
Definition: ntv2dma.cpp:515
CNTV2Card::GetDisplayName
virtual std::string GetDisplayName(void)
Answers with this device's display name.
Definition: ntv2card.cpp:84
AJAStatus
AJAStatus
Definition: types.h:365
NTV2StreamPlayer::StartConsumerThread
virtual void StartConsumerThread(void)
Starts my consumer thread.
Definition: ntv2streamplayer.cpp:476
NTV2FormatDescriptor::numPixels
ULWord numPixels
Width – total number of pixels per line.
Definition: ntv2formatdescriptor.h:349
process.h
Declares the AJAProcess class.
NTV2StreamPlayer::SetUpVideo
virtual AJAStatus SetUpVideo(void)
Performs all video setup.
Definition: ntv2streamplayer.cpp:181
AJATime::Sleep
static void Sleep(const int32_t inMilliseconds)
Suspends execution of the current thread for a given number of milliseconds.
Definition: systemtime.cpp:284
AJACircularBuffer::Add
AJAStatus Add(FrameDataPtr pInFrameData)
Appends a new frame buffer to me, increasing my frame storage capacity by one frame.
Definition: circularbuffer.h:92
NTV2StreamPlayer::SetUpAudio
virtual AJAStatus SetUpAudio(void)
Performs all audio setup.
Definition: ntv2streamplayer.cpp:250
NTV2Standard
NTV2Standard
Identifies a particular video standard.
Definition: ntv2enums.h:153
NTV2_TestPatt_Ramp
@ NTV2_TestPatt_Ramp
Definition: ntv2testpatterngen.h:29
NTV2_VANCMODE_OFF
@ NTV2_VANCMODE_OFF
This identifies the mode in which there are no VANC lines in the frame buffer.
Definition: ntv2enums.h:3713
CNTV2Card::SetSDIOutputAudioSystem
virtual bool SetSDIOutputAudioSystem(const NTV2Channel inSDIOutputConnector, const NTV2AudioSystem inAudioSystem)
Sets the device's NTV2AudioSystem that will provide audio for the given SDI output's audio embedder....
Definition: ntv2audio.cpp:573
AJATimeBase
Definition: timebase.h:18
AJA_STATUS_FEATURE
@ AJA_STATUS_FEATURE
Definition: types.h:380
AJA_STATUS_FAIL
@ AJA_STATUS_FAIL
Definition: types.h:369
NTV2StreamPlayer::SetUpTestPatternBuffers
virtual AJAStatus SetUpTestPatternBuffers(void)
Creates my test pattern buffers.
Definition: ntv2streamplayer.cpp:341
ULWord
uint32_t ULWord
Definition: ajatypes.h:246
NTV2_TestPatt_FlatField
@ NTV2_TestPatt_FlatField
Definition: ntv2testpatterngen.h:33
NTV2FrameData::fVideoBuffer
NTV2Buffer fVideoBuffer
Host video buffer.
Definition: ntv2democommon.h:82
ntv2devicescanner.h
Declares the CNTV2DeviceScanner class.
NTV2FormatDescriptor::numLines
ULWord numLines
Height – total number of lines.
Definition: ntv2formatdescriptor.h:348
CNTV2Card::StreamChannelStart
virtual ULWord StreamChannelStart(const NTV2Channel inChannel, NTV2StreamChannel &status)
Start a stream. Put the stream is the active state to start processing queued buffers....
Definition: ntv2stream.cpp:27
NTV2DeviceHasBiDirectionalSDI
bool NTV2DeviceHasBiDirectionalSDI(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:6454
NTV2FormatDescriptor::GetTotalBytes
ULWord GetTotalBytes(void) const
Definition: ntv2formatdescriptor.cpp:851
CNTV2Card::StreamChannelStatus
virtual ULWord StreamChannelStatus(const NTV2Channel inChannel, NTV2StreamChannel &status)
Get the current stream status.
Definition: ntv2stream.cpp:51
CNTV2DemoCommon::SetDefaultPageSize
static size_t SetDefaultPageSize(void)
Definition: ntv2democommon.cpp:1505
gNumFrequencies
static const ULWord gNumFrequencies(sizeof(gFrequencies)/sizeof(double))
gAudMaxSizeBytes
static const uint32_t gAudMaxSizeBytes(256 *1024)
The maximum number of bytes of 48KHz audio that can be transferred for a single frame....
CNTV2Card::SetReference
virtual bool SetReference(const NTV2ReferenceSource inRefSource, const bool inKeepFramePulseSelect=false)
Sets the device's clock reference source. See Device Clocking and Synchronization for more informatio...
Definition: ntv2register.cpp:1486
GetCSCOutputXptFromChannel
NTV2OutputXptID GetCSCOutputXptFromChannel(const NTV2Channel inCSC, const bool inIsKey=false, const bool inIsRGB=false)
Definition: ntv2signalrouter.cpp:819
AJAProcess::GetPid
static uint64_t GetPid()
Definition: process.cpp:35
NTV2DeviceGetNumHDMIVideoOutputs
UWord NTV2DeviceGetNumHDMIVideoOutputs(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:10855
NTV2StreamPlayer::ConsumerThreadStatic
static void ConsumerThreadStatic(AJAThread *pThread, void *pContext)
This is the consumer thread's static callback function that gets called when the consumer thread star...
Definition: ntv2streamplayer.cpp:487
CNTV2Card::Connect
virtual bool Connect(const NTV2InputCrosspointID inInputXpt, const NTV2OutputCrosspointID inOutputXpt, const bool inValidate=false)
Connects the given widget signal input (sink) to the given widget signal output (source).
Definition: ntv2regroute.cpp:87
CNTV2Card::UnsubscribeOutputVerticalEvent
virtual bool UnsubscribeOutputVerticalEvent(const NTV2Channel inChannel)
Unregisters me so I'm no longer notified when an output VBI is signaled on the given output channel.
Definition: ntv2subscriptions.cpp:61
NTV2Buffer::CopyFrom
bool CopyFrom(const void *pInSrcBuffer, const ULWord inByteCount)
Replaces my contents from the given memory buffer, resizing me to the new byte count.
Definition: ntv2publicinterface.cpp:1642
UWord
uint16_t UWord
Definition: ajatypes.h:244
PlayerConfig::fVideoFormat
NTV2VideoFormat fVideoFormat
The video format to use.
Definition: ntv2democommon.h:319
AJACircularBuffer::StartProduceNextBuffer
FrameDataPtr StartProduceNextBuffer(void)
The thread that's responsible for providing frames – the producer – calls this function to populate t...
Definition: circularbuffer.h:109
NTV2_REFERENCE_FREERUN
@ NTV2_REFERENCE_FREERUN
Specifies the device's internal clock.
Definition: ntv2enums.h:1404
PlayerConfig::fOutputChannel
NTV2Channel fOutputChannel
The device channel to use.
Definition: ntv2democommon.h:315
NTV2DeviceCanDo3GLevelConversion
bool NTV2DeviceCanDo3GLevelConversion(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:647
NTV2VideoFormatToString
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
Definition: ntv2utils.cpp:6750
GetCSCInputXptFromChannel
NTV2InputXptID GetCSCInputXptFromChannel(const NTV2Channel inCSC, const bool inIsKeyInput=false)
Definition: ntv2signalrouter.cpp:775
CNTV2Card::StreamBufferRelease
virtual ULWord StreamBufferRelease(const NTV2Channel inChannel, NTV2StreamBuffer &status)
Remove the oldest buffer released by the streaming engine from the buffer queue.
Definition: ntv2stream.cpp:77
CNTV2Card::DMABufferLock
virtual bool DMABufferLock(const NTV2Buffer &inBuffer, bool inMap=false, bool inRDMA=false)
Page-locks the given host buffer to reduce transfer time and CPU usage of DMA transfers.
Definition: ntv2dma.cpp:487
NTV2DeviceGetNumFrameStores
UWord NTV2DeviceGetNumFrameStores(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:10487
NTV2DeviceGetNumAnalogVideoOutputs
UWord NTV2DeviceGetNumAnalogVideoOutputs(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:9775
IsVideoFormatA
bool IsVideoFormatA(const NTV2VideoFormat format)
Definition: ntv2utils.cpp:5490
NTV2_TestPatt_ColorBars75
@ NTV2_TestPatt_ColorBars75
Definition: ntv2testpatterngen.h:28
NTV2_TASK_MODE_INVALID
@ NTV2_TASK_MODE_INVALID
Definition: ntv2publicinterface.h:4262
CNTV2DriverInterface::IsDeviceReady
virtual bool IsDeviceReady(const bool inCheckValid=(0))
Definition: ntv2driverinterface.cpp:1228
DEVICE_ID_INVALID
@ DEVICE_ID_INVALID
Definition: ntv2enums.h:91
NTV2DeviceCanDoPlayback
bool NTV2DeviceCanDoPlayback(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:4438
kDemoAppSignature
static const ULWord kDemoAppSignature((((uint32_t)( 'D'))<< 24)|(((uint32_t)( 'E'))<< 16)|(((uint32_t)( 'M'))<< 8)|(((uint32_t)( 'O'))<< 0))
AJACircularBuffer::EndConsumeNextBuffer
void EndConsumeNextBuffer(void)
The consumer thread calls this function to signal that it has finished processing the frame it obtain...
Definition: circularbuffer.h:266
CNTV2Card::SetEveryFrameServices
virtual bool SetEveryFrameServices(const NTV2EveryFrameTaskMode inMode)
Sets the device's task mode.
Definition: ntv2register.cpp:179
NTV2StringList
std::vector< std::string > NTV2StringList
Definition: ntv2utils.h:1134
AJA_STATUS_UNSUPPORTED
@ AJA_STATUS_UNSUPPORTED
Definition: types.h:381
gAncMaxSizeBytes
static ULWord gAncMaxSizeBytes(NTV2_ANCSIZE_MAX)
The maximum number of bytes of ancillary data that can be transferred for a single field....
NTV2_INPUT_CROSSPOINT_INVALID
@ NTV2_INPUT_CROSSPOINT_INVALID
Definition: ntv2enums.h:2822
CNTV2Card::SetHDMIOutAudioRate
virtual bool SetHDMIOutAudioRate(const NTV2AudioRate inNewValue)
Sets the HDMI output's audio rate.
Definition: ntv2audio.cpp:1082
CNTV2DemoCommon::GetAJAFrameRate
static AJA_FrameRate GetAJAFrameRate(const NTV2FrameRate inFrameRate)
Definition: ntv2democommon.cpp:1022
NTV2DeviceGetNumAudioSystems
UWord NTV2DeviceGetNumAudioSystems(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:9864
NTV2Buffer::GetHostAddress
void * GetHostAddress(const ULWord inByteOffset, const bool inFromEnd=false) const
Definition: ntv2publicinterface.cpp:1610
NTV2TestPatternGen
The NTV2 test pattern generator.
Definition: ntv2testpatterngen.h:67
NTV2StreamPlayer::Run
virtual AJAStatus Run(void)
Runs me.
Definition: ntv2streamplayer.cpp:462
NTV2_FORMAT_UNKNOWN
@ NTV2_FORMAT_UNKNOWN
Definition: ntv2enums.h:498
NTV2FrameData::fAudioBuffer
NTV2Buffer fAudioBuffer
Host audio buffer.
Definition: ntv2democommon.h:84
NTV2_TestPatt_Border
@ NTV2_TestPatt_Border
Definition: ntv2testpatterngen.h:37
AJA_STATUS_INITIALIZE
@ AJA_STATUS_INITIALIZE
Definition: types.h:373
DEC
#define DEC(__x__)
Definition: ntv2publicinterface.h:5579
CNTV2Card::SetSDIOutputStandard
virtual bool SetSDIOutputStandard(const UWord inOutputSpigot, const NTV2Standard inValue)
Sets the SDI output spigot's video standard.
Definition: ntv2register.cpp:3216
CNTV2Card::StreamChannelWait
virtual ULWord StreamChannelWait(const NTV2Channel inChannel, NTV2StreamChannel &status)
Wait for any stream event. Returns for any state or buffer change.
Definition: ntv2stream.cpp:59
NTV2_OUTPUTDESTINATION_HDMI
@ NTV2_OUTPUTDESTINATION_HDMI
Definition: ntv2enums.h:1279
false
#define false
Definition: ntv2devicefeatures.h:25
ancillarydata_hdr_hdr10.h
Declares the AJAAncillaryData_HDR_HDR10 class.
GetFrameBufferOutputXptFromChannel
NTV2OutputXptID GetFrameBufferOutputXptFromChannel(const NTV2Channel inFrameStore, const bool inIsRGB=false, const bool inIs425=false)
Definition: ntv2signalrouter.cpp:845
PlayerConfig::fDeviceSpec
std::string fDeviceSpec
The AJA device to use.
Definition: ntv2democommon.h:313
AJA_STATUS_BAD_PARAM
@ AJA_STATUS_BAD_PARAM
Definition: types.h:379
ntv2streamplayer.h
NTV2StreamPlayer::ProducerThreadStatic
static void ProducerThreadStatic(AJAThread *pThread, void *pContext)
This is the producer thread's static callback function that gets called when the producer thread star...
Definition: ntv2streamplayer.cpp:625
IsRGBFormat
bool IsRGBFormat(const NTV2FrameBufferFormat format)
Definition: ntv2utils.cpp:5442
CIRCULAR_BUFFER_SIZE
static const size_t CIRCULAR_BUFFER_SIZE(10)
Number of NTV2FrameData's in our ring.
CNTV2MacDriverInterface::AcquireStreamForApplication
virtual bool AcquireStreamForApplication(ULWord inApplicationType, int32_t inProcessID)
Reserves exclusive use of the AJA device for a given process, preventing other processes on the host ...
Definition: ntv2macdriverinterface.cpp:808
CNTV2Card::SetSDIOutputDS2AudioSystem
virtual bool SetSDIOutputDS2AudioSystem(const NTV2Channel inSDIOutputConnector, const NTV2AudioSystem inAudioSystem)
Sets the Audio System that will supply audio for the given SDI output's audio embedder for Data Strea...
Definition: ntv2audio.cpp:630
NTV2_AudioChannel1_8
@ NTV2_AudioChannel1_8
This selects audio channels 1 thru 8.
Definition: ntv2enums.h:3242
NTV2_STREAM_STATUS_SUCCESS
#define NTV2_STREAM_STATUS_SUCCESS
Used in NTV2Stream success.
Definition: ntv2publicinterface.h:8692
CNTV2DriverInterface::GetDeviceID
virtual NTV2DeviceID GetDeviceID(void)
Definition: ntv2driverinterface.cpp:371
CNTV2Card::StreamChannelInitialize
virtual ULWord StreamChannelInitialize(const NTV2Channel inChannel)
Initialize a stream. Put the stream queue and hardware in a known good state ready for use....
Definition: ntv2stream.cpp:11
CNTV2Card::GetEveryFrameServices
virtual bool GetEveryFrameServices(NTV2EveryFrameTaskMode &outMode)
Retrieves the device's current "retail service" task mode.
Definition: ntv2register.cpp:184
AJACircularBuffer::SetAbortFlag
void SetAbortFlag(const bool *pAbortFlag)
Tells me the boolean variable I should monitor such that when it gets set to "true" will cause any th...
Definition: circularbuffer.h:51
gFrequencies
static const double gFrequencies[]
Definition: ntv2streamplayer.cpp:50
NTV2_TestPatt_MultiPattern
@ NTV2_TestPatt_MultiPattern
Definition: ntv2testpatterngen.h:34
PlayerConfig
Configures an NTV2Player instance.
Definition: ntv2democommon.h:310
PlayerConfig::fDoABConversion
bool fDoABConversion
If true, do level-A/B conversion; otherwise don't.
Definition: ntv2democommon.h:327
CNTV2Card::SetHDMIOutAudioSource8Channel
virtual bool SetHDMIOutAudioSource8Channel(const NTV2Audio8ChannelSelect inNewValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Changes the HDMI output's 8-channel audio source.
Definition: ntv2audio.cpp:1024
GetNTV2StandardFromVideoFormat
NTV2Standard GetNTV2StandardFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Definition: ntv2utils.cpp:2277
PlayerConfig::fPixelFormat
NTV2PixelFormat fPixelFormat
The pixel format to use.
Definition: ntv2democommon.h:318
NTV2OutputXptID
enum NTV2OutputCrosspointID NTV2OutputXptID
NTV2Buffer::Fill
bool Fill(const T &inValue)
Fills me with the given scalar value.
Definition: ntv2publicinterface.h:6192
AJAThread::SetPriority
virtual AJAStatus SetPriority(AJAThreadPriority priority)
Definition: thread.cpp:133
NTV2DeviceGetNumVideoOutputs
UWord NTV2DeviceGetNumVideoOutputs(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:12012
NTV2TestPatternGen::getTestPatternNames
static NTV2TestPatternNames getTestPatternNames(void)
Definition: ntv2testpatterngen.cpp:2542
NTV2DeviceCanDoCustomAnc
bool NTV2DeviceCanDoCustomAnc(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:2087
PLNOTE
#define PLNOTE(_xpr_)
Definition: ntv2democommon.h:36
AJA_STATUS_OPEN
@ AJA_STATUS_OPEN
Definition: types.h:375
CNTV2Card::SetFrameBufferFormat
virtual bool SetFrameBufferFormat(NTV2Channel inChannel, NTV2FrameBufferFormat inNewFormat, bool inIsAJARetail=true, NTV2HDRXferChars inXferChars=NTV2_VPID_TC_SDR_TV, NTV2HDRColorimetry inColorimetry=NTV2_VPID_Color_Rec709, NTV2HDRLuminance inLuminance=NTV2_VPID_Luminance_YCbCr)
Sets the frame buffer format for the given FrameStore on the AJA device.
Definition: ntv2register.cpp:1828
CNTV2Card::SetNumberAudioChannels
virtual bool SetNumberAudioChannels(const ULWord inNumChannels, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the number of audio channels to be concurrently captured or played for a given Audio System on t...
Definition: ntv2audio.cpp:149
NTV2_TestPatt_LineSweep
@ NTV2_TestPatt_LineSweep
Definition: ntv2testpatterngen.h:31
CNTV2Card::SetAudioBufferSize
virtual bool SetAudioBufferSize(const NTV2AudioBufferSize inValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Changes the size of the audio buffer that is used for a given Audio System in the AJA device.
Definition: ntv2audio.cpp:252
ancillarydata_hdr_sdr.h
Declares the AJAAncillaryData_HDR_SDR class.
AJAThread::Start
virtual AJAStatus Start()
Definition: thread.cpp:91
CNTV2Card::SetMode
virtual bool SetMode(const NTV2Channel inChannel, const NTV2Mode inNewValue, const bool inIsRetail=true)
Determines if a given FrameStore on the AJA device will be used to capture or playout video.
Definition: ntv2register.cpp:1613
PLFAIL
#define PLFAIL(_xpr_)
Definition: ntv2democommon.h:34
CNTV2DemoCommon::GetAJAPixelFormat
static AJA_PixelFormat GetAJAPixelFormat(const NTV2FrameBufferFormat inFormat)
Definition: ntv2democommon.cpp:1054
xHEX0N
#define xHEX0N(__x__, __n__)
Definition: ntv2publicinterface.h:5578
AJA_FAILURE
#define AJA_FAILURE(_status_)
Definition: types.h:358
NTV2StreamBuffer
Definition: ntv2publicinterface.h:8741
NTV2StreamPlayer::RouteOutputSignal
virtual bool RouteOutputSignal(void)
Performs all widget/signal routing for playout.
Definition: ntv2streamplayer.cpp:393
NTV2StreamPlayer::NTV2StreamPlayer
NTV2StreamPlayer(const PlayerConfig &inConfig)
Constructs me using the given configuration settings.
Definition: ntv2streamplayer.cpp:56
CNTV2Card::EnableChannel
virtual bool EnableChannel(const NTV2Channel inChannel)
Enables the given FrameStore.
Definition: ntv2register.cpp:2113
NTV2_MODE_DISPLAY
@ NTV2_MODE_DISPLAY
Playout (output) mode, which reads from device SDRAM.
Definition: ntv2enums.h:1200
NTV2DeviceCanDo2110
bool NTV2DeviceCanDo2110(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:467
CNTV2Card::SetHDMIOutAudioFormat
virtual bool SetHDMIOutAudioFormat(const NTV2AudioFormat inNewValue)
Sets the HDMI output's audio format.
Definition: ntv2audio.cpp:1094
NTV2ChannelToAudioSystem
NTV2AudioSystem NTV2ChannelToAudioSystem(const NTV2Channel inChannel)
Converts the given NTV2Channel value into its equivalent NTV2AudioSystem.
Definition: ntv2utils.cpp:4927
NTV2_OUTPUTDESTINATION_ANALOG
@ NTV2_OUTPUTDESTINATION_ANALOG
Definition: ntv2enums.h:1278
NTV2FormatDescriptor::IsValid
bool IsValid(void) const
Definition: ntv2formatdescriptor.h:94
BUFFER_PAGE_ALIGNED
static const bool BUFFER_PAGE_ALIGNED(true)
NTV2_ANCSIZE_MAX
#define NTV2_ANCSIZE_MAX
Definition: ntv2democommon.h:47
PLWARN
#define PLWARN(_xpr_)
Definition: ntv2democommon.h:35
NTV2StreamPlayer::StartProducerThread
virtual void StartProducerThread(void)
Starts my producer thread.
Definition: ntv2streamplayer.cpp:615
NTV2StreamPlayer::GetStreamStatus
virtual void GetStreamStatus(NTV2StreamChannel &outStatus)
Provides status information about my output (playout) process.
Definition: ntv2streamplayer.cpp:667
NTV2DeviceGetMaxAudioChannels
UWord NTV2DeviceGetMaxAudioChannels(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:8796
CNTV2Card::SetSDIOutLevelAtoLevelBConversion
virtual bool SetSDIOutLevelAtoLevelBConversion(const UWord inOutputSpigot, const bool inEnable)
Enables or disables 3G level A to 3G level B conversion at the SDI output widget (assuming the AJA de...
Definition: ntv2register.cpp:4217
NTV2_OEM_TASKS
@ NTV2_OEM_TASKS
2: OEM: Device is configured by controlling application(s), with minimal driver involvement.
Definition: ntv2publicinterface.h:4261
CNTV2Card::SetAudioRate
virtual bool SetAudioRate(const NTV2AudioRate inRate, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the NTV2AudioRate for the given Audio System.
Definition: ntv2audio.cpp:208
NTV2_AUDIOSYSTEM_INVALID
@ NTV2_AUDIOSYSTEM_INVALID
Definition: ntv2enums.h:3821
timebase.h
Declares the AJATimeBase class.
NTV2StreamPlayer::ProduceFrames
virtual void ProduceFrames(void)
My producer thread that repeatedly produces video frames.
Definition: ntv2streamplayer.cpp:634