Ejemplo n.º 1
0
BOOL DMOSetMediaType(ASF_FILE_INFO* pInfo)
{
	if (!SetInputMediaType(pInfo))
		return FALSE;

	if (!SetOutputMediaType(pInfo))
		return FALSE;

	if (FAILED(pInfo->pMediaObject->AllocateStreamingResources()))
		return FALSE;

	pInfo->bDiscontinuity = FALSE;
	return TRUE;
}
Ejemplo n.º 2
0
void EncodeTransform::Init(int width, int height)
{
	VTUNE_TASK(g_pDomain, "Encoder Init");

	mStreamHeight = height;
	mStreamWidth = width;
	mCompressedBuffer = new DWORD[(width*height) / 2];

	HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
	if (SUCCEEDED(hr) || (FAILED(hr) && hr == RPC_E_CHANGED_MODE))
	{
		hr = FindEncoder(MFVideoFormat_H264);
		if (FAILED(hr))
		{
			std::cout << "failed to find/Create specified encoder mft" << std::endl;
		}

		// set the media output info
		hr = SetOutputMediaType();
		if (FAILED(hr))
		{
			std::cout << "failed to SetOutputMediaType " << std::endl;
		}

		// set the media input info
		hr = SetInputMediaType();
		if (FAILED(hr))
		{
			std::cout << "failed to SetInputMediaType" << std::endl;
		}

		// query media input stream info
		hr = QueryInputStreamInfo();
		if (FAILED(hr))
		{
			std::cout << "failed to QueryInputStreamInfo" << std::endl;
		}

		{  //used to be NUM_PIXELS_YUY2 * 4
			HRESULT hr = MFCreateMemoryBuffer((mStreamWidth*mStreamHeight) * 2, &mpInputBuffer);
			if (FAILED(hr))
			{
				std::cout << "Failed to MFCreateMemoryBuffer" << std::endl;
			}

			hr = MFCreateSample(&pSampleProcIn);
			if (FAILED(hr))
			{
				std::cout << "Failed to MFCreateSample" << std::endl;
			}
			hr = pSampleProcIn->AddBuffer(mpInputBuffer);
			if (FAILED(hr))
			{
				std::cout << "Failed to AddBuffer to sample" << std::endl;
			}
		}

		{   //used to be NUM_PIXELS_YUY2 * 4
			hr = MFCreateMemoryBuffer(mStreamWidth * mStreamWidth * 2, &mpEncodedBuffer);
			if (FAILED(hr))
			{
				std::cout << "Failed to MFCreateMemoryBuffer" << std::endl;
			}

			hr = MFCreateSample(&pSampleProcOut);
			if (FAILED(hr))
			{
				std::cout << "Failed to MFCreateSample" << std::endl;
			}

			hr = pSampleProcOut->AddBuffer(mpEncodedBuffer);
			if (FAILED(hr))
			{
				std::cout << "Failed to AddBuffer to sample" << std::endl;
			}
		}
	}
}
Ejemplo n.º 3
0
void init(int argc, char **argv)
{
FILE *fp;
int daemon = FALSE;
int i, ntoken, status, problems;
BOOL debug;
THREAD tid;
char pwd[MAXPATHLEN+1], RunFile[MAXPATHLEN+1];
char *token[MAXTOKEN];
char *myname, *sta, *log, *user, *prefix, *dbspec = NULL;
struct stat statbuf;
struct isp_dascnf dascnf;
LOGIO *lp = NULL;
static char *fid = "init";

    memset(DasCnf, 0, sizeof(struct isp_dascnf));
    MUTEX_INIT(&DasCnf->mutex);

/* Get my name without path prefix (if any) */

    if ((myname = strdup(argv[0])) == NULL) {
        perror(argv[0]);
        exit(1);
    }

    ntoken = util_sparse(myname, token, "./", MAXTOKEN);
    myname = token[ntoken-1];

/* Parse command line for required input and selected overrides */

    sta   = (char *) NULL;
    user  = ISPD_DEF_USER;
    log   = NULL;
    debug = ISPD_DEF_DEBUG;

    for (i = 1; i < argc; i++) {
        if (strncasecmp(argv[i], "sta=", strlen("sta=")) == 0) {
            sta = argv[i] + strlen("sta=");
        } else if (strncasecmp(argv[i], "log=", strlen("log=")) == 0) {
            log = argv[i] + strlen("log=");
        } else if (strncasecmp(argv[i], "db=", strlen("db=")) == 0) {
            dbspec = argv[i] + strlen("db=");
        } else if (strncasecmp(argv[i], "user="******"user="******"user="******"-debug") == 0) {
            debug = TRUE;
        } else if (strcasecmp(argv[i], "-bd") == 0) {
            daemon = TRUE;
        } else if (sta == (char *) NULL) {
            sta = argv[i];
        } else {
            help(myname);
        }
    }

    if (sta == NULL) {
        fprintf(stderr, "%s: system name must be specified\n", myname);
        help(myname);
    }

    if (log == NULL) log = daemon ? DEFAULT_BACKGROUND_LOG : DEFAULT_FOREGROUND_LOG;

    if (!isidlSetGlobalParameters(dbspec, argv[0], &Params->glob)) {
        fprintf(stderr, "%s: isidlSetGlobalParameters: %s\n", argv[0], strerror(errno));
        exit(1);
    }

    sprintf(pwd, "%s/%s/%s", Params->glob.root, sta, ISP_SUBDIR);
    if (chdir(pwd) != 0) {
        fprintf(stderr, "%s: chdir: ", myname);
        perror(pwd);
        exit (1);
    }

    Home    = strdup(Params->glob.root);
    Syscode = strdup(sta);
    prefix  = strdup(sta);

    if (Home == (char *) NULL || Syscode == (char *) NULL || prefix == NULL) {
        perror(myname);
        exit(1);
    }
    Syscode = util_lcase(Syscode);

/* Make sure we can find the various set up files now */

    problems = 0;

    if ((fp = fopen(ISP_RUN_FILE, "r")) == (FILE *) NULL) {
        fprintf(stderr, "%s: fopen: %s/", myname, pwd);
        perror(ISP_RUN_FILE);
        ++problems;
    } else {
        fclose(fp);
    }

    if (problems) exit(1);

/* Load run parameters */

    sprintf(RunFile, "%s/%s", pwd, ISP_RUN_FILE);
    if (!ispLoadRunParam(RunFile, sta, Params, Server)) {
        fprintf(stderr, "%s: problems with parameter file\n", myname);
        exit(1);
    }

/* By insuring that we can stat the output device now, we will later
 * be able to treat open failures as no-media-installed conditions.
 */

    SetOutputMediaType();
    if (OutputMediaType() == ISP_OUTPUT_TAPE && stat(Params->odev, &statbuf) != 0) {
        fprintf(stderr, "%s: can't stat: ", myname);
        perror(Params->odev);
        exit(1);
    }


/* Check for digitizer specific support files */

    if (Params->digitizer == ISP_DAS) {
        if (isp_getcnf(&dascnf) != 0) {
            fprintf(stderr, "%s: fopen: %s/", myname, pwd);
            perror(ISP_CNF_FILE);
            fprintf(stderr, "can't load DAS configuration... set default\n");
            dascnf.flag = ISP_DASCNF_DEF;
            if (isp_setcnf(&dascnf) != 0 || isp_getcnf(&dascnf) != 0) {
                perror("can't load default DAS configuration either!\n");
                ++problems;
            }
        }
    }

    if (problems) exit(1);

/* Set user and group identity */

    utilSetIdentity(user);

/* Go into the background */

    if (daemon && !utilBackGround()) {
        perror("utilBackGround");
        exit(1);
    }

/* Start logging facility */

    util_ucase(prefix);
    if ((lp = InitLogging(myname, log, prefix, debug)) == NULL) {
        perror("InitLogging");
        exit(1);
    }
    ispSetLogParameter(Params, lp);

    LogMsg(LOG_DEBUG, "uid=%d, euid=%d, gid=%d, egid=%d", getuid(), geteuid(), getgid(), getegid());

    if (Params->rt593.present) {
        LogMsg(LOG_INFO, "Configured for RT593 with %d tic delay", Params->rt593.correct);
    }

/* Initialize the message queues and massio buffers */

    InitMsgqs();

/* Initialize the status structure */

    status_init();

/* Start signal handling thread */

    signals_init();

/* Initialize the output device */

    InitMediaOps();

/* Start the ISI thread */

    InitIsi(lp);
    sleep(1);

/* Start the digitizer specific I/O thread */

    if (Params->digitizer == ISP_DAS) {
        InitDasIO();
    } else {
        InitSanIO();
    }
    sleep(1);

/* Start the DAS packet processor thread */

    InitProcess();
    sleep(1);

/* Start the massio buffering thread */

    InitMassio();
    sleep(1);

/* Start the DAS status request thread */

    InitSoh();
    sleep(1);

/* Start the digitizer configuration verification process */

    if (Params->digitizer == ISP_DAS) {
        VerifyDasConfig(0);
    } else {
        VerifySanConfig(0);
    }

/* Start up auxiliary threads, if any */

    if (Params->clock.enabled) {
        set_alarm(ISP_ALARM_AUXCLK);
        InitClock();
    }

    if (Params->baro.enabled) {
        set_alarm(ISP_ALARM_AUX);
        InitBaro();
    }

    if (Params->dpm.enabled) {
        set_alarm(ISP_ALARM_AUX);
        InitDPM();
    }

/* Start up ISP injection service */

    if (Params->inject) isp_inject();

/* Command and control server */

    server_init();

/* iboot watchdog */

    StartIbootWatchdog();

    return;
}