void CSignalGeneratorDlg::OnBnClickedOk()
{
	if (m_running == false)
		StartRunning();
	else
		StopRunning();
}
Exemple #2
0
BMDOutputDelegate::BMDOutputDelegate(IDeckLink* link)
	: m_deckLink(link)
	, m_deckLinkConverter(0)
	, m_rgbFrame(0)
	, m_yuvFrame(0)
	, m_running(false)
	, m_frameSet(false)
	, m_frameReceivedCount(0)
{
	// Obtain the audio/video output interface (IDeckLinkOutput)
	if (m_deckLink->QueryInterface(IID_IDeckLinkOutput, (void**)&m_deckLinkOutput) != S_OK)
		goto bail;
		
	#ifdef Q_OS_WIN
	if(CoCreateInstance(CLSID_CDeckLinkVideoConversion, NULL, CLSCTX_ALL,IID_IDeckLinkVideoConversion, (void**)&m_deckLinkConverter) != S_OK)
	#else
	if(!(m_deckLinkConverter = CreateVideoConversionInstance()))
	#endif
 	{
 		qDebug() << "BMDCaptureDelegate: Cannot create an instance of IID_IDeckLinkVideoConversion, therefore cannot convert YUV->RGB, therefore we will not emit proper RGB frames now.";
 		m_deckLinkConverter = NULL;
 		goto bail;
 	}

	// Provide this class as a delegate to the audio and video output interfaces
	m_deckLinkOutput->SetScheduledFrameCompletionCallback(this);
	
	// Start.
	StartRunning();
	
	return;
		
bail:
	if (m_running == true)
	{
		StopRunning();
	}
	else
	{
		// Release any resources that were partially allocated
		if (m_deckLinkOutput != NULL)
		{
			m_deckLinkOutput->Release();
			m_deckLinkOutput = NULL;
		}
		//
		if (m_deckLink != NULL)
		{
			m_deckLink->Release();
			m_deckLink = NULL;
		}
	}
	
	return ;
	
};
Exemple #3
0
Ouroboros::Ouroboros(QWidget *parent) :
    QMainWindow(parent),
    PlayStatus(PLAYSTATUS_STOPPED),
    AnimeProgressStyle(this), //assign this as parent so that stylesheet get inherited
    ui(new Ui::Ouroboros)
{
    ui->setupUi(this);\
    setMouseTracking(true);

    //setup main window
    QString Title = QString(APP_NAME) + " " + QString::number(APP_MAJOR_VERSION) + "." + QString::number(APP_MINOR_VERSION);
    if(APP_DEBUG) Title.append(" Debug");
    this->setWindowTitle(Title);

    //Generate a random seed for other classes
    QTime CurrentTime = QTime::currentTime();
    qsrand((uint)CurrentTime.msec());

    //setup views
    SetViewLayouts();

    //setup tray icon
    SetupTrayIcon();

    //Load settings
    Settings.Load();

    //Load the style
    Theme_Manager.LoadThemeList();
    Theme_Manager.LoadTheme(Settings.Application.Stylesheet);
    this->setStyleSheet(QString(Theme_Manager.GetTheme()));

    //Set the ui for the manager
    GUI_Manager.SetMainWindow(this);

    //Setup Detection
    //Only detects on windows currently
#ifdef WIN32
    File_Manager.SaveMedia();
    //Load Media
    File_Manager.LoadMedia();
    if(Media_Manager.MediaListLoaded)
    {
        DetectionTimer.setInterval(RECOGNITION_TIMEDELAY);
        connect(&DetectionTimer,SIGNAL(timeout()),&Media_Manager,SLOT(DetectAnime()));
        connect(this,SIGNAL(StopDetectionTimer()),&DetectionTimer,SLOT(stop()));
        DetectionTimer.start();
    }
#endif

    //Setup a timer to run the queue every 5 minutes
    QTimer *RunTimer = new QTimer(this);
    connect(RunTimer,SIGNAL(timeout()),&Queue_Manager,SLOT(Run()));
    connect(RunTimer,SIGNAL(timeout()),&Theme_Manager,SLOT(LoadThemeList()));
    RunTimer->start(30000);

    //Connect signals and slots
    connect(RunTimer,SIGNAL(timeout()),&Queue_Manager,SLOT(StartRunning()));
    connect(&Api_Manager,SIGNAL(ChangeStatus(QString,int)),this,SLOT(ChangeStatus(QString,int)));
    connect(&GUI_Manager,SIGNAL(ShowTrayMessage(QString,QString,int)),this,SLOT(ShowTrayMessage(QString,QString,int)));
    connect(&Media_Manager,SIGNAL(ShowTrayMessage(QString,QString,int)),this,SLOT(ShowTrayMessage(QString,QString,int)));
    connect(&Theme_Manager,SIGNAL(ThemeChanged(QString)),this,SLOT(setStyleSheet(QString)));

    //Load user info
    File_Manager.LoadUserInformation();

    //Load history
    File_Manager.LoadHistory();

    //Load local database
    File_Manager.LoadAnimeDatabase();
    GUI_Manager.PopulateModel();

    //Sync anime
    if(CurrentUser.isValid())
    {
        emit ChangeStatus("Syncing ...", 3000);
        Queue_Manager.Sync(true);
    }
}
Exemple #4
0
bool Player::Init(int videomode, int connection, int camera)
{
    // Initialize the DeckLink API
    IDeckLinkIterator *deckLinkIterator = CreateDeckLinkIteratorInstance();
    HRESULT result;
    int i = 0;

    if (!deckLinkIterator) {
        fprintf(stderr,
                "This application requires the DeckLink drivers installed.\n");
        goto bail;
    }

    m_audioSampleDepth =
        av_get_exact_bits_per_sample(audio_st->codec->codec_id);

    switch (audio_st->codec->channels) {
        case  2:
        case  8:
        case 16:
            break;
        default:
            fprintf(stderr,
                    "%d channels not supported, please use 2, 8 or 16\n",
                    audio_st->codec->channels);
            goto bail;
    }

    switch (m_audioSampleDepth) {
        case 16:
        case 32:
            break;
        default:
            fprintf(stderr, "%dbit audio not supported use 16bit or 32bit\n",
                    m_audioSampleDepth);
    }

    do
        result = deckLinkIterator->Next(&m_deckLink);
    while (i++ < camera);

    if (result != S_OK) {
        fprintf(stderr, "No DeckLink PCI cards found\n");
        goto bail;
    }

    // Obtain the audio/video output interface (IDeckLinkOutput)
    if (m_deckLink->QueryInterface(IID_IDeckLinkOutput,
                                   (void **)&m_deckLinkOutput) != S_OK)
        goto bail;

    result = m_deckLink->QueryInterface(IID_IDeckLinkConfiguration,
                                        (void **)&deckLinkConfiguration);
    if (result != S_OK) {
        fprintf(
            stderr,
            "Could not obtain the IDeckLinkConfiguration interface - result = %08x\n",
            result);
        goto bail;
    }
    //XXX make it generic
    switch (connection) {
    case 1:
        DECKLINK_SET_VIDEO_CONNECTION(bmdVideoConnectionComposite);
        DECKLINK_SET_AUDIO_CONNECTION(bmdAudioConnectionAnalog);
        break;
    case 2:
        DECKLINK_SET_VIDEO_CONNECTION(bmdVideoConnectionComponent);
        DECKLINK_SET_AUDIO_CONNECTION(bmdAudioConnectionAnalog);
        break;
    case 3:
        DECKLINK_SET_VIDEO_CONNECTION(bmdVideoConnectionHDMI);
        DECKLINK_SET_AUDIO_CONNECTION(bmdAudioConnectionEmbedded);
        break;
    case 4:
        DECKLINK_SET_VIDEO_CONNECTION(bmdVideoConnectionSDI);
        DECKLINK_SET_AUDIO_CONNECTION(bmdAudioConnectionEmbedded);
        break;
    default:
        // do not change it
        break;
    }

    // Provide this class as a delegate to the audio and video output interfaces
    m_deckLinkOutput->SetScheduledFrameCompletionCallback(this);
    m_deckLinkOutput->SetAudioCallback(this);

    avframe = avcodec_alloc_frame();

    packet_queue_init(&audioqueue);
    packet_queue_init(&videoqueue);
    packet_queue_init(&dataqueue);
    pthread_t th;
    pthread_create(&th, NULL, fill_queues, NULL);

    usleep(buffer); // You can add the microseconds you need for pre-buffering before start playing
    // Start playing
    StartRunning(videomode);

    pthread_mutex_lock(&sleepMutex);
    pthread_cond_wait(&sleepCond, &sleepMutex);
    pthread_mutex_unlock(&sleepMutex);
    fill_me = 0;
    fprintf(stderr, "Exiting, cleaning up\n");
    packet_queue_end(&audioqueue);
    packet_queue_end(&videoqueue);

bail:
    if (m_running == true) {
        StopRunning();
    } else {
        // Release any resources that were partially allocated
        if (m_deckLinkOutput != NULL) {
            m_deckLinkOutput->Release();
            m_deckLinkOutput = NULL;
        }
        //
        if (m_deckLink != NULL) {
            m_deckLink->Release();
            m_deckLink = NULL;
        }
    }

    if (deckLinkIterator != NULL)
        deckLinkIterator->Release();

    return true;
}
bool TestPattern::Init()
{
	HRESULT							result;
	int								idx;
	bool							success = false;

	IDeckLinkIterator*				deckLinkIterator = NULL;
	IDeckLinkDisplayModeIterator*	displayModeIterator = NULL;
	char*							displayModeName = NULL;

	// Get the DeckLink device
	deckLinkIterator = CreateDeckLinkIteratorInstance();
	if (!deckLinkIterator)
	{
		fprintf(stderr, "This application requires the DeckLink drivers installed.\n");
		goto bail;
	}

	idx = m_config->m_deckLinkIndex;

	while ((result = deckLinkIterator->Next(&m_deckLink)) == S_OK)
	{
		if (idx == 0)
			break;
		--idx;

		m_deckLink->Release();
	}

	if (result != S_OK || m_deckLink == NULL)
	{
		fprintf(stderr, "Unable to get DeckLink device %u\n", m_config->m_deckLinkIndex);
		goto bail;
	}

	// Get the output (display) interface of the DeckLink device
	if (m_deckLink->QueryInterface(IID_IDeckLinkOutput, (void**)&m_deckLinkOutput) != S_OK)
		goto bail;

	// Get the display mode
	idx = m_config->m_displayModeIndex;

	result = m_deckLinkOutput->GetDisplayModeIterator(&displayModeIterator);
	if (result != S_OK)
		goto bail;

	while ((result = displayModeIterator->Next(&m_displayMode)) == S_OK)
	{
		if (idx == 0)
			break;
		--idx;

		m_displayMode->Release();
	}

	if (result != S_OK || m_displayMode == NULL)
	{
		fprintf(stderr, "Unable to get display mode %d\n", m_config->m_displayModeIndex);
		goto bail;
	}

	// Get display mode name
	result = m_displayMode->GetName((const char**)&displayModeName);
	if (result != S_OK)
	{
		displayModeName = (char *)malloc(32);
		snprintf(displayModeName, 32, "[index %d]", m_config->m_displayModeIndex);
	}

	// Check for 3D support on display mode
	if ((m_config->m_outputFlags & bmdVideoOutputDualStream3D) && !(m_displayMode->GetFlags() & bmdDisplayModeSupports3D))
	{
		fprintf(stderr, "The display mode %s is not supported with 3D\n", displayModeName);
		goto bail;
	}

	m_config->DisplayConfiguration();

	// Provide this class as a delegate to the audio and video output interfaces
	m_deckLinkOutput->SetScheduledFrameCompletionCallback(this);
	m_deckLinkOutput->SetAudioCallback(this);

	success = true;

	// Start.
	while (!do_exit)
	{
		StartRunning();
		fprintf(stderr, "Starting playback\n");

		pthread_mutex_lock(&sleepMutex);
		pthread_cond_wait(&sleepCond, &sleepMutex);
		pthread_mutex_unlock(&sleepMutex);

		fprintf(stderr, "Stopping playback\n");
		StopRunning();
	}

	printf("\n");

	m_running = false;

bail:
	if (displayModeName != NULL)
		free(displayModeName);

	if (m_displayMode != NULL)
		m_displayMode->Release();

	if (displayModeIterator != NULL)
		displayModeIterator->Release();

	if (m_deckLinkOutput != NULL)
		m_deckLinkOutput->Release();

	if (m_deckLink != NULL)
		m_deckLink->Release();

	if (deckLinkIterator != NULL)
		deckLinkIterator->Release();

	return success;
}