nsresult MP4Reader::GetBuffered(dom::TimeRanges* aBuffered) { MonitorAutoLock mon(mDemuxerMonitor); if (!mIndexReady) { return NS_OK; } UpdateIndex(); MOZ_ASSERT(mStartTime != -1, "Need to finish metadata decode first"); AutoPinned<MediaResource> resource(mDecoder->GetResource()); nsTArray<MediaByteRange> ranges; nsresult rv = resource->GetCachedRanges(ranges); if (NS_SUCCEEDED(rv)) { nsTArray<Interval<Microseconds>> timeRanges; mDemuxer->ConvertByteRangesToTime(ranges, &timeRanges); for (size_t i = 0; i < timeRanges.Length(); i++) { aBuffered->Add((timeRanges[i].start - mStartTime) / 1000000.0, (timeRanges[i].end - mStartTime) / 1000000.0); } } return NS_OK; }
void CPageBoatyard::EndOneTask() { is_producing_ = false; SetWorkFlag(false); entry_tasks_.erase(entry_tasks_.begin()); m_ProgressList.DeleteItem(0); UpdateIndex(); UpdateItemText(); int sel = int(m_ProgressList.GetFirstSelectedItemPosition()) - 1; GetDlgItem(IDC_BTN_CANCEL)->EnableWindow(sel >= 0 && sel < entry_tasks_.size()); if(entry_tasks_.empty() && (!GetCommander()->IsSilentMode())) TipWarpper::Instance().ShowTip("飞船生产任务全部完成"); }
void CStreamProperties::UpdateStreams(stream_vector &newStreams) { // sort the new streams std::sort(newStreams.begin(), newStreams.end()); // ensure we never have more than PVR_STREAMS_MAX_STREAMS streams if (newStreams.size() > PVR_STREAM_MAX_STREAMS) { while (newStreams.size() > PVR_STREAM_MAX_STREAMS) newStreams.pop_back(); KodiAPI::Log(ADDON_LOG_ERROR, "%s - max amount of streams reached", __FUNCTION__); } stream_vector::iterator newStreamPosition; for (stream_vector::iterator it = m_streamVector->begin(); it != m_streamVector->end(); ++it) { newStreamPosition = std::find(newStreams.begin(), newStreams.end(), *it); // if the current stream no longer exists we clear it, otherwise we // copy it and remove it from newStreams if (newStreamPosition == newStreams.end()) it->Clear(); else { *it = *newStreamPosition; newStreams.erase(newStreamPosition); } } // replace cleared streams with new streams for (stream_vector::iterator it = m_streamVector->begin(); it != m_streamVector->end() && !newStreams.empty(); ++it) { if (it->IsCleared()) { *it = newStreams.front(); newStreams.erase(newStreams.begin()); } } // append any remaining new streams m_streamVector->insert(m_streamVector->end(), newStreams.begin(), newStreams.end()); // remove trailing cleared streams while (m_streamVector->back().IsCleared()) m_streamVector->pop_back(); // update the index UpdateIndex(); }
void CPageBoatyard::OnBtnProduce() { UpdateData(TRUE); if(m_ships_produce_number <= 0) return; if(m_ships_produce_number > MAX_PRODUCED_BOAT) { m_ships_produce_number = MAX_PRODUCED_BOAT; UpdateData(FALSE); } //max 256 tasks if(entry_tasks_.size() > 256) return; int sel = m_list.GetSelectedItem(); assert(sel >= BOAT_START && sel < BOAT_MAX); UINT s = GetMaxProduceNumber(sel , m_ships_produce_number); assert(s > 0); Produce_Tast_t task; task.index = sel; task.number = s; entry_tasks_.push_back(task); //resource reduce GetDataPtr()->DecreaseResource(Boats_Entry(sel)->GetProduceMinal() * s , Boats_Entry(sel)->GetProduceCrystal() * s , Boats_Entry(sel)->GetProduceDiplogen() * s); GetCommander()->Notify_Resource_Changed(); CString info; int index = m_ProgressList.GetItemCount(); info.Format("%02d" , index); m_ProgressList.InsertItem(index , info); m_ProgressList.SetItemText(index , 1 , Boats_Entry(sel)->GetName()); info.Format("%d" , s); m_ProgressList.SetItemText(index , 2 , info); m_ProgressList.SetItemText(index , 3 , "0.000%"); UpdateIndex(); if(entry_tasks_.size() == 1) { StartOneTask(); } m_ships_produce_number = 1; UpdateData(FALSE); }
FGroupedKeyArea::FGroupedKeyArea(FSequencerDisplayNode& InNode, int32 InSectionIndex) : Section(nullptr) { // Calling this virtual function is safe here, as it's just called through standard name-lookup, not runtime dispatch FGroupedKeyCollection::InitializeRecursive(InNode, InSectionIndex); for (const TSharedPtr<IKeyArea>& KeyArea : KeyAreas) { auto* OwningSection = KeyArea->GetOwningSection(); // Ensure they all belong to the same section ensure(!Section || Section == OwningSection); Section = OwningSection; } if (Section) { IndexKey = FIndexKey(InNode.GetPathName(), Section); UpdateIndex(); } }
bool Help::Update(void) { GameInput &input = GameInput::GetInstance(); float x = input.GetXf(); float y = input.GetYf(); int nextPage = -1; if(m_Exist) { switch(m_State) { case INDEX: nextPage = UpdateIndex(); if(nextPage >= 0) { m_OldPage = -1; //前ページ保存 m_Page = nextPage; //次ページ格納 m_State = REFERENCE;//ステート切替 m_PageAlpha = 0; //α初期化 } break; case REFERENCE: m_State = UpdateReference(); break; } //閉じるボタン処理 if(Close()) { m_Exist = false; m_OffFrame = true; } } //ボタンの拡縮 if(x >= 0.9425f && y <= 0.07f) m_Help_Button_Scale += (1.3f - m_Help_Button_Scale) * 0.3f; else m_Help_Button_Scale += (1.0f - m_Help_Button_Scale) * 0.3f; return m_Exist; }
static void WritePageInfo(PLStream *pls, FPOS_T pp_offset) { PLmDev *dev = (PLmDev *) pls->dev; FILE *file = pls->OutFile; int isfile = (pls->output_type == 0); U_CHAR c; FPOS_T cp_offset=0; /* Update table of contents. */ if (isfile) { if (pl_fgetpos(file, &cp_offset)) plexit("WritePageInfo (plmeta.c): fgetpos call failed"); UpdateIndex(pls, cp_offset); } /* Write new page header */ if (dev->notfirst) c = BOP; else { c = BOP0; dev->notfirst = 1; } plm_wr( pdf_wr_1byte(pls->pdfs, c) ); plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->page) ); plm_wr( pdf_wr_4bytes(pls->pdfs, (U_LONG) pp_offset) ); plm_wr( pdf_wr_4bytes(pls->pdfs, (U_LONG) 0) ); /* Update last page offset with current page value */ dev->lp_offset = cp_offset; /* Write some page state information just to make things nice later on */ /* Eventually there will be more */ plD_state_plm(pls, PLSTATE_COLOR0); }
void CPageBoatyard::OnBtnCancel() { CString info; int sel = int(m_ProgressList.GetFirstSelectedItemPosition()) - 1; if(!(sel >= 0 && sel < entry_tasks_.size())) return; //sel == 0 if(sel == 0) { if(is_producing_) { info.Format("正在生产:%s,你确定要取消生产吗?" , Boats_Entry(cur_produce_index)->GetName()); if(MessageBox(info , "警告" , MB_YESNO | MB_ICONWARNING) == IDYES) { KillTimer(TIMER_PRODUCE_BOAT); CancelCurrentProducing(); entry_tasks_.erase(entry_tasks_.begin()); m_ProgressList.DeleteItem(0); UpdateIndex(); GetDlgItem(IDC_STA_RESEARCH_TIMER)->SetWindowText(""); if(entry_tasks_.size() > 0) { StartOneTask(); } sel = int(m_ProgressList.GetFirstSelectedItemPosition()) - 1; GetDlgItem(IDC_BTN_CANCEL)->EnableWindow(sel >= 0 && sel < entry_tasks_.size()); return; } else { sel = int(m_ProgressList.GetFirstSelectedItemPosition()) - 1; GetDlgItem(IDC_BTN_CANCEL)->EnableWindow(sel >= 0 && sel < entry_tasks_.size()); return; } } CancelProducingByIndex(0); entry_tasks_.erase(entry_tasks_.begin()); m_ProgressList.DeleteItem(0); UpdateIndex(); if(entry_tasks_.size() > 0) { StartOneTask(); } } //sel != 0 else { CancelProducingByIndex(sel); vector<Produce_Tast_t>::iterator itor = entry_tasks_.begin(); for(int i = 0 ; i < entry_tasks_.size() ; ++i , ++itor) { if(i == sel) break; } entry_tasks_.erase(itor); m_ProgressList.DeleteItem(sel); UpdateIndex(); } sel = int(m_ProgressList.GetFirstSelectedItemPosition()) - 1; GetDlgItem(IDC_BTN_CANCEL)->EnableWindow(sel >= 0 && sel < entry_tasks_.size()); }
nsresult MP4Reader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) { if (!mDemuxerInitialized) { MonitorAutoLock mon(mDemuxerMonitor); bool ok = InvokeAndRetry(this, &MP4Reader::InitDemuxer, mStream, &mDemuxerMonitor); NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE); mIndexReady = true; // To decode, we need valid video and a place to put it. mInfo.mVideo.mHasVideo = mVideo.mActive = mDemuxer->HasValidVideo() && mDecoder->GetImageContainer(); if (mVideo.mActive) { mVideo.mTrackDemuxer = new MP4VideoDemuxer(mDemuxer); } mInfo.mAudio.mHasAudio = mAudio.mActive = mDemuxer->HasValidAudio(); if (mAudio.mActive) { mAudio.mTrackDemuxer = new MP4AudioDemuxer(mDemuxer); } mCrypto = mDemuxer->Crypto(); { MonitorAutoUnlock unlock(mDemuxerMonitor); ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); mInfo.mCrypto.mIsEncrypted = mIsEncrypted = mCrypto.valid; } // Remember that we've initialized the demuxer, so that if we're decoding // an encrypted stream and we need to wait for a CDM to be set, we don't // need to reinit the demuxer. mDemuxerInitialized = true; } else if (mPlatform && !IsWaitingMediaResources()) { *aInfo = mInfo; *aTags = nullptr; return NS_OK; } if (HasAudio()) { const AudioDecoderConfig& audio = mDemuxer->AudioConfig(); mInfo.mAudio.mRate = audio.samples_per_second; mInfo.mAudio.mChannels = audio.channel_count; mAudio.mCallback = new DecoderCallback(this, kAudio); } if (HasVideo()) { const VideoDecoderConfig& video = mDemuxer->VideoConfig(); mInfo.mVideo.mDisplay = nsIntSize(video.display_width, video.display_height); mVideo.mCallback = new DecoderCallback(this, kVideo); // Collect telemetry from h264 AVCC SPS. if (!mFoundSPSForTelemetry) { mFoundSPSForTelemetry = AccumulateSPSTelemetry(video.extra_data); } } if (mIsEncrypted) { nsTArray<uint8_t> initData; ExtractCryptoInitData(initData); if (initData.Length() == 0) { return NS_ERROR_FAILURE; } mInfo.mCrypto.mInitData = initData; mInfo.mCrypto.mType = NS_LITERAL_STRING("cenc"); } // Get the duration, and report it to the decoder if we have it. Microseconds duration; { MonitorAutoLock lock(mDemuxerMonitor); duration = mDemuxer->Duration(); } if (duration != -1) { ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); mDecoder->SetMediaDuration(duration); } *aInfo = mInfo; *aTags = nullptr; if (!IsWaitingMediaResources() && !IsWaitingOnCDMResource()) { NS_ENSURE_TRUE(EnsureDecodersSetup(), NS_ERROR_FAILURE); } MonitorAutoLock mon(mDemuxerMonitor); UpdateIndex(); return NS_OK; }
int main (int argc, char **argv) { /* Check Arguments */ if (!CheckArguments(argc, argv)) { exit(-1); } /* Make variables for all things needed for indexer and indexer testing */ char *page_directory; char *index_filename; char *read_index_filename; char *new_index_filename; // If argument count is 3 initialize only 2 variables else initialize all page_directory = argv[1]; index_filename = argv[2]; // Initialize hashtable, word node, and document node HashTable *index_hashtable = calloc(1, sizeof(HashTable)); /*Make array to hold filenames (just document numbers) and use GetFilenamesInDir to grab all names */ char **filename_array; int number_of_files; if ((number_of_files = GetFilenamesInDir(page_directory, &filename_array)) < 0) { fprintf(stderr, "Could not get filenames in page directory. Exiting Now.\n"); exit(-1); } /* Add page_directory to the front of the filenames */ for (int i = 0; i < number_of_files; i++) { // Make pointe to current string in filename_array char *previous_string = filename_array[i]; // Get length of full string and initialize element of filename_array to that size int len = strlen(page_directory) + strlen(previous_string) + 1; char *new_string = calloc(len, sizeof(char)); // Make new string and free previous string strcpy(new_string, page_directory); strcat(new_string, previous_string); if (previous_string) free(previous_string); filename_array[i] = new_string; } /* Populate the index data structure from the words on each doc * Then Save to an index file */ for (int i = 0; i < number_of_files; i++) { /* Check that the filenames are digits */ int continue_flag = 0; char *digit_string = filename_array[i] + strlen(page_directory); // Check that every character in the filename is a digit for (int j = 0; j < strlen(digit_string); j++) { if (!isdigit(digit_string[j])) { fprintf(stderr, "This file %s contains something other than a digit \n", filename_array[i]); continue_flag = 1; } } if (continue_flag ==1) continue; // Check that each file in the filename array is a good file char *file_name = filename_array[i]; if (!IsFile(file_name)) { fprintf(stderr, "not file\n"); continue; } // Get contents of file into a string char *document = LoadDocument(file_name); if (document == NULL) { continue; } // Get DocumentID of file (check if bad) int document_id = GetDocumentId(file_name, page_directory); if (document_id < 0) { fprintf(stderr, "Error when converting document id char to integer\n"); continue; } // Use GetNext word, with pos variable and buffer, to get every word and add the word to the data structure int pos = 0; char *word_buffer; while ((pos = GetNextWord(document, pos, &word_buffer)) > 0) { // Update the index for each word // Normalize word then update index with that word NormalizeWord(word_buffer); UpdateIndex(word_buffer, document_id, index_hashtable); free(word_buffer); } // free the string containing the html and the word in filenamearray free(document); } /* Save to index file, and check that it actually went well */ if (!SaveIndexToFile(index_hashtable, index_filename)) { fprintf(stderr, "Could not save index hashtable to file\n"); exit(-1); } for (int i = 0; i < number_of_files; i++) { free(filename_array[i]); } free(filename_array); FreeHashTable(index_hashtable); if (argc == 3) { ; } /* Read index file into data strucutres and save to new index file */ else { // Assign 2 filenames read_index_filename = argv[3]; new_index_filename = argv[4]; // Read index file into data structures HashTable *read_index = ReadFile(read_index_filename); if (read_index == NULL) { fprintf(stderr, "Error when reading index file into data structures.\n"); exit(-1); } // Save index data structures into new file if (!SaveIndexToFile(read_index, new_index_filename)) { fprintf(stderr, "Could not save read index file into new index file\n"); exit(-1); } FreeHashTable(read_index); } return 0; }
nsresult MP4Reader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) { if (!mDemuxerInitialized) { MonitorAutoLock mon(mDemuxerMonitor); bool ok = InvokeAndRetry(this, &MP4Reader::InitDemuxer, mStream, &mDemuxerMonitor); NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE); mIndexReady = true; // To decode, we need valid video and a place to put it. mVideo.mActive = mDemuxer->HasValidVideo() && mDecoder->GetImageContainer(); if (mVideo.mActive) { mVideo.mTrackDemuxer = new MP4VideoDemuxer(mDemuxer); } mAudio.mActive = mDemuxer->HasValidAudio(); if (mAudio.mActive) { mAudio.mTrackDemuxer = new MP4AudioDemuxer(mDemuxer); } mCrypto = mDemuxer->Crypto(); { MonitorAutoUnlock unlock(mDemuxerMonitor); ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); mIsEncrypted = mCrypto.valid; } // Remember that we've initialized the demuxer, so that if we're decoding // an encrypted stream and we need to wait for a CDM to be set, we don't // need to reinit the demuxer. mDemuxerInitialized = true; } else if (mPlatform && !IsWaitingMediaResources()) { *aInfo = mInfo; *aTags = nullptr; } if (HasAudio()) { mInfo.mAudio = mDemuxer->AudioConfig(); mAudio.mCallback = new DecoderCallback(this, TrackInfo::kAudioTrack); } if (HasVideo()) { mInfo.mVideo = mDemuxer->VideoConfig(); mVideo.mCallback = new DecoderCallback(this, TrackInfo::kVideoTrack); // Collect telemetry from h264 AVCC SPS. if (!mFoundSPSForTelemetry) { mFoundSPSForTelemetry = AccumulateSPSTelemetry(mInfo.mVideo.mExtraData); } } if (mCrypto.valid) { nsTArray<uint8_t> initData; ExtractCryptoInitData(initData); if (initData.Length() == 0) { return NS_ERROR_FAILURE; } // Add init data to info, will get sent from HTMLMediaElement::MetadataLoaded // (i.e., when transitioning from HAVE_NOTHING to HAVE_METADATA). mInfo.mCrypto.AddInitData(NS_LITERAL_STRING("cenc"), Move(initData)); } // Get the duration, and report it to the decoder if we have it. Microseconds duration; { MonitorAutoLock lock(mDemuxerMonitor); duration = mDemuxer->Duration(); } if (duration != -1) { ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); mDecoder->SetMediaDuration(duration); } *aInfo = mInfo; *aTags = nullptr; if (!IsWaitingOnCDMResource()) { NS_ENSURE_TRUE(EnsureDecodersSetup(), NS_ERROR_FAILURE); } MonitorAutoLock mon(mDemuxerMonitor); UpdateIndex(); return NS_OK; }
void UserMarkGenerator::SetGroup(kml::MarkGroupId groupId, drape_ptr<IDCollections> && ids) { m_groups[groupId] = std::move(ids); UpdateIndex(groupId); }