aja-source.cpp 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172
  1. #include "aja-card-manager.hpp"
  2. #include "aja-common.hpp"
  3. #include "aja-ui-props.hpp"
  4. #include "aja-source.hpp"
  5. #include "aja-routing.hpp"
  6. #include <util/threading.h>
  7. #include <util/platform.h>
  8. #include <util/dstr.h>
  9. #include <obs-module.h>
  10. #include <ajantv2/includes/ntv2card.h>
  11. #include <ajantv2/includes/ntv2utils.h>
  12. #define NTV2_AUDIOSIZE_MAX (401 * 1024)
  13. AJASource::AJASource(obs_source_t *source)
  14. : mVideoBuffer{},
  15. mAudioBuffer{},
  16. mCard{nullptr},
  17. mSourceName{""},
  18. mCardID{""},
  19. mDeviceIndex{0},
  20. mBuffering{false},
  21. mIsCapturing{false},
  22. mSourceProps{},
  23. mTestPattern{},
  24. mCaptureThread{nullptr},
  25. mMutex{},
  26. mSource{source},
  27. mCrosspoints{}
  28. {
  29. }
  30. AJASource::~AJASource()
  31. {
  32. Deactivate();
  33. mTestPattern.clear();
  34. mVideoBuffer.Deallocate();
  35. mAudioBuffer.Deallocate();
  36. mVideoBuffer = NULL;
  37. mAudioBuffer = NULL;
  38. }
  39. void AJASource::SetCard(CNTV2Card *card)
  40. {
  41. mCard = card;
  42. }
  43. CNTV2Card *AJASource::GetCard()
  44. {
  45. return mCard;
  46. }
  47. void AJASource::SetOBSSource(obs_source_t *source)
  48. {
  49. mSource = source;
  50. }
  51. obs_source_t *AJASource::GetOBSSource(void) const
  52. {
  53. return mSource;
  54. }
  55. void AJASource::SetName(const std::string &name)
  56. {
  57. mSourceName = name;
  58. }
  59. std::string AJASource::GetName() const
  60. {
  61. return mSourceName;
  62. }
  63. void populate_source_device_list(obs_property_t *list)
  64. {
  65. obs_property_list_clear(list);
  66. auto &cardManager = aja::CardManager::Instance();
  67. cardManager.EnumerateCards();
  68. for (const auto &iter : cardManager.GetCardEntries()) {
  69. if (iter.second) {
  70. CNTV2Card *card = iter.second->GetCard();
  71. if (!card)
  72. continue;
  73. if (aja::IsOutputOnlyDevice(iter.second->GetDeviceID()))
  74. continue;
  75. obs_property_list_add_string(
  76. list, iter.second->GetDisplayName().c_str(),
  77. iter.second->GetCardID().c_str());
  78. }
  79. }
  80. }
  81. //
  82. // Capture Thread stuff
  83. //
  84. struct AudioOffsets {
  85. ULWord currentAddress = 0;
  86. ULWord lastAddress = 0;
  87. ULWord readOffset = 0;
  88. ULWord wrapAddress = 0;
  89. ULWord bytesRead = 0;
  90. };
  91. static void ResetAudioBufferOffsets(CNTV2Card *card,
  92. NTV2AudioSystem audioSystem,
  93. AudioOffsets &offsets)
  94. {
  95. if (!card)
  96. return;
  97. offsets.currentAddress = 0;
  98. offsets.lastAddress = 0;
  99. offsets.readOffset = 0;
  100. offsets.wrapAddress = 0;
  101. offsets.bytesRead = 0;
  102. card->GetAudioReadOffset(offsets.readOffset, audioSystem);
  103. card->GetAudioWrapAddress(offsets.wrapAddress, audioSystem);
  104. offsets.wrapAddress += offsets.readOffset;
  105. offsets.lastAddress = offsets.readOffset;
  106. }
  107. void AJASource::GenerateTestPattern(NTV2VideoFormat vf, NTV2PixelFormat pf,
  108. NTV2TestPatternSelect ps)
  109. {
  110. NTV2VideoFormat vid_fmt = vf;
  111. NTV2PixelFormat pix_fmt = pf;
  112. if (vid_fmt == NTV2_FORMAT_UNKNOWN)
  113. vid_fmt = NTV2_FORMAT_720p_5994;
  114. if (pix_fmt == NTV2_FBF_INVALID)
  115. pix_fmt = kDefaultAJAPixelFormat;
  116. NTV2FormatDesc fd(vid_fmt, pix_fmt, NTV2_VANCMODE_OFF);
  117. auto bufSize = fd.GetTotalRasterBytes();
  118. if (bufSize != mTestPattern.size()) {
  119. mTestPattern.clear();
  120. mTestPattern.resize(bufSize);
  121. NTV2TestPatternGen gen;
  122. gen.DrawTestPattern(ps, fd.GetRasterWidth(),
  123. fd.GetRasterHeight(), pix_fmt,
  124. mTestPattern);
  125. }
  126. if (mTestPattern.size() == 0) {
  127. blog(LOG_DEBUG,
  128. "AJASource::GenerateTestPattern: Error generating test pattern!");
  129. return;
  130. }
  131. const enum video_format obs_vid_fmt =
  132. aja::AJAPixelFormatToOBSVideoFormat(pix_fmt);
  133. struct obs_source_frame2 obsFrame;
  134. obsFrame.flip = false;
  135. obsFrame.timestamp = os_gettime_ns();
  136. obsFrame.width = fd.GetRasterWidth();
  137. obsFrame.height = fd.GetRasterHeight();
  138. obsFrame.format = obs_vid_fmt;
  139. obsFrame.data[0] = mTestPattern.data();
  140. obsFrame.linesize[0] = fd.GetBytesPerRow();
  141. video_colorspace colorspace = VIDEO_CS_709;
  142. if (NTV2_IS_SD_VIDEO_FORMAT(vid_fmt))
  143. colorspace = VIDEO_CS_601;
  144. video_format_get_parameters_for_format(colorspace, VIDEO_RANGE_PARTIAL,
  145. obs_vid_fmt,
  146. obsFrame.color_matrix,
  147. obsFrame.color_range_min,
  148. obsFrame.color_range_max);
  149. obs_source_output_video2(mSource, &obsFrame);
  150. blog(LOG_DEBUG, "AJASource::GenerateTestPattern: Black");
  151. }
  152. void AJASource::CaptureThread(AJAThread *thread, void *data)
  153. {
  154. UNUSED_PARAMETER(thread);
  155. auto ajaSource = (AJASource *)data;
  156. if (!ajaSource) {
  157. blog(LOG_WARNING,
  158. "AJASource::CaptureThread: Plugin instance is null!");
  159. return;
  160. }
  161. blog(LOG_INFO,
  162. "AJASource::CaptureThread: Starting capture thread for AJA source %s",
  163. ajaSource->GetName().c_str());
  164. auto card = ajaSource->GetCard();
  165. if (!card) {
  166. blog(LOG_ERROR,
  167. "AJASource::CaptureThread: Card instance is null!");
  168. return;
  169. }
  170. auto sourceProps = ajaSource->GetSourceProps();
  171. ajaSource->ResetVideoBuffer(sourceProps.videoFormat,
  172. sourceProps.pixelFormat);
  173. auto inputSource = sourceProps.InitialInputSource();
  174. auto channel = sourceProps.Channel();
  175. auto audioSystem = sourceProps.AudioSystem();
  176. // Current "on-air" frame on the card. The capture thread "Ping-pongs" between
  177. // two frames, starting at an index corresponding to the framestore channel.
  178. // For example:
  179. // Channel 1 (index 0) = frames 0/1
  180. // Channel 2 (index 1) = frames 2/3
  181. // Channel 3 (index 2) = frames 4/5
  182. // Channel 4 (index 3) = frames 6/7
  183. // etc...
  184. ULWord currentCardFrame = (uint32_t)channel * 2;
  185. card->WaitForInputFieldID(NTV2_FIELD0, channel);
  186. currentCardFrame ^= 1;
  187. card->SetInputFrame(channel, currentCardFrame);
  188. AudioOffsets offsets;
  189. ResetAudioBufferOffsets(card, audioSystem, offsets);
  190. obs_data_t *settings = obs_source_get_settings(ajaSource->mSource);
  191. while (ajaSource->IsCapturing()) {
  192. if (card->GetModelName() == "(Not Found)") {
  193. os_sleep_ms(250);
  194. obs_source_update(ajaSource->mSource, settings);
  195. break;
  196. }
  197. auto videoFormat = sourceProps.videoFormat;
  198. auto pixelFormat = sourceProps.pixelFormat;
  199. auto ioSelection = sourceProps.ioSelect;
  200. bool audioOverrun = false;
  201. card->WaitForInputFieldID(NTV2_FIELD0, channel);
  202. currentCardFrame ^= 1;
  203. // Card format detection -- restarts capture thread via aja_source_update callback
  204. auto newVideoFormat = card->GetInputVideoFormat(
  205. inputSource, aja::Is3GLevelB(card, channel));
  206. if (newVideoFormat == NTV2_FORMAT_UNKNOWN) {
  207. blog(LOG_DEBUG,
  208. "AJASource::CaptureThread: Video format unknown!");
  209. ajaSource->GenerateTestPattern(videoFormat, pixelFormat,
  210. NTV2_TestPatt_Black);
  211. os_sleep_ms(250);
  212. continue;
  213. }
  214. newVideoFormat = aja::HandleSpecialCaseFormats(
  215. ioSelection, newVideoFormat, sourceProps.deviceID);
  216. if (sourceProps.autoDetect && (videoFormat != newVideoFormat)) {
  217. blog(LOG_INFO,
  218. "AJASource::CaptureThread: New Video Format detected! Triggering 'aja_source_update' callback and returning...");
  219. blog(LOG_INFO,
  220. "AJASource::CaptureThread: Current Video Format: %s, | Want Video Format: %s",
  221. NTV2VideoFormatToString(videoFormat, true).c_str(),
  222. NTV2VideoFormatToString(newVideoFormat, true)
  223. .c_str());
  224. os_sleep_ms(250);
  225. obs_source_update(ajaSource->mSource, settings);
  226. break;
  227. }
  228. card->ReadAudioLastIn(offsets.currentAddress, audioSystem);
  229. offsets.currentAddress &= ~0x3; // Force DWORD alignment
  230. offsets.currentAddress += offsets.readOffset;
  231. if (offsets.currentAddress < offsets.lastAddress) {
  232. offsets.bytesRead =
  233. offsets.wrapAddress - offsets.lastAddress;
  234. if (offsets.bytesRead >
  235. ajaSource->mAudioBuffer.GetByteCount()) {
  236. blog(LOG_DEBUG,
  237. "AJASource::CaptureThread: Audio overrun (1)! Buffer Size: %d, Bytes Captured: %d",
  238. ajaSource->mAudioBuffer.GetByteCount(),
  239. offsets.bytesRead);
  240. ResetAudioBufferOffsets(card, audioSystem,
  241. offsets);
  242. audioOverrun = true;
  243. }
  244. if (!audioOverrun) {
  245. card->DMAReadAudio(audioSystem,
  246. ajaSource->mAudioBuffer,
  247. offsets.lastAddress,
  248. offsets.bytesRead);
  249. card->DMAReadAudio(
  250. audioSystem,
  251. reinterpret_cast<ULWord *>(
  252. ajaSource->mAudioBuffer
  253. .GetHostAddress(
  254. offsets.bytesRead)),
  255. offsets.readOffset,
  256. offsets.currentAddress -
  257. offsets.readOffset);
  258. offsets.bytesRead += offsets.currentAddress -
  259. offsets.readOffset;
  260. }
  261. if (offsets.bytesRead >
  262. ajaSource->mAudioBuffer.GetByteCount()) {
  263. blog(LOG_DEBUG,
  264. "AJASource::CaptureThread: Audio overrun (2)! Buffer Size: %d, Bytes Captured: %d",
  265. ajaSource->mAudioBuffer.GetByteCount(),
  266. offsets.bytesRead);
  267. ResetAudioBufferOffsets(card, audioSystem,
  268. offsets);
  269. audioOverrun = true;
  270. }
  271. } else {
  272. offsets.bytesRead =
  273. offsets.currentAddress - offsets.lastAddress;
  274. if (offsets.bytesRead >
  275. ajaSource->mAudioBuffer.GetByteCount()) {
  276. blog(LOG_DEBUG,
  277. "AJASource::CaptureThread: Audio overrun (3)! Buffer Size: %d, Bytes Captured: %d",
  278. ajaSource->mAudioBuffer.GetByteCount(),
  279. offsets.bytesRead);
  280. ResetAudioBufferOffsets(card, audioSystem,
  281. offsets);
  282. audioOverrun = true;
  283. }
  284. if (!audioOverrun) {
  285. card->DMAReadAudio(audioSystem,
  286. ajaSource->mAudioBuffer,
  287. offsets.lastAddress,
  288. offsets.bytesRead);
  289. }
  290. }
  291. if (!audioOverrun) {
  292. offsets.lastAddress = offsets.currentAddress;
  293. obs_source_audio audioPacket;
  294. audioPacket.samples_per_sec = 48000;
  295. audioPacket.format = AUDIO_FORMAT_32BIT;
  296. audioPacket.speakers = SPEAKERS_7POINT1;
  297. audioPacket.frames = offsets.bytesRead / 32;
  298. audioPacket.timestamp = os_gettime_ns();
  299. audioPacket.data[0] = (uint8_t *)ajaSource->mAudioBuffer
  300. .GetHostPointer();
  301. obs_source_output_audio(ajaSource->mSource,
  302. &audioPacket);
  303. }
  304. if (ajaSource->mVideoBuffer.GetByteCount() == 0) {
  305. blog(LOG_DEBUG,
  306. "AJASource::CaptureThread: 0 bytes in video buffer! Something went wrong!");
  307. continue;
  308. }
  309. card->DMAReadFrame(currentCardFrame, ajaSource->mVideoBuffer,
  310. ajaSource->mVideoBuffer.GetByteCount());
  311. auto actualVideoFormat = videoFormat;
  312. if (aja::Is3GLevelB(card, channel))
  313. actualVideoFormat = aja::GetLevelAFormatForLevelBFormat(
  314. videoFormat);
  315. const enum video_format obs_vid_fmt =
  316. aja::AJAPixelFormatToOBSVideoFormat(
  317. sourceProps.pixelFormat);
  318. NTV2FormatDesc fd(actualVideoFormat, pixelFormat);
  319. struct obs_source_frame2 obsFrame;
  320. obsFrame.flip = false;
  321. obsFrame.timestamp = os_gettime_ns();
  322. obsFrame.width = fd.GetRasterWidth();
  323. obsFrame.height = fd.GetRasterHeight();
  324. obsFrame.format = obs_vid_fmt;
  325. obsFrame.data[0] = reinterpret_cast<uint8_t *>(
  326. (ULWord *)ajaSource->mVideoBuffer.GetHostPointer());
  327. obsFrame.linesize[0] = fd.GetBytesPerRow();
  328. video_colorspace colorspace = VIDEO_CS_709;
  329. if (NTV2_IS_SD_VIDEO_FORMAT(actualVideoFormat))
  330. colorspace = VIDEO_CS_601;
  331. video_format_get_parameters_for_format(
  332. colorspace, VIDEO_RANGE_PARTIAL, obs_vid_fmt,
  333. obsFrame.color_matrix, obsFrame.color_range_min,
  334. obsFrame.color_range_max);
  335. obs_source_output_video2(ajaSource->mSource, &obsFrame);
  336. card->SetInputFrame(channel, currentCardFrame);
  337. }
  338. blog(LOG_INFO, "AJASource::Capturethread: Thread loop stopped");
  339. ajaSource->GenerateTestPattern(sourceProps.videoFormat,
  340. sourceProps.pixelFormat,
  341. NTV2_TestPatt_Black);
  342. obs_data_release(settings);
  343. }
  344. void AJASource::Deactivate()
  345. {
  346. SetCapturing(false);
  347. if (mCaptureThread) {
  348. if (mCaptureThread->Active()) {
  349. mCaptureThread->Stop();
  350. blog(LOG_INFO, "AJASource::CaptureThread: Stopped!");
  351. }
  352. delete mCaptureThread;
  353. mCaptureThread = nullptr;
  354. blog(LOG_INFO, "AJASource::CaptureThread: Destroyed!");
  355. }
  356. }
  357. void AJASource::Activate(bool enable)
  358. {
  359. if (mCaptureThread == nullptr) {
  360. mCaptureThread = new AJAThread();
  361. mCaptureThread->Attach(AJASource::CaptureThread, this);
  362. mCaptureThread->SetPriority(AJA_ThreadPriority_High);
  363. blog(LOG_INFO, "AJASource::CaptureThread: Created!");
  364. }
  365. if (enable) {
  366. SetCapturing(true);
  367. if (!mCaptureThread->Active()) {
  368. mCaptureThread->Start();
  369. blog(LOG_INFO, "AJASource::CaptureThread: Started!");
  370. }
  371. }
  372. }
  373. bool AJASource::IsCapturing() const
  374. {
  375. return mIsCapturing;
  376. }
  377. void AJASource::SetCapturing(bool capturing)
  378. {
  379. std::lock_guard<std::mutex> lock(mMutex);
  380. mIsCapturing = capturing;
  381. }
  382. //
  383. // CardEntry/Device stuff
  384. //
  385. std::string AJASource::CardID() const
  386. {
  387. return mCardID;
  388. }
  389. void AJASource::SetCardID(const std::string &cardID)
  390. {
  391. mCardID = cardID;
  392. }
  393. uint32_t AJASource::DeviceIndex() const
  394. {
  395. return static_cast<uint32_t>(mDeviceIndex);
  396. }
  397. void AJASource::SetDeviceIndex(uint32_t index)
  398. {
  399. mDeviceIndex = static_cast<UWord>(index);
  400. }
  401. //
  402. // AJASource Properties stuff
  403. //
  404. void AJASource::SetSourceProps(const SourceProps &props)
  405. {
  406. mSourceProps = props;
  407. }
  408. SourceProps AJASource::GetSourceProps() const
  409. {
  410. return mSourceProps;
  411. }
  412. void AJASource::CacheConnections(const NTV2XptConnections &cnx)
  413. {
  414. mCrosspoints.clear();
  415. mCrosspoints = cnx;
  416. }
  417. void AJASource::ClearConnections()
  418. {
  419. for (auto &&xpt : mCrosspoints) {
  420. mCard->Connect(xpt.first, NTV2_XptBlack);
  421. }
  422. mCrosspoints.clear();
  423. }
  424. bool AJASource::ReadChannelVPIDs(NTV2Channel channel, VPIDData &vpids)
  425. {
  426. ULWord vpid_a = 0;
  427. ULWord vpid_b = 0;
  428. bool read_ok = mCard->ReadSDIInVPID(channel, vpid_a, vpid_b);
  429. vpids.SetA(vpid_a);
  430. vpids.SetB(vpid_b);
  431. vpids.Parse();
  432. return read_ok;
  433. }
  434. bool AJASource::ReadWireFormats(NTV2DeviceID device_id, IOSelection io_select,
  435. NTV2VideoFormat &vf, NTV2PixelFormat &pf,
  436. VPIDDataList &vpids)
  437. {
  438. NTV2InputSourceSet input_srcs;
  439. aja::IOSelectionToInputSources(io_select, input_srcs);
  440. if (input_srcs.empty()) {
  441. blog(LOG_INFO,
  442. "AJASource::ReadWireFormats: No NTV2InputSources found for IOSelection %s",
  443. aja::IOSelectionToString(io_select).c_str());
  444. return false;
  445. }
  446. NTV2InputSource initial_src = *input_srcs.begin();
  447. for (auto &&src : input_srcs) {
  448. auto channel = NTV2InputSourceToChannel(src);
  449. mCard->EnableChannel(channel);
  450. if (NTV2_INPUT_SOURCE_IS_SDI(src)) {
  451. if (NTV2DeviceHasBiDirectionalSDI(device_id)) {
  452. mCard->SetSDITransmitEnable(channel, false);
  453. }
  454. mCard->WaitForInputVerticalInterrupt(channel);
  455. VPIDData vpid_data;
  456. if (ReadChannelVPIDs(channel, vpid_data))
  457. vpids.push_back(vpid_data);
  458. } else if (NTV2_INPUT_SOURCE_IS_HDMI(src)) {
  459. mCard->WaitForInputVerticalInterrupt(channel);
  460. ULWord hdmi_version =
  461. NTV2DeviceGetHDMIVersion(device_id);
  462. // HDMIv1 handles its own RGB->YCbCr color space conversion
  463. if (hdmi_version == 1) {
  464. pf = kDefaultAJAPixelFormat;
  465. } else {
  466. NTV2LHIHDMIColorSpace hdmiInputColor;
  467. mCard->GetHDMIInputColor(hdmiInputColor,
  468. channel);
  469. if (hdmiInputColor ==
  470. NTV2_LHIHDMIColorSpaceYCbCr) {
  471. pf = kDefaultAJAPixelFormat;
  472. } else if (hdmiInputColor ==
  473. NTV2_LHIHDMIColorSpaceRGB) {
  474. pf = NTV2_FBF_24BIT_BGR;
  475. }
  476. }
  477. }
  478. }
  479. NTV2Channel initial_channel = NTV2InputSourceToChannel(initial_src);
  480. mCard->WaitForInputVerticalInterrupt(initial_channel);
  481. vf = mCard->GetInputVideoFormat(
  482. initial_src, aja::Is3GLevelB(mCard, initial_channel));
  483. if (NTV2_INPUT_SOURCE_IS_SDI(initial_src)) {
  484. if (vpids.size() > 0) {
  485. auto vpid = *vpids.begin();
  486. if (vpid.Sampling() == VPIDSampling_YUV_422) {
  487. pf = NTV2_FBF_8BIT_YCBCR;
  488. blog(LOG_INFO,
  489. "AJASource::ReadWireFormats - Detected pixel format %s",
  490. NTV2FrameBufferFormatToString(pf, true)
  491. .c_str());
  492. } else if (vpid.Sampling() == VPIDSampling_GBR_444) {
  493. pf = NTV2_FBF_24BIT_BGR;
  494. blog(LOG_INFO,
  495. "AJASource::ReadWireFormats - Detected pixel format %s",
  496. NTV2FrameBufferFormatToString(pf, true)
  497. .c_str());
  498. }
  499. }
  500. }
  501. vf = aja::HandleSpecialCaseFormats(io_select, vf, device_id);
  502. blog(LOG_INFO, "AJASource::ReadWireFormats - Detected video format %s",
  503. NTV2VideoFormatToString(vf).c_str());
  504. return true;
  505. }
  506. void AJASource::ResetVideoBuffer(NTV2VideoFormat vf, NTV2PixelFormat pf)
  507. {
  508. if (vf != NTV2_FORMAT_UNKNOWN) {
  509. auto videoBufferSize = GetVideoWriteSize(vf, pf);
  510. if (mVideoBuffer)
  511. mVideoBuffer.Deallocate();
  512. mVideoBuffer.Allocate(videoBufferSize, true);
  513. blog(LOG_INFO,
  514. "AJASource::ResetVideoBuffer: Video Format: %s | Pixel Format: %s | Buffer Size: %d",
  515. NTV2VideoFormatToString(vf, false).c_str(),
  516. NTV2FrameBufferFormatToString(pf, true).c_str(),
  517. videoBufferSize);
  518. }
  519. }
  520. void AJASource::ResetAudioBuffer(size_t size)
  521. {
  522. if (mAudioBuffer)
  523. mAudioBuffer.Deallocate();
  524. mAudioBuffer.Allocate(size, true);
  525. }
  526. static const char *aja_source_get_name(void *);
  527. static void *aja_source_create(obs_data_t *, obs_source_t *);
  528. static void aja_source_destroy(void *);
  529. static void aja_source_activate(void *);
  530. static void aja_source_deactivate(void *);
  531. static void aja_source_update(void *, obs_data_t *);
  532. const char *aja_source_get_name(void *unused)
  533. {
  534. UNUSED_PARAMETER(unused);
  535. return obs_module_text(kUIPropCaptureModule.text);
  536. }
  537. bool aja_source_device_changed(void *data, obs_properties_t *props,
  538. obs_property_t *list, obs_data_t *settings)
  539. {
  540. UNUSED_PARAMETER(list);
  541. blog(LOG_DEBUG, "AJA Source Device Changed");
  542. auto *ajaSource = (AJASource *)data;
  543. if (!ajaSource) {
  544. blog(LOG_DEBUG,
  545. "aja_source_device_changed: AJA Source instance is null!");
  546. return false;
  547. }
  548. const char *cardID = obs_data_get_string(settings, kUIPropDevice.id);
  549. if (!cardID || !cardID[0])
  550. return false;
  551. auto &cardManager = aja::CardManager::Instance();
  552. auto cardEntry = cardManager.GetCardEntry(cardID);
  553. if (!cardEntry) {
  554. blog(LOG_DEBUG,
  555. "aja_source_device_changed: Card Entry not found for %s",
  556. cardID);
  557. return false;
  558. }
  559. blog(LOG_DEBUG, "Found CardEntry for %s", cardID);
  560. CNTV2Card *card = cardEntry->GetCard();
  561. if (!card) {
  562. blog(LOG_DEBUG,
  563. "aja_source_device_changed: Card instance is null!");
  564. return false;
  565. }
  566. const NTV2DeviceID deviceID = card->GetDeviceID();
  567. /* If Channel 1 is actively in use, filter the video format list to only
  568. * show video formats within the same framerate family. If Channel 1 is
  569. * not active we just go ahead and try to set all framestores to the same video format.
  570. * This is because Channel 1's clock rate will govern the card's Free Run clock.
  571. */
  572. NTV2VideoFormat videoFormatChannel1 = NTV2_FORMAT_UNKNOWN;
  573. if (!cardEntry->ChannelReady(NTV2_CHANNEL1, ajaSource->GetName())) {
  574. card->GetVideoFormat(videoFormatChannel1, NTV2_CHANNEL1);
  575. }
  576. obs_property_t *devices_list =
  577. obs_properties_get(props, kUIPropDevice.id);
  578. obs_property_t *io_select_list =
  579. obs_properties_get(props, kUIPropInput.id);
  580. obs_property_t *vid_fmt_list =
  581. obs_properties_get(props, kUIPropVideoFormatSelect.id);
  582. obs_property_t *pix_fmt_list =
  583. obs_properties_get(props, kUIPropPixelFormatSelect.id);
  584. obs_property_t *sdi_trx_list =
  585. obs_properties_get(props, kUIPropSDITransport.id);
  586. obs_property_t *sdi_4k_list =
  587. obs_properties_get(props, kUIPropSDITransport4K.id);
  588. obs_property_list_clear(vid_fmt_list);
  589. obs_property_list_add_int(vid_fmt_list, obs_module_text("Auto"),
  590. kAutoDetect);
  591. populate_video_format_list(deviceID, vid_fmt_list, videoFormatChannel1,
  592. true);
  593. obs_property_list_clear(pix_fmt_list);
  594. obs_property_list_add_int(pix_fmt_list, obs_module_text("Auto"),
  595. kAutoDetect);
  596. populate_pixel_format_list(deviceID, pix_fmt_list);
  597. IOSelection io_select = static_cast<IOSelection>(
  598. obs_data_get_int(settings, kUIPropInput.id));
  599. obs_property_list_clear(sdi_trx_list);
  600. populate_sdi_transport_list(sdi_trx_list, io_select, deviceID, true);
  601. obs_property_list_clear(sdi_4k_list);
  602. populate_sdi_4k_transport_list(sdi_4k_list);
  603. populate_io_selection_input_list(cardID, ajaSource->GetName(), deviceID,
  604. io_select_list);
  605. auto curr_vf = static_cast<NTV2VideoFormat>(
  606. obs_data_get_int(settings, kUIPropVideoFormatSelect.id));
  607. bool have_cards = cardManager.NumCardEntries() > 0;
  608. obs_property_set_visible(devices_list, have_cards);
  609. obs_property_set_visible(io_select_list, have_cards);
  610. obs_property_set_visible(vid_fmt_list, have_cards);
  611. obs_property_set_visible(pix_fmt_list, have_cards);
  612. obs_property_set_visible(
  613. sdi_trx_list, have_cards && aja::IsIOSelectionSDI(io_select));
  614. obs_property_set_visible(
  615. sdi_4k_list, have_cards && NTV2_IS_4K_VIDEO_FORMAT(curr_vf));
  616. return true;
  617. }
  618. bool aja_io_selection_changed(void *data, obs_properties_t *props,
  619. obs_property_t *list, obs_data_t *settings)
  620. {
  621. UNUSED_PARAMETER(list);
  622. AJASource *ajaSource = (AJASource *)data;
  623. if (!ajaSource) {
  624. blog(LOG_DEBUG,
  625. "aja_io_selection_changed: AJA Source instance is null!");
  626. return false;
  627. }
  628. const char *cardID = obs_data_get_string(settings, kUIPropDevice.id);
  629. if (!cardID || !cardID[0])
  630. return false;
  631. auto &cardManager = aja::CardManager::Instance();
  632. auto cardEntry = cardManager.GetCardEntry(cardID);
  633. if (!cardEntry) {
  634. blog(LOG_DEBUG,
  635. "aja_io_selection_changed: Card Entry not found for %s",
  636. cardID);
  637. return false;
  638. }
  639. filter_io_selection_input_list(cardID, ajaSource->GetName(),
  640. obs_properties_get(props,
  641. kUIPropInput.id));
  642. obs_property_set_visible(
  643. obs_properties_get(props, kUIPropSDITransport.id),
  644. aja::IsIOSelectionSDI(static_cast<IOSelection>(
  645. obs_data_get_int(settings, kUIPropInput.id))));
  646. return true;
  647. }
  648. bool aja_sdi_mode_list_changed(obs_properties_t *props, obs_property_t *list,
  649. obs_data_t *settings)
  650. {
  651. UNUSED_PARAMETER(props);
  652. UNUSED_PARAMETER(list);
  653. UNUSED_PARAMETER(settings);
  654. return true;
  655. }
  656. void *aja_source_create(obs_data_t *settings, obs_source_t *source)
  657. {
  658. blog(LOG_DEBUG, "AJA Source Create");
  659. auto ajaSource = new AJASource(source);
  660. ajaSource->SetName(obs_source_get_name(source));
  661. obs_source_set_async_decoupled(source, true);
  662. ajaSource->SetOBSSource(source);
  663. ajaSource->ResetAudioBuffer(NTV2_AUDIOSIZE_MAX);
  664. ajaSource->Activate(false);
  665. obs_source_update(source, settings);
  666. return ajaSource;
  667. }
  668. void aja_source_destroy(void *data)
  669. {
  670. blog(LOG_DEBUG, "AJA Source Destroy");
  671. auto ajaSource = (AJASource *)data;
  672. if (!ajaSource) {
  673. blog(LOG_ERROR, "aja_source_destroy: Plugin instance is null!");
  674. return;
  675. }
  676. ajaSource->Deactivate();
  677. NTV2DeviceID deviceID = DEVICE_ID_NOTFOUND;
  678. CNTV2Card *card = ajaSource->GetCard();
  679. if (card) {
  680. deviceID = card->GetDeviceID();
  681. aja::Routing::StopSourceAudio(ajaSource->GetSourceProps(),
  682. card);
  683. }
  684. ajaSource->mVideoBuffer.Deallocate();
  685. ajaSource->mAudioBuffer.Deallocate();
  686. ajaSource->mVideoBuffer = NULL;
  687. ajaSource->mAudioBuffer = NULL;
  688. auto &cardManager = aja::CardManager::Instance();
  689. const auto &cardID = ajaSource->CardID();
  690. auto cardEntry = cardManager.GetCardEntry(cardID);
  691. if (!cardEntry) {
  692. blog(LOG_DEBUG,
  693. "aja_source_destroy: Card Entry not found for %s",
  694. cardID.c_str());
  695. return;
  696. }
  697. auto ioSelect = ajaSource->GetSourceProps().ioSelect;
  698. if (!cardEntry->ReleaseInputSelection(ioSelect, deviceID,
  699. ajaSource->GetName())) {
  700. blog(LOG_WARNING,
  701. "aja_source_destroy: Error releasing Input Selection!");
  702. }
  703. delete ajaSource;
  704. ajaSource = nullptr;
  705. }
  706. static void aja_source_show(void *data)
  707. {
  708. auto ajaSource = (AJASource *)data;
  709. if (!ajaSource) {
  710. blog(LOG_ERROR,
  711. "aja_source_show: AJA Source instance is null!");
  712. return;
  713. }
  714. bool deactivateWhileNotShowing =
  715. ajaSource->GetSourceProps().deactivateWhileNotShowing;
  716. bool showing = obs_source_showing(ajaSource->GetOBSSource());
  717. blog(LOG_DEBUG,
  718. "aja_source_show: deactivateWhileNotShowing = %s, showing = %s",
  719. deactivateWhileNotShowing ? "true" : "false",
  720. showing ? "true" : "false");
  721. if (deactivateWhileNotShowing && showing && !ajaSource->IsCapturing()) {
  722. ajaSource->Activate(true);
  723. blog(LOG_DEBUG, "aja_source_show: activated capture thread!");
  724. }
  725. }
  726. static void aja_source_hide(void *data)
  727. {
  728. auto ajaSource = (AJASource *)data;
  729. if (!ajaSource)
  730. return;
  731. bool deactivateWhileNotShowing =
  732. ajaSource->GetSourceProps().deactivateWhileNotShowing;
  733. bool showing = obs_source_showing(ajaSource->GetOBSSource());
  734. blog(LOG_DEBUG,
  735. "aja_source_hide: deactivateWhileNotShowing = %s, showing = %s",
  736. deactivateWhileNotShowing ? "true" : "false",
  737. showing ? "true" : "false");
  738. if (deactivateWhileNotShowing && !showing && ajaSource->IsCapturing()) {
  739. ajaSource->Deactivate();
  740. blog(LOG_DEBUG, "aja_source_hide: deactivated capture thread!");
  741. }
  742. }
  743. static void aja_source_activate(void *data)
  744. {
  745. UNUSED_PARAMETER(data);
  746. }
  747. static void aja_source_deactivate(void *data)
  748. {
  749. UNUSED_PARAMETER(data);
  750. }
  751. static void aja_source_update(void *data, obs_data_t *settings)
  752. {
  753. static bool initialized = false;
  754. auto ajaSource = (AJASource *)data;
  755. if (!ajaSource) {
  756. blog(LOG_WARNING,
  757. "aja_source_update: Plugin instance is null!");
  758. return;
  759. }
  760. auto io_select = static_cast<IOSelection>(
  761. obs_data_get_int(settings, kUIPropInput.id));
  762. auto vf_select = static_cast<NTV2VideoFormat>(
  763. obs_data_get_int(settings, kUIPropVideoFormatSelect.id));
  764. auto pf_select = static_cast<NTV2PixelFormat>(
  765. obs_data_get_int(settings, kUIPropPixelFormatSelect.id));
  766. auto sdi_trx_select = static_cast<SDITransport>(
  767. obs_data_get_int(settings, kUIPropSDITransport.id));
  768. auto sdi_t4k_select = static_cast<SDITransport4K>(
  769. obs_data_get_int(settings, kUIPropSDITransport4K.id));
  770. bool deactivateWhileNotShowing =
  771. obs_data_get_bool(settings, kUIPropDeactivateWhenNotShowing.id);
  772. const std::string &wantCardID =
  773. obs_data_get_string(settings, kUIPropDevice.id);
  774. const std::string &currentCardID = ajaSource->CardID();
  775. if (wantCardID != currentCardID) {
  776. initialized = false;
  777. ajaSource->Deactivate();
  778. }
  779. auto &cardManager = aja::CardManager::Instance();
  780. cardManager.EnumerateCards();
  781. auto cardEntry = cardManager.GetCardEntry(wantCardID);
  782. if (!cardEntry) {
  783. blog(LOG_DEBUG,
  784. "aja_source_update: Card Entry not found for %s",
  785. wantCardID.c_str());
  786. return;
  787. }
  788. CNTV2Card *card = cardEntry->GetCard();
  789. if (!card || !card->IsOpen()) {
  790. blog(LOG_ERROR, "aja_source_update: AJA device %s not open!",
  791. wantCardID.c_str());
  792. return;
  793. }
  794. if (card->GetModelName() == "(Not Found)") {
  795. blog(LOG_ERROR,
  796. "aja_source_update: AJA device %s disconnected?",
  797. wantCardID.c_str());
  798. return;
  799. }
  800. ajaSource->SetCard(cardEntry->GetCard());
  801. SourceProps curr_props = ajaSource->GetSourceProps();
  802. // Release Channels from previous card if card ID changes
  803. if (wantCardID != currentCardID) {
  804. auto prevCardEntry = cardManager.GetCardEntry(currentCardID);
  805. if (prevCardEntry) {
  806. const std::string &ioSelectStr =
  807. aja::IOSelectionToString(curr_props.ioSelect);
  808. if (!prevCardEntry->ReleaseInputSelection(
  809. curr_props.ioSelect, curr_props.deviceID,
  810. ajaSource->GetName())) {
  811. blog(LOG_WARNING,
  812. "aja_source_update: Error releasing IOSelection %s for card ID %s",
  813. ioSelectStr.c_str(),
  814. currentCardID.c_str());
  815. } else {
  816. blog(LOG_INFO,
  817. "aja_source_update: Released IOSelection %s for card ID %s",
  818. ioSelectStr.c_str(),
  819. currentCardID.c_str());
  820. ajaSource->SetCardID(wantCardID);
  821. io_select = IOSelection::Invalid;
  822. }
  823. }
  824. }
  825. if (io_select == IOSelection::Invalid) {
  826. blog(LOG_DEBUG, "aja_source_update: Invalid IOSelection");
  827. return;
  828. }
  829. SourceProps want_props;
  830. want_props.deviceID = card->GetDeviceID();
  831. want_props.ioSelect = io_select;
  832. want_props.videoFormat =
  833. ((int32_t)vf_select == kAutoDetect)
  834. ? NTV2_FORMAT_UNKNOWN
  835. : static_cast<NTV2VideoFormat>(vf_select);
  836. want_props.pixelFormat =
  837. ((int32_t)pf_select == kAutoDetect)
  838. ? NTV2_FBF_INVALID
  839. : static_cast<NTV2PixelFormat>(pf_select);
  840. want_props.sdiTransport =
  841. ((int32_t)sdi_trx_select == kAutoDetect)
  842. ? SDITransport::Unknown
  843. : static_cast<SDITransport>(sdi_trx_select);
  844. want_props.sdi4kTransport = sdi_t4k_select;
  845. want_props.vpids.clear();
  846. want_props.deactivateWhileNotShowing = deactivateWhileNotShowing;
  847. if (aja::IsIOSelectionSDI(io_select)) {
  848. want_props.autoDetect = (int)sdi_trx_select == kAutoDetect;
  849. } else {
  850. want_props.autoDetect = ((int)vf_select == kAutoDetect ||
  851. (int)pf_select == kAutoDetect);
  852. }
  853. ajaSource->SetCardID(wantCardID);
  854. ajaSource->SetDeviceIndex((UWord)cardEntry->GetCardIndex());
  855. // Release Channels if IOSelection changes
  856. if (want_props.ioSelect != curr_props.ioSelect) {
  857. const std::string &ioSelectStr =
  858. aja::IOSelectionToString(curr_props.ioSelect);
  859. if (!cardEntry->ReleaseInputSelection(curr_props.ioSelect,
  860. curr_props.deviceID,
  861. ajaSource->GetName())) {
  862. blog(LOG_WARNING,
  863. "aja_source_update: Error releasing IOSelection %s for card ID %s",
  864. ioSelectStr.c_str(), currentCardID.c_str());
  865. } else {
  866. blog(LOG_INFO,
  867. "aja_source_update: Released IOSelection %s for card ID %s",
  868. ioSelectStr.c_str(), currentCardID.c_str());
  869. }
  870. }
  871. // Acquire Channels for current IOSelection
  872. if (!cardEntry->AcquireInputSelection(want_props.ioSelect,
  873. want_props.deviceID,
  874. ajaSource->GetName())) {
  875. blog(LOG_ERROR,
  876. "aja_source_update: Could not acquire IOSelection %s",
  877. aja::IOSelectionToString(want_props.ioSelect).c_str());
  878. return;
  879. }
  880. // Read SDI video payload IDs (VPID) used for helping to determine the wire format
  881. NTV2VideoFormat new_vf = want_props.videoFormat;
  882. NTV2PixelFormat new_pf = want_props.pixelFormat;
  883. if (!ajaSource->ReadWireFormats(want_props.deviceID,
  884. want_props.ioSelect, new_vf, new_pf,
  885. want_props.vpids)) {
  886. blog(LOG_ERROR, "aja_source_update: ReadWireFormats failed!");
  887. cardEntry->ReleaseInputSelection(want_props.ioSelect,
  888. curr_props.deviceID,
  889. ajaSource->GetName());
  890. return;
  891. }
  892. // Set auto-detected formats
  893. if ((int32_t)vf_select == kAutoDetect)
  894. want_props.videoFormat = new_vf;
  895. if ((int32_t)pf_select == kAutoDetect)
  896. want_props.pixelFormat = new_pf;
  897. if (want_props.videoFormat == NTV2_FORMAT_UNKNOWN ||
  898. want_props.pixelFormat == NTV2_FBF_INVALID) {
  899. blog(LOG_ERROR,
  900. "aja_source_update: Unknown video/pixel format(s): %s / %s",
  901. NTV2VideoFormatToString(want_props.videoFormat).c_str(),
  902. NTV2FrameBufferFormatToString(want_props.pixelFormat)
  903. .c_str());
  904. cardEntry->ReleaseInputSelection(want_props.ioSelect,
  905. curr_props.deviceID,
  906. ajaSource->GetName());
  907. return;
  908. }
  909. // Change capture format and restart capture thread
  910. if (!initialized || want_props != ajaSource->GetSourceProps()) {
  911. ajaSource->ClearConnections();
  912. NTV2XptConnections xpt_cnx;
  913. aja::Routing::ConfigureSourceRoute(
  914. want_props, NTV2_MODE_CAPTURE, card, xpt_cnx);
  915. ajaSource->CacheConnections(xpt_cnx);
  916. ajaSource->Deactivate();
  917. initialized = true;
  918. }
  919. ajaSource->SetSourceProps(want_props);
  920. aja::Routing::StartSourceAudio(want_props, card);
  921. card->SetReference(NTV2_REFERENCE_FREERUN);
  922. ajaSource->Activate(true);
  923. }
  924. static obs_properties_t *aja_source_get_properties(void *data)
  925. {
  926. obs_properties_t *props = obs_properties_create();
  927. obs_property_t *device_list = obs_properties_add_list(
  928. props, kUIPropDevice.id, obs_module_text(kUIPropDevice.text),
  929. OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
  930. populate_source_device_list(device_list);
  931. obs_property_t *io_select_list = obs_properties_add_list(
  932. props, kUIPropInput.id, obs_module_text(kUIPropInput.text),
  933. OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
  934. obs_property_t *vid_fmt_list = obs_properties_add_list(
  935. props, kUIPropVideoFormatSelect.id,
  936. obs_module_text(kUIPropVideoFormatSelect.text),
  937. OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
  938. obs_properties_add_list(props, kUIPropPixelFormatSelect.id,
  939. obs_module_text(kUIPropPixelFormatSelect.text),
  940. OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
  941. obs_properties_add_list(props, kUIPropSDITransport.id,
  942. obs_module_text(kUIPropSDITransport.text),
  943. OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
  944. obs_properties_add_list(props, kUIPropSDITransport4K.id,
  945. obs_module_text(kUIPropSDITransport4K.text),
  946. OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
  947. obs_properties_add_bool(
  948. props, kUIPropDeactivateWhenNotShowing.id,
  949. obs_module_text(kUIPropDeactivateWhenNotShowing.text));
  950. obs_property_set_modified_callback(vid_fmt_list,
  951. aja_video_format_changed);
  952. obs_property_set_modified_callback2(device_list,
  953. aja_source_device_changed, data);
  954. obs_property_set_modified_callback2(io_select_list,
  955. aja_io_selection_changed, data);
  956. return props;
  957. }
  958. void aja_source_get_defaults(obs_data_t *settings)
  959. {
  960. obs_data_set_default_int(settings, kUIPropInput.id,
  961. static_cast<long long>(IOSelection::Invalid));
  962. obs_data_set_default_int(settings, kUIPropVideoFormatSelect.id,
  963. static_cast<long long>(kAutoDetect));
  964. obs_data_set_default_int(settings, kUIPropPixelFormatSelect.id,
  965. static_cast<long long>(kAutoDetect));
  966. obs_data_set_default_int(settings, kUIPropSDITransport.id,
  967. static_cast<long long>(kAutoDetect));
  968. obs_data_set_default_int(
  969. settings, kUIPropSDITransport4K.id,
  970. static_cast<long long>(SDITransport4K::TwoSampleInterleave));
  971. obs_data_set_default_bool(settings, kUIPropDeactivateWhenNotShowing.id,
  972. false);
  973. }
  974. void aja_source_save(void *data, obs_data_t *settings)
  975. {
  976. AJASource *ajaSource = (AJASource *)data;
  977. if (!ajaSource) {
  978. blog(LOG_ERROR,
  979. "aja_source_save: AJA Source instance is null!");
  980. return;
  981. }
  982. const char *cardID = obs_data_get_string(settings, kUIPropDevice.id);
  983. if (!cardID || !cardID[0])
  984. return;
  985. auto &cardManager = aja::CardManager::Instance();
  986. auto cardEntry = cardManager.GetCardEntry(cardID);
  987. if (!cardEntry) {
  988. blog(LOG_DEBUG, "aja_source_save: Card Entry not found for %s",
  989. cardID);
  990. return;
  991. }
  992. auto oldName = ajaSource->GetName();
  993. auto newName = obs_source_get_name(ajaSource->GetOBSSource());
  994. if (oldName != newName &&
  995. cardEntry->UpdateChannelOwnerName(oldName, newName)) {
  996. ajaSource->SetName(newName);
  997. blog(LOG_DEBUG, "aja_source_save: Renamed \"%s\" to \"%s\"",
  998. oldName.c_str(), newName);
  999. }
  1000. }
  1001. struct obs_source_info create_aja_source_info()
  1002. {
  1003. struct obs_source_info aja_source_info = {};
  1004. aja_source_info.id = kUIPropCaptureModule.id;
  1005. aja_source_info.type = OBS_SOURCE_TYPE_INPUT;
  1006. aja_source_info.output_flags = OBS_SOURCE_ASYNC_VIDEO |
  1007. OBS_SOURCE_AUDIO |
  1008. OBS_SOURCE_DO_NOT_DUPLICATE;
  1009. aja_source_info.get_name = aja_source_get_name;
  1010. aja_source_info.create = aja_source_create;
  1011. aja_source_info.destroy = aja_source_destroy;
  1012. aja_source_info.update = aja_source_update;
  1013. aja_source_info.show = aja_source_show;
  1014. aja_source_info.hide = aja_source_hide;
  1015. aja_source_info.activate = aja_source_activate;
  1016. aja_source_info.deactivate = aja_source_deactivate;
  1017. aja_source_info.get_properties = aja_source_get_properties;
  1018. aja_source_info.get_defaults = aja_source_get_defaults;
  1019. aja_source_info.save = aja_source_save;
  1020. aja_source_info.icon_type = OBS_ICON_TYPE_CAMERA;
  1021. return aja_source_info;
  1022. }