bool BaseMediaDocument::Process() { double startTime = 0; double endTime = 0; GETCLOCKS(startTime); //1. Compute the names _mediaFilePath = (string) _metadata[META_SERVER_FULL_PATH]; _metaFilePath = _mediaFilePath + "."MEDIA_TYPE_META; _seekFilePath = _mediaFilePath + "."MEDIA_TYPE_SEEK; _keyframeSeek = (bool)_metadata[CONF_APPLICATION_KEYFRAMESEEK]; _seekGranularity = (uint32_t) _metadata[CONF_APPLICATION_SEEKGRANULARITY]; //1. Open the media file #ifdef HAS_MMAP if (!_mediaFile.Initialize(_mediaFilePath, 4 * 1024 * 1024, true)) { FATAL("Unable to open media file: %s", STR(_mediaFilePath)); return false; } #else if (!_mediaFile.Initialize(_mediaFilePath)) { FATAL("Unable to open media file: %s", STR(_mediaFilePath)); return false; } #endif //4. Read the document if (!ParseDocument()) { FATAL("Unable to parse document"); return false; } //5. Build the frames if (!BuildFrames()) { FATAL("Unable to build frames"); return false; } //6. Save the seek file if (!SaveSeekFile()) { FATAL("Unable to save seeking file"); return false; } //7. Build the meta if (!SaveMetaFile()) { FATAL("Unable to save meta file"); return false; } GETCLOCKS(endTime); INFO("%"PRIz"u frames computed in %.2f seconds at a speed of %.2f FPS", _frames.size(), (endTime - startTime) / (double) CLOCKS_PER_SECOND, (double) _frames.size() / ((endTime - startTime) / (double) CLOCKS_PER_SECOND)); if (_frames.size() != 0) { uint32_t totalSeconds = (uint32_t) (((uint32_t) _frames[_frames.size() - 1].absoluteTime) / 1000); uint32_t hours = totalSeconds / 3600; uint32_t minutes = (totalSeconds - hours * 3600) / 60; uint32_t seconds = (totalSeconds - hours * 3600 - minutes * 60); INFO("File size: %"PRIu64" bytes; Duration: %u:%u:%u (%u sec); Optimal bandwidth: %.2f kb/s", _mediaFile.Size(), hours, minutes, seconds, totalSeconds, (double) _streamCapabilities.bandwidthHint); } moveFile(_seekFilePath + ".tmp", _seekFilePath); moveFile(_metaFilePath + ".tmp", _metaFilePath); chmod(STR(_seekFilePath), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); chmod(STR(_metaFilePath), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); return true; }
STDMETHODIMP CSVGSwatchesDlg::Drop(IDataObject * pDataObject, DWORD grfKeyState, POINTL pt, DWORD * pdwEffect) { ASSERT(0); #if 0 POINT point; point.x = pt.x; point.y = pt.y; ScreenToClient(&point); COleDataObjectWrapper dataObject; dataObject.Attach(pDataObject); HGLOBAL hData; if (m_viewGroup) { CComPtr<IEXMLDocument> eXMLDocument; m_viewGroup->get_eXMLDocument(&eXMLDocument); #if 0 if (hData = dataObject.GetGlobalData(CF_HDROP)) { DROPFILES* dp = (DROPFILES*)GlobalLock(hData); if (dp) { char* p = (char*)(dp+1); int i = 0; TCHAR filename[512]; while (*p) { filename[i++] = *p++; } filename[i] = 0; CHTMDesignFrame* pFrame = NULL; m_pFrameSet->OnButtonDown(0, point, 0, FALSE, &pFrame); if (pFrame) { pFrame->m_pElement->setAttribute(L"src", _bstr_t(filename)); //m_pDocument->CreateHTMLTree(); //m_pDocument->UpdateAllViews(NULL); } } GlobalUnlock(hData); { BuildFrames(); OnSize(); InvalidateRect(NULL, TRUE); } *pdwEffect = DROPEFFECT_COPY; } else #endif if (hData = dataObject.GetGlobalData(CF_UNICODETEXT)) { WCHAR* text = (WCHAR*)GlobalLock(hData); int len = GlobalSize(hData); CComPtr<ILSVGDocument> svgdocument; svgdocument.CoCreateInstance(CLSID_LSVGDocument); VARIANT_BOOL bsuccess; svgdocument->loadXML(_bstr_t(text), &bsuccess); if (bsuccess) { CComQIPtr<IEDocument> eDocument = eXMLDocument; IUndoManager* undoManager; eDocument->get_undoManager(&undoManager); CComObject<CUndoParent>* pParentUndo; CComObject<CUndoParent>::CreateInstance(&pParentUndo); if (pParentUndo) { pParentUndo->AddRef(); // ??? undoManager->Open(pParentUndo); CComPtr<ILSVGElement> svgDefsElement; eXMLDocument->FindOrCreateSVGDefs(&svgDefsElement); if (svgDefsElement) { CComPtr<ILDOMElement> documentElement; svgdocument->get_documentElement(&documentElement); CComPtr<ILDOMNode> node; documentElement->get_firstChild(&node); while (node) { CComPtr<ILDOMNode> nextSibling; node->get_nextSibling(&nextSibling); CComQIPtr<ILSVGGradientElement> svgGradientElement = node; if (svgGradientElement) { m_listView.m_xmlDocument->adoptNode(svgGradientElement, NULL); CComObject<CWEUndoNewElement>* pUndo; CComObject<CWEUndoNewElement>::CreateInstance(&pUndo); if (pUndo) { // pUndo->AddRef(); pUndo->m_pDocument = static_cast<CEXMLDocument*>(eXMLDocument.p); pUndo->DoInitial(undoManager, svgGradientElement, svgDefsElement, NULL); } } node = nextSibling; } } undoManager->Close(pParentUndo, TRUE/*commit*/); } } GlobalUnlock(hData); //return TRUE; } } #endif return S_OK; }
bool BaseMediaDocument::Process() { double startTime = 0; double endTime = 0; GETCLOCKS(startTime, double); //1. Compute the names _mediaFilePath = _metadata.mediaFullPath(); _metaFilePath = _metadata.metaFileFullPath(); _seekFilePath = _metadata.seekFileFullPath(); _keyframeSeek = _metadata.storage().keyframeSeek(); _seekGranularity = _metadata.storage().seekGranularity(); //1. Open the media file if (!GetFile(_mediaFilePath, 4 * 1024 * 1024, _mediaFile)) { FATAL("Unable to open media file: %s", STR(_mediaFilePath)); return false; } //4. Read the document if (!ParseDocument()) { FATAL("Unable to parse document"); return false; } //5. Build the frames if (!BuildFrames()) { FATAL("Unable to build frames"); return false; } //6. Save the seek file if (!SaveSeekFile()) { FATAL("Unable to save seeking file"); return false; } //7. Build the meta if (!SaveMetaFile()) { FATAL("Unable to save meta file"); return false; } GETCLOCKS(endTime, double); uint64_t framesCount = _audioSamplesCount + _videoSamplesCount; if (framesCount == 0) framesCount = (uint64_t) _frames.size(); INFO("%"PRIu64" frames computed in %.2f seconds at a speed of %.2f FPS", framesCount, (endTime - startTime) / (double) CLOCKS_PER_SECOND, (double) framesCount / ((endTime - startTime) / (double) CLOCKS_PER_SECOND)); if (_frames.size() != 0) { uint32_t totalSeconds = (uint32_t) (((uint32_t) _frames[_frames.size() - 1].dts) / 1000); uint32_t hours = totalSeconds / 3600; uint32_t minutes = (totalSeconds - hours * 3600) / 60; uint32_t seconds = (totalSeconds - hours * 3600 - minutes * 60); INFO("File size: %"PRIu64" bytes; Duration: %u:%u:%u (%u sec); Optimal bandwidth: %.2f kB/s", _mediaFile.Size(), hours, minutes, seconds, totalSeconds, (double) _streamCapabilities.GetTransferRate() / 8192); } moveFile(_seekFilePath + ".tmp", _seekFilePath); moveFile(_metaFilePath + ".tmp", _metaFilePath); chmod(STR(_seekFilePath), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); chmod(STR(_metaFilePath), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); return true; }