⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 streaminfo.cpp

📁 linux下实现视频播放的播放器
💻 CPP
字号:
/* *  Copyright (C) 2008  mtrooper * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *//* $Id$ */#include "iptv.h"#include "video.h"#if (C_HAVE_WXGUI)#include "StreamInfo.h"#include "../resource/friptv.xpm"StreamInfo::StreamInfo(wxWindow * parent, wxWindowID id, const wxString & title, const wxPoint & position,		       const wxSize & size, long style) : wxDialog(parent, id, title, position, size, style){    CreateGUIControls();}StreamInfo::~StreamInfo(){}void StreamInfo::CreateGUIControls(){    SetTitle(wxT("Stream Info"));    SetIcon(wxIcon(friptv_xpm));    SetSize(8, 8, 320, 370);    Center();    AllStreams = new wxStaticBox(this, ID_ALLSTREAMS, wxT("All streams:"), wxPoint(8, 232), wxSize(292, 108));    Streams = new wxListView(this, ID_STREAMS, wxPoint(16, 248), wxSize(277, 82), wxLC_REPORT);    Streams->InsertColumn(0, "PID");    Streams->InsertColumn(1, "Stream type");    Streams->InsertColumn(2, "Active");    AudioStream = new wxStaticBox(this, ID_AUDIOSTREAM, wxT("Audio stream:"),		    wxPoint(8, 136), wxSize(292, 88));    AudioStreamPID = new wxStaticText(this, ID_AUDIOSTREAMPID, wxT("PID:"),		    wxPoint(16, 152), wxDefaultSize, 0, wxT("AudioStreamPID"));    AudioStreamType = new wxStaticText(this, ID_AUDIOSTREAMTYPE, wxT("Stream type:"),		    wxPoint(16, 168), wxDefaultSize, 0, wxT("AudioStreamType"));    AudioStreamBitrate = new wxStaticText(this, ID_AUDIOSTREAMBITRATE, wxT("Bitrate:"),		    wxPoint(16, 184), wxDefaultSize, 0, wxT("AudioStreamBitrate"));    AudioStreamFrequency = new wxStaticText(this, ID_AUDIOSTREAMFREQUENCY, wxT("Frequency:"),		    wxPoint(16, 200), wxDefaultSize, 0, wxT("AudioStreamBitrate"));    VideoStream = new wxStaticBox(this, ID_VIDEOSTREAMPID, wxT("Video stream:"),		    wxPoint(5, 8), wxSize(292, 120));    VideoStreamPID = new wxStaticText(this, ID_VIDEOSTREAMPID, wxT("PID:"),		    wxPoint(16, 24), wxDefaultSize, 0, wxT("VideoStreamPID"));    VideoStreamType = new wxStaticText(this, ID_VIDEOSTREAMTYPE, wxT("Stream type:"),		    wxPoint(16, 40), wxDefaultSize, 0, wxT("VideoStreamType"));    VideoStreamResolution = new wxStaticText(this, ID_VIDEOSTREAMRESOLUTION, wxT("Resolution:"),		    wxPoint(16, 56), wxDefaultSize, 0, wxT("VideoStreamResolution"));    VideoStreamAR = new wxStaticText(this, ID_VIDEOSTREAMAR, wxT("AR:"), wxPoint(16, 72),		    wxDefaultSize, 0, wxT("VideoStreamResolution"));    VideoStreamBitrate = new wxStaticText(this, ID_VIDEOSTREAMBITRATE, wxT("Bitrate:"),		    wxPoint(16, 88), wxDefaultSize, 0, wxT("VideoStreamBitrate"));    VideoStreamActualBitrate = new wxStaticText(this, ID_VIDEO_STREAM_ACTUAL_BITRATE,		    wxT("Actual bitrate:"), wxPoint(16, 104), wxDefaultSize, 0, wxT("VideoStreamBitrate"));    Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(StreamInfo::OnClose));    Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(StreamInfo::OnStreamInfoKeyDown));    Streams->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(StreamInfo::OnStreamInfoKeyDown), NULL, this);}void StreamInfo::OnClose(wxCloseEvent& event){    Show(false);}void StreamInfo::UpdateStreamInfo(PAT_entry * pat_entries,				  int num_pat_entries, int num_valid_pmts,				  unsigned int MPEG2_Transport_VideoPID,				  unsigned int MPEG2_Transport_AudioPID){    if((num_pat_entries == 0) && (num_valid_pmts < num_pat_entries))	return;    wxString tempStr;    Streams->DeleteAllItems();    int videoStreamIndex = 0, audioStreamIndex = 0;    for(int i = 0; i < pat_entries[0].num_streams; i++) {	tempStr.Printf("0x%x", pat_entries[0].streams[i].pid);	long index = Streams->InsertItem(i, tempStr);	tempStr.Printf("%s", pat_entries[0].streams[i].stream_type);	Streams->SetItem(i, 1, tempStr);	if(pat_entries[0].streams[i].pid == MPEG2_Transport_VideoPID) {	    Streams->SetItem(i, 2, wxT("Yes"));	    videoStreamIndex = i;	} else if(pat_entries[0].streams[i].pid == MPEG2_Transport_AudioPID) {	    Streams->SetItem(i, 2, wxT("Yes"));	    audioStreamIndex = i;	} else {	    Streams->SetItem(i, 2, wxT("No"));	}    }    Streams->SetColumnWidth(0, wxLIST_AUTOSIZE);    Streams->SetColumnWidth(1, wxLIST_AUTOSIZE);    Streams->SetColumnWidth(2, wxLIST_AUTOSIZE);    if(MPEG2_Transport_VideoPID != 0) {	tempStr.Printf("PID: 0x%x", MPEG2_Transport_VideoPID);	VideoStreamPID->SetLabel(tempStr);	tempStr.Printf("Stream type: %s",		       pat_entries[0].streams[videoStreamIndex].stream_type);	VideoStreamType->SetLabel(tempStr);    } else {	tempStr.Printf("PID: N/A");	VideoStreamPID->SetLabel(tempStr);	tempStr.Printf("Stream type: N/A");	VideoStreamType->SetLabel(tempStr);    }    tempStr.Printf("Actual bitrate [kbps]: N/A");    VideoStreamActualBitrate->SetLabel(tempStr);    if(MPEG2_Transport_AudioPID != 0) {	tempStr.Printf("PID: 0x%x", MPEG2_Transport_AudioPID);	AudioStreamPID->SetLabel(tempStr);	tempStr.Printf("Stream type: %s", pat_entries[0].streams[audioStreamIndex].stream_type);	AudioStreamType->SetLabel(tempStr);    } else {	tempStr.Printf("PID: N/A");	AudioStreamPID->SetLabel(tempStr);	tempStr.Printf("Stream type: N/A");	AudioStreamType->SetLabel(tempStr);    }    tempStr.Printf("Bitrate [kbps]: N/A");    AudioStreamBitrate->SetLabel(tempStr);    tempStr.Printf("Frequency [hz]: N/A");    AudioStreamFrequency->SetLabel(tempStr);}void StreamInfo::UpdateVideoStream(int width, int height, long bitrate, double ar){    wxString tempStr;    tempStr.Printf("Resolution: %d x %d", width, height);    VideoStreamResolution->SetLabel(tempStr);    tempStr.Printf("AR: %f", ar);    VideoStreamAR->SetLabel(tempStr);    if(bitrate == -1)	tempStr.Printf("Bitrate [kbps]: N/A");    else	tempStr.Printf("Bitrate [kbps]: %d", bitrate / 1000);    VideoStreamBitrate->SetLabel(tempStr);}void StreamInfo::UpdateAudioStream(int frequency, int bitrate){    wxString tempStr;    tempStr.Printf("Bitrate [kbps]: %d", bitrate / 1000);    AudioStreamBitrate->SetLabel(tempStr);    tempStr.Printf("Frequency [hz]: %d", frequency);    AudioStreamFrequency->SetLabel(tempStr);}void StreamInfo::UpdateVideoActualBitrate(long actualBitrate){    wxString tempStr;    tempStr.Printf("Actual bitrate [kbps]: %d", actualBitrate / 1000);    VideoStreamActualBitrate->SetLabel(tempStr);}void StreamInfo::OnStreamInfoKeyDown(wxKeyEvent& event){    if((event.GetKeyCode() == 'I') || (event.GetKeyCode() == WXK_ESCAPE)) {	Show(false);    }}#endif // C_HAVE_WXGUI

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -