Пример #1
0
// Destructor
CBDAFilterGraph::~CBDAFilterGraph()
{
    if(m_fGraphRunning)
    {
        StopGraph();
    }

    if(m_fGraphBuilt || m_fGraphFailure)
    {
        TearDownGraph();
    }
}
Пример #2
0
BOOL CDShowCtrl::AddTS(BYTE* data, DWORD size)
{
	if( this->mediaCtrl == NULL ){
		return FALSE;
	}
	if( this->runFlag == FALSE ){
		return FALSE;
	}

	DWORD ret = tsSrc->AddTS(data, size);
	if( this->preCreateFlag == TRUE ){
		//Pinフォーマット決めてもらうために少しだけ流す
		if( ret > 0 ){
			this->preCount+=ret;
		}
		if( this->preCount > 15 ){
			this->preCreateFlag = FALSE;
			this->preCount = 0;
			Sleep(1000);
			StopGraph();
			tsSrc->ClearData();
			ReConnectScale();
			RunGraph();
			for( size_t i=0; i<this->buffData.size(); i++ ){
				tsSrc->AddTS(this->buffData[i]->data, this->buffData[i]->size);
				delete this->buffData[i];
			}
			this->buffData.clear();
			tsSrc->AddTS(data, size);
		}else{
			BUFF_DATA* item = new BUFF_DATA;
			item->size = size;
			item->data = new BYTE[item->size];
			buffData.push_back(item);
		}
	}

	return TRUE;
}
Пример #3
0
void threadGraph::run()
{
    switch(SwMode)
    {
        case 0:
            while(Started)
            {
                if (!Data_GNit->isEmpty())
                {
                    mutexG->lock();
                    point=Data_GNit->dequeue();
                    mutexG->unlock();
                    processingNit();
                }
            }
            break;
        case 1:
            while(Started)
            {
                if(!Data_GR->empty())
                {
                    mutexG->lock();
                    point=Data_GR->dequeue();
                    mutexG->unlock();
                    processingR();
                }
            }
            break;
        case 2:
            while(Started)
            {
                if(!Data_GFsep->empty())
                {
                    mutexG->lock();
                    point=Data_GFsep->dequeue();
                    mutexG->unlock();
                    processingFsep();
                }
            }
            break;
        case 3:
            while(Started)
            {
                if (!Data_GNit->isEmpty())
                {
                    mutexG->lock();
                    point=Data_GNit->dequeue();
                    mutexG->unlock();
                    processingNit();
                }
                for(int i=0;i<SizePacketFsep;++i)
                {
                    if(!Data_GFsep->empty())
                    {
                        mutexG->lock();
                        point=Data_GFsep->dequeue();
                        mutexG->unlock();
                        processingFsep();
                    }
                }
            }
            break;
        case 4:
            while(Started)
            {
                if (!Data_GNit->isEmpty())
                {
                    mutexG->lock();
                    point=Data_GNit->dequeue();
                    mutexG->unlock();
                    processingNit();
                }
                for(int i=0;i<SizePacketR;++i)
                {
                    if(!Data_GR->empty())
                    {
                        mutexG->lock();
                        point=Data_GR->dequeue();
                        mutexG->unlock();
                        processingR();
                    }
                }
            }
            break;
        case 5:
            while(Started)
            {
                for(int i=0;i<SizePacketR;++i)
                {
                    if(!Data_GR->empty())
                    {
                         mutexG->lock();
                         point=Data_GR->dequeue();
                         mutexG->unlock();
                         processingR();
                    }
                }
                for(int i=0;i<SizePacketFsep;++i)
                {
                    if(!Data_GFsep->empty())
                    {
                        mutexG->lock();
                        point=Data_GFsep->dequeue();
                        mutexG->unlock();
                        processingFsep();
                    }
                }
            }
            break;
        default:
            break;
    }
    emit StopGraph();
    exec();
}
Пример #4
0
// BuildGraph sets up devices, adds and connects filters
HRESULT
CBDAFilterGraph::BuildGraph(NETWORK_TYPE NetType)
{
    HRESULT hr = S_OK;
    m_NetworkType = NetType;

    // if we have already have a filter graph, tear it down
    if(m_fGraphBuilt)
    {
        if(m_fGraphRunning)
        {
            hr = StopGraph ();
        }

        hr = TearDownGraph ();
    }

    // STEP 1: load network provider first so that it can configure other
    // filters, such as configuring the demux to sprout output pins.
    // We also need to submit a tune request to the Network Provider so it will
    // tune to a channel
    if(FAILED (hr = LoadNetworkProvider()))
    {
        ErrorMessageBox(TEXT("Cannot load network provider\n"));
        TearDownGraph();
        m_fGraphFailure = true;
        return hr;
    }

    hr = m_pNetworkProvider->QueryInterface(__uuidof (ITuner), reinterpret_cast <void**> (&m_pITuner));
    if(FAILED (hr))
    {
        ErrorMessageBox(TEXT("pNetworkProvider->QI: Can't QI for ITuner.\n"));
        TearDownGraph();
        m_fGraphFailure = true;
        return hr;
    }

    // create a tune request to initialize the network provider
    // before connecting other filters
    CComPtr <IATSCChannelTuneRequest>  pATSCTuneRequest;
    if(FAILED (hr = CreateATSCTuneRequest(
        m_lPhysicalChannel,
        m_lMajorChannel, 
        m_lMinorChannel,
        &pATSCTuneRequest
        )))
    {
        ErrorMessageBox(TEXT("Cannot create tune request\n"));
        TearDownGraph();
        m_fGraphFailure = true;
        return hr;
    }

    //submit the tune request to the network provider
    hr = m_pITuner->put_TuneRequest(pATSCTuneRequest);
    if(FAILED(hr))
    {
        ErrorMessageBox(TEXT("Cannot submit the tune request\n"));
        TearDownGraph();
        m_fGraphFailure = true;
        return hr;
    }


    // STEP2: Load tuner device and connect to network provider
    if(FAILED (hr = LoadFilter (
        KSCATEGORY_BDA_NETWORK_TUNER, 
        &m_pTunerDevice,
        m_pNetworkProvider, 
        TRUE
        )))
    {
        ErrorMessageBox(TEXT("Cannot load tuner device and connect network provider\n"));
        TearDownGraph();
        m_fGraphFailure = true;
        return hr;
    }

    // STEP3: Load tuner device and connect to demodulator device
    if(FAILED (hr = LoadFilter (
        KSCATEGORY_BDA_RECEIVER_COMPONENT, 
        &m_pDemodulatorDevice,
        m_pTunerDevice, 
        TRUE
        )))
    {
        ErrorMessageBox(TEXT("Cannot load capture device and connect tuner\n"));
        TearDownGraph();
        m_fGraphFailure = true;
        return hr;
    }

    // Step4: Load capture device and connect to tuner device
    if(FAILED (hr = LoadFilter (
        KSCATEGORY_BDA_RECEIVER_COMPONENT, 
        &m_pCaptureDevice,
        m_pDemodulatorDevice, 
        TRUE
        )))
    {
        ErrorMessageBox(TEXT("Cannot load capture device and connect tuner\n"));
        TearDownGraph();
        m_fGraphFailure = true;
        return hr;
    }

    // Step5: Load demux
    if(FAILED (hr = LoadDemux()))
    {
        ErrorMessageBox(TEXT("Cannot load demux\n"));
        TearDownGraph();
        m_fGraphFailure = true;
        return hr;
    }

    //
    // this next call loads and connects filters associated with
    // the demultiplexor. if you want to manually load individual
    // filters such as audio and video decoders, use the code at
    // the bottom of this file
    //
#ifdef DEBUG
    hr = AddGraphToRot (m_pFilterGraph, &m_dwGraphRegister);
    if (FAILED(hr))
    {
        ///ErrorMessageBox(TEXT("Failed to register filter graph with ROT!  hr=0x%x"), hr);
        m_dwGraphRegister = 0;
    }
#endif
    //MessageBox (NULL, _T(""), _T(""), MB_OK);
    // Step6: Render demux pins
    if(FAILED (hr = RenderDemux()))
    {
        ErrorMessageBox(TEXT("Cannot load demux\n"));
        TearDownGraph();
        m_fGraphFailure = true;
        return hr;
    }

    m_fGraphBuilt = true;

    return S_OK;
}