private void PollScanProgress() { IntPtr json = HBFunctions.hb_get_state_json(this.hbHandle); string statusJson = Marshal.PtrToStringAnsi(json); this.log.LogMessage(statusJson, LogMessageType.Progress, LogLevel.Trace); JsonState state = JsonConvert.DeserializeObject <JsonState>(statusJson); if (state != null && state.State == NativeConstants.HB_STATE_SCANNING) { if (this.ScanProgress != null) { this.ScanProgress(this, new ScanProgressEventArgs(state.Scanning.Progress, state.Scanning.Preview, state.Scanning.PreviewCount, state.Scanning.Title, state.Scanning.TitleCount)); } } else if (state != null && state.State == NativeConstants.HB_STATE_SCANDONE) { var jsonMsg = HBFunctions.hb_get_title_set_json(this.hbHandle); string scanJson = InteropUtilities.ToStringFromUtf8Ptr(jsonMsg); this.log.LogMessage(scanJson, LogMessageType.Progress, LogLevel.Trace); this.titles = JsonConvert.DeserializeObject <JsonScanObject>(scanJson); this.featureTitle = this.titles.MainFeature; this.scanPollTimer.Stop(); if (this.ScanCompleted != null) { this.ScanCompleted(this, new System.EventArgs()); } } }
/// <summary> /// Converts a native language structure to a Language object. /// </summary> /// <param name="language"> /// The structure to convert. /// </param> /// <returns> /// The converted structure. /// </returns> internal static Language NativeToLanguage(iso639_lang_t language) { string englishName = InteropUtilities.ToStringFromUtf8Ptr(language.eng_name); string nativeName = InteropUtilities.ToStringFromUtf8Ptr(language.native_name); return(new Language(englishName, nativeName, language.iso639_2)); }
public static string GetVideoQualityRateControlName(string encoderShortName) { HBVideoEncoder encoder = GetVideoEncoder(encoderShortName); if (encoder != null) { return(InteropUtilities.ToStringFromUtf8Ptr(HBFunctions.hb_video_quality_get_name((uint)encoder.Id))); } return(string.Empty); }
/// <summary> /// Converts a native language structure to a Language object. /// </summary> /// <param name="language">The structure to convert.</param> /// <returns>The converted structure.</returns> public static Language NativeToLanguage(iso639_lang_t language) { string englishName = InteropUtilities.ToStringFromUtf8Ptr(language.eng_name); string nativeName = InteropUtilities.ToStringFromUtf8Ptr(language.native_name); return(new Language { Code = language.iso639_2, EnglishName = englishName, NativeName = nativeName }); }
private void PollScanProgress() { IntPtr json = HBFunctions.hb_get_state_json(this.hbHandle); string statusJson = Marshal.PtrToStringAnsi(json); this.log.LogMessage(statusJson, LogMessageType.Progress, LogLevel.Trace); JsonState state = null; if (!string.IsNullOrEmpty(statusJson)) { state = JsonConvert.DeserializeObject <JsonState>(statusJson); } TaskState taskState = state != null?TaskState.FromRepositoryValue(state.State) : null; if (taskState != null && (taskState == TaskState.Scanning || taskState == TaskState.Searching)) { if (this.ScanProgress != null && state.Scanning != null) { this.ScanProgress(this, new ScanProgressEventArgs(state.Scanning.Progress, state.Scanning.Preview, state.Scanning.PreviewCount, state.Scanning.Title, state.Scanning.TitleCount)); } } else if (taskState != null && taskState == TaskState.ScanDone) { this.scanPollTimer.Stop(); var jsonMsg = HBFunctions.hb_get_title_set_json(this.hbHandle); this.titlesJson = InteropUtilities.ToStringFromUtf8Ptr(jsonMsg); this.log.LogMessage(this.titlesJson, LogMessageType.Progress, LogLevel.Trace); if (string.IsNullOrEmpty(this.titlesJson)) { this.log.LogMessage("Scan Error: No Scan Data Returned.", LogMessageType.API, LogLevel.Error); } else { this.titles = JsonConvert.DeserializeObject <JsonScanObject>(this.titlesJson); if (this.titles != null) { this.featureTitle = this.titles.MainFeature; } } if (this.ScanCompleted != null) { this.ScanCompleted(this, new System.EventArgs()); } } }
private void PollScanProgress() { IntPtr json = HBFunctions.hb_get_state_json(this.Handle); string statusJson = Marshal.PtrToStringAnsi(json); JsonState state = null; if (!string.IsNullOrEmpty(statusJson)) { state = JsonSerializer.Deserialize <JsonState>(statusJson, JsonSettings.Options); } TaskState taskState = state != null?TaskState.FromRepositoryValue(state.State) : null; if (taskState != null && (taskState == TaskState.Scanning || taskState == TaskState.Searching)) { if (this.ScanProgress != null && state.Scanning != null) { this.ScanProgress(this, new ScanProgressEventArgs(state.Scanning.Progress, state.Scanning.Preview, state.Scanning.PreviewCount, state.Scanning.Title, state.Scanning.TitleCount)); } } else if (taskState != null && taskState == TaskState.ScanDone) { this.scanPollTimer.Stop(); var jsonMsg = HBFunctions.hb_get_title_set_json(this.Handle); this.TitlesJson = InteropUtilities.ToStringFromUtf8Ptr(jsonMsg); if (!string.IsNullOrEmpty(this.TitlesJson)) { this.Titles = JsonSerializer.Deserialize <JsonScanObject>(this.TitlesJson, JsonSettings.Options); if (this.Titles != null) { this.FeatureTitle = this.Titles.MainFeature; } } if (this.ScanCompleted != null) { this.ScanCompleted(this, new System.EventArgs()); } } }