<commit_before>// This file is a part of MikheyevLab/bee_tools. License is MIT

#include "DeckLinkAPI.h"
#include "DeckLinkAPIDispatch.cpp"
#include "DeckLinkAPIVersion.h"

#include <iostream>
#include <cstdlib>

int main(int argc, char *argv[]) {
  IDeckLinkIterator *deckLinkIterator = CreateDeckLinkIteratorInstance();

  if (deckLinkIterator == NULL) {
    return -1;
  }

  // Check all DeckLink devices
  IDeckLink* deckLink;
  char* deviceName;
  HRESULT resultCode;

  resultCode = deckLinkIterator->Next(&deckLink);

  while (resultCode == S_OK) {
    if (deckLink->GetDisplayName((const char **) &deviceName) == S_OK) {
      std::cout << deviceName << "\n";
    }

    // free device name
    std::free(deviceName);

    //Release deckLink device
    deckLink->Release();

    // Get the next device
    resultCode = deckLinkIterator->Next(&deckLink);
  }

  if (resultCode == E_FAIL) {
    return -1;
  }

  return 0;
}<commit_msg>enable videostream of first device<commit_after>// This file is a part of MikheyevLab/bee_tools. License is MIT

#include "DeckLinkAPI.h"
#include "DeckLinkAPIDispatch.cpp"
#include "DeckLinkAPIVersion.h"

#include <iostream>
#include <cstdlib>

int main(int argc, char *argv[]) {
  IDeckLinkIterator *deckLinkIterator = CreateDeckLinkIteratorInstance();

  if (deckLinkIterator == NULL) {
    std::cerr << "Failed to open DeckLink driver";
    return -1;
  }

  // Check all DeckLink devices
  IDeckLink* deckLink;
  char* name;
  HRESULT resultCode;

  resultCode = deckLinkIterator->Next(&deckLink);

  while (resultCode == S_OK) {
    if (deckLink->GetDisplayName((const char **) &name) == S_OK) {
      std::cout << "Found device: " <<  name << "\n";
    }

    // free device name
    std::free(name);

    // TODO: Handoff to thread for multiplex input
    // Release deckLink device
    // deckLink->Release();

    // Get the next device
    // resultCode = deckLinkIterator->Next(&deckLink);
    resultCode = S_FALSE;
  }

  if (resultCode == E_FAIL) {
    std::cerr << "Failed to acquire DeckLink device";
    return -1;
  }

  // Establish input
  IDeckLinkInput* input;
  if (deckLink->QueryInterface(IID_IDeckLinkInput, (void**) &input) == E_NOINTERFACE) {
    std::cerr << "Could not acquire input interface.";
    return -1;
  }

  // Get available modes
  IDeckLinkDisplayModeIterator* modes;
  if (input->GetDisplayModeIterator(&modes) == E_FAIL) {
    std::cerr << "Failed to get display modes";
    return -1;
  }

  //Get mode
  IDeckLinkDisplayMode* mode;
  resultCode = modes->Next(&mode);

  BMDDisplayMode displayMode;
  BMDPixelFormat pixelFormat = bmdFormat10BitYUV;
  BMDVideoInputFlags flags;

  while (resultCode == S_OK && mode != NULL) {
    mode->GetName((const char**) &name);
    std::cout << "Mode: " << name << " ";
    std::cout << "w: " << mode->GetWidth() << " h: " << mode->GetHeight();

    // get frame rate
    BMDTimeValue timeValue; // long
    BMDTimeScale timeScale; // long

    if (mode->GetFrameRate(&timeValue, &timeScale) == S_OK) {
      std::cout << " fps: " << timeScale/timeValue;
    }

    std::cout << "\n";

    displayMode = mode->GetDisplayMode();

    // Manually set mode for now
    if(displayMode == bmdMode4K2160p30) {
      resultCode = S_FALSE;
    }

    flags = mode->GetFlags();

    std::free(name);
    resultCode = modes->Next(&mode);
  }

  BMDDisplayModeSupport support;
  IDeckLinkDisplayMode* resultDisplayMode;
  if (input->DoesSupportVideoMode(displayMode, pixelFormat, flags, &support, &resultDisplayMode) == E_FAIL) {
    std::cerr << "Something went wrong while testing the video mode";
    return -1;
  }

  // Check if display mode is supported
  if (support == bmdDisplayModeNotSupported) {
    std::cerr << "Display mode is not supported";
    return -1;
  } else if (support == bmdDisplayModeSupportedWithConversion) {
    std::cerr << "Display mode only supported with conversion, Carrying on!";
  }

  // Configure video device
  resultCode = input->EnableVideoInput(displayMode, pixelFormat, flags);

  if (resultCode == E_FAIL) {
    std::cerr << "Failed to enable video input";
    return -1;
  } else if (resultCode == E_INVALIDARG) {
    std::cerr << "Could not enable video input. Reason: Invalid argument";
    return -1;
  } else if (resultCode == E_ACCESSDENIED) {
    std::cerr << "Could not enable video input. Reason: Access denied";
    return -1;
  } else if (resultCode == E_OUTOFMEMORY) {
    std::cerr << "Could not enable video input. Reason: Out of memory";
    return -1;
  }
    // SetCallback
    // StartStreams
    // FlushStreams
    // StopStreams

  input->DisableVideoInput();
  input->Release();
  deckLink->Release();
  return 0;
}
{'fraction_non_alphanumeric': 0.135221465076661, 'fraction_numerical': 0.0048977853492333905, 'mean_word_length': 3.3733705772811917, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7185733', 'n_tokens_mistral': 1563, 'n_tokens_neox': 1512, 'n_words': 402}