Hệ thống giám sát và cảnh bảo tín hiệu trong truyền hình

88 164 0
Hệ thống giám sát và cảnh bảo tín hiệu trong truyền hình

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

` BỘ GIÁO DỤC VÀ ĐÀO TẠO VIỆN ĐẠI HỌC MỞ HÀ NỘI LUẬN VĂN THẠC SỸ CHUYÊN NGÀNH: CÔNG NGHỆ THÔNG TIN HỆ THỐNG GIÁM SÁT VÀ CẢNH BÁO TÍ HIỆU TRONG TRUYỀN HÌNH DƢƠNG TRỌNG LÂM HÀ NỘI - 2016 ` BỘ GIÁO DỤC VÀ ĐÀO TẠO VIỆN ĐẠI HỌC MỞ HÀ NỘI LUẬN VĂN THẠC SỸ HỆ THỐNG GIÁM SÁT VÀ CẢNH BÁO TÍ HIỆU TRONG TRUYỀN HÌNH DƢƠNG TRỌNG LÂM CHUN NGÀNH : CƠNG NGHỆ THƠNG TIN MÃ SỐ: 60.48.02.018 HƢỚNG DẪN KHOA HỌC PSG.TS NGUYỄN VĂN TAM HÀ NỘI - 2016 ` LỜI CAM ĐOAN Tôi tên là: Dƣơng Trọng Lâm Học viên lớp Cao học Công nghệ thông tin 2014 - 2016 Tôi làm luận văn cao học CNTT với tên đề tài: Hệ thống giám sát cảnh báo tín hiệu truyền hình, PGS.TS Nguyễn Văn Tam hƣớng dẫn Tơi xin cam đoan nội dung luận văn tơi tìm hiểu, nghiên cứu thực Nếu sai tơi hồn tồn chịu trách nhiệm trƣớc trƣờng, pháp luật Hà Nội, ngày tháng Ngƣời cam đoan Dƣơng Trọng Lâm năm ` LỜI CẢM ƠN Để hoàn thành luận văn này, cố gắng cá nhân em có giúp đỡ tận tình PGS.TS Nguyễn Văn Tam Thầy định hƣớng, cung cấp tài liệu, hƣớng dẫn chi tiết sửa chữa sai sót em mắc phải q trình thực Em cảm ơn thầy cô giáo Khoa sau Đại học khoa Công nghệ thông tin Viện đại học Mở Hà nội tận tình dạy dỗ thời gian em học tập trƣờng Trong trình tìm hiểu nghiên cứu luận văn, kinh nghiệm khả hạn chế nên luận văn khó tránh khỏi nhiều thiếu sót, em mong đƣợc thơng cảm, đóng góp thầy bạn để luận văn hồn thiện Một lần em xin chân thành cảm ơn! ` MỤC LỤC LỜI CAM ĐOAN I LỜI CẢM ƠN II MỤC LỤC III DANH MỤC CÁC KÝ HIỆU CÁC CHỮ VIẾT TẮT V DANH MỤC CÁC BẢNG VII DANH MỤC CÁC HÌNH VIII MỞ ĐẦU CHƢƠNG TỔNG QUAN VỀ TRUYỀN HÌNH SỐ MẶT ĐẤT DVB-T 1.1.GIỚI THIỆU VỀ TRUYỀN HÌNH SỐ MẶT ĐẤT 1.1.1 Khái niệm 1.1.2 Sơ đồ tổng thể của hệ thống 1.2 CÁC THÀNH PHẦN TÍN HIỆU CƠ BẢN 1.2.1 Định nghĩa tín hiệu 1.2.2 Phân loại tín hiệu 1.3 MỘT SỐ CHUẨN NÉN VÀ TRUYỀN THÔNG TRONG TRUYỀN HÌNH SỐ MẶT ĐẤT 1.3.1 Vấn đề nén truyền hình số mặt đất 1.3.2 Ghép tín hiệu truyền hình sớ mặt đất 14 1.3.3 Truyền hình sớ mặt đất với giao thức quảng bá nhóm IP ( IP Multicast) 19 1.4 VẤN ĐỀ NÂNG CAO CHẤT LƢỢNG DỊCH VỤ TRUYỀN HÌNH SỐ MẶT ĐẤT 21 1.4.1 Nhu cầu chất lượng dịch vụ truyền hình sớ mặt đất 21 1.4.2 Bài toán giám sát cảnh báo tín hiệu truyền hình sớ mặt đất 22 CHƢƠNG XỬ LÝ TÍN HIỆU VÀ BẢO ĐẢM 23 CHẤT LƢỢNG TRONG TRUYỀN HÌNH 23 2.1 XỬ LÝ TÍN HIỆU TRUYỀN HÌNH 23 2.1.1 Một số khái niệm truyền hình 23 2.1.2 Các bước xử lý tín hiệu nén Mpeg2 27 ` 2.1.2.1 Nén video 28 2.1.2.2 Nén Audio 34 2.2 BẢO ĐẢM CHẤT LƢỢNG DỊCH VỤ 40 2.2.1 Vấn đề lỗi truyền hình sớ 40 2.2.2 Giải pháp khắc phục lỗi truyền hình sớ 40 2.3 PHÁT HIỆN VÀ CẢNH BÁO CHẤT LƢỢNG TÍN HIỆU TRUYỀN HÌNH SỐ 44 2.3.1 Giới thiệu chung hệ thớng giám sát cảnh báo tín hiệu 44 2.3.2 Hệ thống giám sát cảnh báo tín hiệu đơn giản 45 CHƢƠNG XÂY DỰNG HỆ THỐNG GIÁM SÁT VÀ CẢNH BÁO TÍN HIỆU TRONG TRUYỀN HÌNH 47 3.1 THIẾT KẾ HỆ THỐNG TỔNG THỂ 47 3.1.1 Phân tích dòng truyền tải 47 3.1.2 Chuyển đổi liệu 47 3.1.3 Lấy mẫu xử lý liệu 48 3.2 LỰA CHỌN CƠNG CỤ VÀ NGƠN NGỮ LẬP TRÌNH 48 3.2.1 Lựa chọn cụng cụ 48 3.2.2 Lựa chọn ngôn ngữ lập trình 53 3.3 THIẾT KẾ GIAO DIỆN VÀ LƢU ĐỒ THUẬT TOÁN 53 3.3.1 Thiết kế giao diện 53 3.3.2 Lưu đờ thuật tốn 55 3.4 MỘT SỐ KỊCH BẢN THỬ NGHIỆM VÀ ĐÁNH GIÁ KẾT QUẢ 58 3.4.1 Giới thiệu chung tín hiệu chuẩn tín hiệu bị lỗi để kiểm tra 58 3.4.2 Phát hiện cảnh báo tín hiệu lỗi video bị dừng hình hoặc bị 59 3.4.3 Phát hiện cảnh báo lỗi audio có âm lượng to hoặc nhỏ 59 3.4.4 Phát hiện cảnh báo băng thông 60 KẾT LUẬN 61 TÀI LIỆU THAM KHẢO 62 PHỤ LỤC 63 ` DANH MỤC CÁC KÝ HIỆU CÁC CHỮ VIẾT TẮT Từ viết tắt ASI BNC B-frame DCT DEMUX DVB DVD ES GOP I-frame HAS Tiếng Anh Asynchorous Serial Interface British Naval Connector Bi-directionally predicted frame Discrete Cosine Transform DeMultiplexers Digital Video Broadcast Digital Video Disk Elementary Stream Group of Picture Intra-frame Internet Group Management Protocol Human Auditory System HDTV High Definition Television IGMP MB MUX Inverse Discrete Cosine Transform International Electrotechnical Commission International Standards Organization International Telecommunication Union Macroblock Multiplexers MPEG Moving Picture Experts Group IDCT IEC ISO ITU P-frame PAL PAT PCR PES National televison System Committee Forward prediction frame Phase Alternation Line Program Association Table Presentation Clock Refference Packetized Elementary Stream PIM Protocol Independent Multicast Pixel PID PST Picture element Packet Identifier Program Specific Information NTSC Tiếng Việt Dữ liệu số nối tiếp không đồng Rắc cắm cáp đồng trục Khung hình dự đốn chiều Phép biến đổi cosine rời rạc Giải ghép kênh Phát sóng kỹ thuật số Đĩa video dùng kỹ thuật số Dòng sơ cấp Nhóm ảnh Frame kiểu Intra Giao thức quản lý nhóm Internet Hệ thống thính giác ngƣời Truyền hình số có độ phân giải cao Biến đổi cosine rời rạc ngƣợc Uỷ ban kỹ thuật điện quốc tế Tổ chức tiêu chuẩn quốc tế Liên minh viễn thông quốc tế Macroblock Ghép kênh Nhóm chuyên gia nghiên cứu ảnh động Hội đồng hệ thống TV quốc gia Mỹ Frame dự đoán thuận Hệ PAL Bảng liên kết chƣơng trình Tham chiếu thời gian đồng Dòng liệu đóng gói Giao thức hoạt động độc lập với giao thức định tuyến IP Điểm ảnh Định danh gói Bảng đặc tả chƣơng trình ` RLC SDI SDTV SNR TS TSP VLC UHF Run – Length Coding Serial Digital Interface Standard Television Signal to Noise Ratio Transport Stream Transport Stream Packet Variable Length Coding Ultra High Frequence Mã hóa loạt dài Dữ liệu số nối tiếp Truyền hình số tiêu chuẩn Tỉ số tín hiệu nhiễu Dòng truyền tải Gói truyền tải Mã độ dài thay đổi Tần số cao ` DANH MỤC CÁC BẢNG Bảng 1.1: Khái quát tiêu chuẩn nén Bảng 1.2: Dạng lớp cú pháp dòng bit MPEG-2 Bảng 1.3: Mức ảnh MPEG-2 11 Bảng 1.4: Đặc điểm Audio Mpeg-1, Mpeg-2 13 Bảng 1.5: Các giá trị PID 18 Bảng 2.1: Các bƣớc q trình mã hóa biến đổi DCT khối 30 Bảng 2.2: Quét zigzag .31 Bảng 2.3: Quét Zigzag mã hóa Huffman .32 ` DANH MỤC CÁC HÌNH Hình 1.1: Sơ đồ khối truyền hình số mặt đất Hình 1.2: Minh họa loại tín hiệu Hình 1.3: Cấu trúc lớp dòng bit MPEG-2 10 Hình 1.4: Sơ đồ khối má hóa audio MPEG 14 Hình 1.5: Cấu trúc gói liệu 14 Hình 1.6: Cấu trúc gói PES .15 Hình 1.7: Định dạng dòng chƣơng trình dòng truyền tải từ dòng đóng gói PES 16 Hình 1.8: Cấu trúc gói truyền tải ( Transport stream packet TS ) MPEG .17 Hình 1.9: Định dạng dòng truyền tải MPEG-2 18 Hình 2.1: Biểu diễn điểm ảnh 23 Hình 2.2: Nội suy bù chuyển động 26 Hình 2.3: Thứ tự truyền dẫn hiển thị ảnh .27 Hình 2.4: Các bƣớc xử lý MPEG 27 Hình 2.5: Băng thơng độ sáng tín hiệu màu 28 Hình 2.6: Ngƣỡng nghe thấy tuyệt đối ngƣỡng nghe phủ tần số 36 Hình 2.7: Sự che lấp thời gian 37 Hình 2.8: Đƣờng cong che lấp phân phối bit 39 Hình 2.9: Mối quan hệ không gian macroblock đƣợc che phủ macroblock bên cạnh .43 Hình 2.10: Bảo vệ MPEG-2 dùng mã FEC .43 Hình 2.11: Sơ đồ hệ thống giám sát tín hiệu .45 Hình 2.12: Sơ đồ hệ thống giám sát tín hiệu đơn giản 46 Hình 3.1: Các khối chức hệ thống 47 Hình 3.2: Phần mềm đọc file Ffmpeg .50 Hình 3.3: Hiển thị thơng tin file 51 Hình 3.4: Giao diện đọc thơng tin file 54 Hình 3.5: Giao diện hiển thị thông tin Video Audio 54 Hình 3.6: Thuật tốn phân tích dòng truyền tải 55 Hình 3.7: Lƣu đồ thuật tốn xử lý định nghĩa luật xử lý hình ảnh 56 ` PHỤ LỤC Một số hàm viết chƣơng trình Make-player (Khởi tạo giao diện phần mềm ) private void GeneratePlayer() { try { int rows = CurrentTemplate.Row; int cols = CurrentTemplate.Col; int w = panelPreview.Width; int h = panelPreview.Height; int oneW = (int)(w / cols); int oneH = (int)(h / rows); int index = 0; var controls = panelPreview.Controls.Cast().OrderBy(x=> x.Tag).ToList(); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { try { controls[index]._Width = panelPreview.Width; controls[index]._Height = panelPreview.Height; controls[index].Width = oneW; controls[index].Height = oneH; controls[index].Location = new Point(j * oneW, i * oneH); index++; } catch { } } } SaveListInput(); } catch { } } Class_call_lib_vlc (kết nối thƣ viện VLC) using System; using System.Runtime.InteropServices; using System.Security; ` namespace SCastCore { [SuppressUnmanagedCodeSecurity] public static class LibVlcMethods { #region libvlc.h [MinimalLibVlcVersion("1.2.0")] [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr libvlc_audio_filter_list_get(IntPtr p_instance); } } InitPlayer (Khởi tạo đối tƣợng player) public void InitPlayer() { labelLevelRight.Top = bgRight.Height; labelLevelLeft.Top = bgLeft.Height; m_factory = new MediaPlayerFactory(true); m_player = m_factory.CreatePlayer(); } Start (phát tín hiệu) public void Start() { this.BeginInvoke((ThreadStart)delegate () { lbName.Name = Source.Name; lbName.Refresh(); lbName.BringToFront(); string param = string.Empty; if (File.Exists(Source.Url)) { param = Source.ProgramId > ? ":program=" + Source.ProgramId : ""; m_media = m_factory.CreateMedia(Source.Url, param); } else ` { if (!string.IsNullOrEmpty(Source.UrlRetream) && Source.UrlRetream.Length > 4) { param = ""; } else { param = Source.ProgramId > ? ":program=" + Source.ProgramId : ""; } //Khoi tao doi tuong media theo url nguon vao m_media = m_factory.CreateMedia(Source.Url, param); } //Khai bao nhan du lieu audio IAudioRenderer auRender = m_player.CustomAudioRenderer; //Dang ky ham callback de nhan du lieu audio dang bytes auRender.SetCallbacks(OnVolumeChangedCallback, OnNewSoundCallback); auRender.SetFormat(new SoundFormat(SoundType.S16N, Source.AudioRate, 2)); if (!string.IsNullOrEmpty(Source.UrlRetream) && Source.UrlRetream.Length > 0) { mConvert.Checked = true; mReStream_Click(null, null); } m_player.Open(m_media); //Dang ky nhan du lieu Video luu vao memory IMemoryRenderer memRender = m_player.CustomRenderer; memRender.SetFormat(Source.AspectRatio == "16:9" ? new BitmapFormat(320, 180, ChromaType.RV32) : new BitmapFormat(320, 240, ChromaType.RV32)); m_player.Play(); timerExtractImg.Enabled = true; if (!CheckAudio) SetInitialVolume(); int interval = int.Parse(ConfigSettings.ReadSetting("audio_check_interval")); aAlert.Interval = interval * 1000; aAlert.Enabled = true; int vInterval = int.Parse(ConfigSettings.ReadSetting("video_check_interval")); vAlert.Interval = vInterval * 1000; ` vAlert.Enabled = true; IsStart = false; // Logger.LogThisLine("STARTED"); }); } Timer (Hiển thị thông tin cột Audio) private void timerVu_Tick(object sender, EventArgs e) { try { if (m_player.IsPlaying) { dbLeft = dbLeft > -60 ? dbLeft : -60; //Debug.WriteLine("L:" + dbLeft.ToString()); int nHeight = (int)((double)(60 + dbLeft) / 60 * bgLeft.Height); labelLevelLeft.Top = (bgLeft.Height - nHeight); if (dbLeft < Source.MinAudioLevel) { labelLevelLeft.BackColor = Color.Yellow; } else if (dbLeft > Source.MaxAudioLevel) { labelLevelLeft.BackColor = Color.Red; } else { labelLevelLeft.BackColor = Color.Lime; } dbRight = dbRight > -60 ? dbRight : -60; //Debug.WriteLine("R:" + dbRight.ToString()); nHeight = (int)((double)(60 + dbRight) / 60 * bgRight.Height); labelLevelRight.Top = (bgRight.Height - nHeight); if (dbRight < Source.MinAudioLevel) { labelLevelRight.BackColor = Color.Yellow; } else if (dbRight > Source.MaxAudioLevel) { labelLevelRight.BackColor = Color.Red; } else ` { labelLevelRight.BackColor = Color.Lime; } } else if (blUpdateSource || IsStart) { this.BackColor = Color.Red; lbName.BackColor = Color.Red; } } catch { } } TimerAlert (Đƣa cảnh báo hình ảnh , âm thanh) (so sánh âm thanh) private void timerAlert_Tick(object sender, EventArgs e) { try { if (m_player.IsPlaying) { if (CheckAudio) { if (dbLeft == dbLeftAudio && dbRight == dbRightAudio) { counterLose++; } else { counterLose = 0; this.BackColor = Color.Transparent; lbName.BackColor = Color.FromArgb(52, 52, 52); } if (counterLose >= 2) { this.BackColor = Color.Red; lbName.BackColor = Color.Red; if (counterLose >= int.Parse(ConfigSettings.ReadSetting("sound_max"))) { PlaySoundAlert(); // cảnh báo tiếng audio bằng file mp3, wave } ` } dbLeftAudio = dbLeft; dbRightAudio = dbRight; } } else { this.BackColor = Color.Red; lbName.BackColor = Color.Red; counterLose++; if (counterLose >= int.Parse(ConfigSettings.ReadSetting("sound_max"))) { Thread thread = new Thread(new ThreadStart(PlaySoundAlert)); thread.Start(); } } } catch { } } timerExtractImg (lấy mẫu ảnh bị lỗi khoảng thời gian) ( so sánh hình ảnh) private void timerExtractImg_Tick(object sender, EventArgs e) { string path = string.Format("{0}\\{1}", rootPath, DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss")); string url = Source.Url; if (Source.ProgramId > 0) { url = Source.Url + " -map 0:p:" + Source.ProgramId + ":0 -map 0:p:" + Source.ProgramId + ":1 "; } string param = string.Format("-re -y -i {0} -an -vframes \"{1}.png\"", url, path); ExtractImgProcess(param); } ExtractImgProcess (triết xuất ảnh bị lỗi thƣ mục để báo cáo) private Process proExtractImg; //Save file from stream ` private void ExtractImgProcess(string Parameters) { try { //Create process info string ffmpegPath = ConfigSettings.ReadSetting("exe_path"); ProcessStartInfo oInfo = new ProcessStartInfo(ffmpegPath, Parameters); //Set process properties oInfo.UseShellExecute = false; oInfo.CreateNoWindow = true; oInfo.RedirectStandardOutput = false; oInfo.RedirectStandardError = true; //Construct the process proExtractImg = new Process(); //Set start info proExtractImg.StartInfo = oInfo; //Hook up events proExtractImg.EnableRaisingEvents = true; proExtractImg.ErrorDataReceived += new DataReceivedEventHandler(proExtractImg_ErrorDataReceived); //Start the process proExtractImg.Start(); //Start async output reading proExtractImg.BeginErrorReadLine(); } catch { } } Process ( xử lý mảng byte audio giá trị dexibel) public void Process(ref byte[] wave) { try { double sumLeft = 0; double sumRight = 0; for (var i = 0; i < wave.Length; i = i + 4) ` { double sample = BitConverter.ToInt16(wave, i) / 32768.0; sumLeft += (sample * sample); sample = BitConverter.ToInt16(wave, i + 2) / 32768.0; sumRight += (sample * sample); } double rms = Math.Sqrt(sumLeft / (wave.Length / 2)); dbLeft = 20 * Math.Log10(rms); rms = Math.Sqrt(sumRight / (wave.Length / 2)); dbRight = 20 * Math.Log10(rms); } catch { } } 10 mReStream ( encoder nguồn tín hiệu gốc mà không xem đƣợc) private void mReStream_Click(object sender, EventArgs e) { if (mConvert.Checked) { string vf = string.IsNullOrEmpty(Source.Vf) ? "" :" -vf " + Source.Vf; if (Source.ProgramId > 0) { param = "-re -i " + Source.UrlRetream + " -map 0:p:" + Source.ProgramId + ":0 -map 0:p:" + Source.ProgramId + ":1 " + vf + " -b:v 2M -b:a 96k -f mpegts " + Source.Url; } else { param = "-re -i " + Source.UrlRetream + vf + " -b:v 2M -b:a 96k -f mpegts " + Source.Url; } ` ReStreamProcessAsync(param); } else { param = string.Empty; if (proStream != null) { //Murder try { proStream.Kill(); } catch { } } } } 11 Khởi tạo đối tƣợng Đồ Họa Private void InitChart() { // Populating the data arrays this.cpuUsageChart.Series.Clear(); this.cpuUsageChart.Palette = ChartColorPalette.SeaGreen; // Set chart title this.cpuUsageChart.Titles.Add("BandWidth"); // Add chart series Series series = this.cpuUsageChart.Series.Add("BandWidth"); cpuUsageChart.Series[0].ChartType = SeriesChartType.FastLine; // Add Initial Point as Zero series.Points.Add(0); //Populating X Y Axis Information cpuUsageChart.Series[0].YAxisType = AxisType.Primary; cpuUsageChart.Series[0].YValueType = ChartValueType.Int32; cpuUsageChart.Series[0].IsXValueIndexed = false; cpuUsageChart.ResetAutoValues(); ` cpuUsageChart.ChartAreas[0].AxisY.Maximum =100;//Max Y cpuUsageChart.ChartAreas[0].AxisY.Minimum = 0; cpuUsageChart.ChartAreas[0].AxisX.Enabled = AxisEnabled.False; cpuUsageChart.ChartAreas[0].AxisY.Title = "BandWidth %"; cpuUsageChart.ChartAreas[0].AxisY.IntervalAutoMode = IntervalAutoMode.VariableCount; populateCPUInfo(); } 12 Tính tồn băng thơng private void populateCPUInfo() { try { cpu = CpuUsage.Create(); Thread thread = new Thread(new ThreadStart(delegate() { try { while (iscontinue) { this.Invoke(new System.Windows.Forms.MethodInvoker(delegate() { int process = cpu.Query(); proVal.Text = process.ToString() + "%"; cpuUsageChart.Series[0].Points.AddY(process); if (cpuUsageChart.Series[0].Points.Count > 40) cpuUsageChart.Series[0].Points.RemoveAt(0); })); Thread.Sleep(450); } } catch (Exception ex) { } })); ` thread.Priority = ThreadPriority.Highest; thread.IsBackground = true; thread.Start(); } catch (Exception ex) { Console.WriteLine(ex); } } 13 Chuyển đổi liệu video public void Start() { this.BeginInvoke((ThreadStart)delegate () { lbName.Name = Source.Name; lbName.Refresh(); lbName.BringToFront(); string param = string.Empty; if (File.Exists(Source.Url)) { param = Source.ProgramId > ? ":program=" + Source.ProgramId : ""; m_media = m_factory.CreateMedia(Source.Url, param); } else { if (!string.IsNullOrEmpty(Source.UrlRetream) && Source.UrlRetream.Length > 4) { param = ""; } else { param = Source.ProgramId > ? ":program=" + Source.ProgramId : ""; } //Khoi tao doi tuong media theo url nguon vao m_media = m_factory.CreateMedia(Source.Url, param); } //Khai bao nhan du lieu audio IAudioRenderer auRender = m_player.CustomAudioRenderer; ` //Dang ky ham callback de nhan du lieu audio dang bytes auRender.SetCallbacks(OnVolumeChangedCallback, OnNewSoundCallback); auRender.SetFormat(new SoundFormat(SoundType.S16N, Source.AudioRate, 2)); if (!string.IsNullOrEmpty(Source.UrlRetream) && Source.UrlRetream.Length > 0) { mConvert.Checked = true; mReStream_Click(null, null); } m_player.Open(m_media); //Dang ky nhan du lieu Video luu vao memory IMemoryRenderer memRender = m_player.CustomRenderer; memRender.SetFormat(Source.AspectRatio == "16:9" ? new BitmapFormat(320, 180, ChromaType.RV32) : new BitmapFormat(320, 240, ChromaType.RV32)); m_player.Play(); timerExtractImg.Enabled = true; if (!CheckAudio) SetInitialVolume(); int interval = int.Parse(ConfigSettings.ReadSetting("audio_check_interval")); aAlert.Interval = interval * 1000; aAlert.Enabled = true; int vInterval = int.Parse(ConfigSettings.ReadSetting("video_check_interval")); vAlert.Interval = vInterval * 1000; vAlert.Enabled = true; IsStart = false; // Logger.LogThisLine("STARTED"); }); } private void timerExtractImg_Tick(object sender, EventArgs e) { try { // Convert current frame to image bitmap var bitmap = new Bitmap(m_player.CustomRenderer.CurrentFrame); // Display bitmap on screen panelPreview.BackgroundImage = bitmap; ` panelPreview.BackgroundImageLayout = ImageLayout.Zoom; //Lay du lieu bandwidth hien tai _vBandwidth = (m_media.Statistics.DemuxBitrate * 8000 / 1024f); // Tinh % hien thi len giao dien UISync.Execute(() => proVal.Text = _vBandwidth.ToString("0.00") + " Mb/s"); //_perent = (int)Math.Round((((m_media.Statistics.DemuxBitrate * 8000 / 1024f) / Source.MaxBandwidth) * 100)); m_player.CustomRenderer.CurrentFrame.Dispose(); } catch { } } private void vAlert_Tick(object sender, EventArgs e) { try { //Canh bao bandwidth qua thap if(_vBandwidth > Source.MaxBandwidth || _vBandwidth < Source.MinBandwidth) { _counterVLose++; }else { if (_isVFalse) { proVal.BackColor = Color.Transparent; Logger.LogThisLine("Tín hiệu Video nguồn vào bình thƣờng"); } _counterVLose = 0; _isVFalse = false; } if(_counterVLose >= Source.MaxBandwidthCount) { if (!_isVFalse) { proVal.BackColor = Color.Red; Logger.LogThisLine("Mất tín hiệu Video nguồn"); Logger.LogBandwidth(_vBandwidth.ToString()); } ` _isVFalse = true; } } catch { } } 14 Chuyển đổi liệu audio private void OnNewSoundCallback(Sound s) { try { //nhan du lieu audio dang bytes int size = (int)s.SamplesSize; byte[] managedArray = new byte[size]; Marshal.Copy(s.SamplesData, managedArray, 0, size); Process(ref managedArray); } catch { } } public void Process(ref byte[] wave) { try { //Bien doi audio bytes decibel voi gia tri kenh left right double sumLeft = 0; double sumRight = 0; for (var i = 0; i < wave.Length; i = i + 4) { double sample = BitConverter.ToInt16(wave, i) / 32768.0; sumLeft += (sample * sample); sample = BitConverter.ToInt16(wave, i + 2) / 32768.0; sumRight += (sample * sample); } double rms = Math.Sqrt(sumLeft / (wave.Length / 2)); dbLeft = 20 * Math.Log10(rms); rms = Math.Sqrt(sumRight / (wave.Length / 2)); dbRight = 20 * Math.Log10(rms); // dbLeft = dbLeft > -60 ? dbLeft : -60; ` //Tinh toan % màu cột âm trái hiển thị lên hình int nHeight = (int)((double)(60 + dbLeft) / 60 * bgLeft.Height); UISync.Execute(() => labelLevelLeft.Top = (bgLeft.Height nHeight)); if (dbLeft < Source.MinAudioLevel) { UISync.Execute(() => labelLevelLeft.BackColor = Color.Yellow); } else if (dbLeft > Source.MaxAudioLevel) { UISync.Execute(() => labelLevelLeft.BackColor = Color.Red); } else { UISync.Execute(() => labelLevelLeft.BackColor = Color.Lime); } dbRight = dbRight > -60 ? dbRight : -60; //Tinh toan % màu cột âm phải hiển thị lên hình nHeight = (int)((double)(60 + dbRight) / 60 * bgRight.Height); UISync.Execute(() => labelLevelRight.Top = (bgRight.Height nHeight)); if (dbRight < Source.MinAudioLevel) { UISync.Execute(() => labelLevelRight.BackColor = Color.Yellow); } else if (dbRight > Source.MaxAudioLevel) { UISync.Execute(() => labelLevelRight.BackColor = Color.Red); } else { UISync.Execute(() => labelLevelRight.BackColor = Color.Lime); } } catch { } } ... mã FEC .43 Hình 2.11: Sơ đồ hệ thống giám sát tín hiệu .45 Hình 2.12: Sơ đồ hệ thống giám sát tín hiệu đơn giản 46 Hình 3.1: Các khối chức hệ thống 47 Hình 3.2: Phần mềm... truyền hình số mặt đất ` Chƣơng 2: Xử lý tín hiệu đảm bảo chất lƣợng tín hiệu truyền hình Chƣơng Giới thiệu bƣớc xử lý tín hiệu truyền hình Vấn đề liên quan đến đảm bảo chất lƣợng tín hiệu truyền. .. băng thơng 58 Hình 3.10: Cảnh báo tín hiệu hình ảnh bị 59 Hình 3.11: Cảnh báo tín hiệu tiếng âm to 59 Hình 3.12: Cảnh báo tín hiệu tiếng âm nhỏ 60 Hình 3.13: Phát cảnh báo băng

Ngày đăng: 22/03/2018, 18:49

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan