public static extern void hb_get_state(IntPtr hbHandle, ref hb_state_s state);
public static extern void hb_get_state2(ref hb_handle_s param0, ref hb_state_s param1);
/// <summary> /// Checks the status of the ongoing scan. /// </summary> private void PollScanProgress() { var state = new hb_state_s(); HBFunctions.hb_get_state(this.hbHandle, ref state); if (state.state == NativeConstants.HB_STATE_SCANNING) { if (this.ScanProgress != null) { int currentTitle = state.param.scanning.title_cur; int totalTitles = state.param.scanning.title_count; this.ScanProgress(this, new ScanProgressEventArgs { CurrentTitle = currentTitle, Titles = totalTitles }); } } else if (state.state == NativeConstants.HB_STATE_SCANDONE) { this.titles = new List<Title>(); IntPtr listPtr = HBFunctions.hb_get_titles(this.hbHandle); this.originalTitles = InteropUtilities.ConvertList<hb_title_s>(listPtr); foreach (hb_title_s title in this.originalTitles) { var newTitle = this.ConvertTitle(title); this.titles.Add(newTitle); } if (this.originalTitles.Count > 0) { var nativeJob = InteropUtilities.ReadStructure<hb_job_s>(this.originalTitles[0].job); this.featureTitle = nativeJob.feature; } else { this.featureTitle = 0; } this.scanPollTimer.Stop(); if (this.ScanCompleted != null) { this.ScanCompleted(this, new EventArgs()); } } }
public static extern void hb_get_state2(IntPtr hbHandle, ref hb_state_s param1);
/// <summary> /// Checks the status of the ongoing encode. /// </summary> private void PollEncodeProgress() { hb_state_s state = new hb_state_s(); HBFunctions.hb_get_state(this.hbHandle, ref state); if (state.state == NativeConstants.HB_STATE_WORKING) { if (this.EncodeProgress != null) { int pass = 1; int rawJobNumber = state.param.working.job_cur; if (this.currentJob.EncodingProfile.TwoPass) { if (this.subtitleScan) { switch (rawJobNumber) { case 1: pass = -1; break; case 2: pass = 1; break; case 3: pass = 2; break; default: break; } } else { switch (rawJobNumber) { case 1: pass = 1; break; case 2: pass = 2; break; default: break; } } } else { if (this.subtitleScan) { switch (rawJobNumber) { case 1: pass = -1; break; case 2: pass = 1; break; default: break; } } else { pass = 1; } } var progressEventArgs = new EncodeProgressEventArgs { FractionComplete = state.param.working.progress, CurrentFrameRate = state.param.working.rate_cur, AverageFrameRate = state.param.working.rate_avg, EstimatedTimeLeft = new TimeSpan(state.param.working.hours, state.param.working.minutes, state.param.working.seconds), Pass = pass }; this.EncodeProgress(this, progressEventArgs); } } else if (state.state == NativeConstants.HB_STATE_WORKDONE) { InteropUtilities.FreeMemory(this.encodeAllocatedMemory); this.encodePollTimer.Stop(); if (this.EncodeCompleted != null) { this.EncodeCompleted(this, new EncodeCompletedEventArgs { Error = state.param.workdone.error > 0 }); } } }
/// <summary> /// Checks the status of the ongoing scan. /// </summary> private void PollScanProgress() { var state = new hb_state_s(); HBFunctions.hb_get_state(this.hbHandle, ref state); if (state.state == NativeConstants.HB_STATE_SCANNING) { if (this.ScanProgress != null) { hb_state_scanning_anon scanningState = state.param.scanning; this.ScanProgress(this, new ScanProgressEventArgs { Progress = scanningState.progress, CurrentPreview = scanningState.preview_cur, Previews = scanningState.preview_count, CurrentTitle = scanningState.title_cur, Titles = scanningState.title_count }); } } else if (state.state == NativeConstants.HB_STATE_SCANDONE) { this.titles = new List<Title>(); IntPtr titleSetPtr = HBFunctions.hb_get_title_set(this.hbHandle); hb_title_set_s titleSet = InteropUtilities.ReadStructure<hb_title_set_s>(titleSetPtr); this.originalTitles = titleSet.list_title.ToList<hb_title_s>(); foreach (hb_title_s title in this.originalTitles) { var newTitle = this.ConvertTitle(title); // Convert the Path to UTF-8. byte[] bytes = Encoding.Default.GetBytes(title.path); string utf8Str = Encoding.UTF8.GetString(bytes); newTitle.Path = utf8Str; this.titles.Add(newTitle); } if (this.originalTitles.Count > 0) { this.featureTitle = titleSet.feature; } else { this.featureTitle = 0; } this.scanPollTimer.Stop(); if (this.ScanCompleted != null) { this.ScanCompleted(this, new System.EventArgs()); } } }