コード例 #1
0
void pv_metadata_engine_test::Run()
{
    int error = 0;

    switch (iState)
    {
        case STATE_CREATE:
        {
            iPVMEContainer.iCmdStatusObserver = this;
            iPVMEContainer.iInfoEventObserver = this;
            iPVMEContainer.iErrorEventObserver = this;
            iPVMEContainer.iMode = iMode;

            if (iPVMEContainer.iMode == PV_METADATA_ENGINE_THREADED_MODE)
            {
                //Configure the threadsafe queues that are used for engine
                //thread callbacks.
                iThreadSafeCommandQueue.Configure(this);
                iThreadSafeErrorQueue.Configure(this);
                iThreadSafeInfoQueue.Configure(this);

                iPVMEContainer.iSem.Create();

                iPVMEContainer.iAppenderType = iLoggerInfo.iAppenderType;
                iPVMEContainer.iLogfilename = iLoggerInfo.logfilename;
                iPVMEContainer.iLoggerConfigElements = iLoggerInfo.iLoggerConfigElements;
            }

            OSCL_TRY(error, PVMetadataEngineFactory::CreatePVMetadataEngine(iPVMEContainer));

            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                            (0, "PVMetadataEngineTest::Create Called ClockInMS=%d", OsclTickCount::TicksToMsec(OsclTickCount::TickCount())));

            if (error || iPVMEContainer.iPVMEInterface == NULL)
            {
                PVMEATB_TEST_IS_TRUE(false);
                iObserver->TestCompleted(*iTestCase);
            }
            else
            {
                iState = STATE_INIT;
                RunIfNotReady();
            }
        }
        break;


        case STATE_INIT:
        {

            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                            (0, "PVMetadataEngineTest::Init Issued ClockInMS=%d", OsclTickCount::TicksToMsec(OsclTickCount::TickCount())));

            iCurrentCmdId = iPVMEContainer.iPVMEInterface->Init((OsclAny*) & iContextObject);

        }
        break;

        case STATE_SETMETADATAKEYS:
        {
            ReadMetadataFile();
            ReadClipsFile();

            if (iClipFilePresent == false)
            {
                fprintf(file, "\nClip File Not Present \n");
                iState = STATE_RESET;
                RunIfNotReady();
            }

            else if (iMetadataKeyList.size() != 0)
            {
                PVMFStatus status;
                PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                                (0, "PVMetadataEngineTest::SetMetadataKeys Issued ClockInMS=%d", OsclTickCount::TicksToMsec(OsclTickCount::TickCount())));
                status = iPVMEContainer.iPVMEInterface->SetMetaDataKeys(iMetadataKeyList);

                if (status == PVMFErrInvalidState)
                {
                    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                                    (0, "PVMetadataEngineTest::SetMetadataKeys called in wrong state"));
                }
                else
                {
                    iState = STATE_GETMETADATA;
                    RunIfNotReady();
                }
            }

            else
            {
                iState = STATE_GETMETADATA;
                RunIfNotReady();
            }
        }
        break;

        case STATE_GETMETADATA:
        {
            //If GetMetadata is being called second time in MultipleGetMetadataTest, we don't want these statements to execute again
            if (iDataSource == NULL)
            {
                // Create a player data source and add it
                iDataSource = new PVPlayerDataSourceURL;
            }

            OSCL_wHeapString<OsclMemAllocator> inputfilename;

            // Convert the source file name to UCS2 and extract the filename part
            PVMFFormatType iFileType;
            iFileName = *it;
            it++;
            GetSourceFormatType(iFileName, iFileType);

            oscl_UTF8ToUnicode(iFileName, oscl_strlen(iFileName), iTempWCharBuf, 512);
            wFileName.set(iTempWCharBuf, oscl_strlen(iTempWCharBuf));
            RetrieveFilename(wFileName.get_str(), inputfilename);

            printf("\nInput File Name is %s", iFileName);

            iDataSource->SetDataSourceURL(wFileName);
            iDataSource->SetDataSourceFormatType(iFileType);

            start_time = OsclTickCount::TicksToMsec(OsclTickCount::TickCount());

            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                            (0, "PVMetadataEngineTest::GetMetadata Issued ClockInMS = (%d)", start_time));


            OSCL_TRY(error, iCurrentCmdId = iPVMEContainer.iPVMEInterface->GetMetadata(*iDataSource, iMetadataValueList, (OsclAny*) & iContextObject));
            OSCL_FIRST_CATCH_ANY(error, PVMEATB_TEST_IS_TRUE(false); iState = STATE_RESET; RunIfNotReady());
        }

        break;

        case STATE_RESET:
        {
            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                            (0, "PVMetadataEngineTest::Reset Issued ClockInMS=%d", OsclTickCount::TicksToMsec(OsclTickCount::TickCount())));

            iCurrentCmdId = iPVMEContainer.iPVMEInterface->Reset((OsclAny*) & iContextObject);

        }
        break;

        case STATE_DELETE:
        {

            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                            (0, "PVMetadataEngineTest::Delete Called ClockInMS=%d", OsclTickCount::TicksToMsec(OsclTickCount::TickCount())));
            PVMFStatus status = PVMetadataEngineFactory::DeletePVMetadataEngine(iPVMEContainer);
            if (status != PVMFSuccess)
            {
                PVMEATB_TEST_IS_TRUE(false);
            }
            delete iDataSource;
            iDataSource = NULL;

            iFS.Close();

            if (iPVMEContainer.iMode == PV_METADATA_ENGINE_THREADED_MODE)
            {
                iPVMEContainer.iSem.Close();
            }




            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                            (0, "PVMetadataEngineTest::TotalNumClips=%d", numOfClips));

            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                            (0, "PVMetadataEngineTest::AverageGetMetaDataTimeInMS=%d", (AverageGetMetaDataTimeInMS / numOfClips)));

            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                            (0, "PVMetadataEngineTest::MaxGetMetaDataTime=%d", MaxGetMetaDataTime));

            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                            (0, "PVMetadataEngineTest::MinGetMetaDataTime=%d", MinGetMetaDataTime));

            iObserver->TestCompleted(*iTestCase);
        }
        break;

        default:
            break;

    }
}
コード例 #2
0
//--------------------------------------------------------------------------
/// Handle what happens when a Linked Trace is requested. We can either:
/// 1. Return the trace response as normal.
/// 2. Cache the response to disk, and generate a "trace metadata" file used to retrieve the trace later.
/// \param inFullResponseString The response string built by tracing the application.
/// \param inbSaveResponseToFile A switch used to determine which response method to use.
//--------------------------------------------------------------------------
void MultithreadedTraceAnalyzerLayer::HandleLinkedTraceResponse(gtASCIIString& inFullResponseString, bool inbSaveResponseToFile)
{
    ModernAPILayerManager* parentLayerManager = GetParentLayerManager();

    if (parentLayerManager->InCapturePlayer())
    {
        const std::string& metadataFile = parentLayerManager->GetPathToTargetMetadataFile();

        if (metadataFile.length() > 0)
        {
            // Read the metadata file and store the contents in a structure.
            TraceMetadata traceMetadata;
            traceMetadata.mFrameInfo = new FrameInfo;

            bool bReadMetadataFileSuccessfully = ReadMetadataFile(metadataFile, &traceMetadata);

            if (bReadMetadataFileSuccessfully)
            {
                gtASCIIString traceContents;
                bool bReadTraceSuccessfully = LoadTraceFile(traceMetadata.mPathToTraceFile, traceContents);

                if (bReadTraceSuccessfully)
                {
                    // At this point the full trace response text should be loaded into our string and ready to be sent back to the client.
                    mCmdLinkedTrace.Send(traceContents.asCharArray());
                }
                else
                {
                    Log(logERROR, "Failed to read trace file at '%s'.", traceMetadata.mPathToTraceFile.c_str());
                }
            }
            else
            {
                Log(logERROR, "Failed to read metadata file at '%s'.", metadataFile.c_str());
            }

            // Destroy the FrameInfo instance that was created above.
            SAFE_DELETE(traceMetadata.mFrameInfo);
        }
        else
        {
            Log(logERROR, "Failed to locate valid path to trace metadata file.");
        }
    }
    else
    {
        gtASCIIString traceHeaderBlock;
        bool bBuiltHeaderSuccessfully = GenerateLinkedTraceHeader(traceHeaderBlock);

        if (bBuiltHeaderSuccessfully)
        {
            bool bKeypressTrigger = parentLayerManager->IsTraceTriggeredByKeypress();

            // Collect a trace and generate the trace metadata string. Write the trace and metadata files to disk.
            std::string metadataXMLString;
            bool bWriteMetadataSuccessful = WriteTraceAndMetadataFiles(traceHeaderBlock, inFullResponseString, metadataXMLString);

            // If the trace wasn't triggered by a keypress, we'll need to send a response back through either of the following commands.
            CommandResponse& frameCaptureWithSaveResponse = (inbSaveResponseToFile == true) ? parentLayerManager->mCmdFrameCaptureWithSave : mCmdLinkedTrace;

            if (bWriteMetadataSuccessful)
            {
                // We only need to send the response back through a request if the client triggered collection.
                if (!bKeypressTrigger)
                {
                    // Check if we want to cache the response to disk, or return it as-is.
                    if (inbSaveResponseToFile)
                    {
                        if (bWriteMetadataSuccessful)
                        {
                            // Send a response back to the client indicating which trace metadata file was written to disk.
                            frameCaptureWithSaveResponse.Send(metadataXMLString.c_str());
                        }
                        else
                        {
                            Log(logERROR, "Failed to write trace metadata XML.\n");
                            frameCaptureWithSaveResponse.Send("Failed");
                        }
                    }
                    else
                    {
                        // Send a response containing the API and GPU trace text.
                        frameCaptureWithSaveResponse.Send(inFullResponseString.asCharArray());
                    }
                }
                else
                {
                    Log(logMESSAGE, "Successfully traced frame %d.\n", parentLayerManager->GetFrameCount());
                }
            }
            else
            {
                Log(logERROR, "Failed to write trace metadata XML.\n");

                // If a failed trace collection was triggered by a command, we need to respond with an error message.
                if (!bKeypressTrigger)
                {
                    frameCaptureWithSaveResponse.Send("Failed");
                }
            }
        }
    }
}