Esempio n. 1
0
int main() {
	IWindow* w;
	ISurface* s;
	ILocalDeviceManager* dm;
	IPlayer* player;
	IPlayer* img;

#if HAVE_COMPSUPPORT
	IComponentManager* cm = IComponentManager::getCMInstance();
	dm = ((LocalDeviceManagerCreator*)(cm->getObject("LocalDeviceManager")))();
#else
	dm = LocalDeviceManager::getInstance();
#endif

	dm->createDevice("systemScreen(0)");
#if HAVE_COMPSUPPORT
	w = ((WindowCreator*)(cm->getObject("Window")))(10, 10, 100, 100);
#else
	w = new DFBWindow(10, 10, 100, 100);
#endif

	w->setCaps(w->getCap("ALPHACHANNEL"));
	w->draw();
	w->show();

	player = new Player("teste");
	img = new ImagePlayer("/root/bg_initializing.png");
	s = img->getSurface();
	w->renderFrom(s);

	//TODO: tests
	cout << "Player test has shown image. press enter to continue" << endl;
	getchar();
	dm->clearWidgetPools();
	cout << "Player test has released widgets. press enter to continue" << endl;
	getchar();

	return 0;
}
	void CommonCoreManager::startPresentation() {
		int aPid, vPid;

#if HAVE_TUNER && HAVE_TSPARSER && HAVE_DSMCC

		NclPlayerData* data   = NULL;
		StcWrapper* sw        = NULL;
		INetworkInterface* ni = NULL;
		ITSFilter* mavFilter  = NULL;
		IWindow* wmv          = NULL;
		ISurface* s           = NULL;
		ISurface* smv         = NULL;
		//IPlayer* ma           = NULL;
		IPlayer* mv           = NULL;
		string mrlv           = "sbtvd-ts://dvr0.ts";
		//string mrla           = "sbtvd-ts://dvr1.ts";

		data = pem->createNclPlayerData();

		if (fileExists(PREFIX_PATH "/tuner/tuning.png")) {
#if HAVE_COMPSUPPORT
			tuningWindow = ((WindowCreator*)(cm->getObject("Window")))(
					data->x, data->y, data->w, data->h);

			s = ((ImageRenderer*)(cm->getObject("ImageRenderer")))(
					(char*)(PREFIX_PATH "/tuner/tuning.png"));

#else
			tuningWindow = new DFBWindow(data->x, data->y, data->w, data->h);
			s = ImagePlayer::renderImage(
					PREFIX_PATH "/tuner/tuning.png");
#endif

			((IWindow*)tuningWindow)->setCaps(
					((IWindow*)tuningWindow)->getCap("ALPHACHANNEL"));

			((IWindow*)tuningWindow)->draw();
			((IWindow*)tuningWindow)->show();
			((IWindow*)tuningWindow)->lowerToBottom();
			((IWindow*)tuningWindow)->renderFrom(s);

			delete s;
			s = NULL;
		}

#if HAVE_COMPSUPPORT
		wmv = ((WindowCreator*)(cm->getObject("Window")))(
				data->x, data->y, data->w, data->h);

#else
		wmv = new DFBWindow(data->x, data->y, data->w, data->h);
#endif

		wmv->draw();

		delete data;

		((ITuner*)tuner)->tune();
		((IDemuxer*)demuxer)->waitProgramInformation();

		if (ocDelay == 0) {
			((IDataProcessor*)dataProcessor)->
				createStreamTypeSectionFilter(
						STREAM_TYPE_DSMCC_TYPE_B, (IDemuxer*)demuxer);
		}

		pem->setCurrentPrivateBaseId(((IDemuxer*)demuxer)->getTSId());

		if (ocDelay > 0) {
			((IDataProcessor*)dataProcessor)->
					createStreamTypeSectionFilter(
							STREAM_TYPE_DSMCC_TYPE_B, (IDemuxer*)demuxer);

			::usleep((int)(ocDelay * 1000));
		}

#if HAVE_COMPSUPPORT
		mavFilter = ((filterCreator*)(cm->getObject("PipeFilter")))(0);

#else
		mavFilter = new PipeFilter(0);
#endif

		//mavFilter->addDestination(1);

		((IDemuxer*)demuxer)->addPesFilter(PFT_DEFAULTTS, mavFilter);

		// Create Main AV
		cout << "lssm-ccm::sp creating av player" << endl;

#if HAVE_COMPSUPPORT
		mv = ((PlayerCreator*)(cm->getObject("AVPlayer")))(
				mrlv.c_str(), true);

		//ma = ((PlayerCreator*)(cm->getObject("AVPlayer")))(
		//		mrla.c_str(), false);

#else
		mv = new AVPlayer(mrlv.c_str(), true);
		//ma = new AVPlayer(mrla.c_str(), true);
#endif

		//ma->setOutWindow(NULL);
		mv->setOutWindow(wmv);

		cout << "lssm-ccp::sp create av ok" << endl;

		vPid = ((IDemuxer*)demuxer)->getDefaultMainVideoPid();
		aPid = ((IDemuxer*)demuxer)->getDefaultMainAudioPid();

		((IDemuxer*)demuxer)->waitBuffers();
		while (smv == NULL) {
			smv = mv->getSurface();
			::usleep(100000);
		}

		ni = ((ITuner*)tuner)->getCurrentInterface();
		if (ni != NULL && ni->getCaps() & DPC_CAN_DECODESTC) {
			cout << "lssm-ccp::sp using stc hardware!" << endl;
			((IDataProcessor*)dataProcessor)->setSTCProvider(ni);

		} else {
			cout << "lssm-ccp::sp using stc wrapper!" << endl;
			sw = new StcWrapper(mv);
			((IDataProcessor*)dataProcessor)->setSTCProvider(sw);
		}

		nptProvider = ((IDataProcessor*)dataProcessor)->getNPTProvider();
		if (nptProvider != NULL) {
			pem->setTimeBaseProvider((ITimeBaseProvider*)nptProvider);
		}

		/*((IDataProcessor*)dataProcessor)->
				createStreamTypeSectionFilter(
						STREAM_TYPE_DSMCC_TYPE_C, (IDemuxer*)demuxer);*/

		((IDataProcessor*)dataProcessor)->
				createStreamTypeSectionFilter(
						STREAM_TYPE_DSMCC_TYPE_D, (IDemuxer*)demuxer);

		/*((IDataProcessor*)dataProcessor)->
				createPidSectionFilter(
						SDT_PID, (IDemuxer*)demuxer); //SDT

		((IDataProcessor*)dataProcessor)->
				createPidSectionFilter(
						EIT_PID, (IDemuxer*)demuxer); //EIT

		((IDataProcessor*)dataProcessor)->
				createPidSectionFilter(
						CDT_PID, (IDemuxer*)demuxer); //CDT*/

		wmv->show();

		if (tuningWindow != NULL) {
			((IWindow*)tuningWindow)->clearContent();
			((IWindow*)tuningWindow)->hide();
			delete ((IWindow*)tuningWindow);
			tuningWindow = NULL;
		}

		pthread_mutex_t mutex;
		pthread_cond_t condition;

		cout << "lssm ccm::sp cond_wait" << endl;
		pthread_mutex_init(&mutex, NULL);
		pthread_cond_init(&condition, NULL);

		pthread_mutex_lock(&mutex);
		pthread_cond_wait(&condition, &mutex);
		pthread_mutex_unlock(&mutex);

		pthread_mutex_destroy(&mutex);
		pthread_cond_destroy(&condition);

		cout << "lssm ccm::sp all done!" << endl;
#endif //TUNER...
		
		// Activate PEM Connector
		//pem->startConnector();

	}