📄 fileprops.cpp
字号:
/* * GPAC - Multimedia Framework C SDK * * Copyright (c) Jean Le Feuvre 2000-2005 * All rights reserved * * This file is part of GPAC / Osmo4 wxWidgets GUI * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * GPAC 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * */#include "fileprops.h"#include "wxOsmo4.h"#include "Playlist.h"#include <wx/filename.h>#include <gpac/modules/codec.h>#include <gpac/modules/service.h>#include <gpac/constants.h>/*ISO 639 languages*/#include <gpac/iso639.h>wxFileProps::wxFileProps(wxWindow *parent) : wxDialog(parent, -1, wxString(_T("File Properties"))){ m_pApp = (wxOsmo4Frame *)parent; SetSize(540, 260); assert(m_pApp->m_pPlayList); m_pTreeView = new wxTreeCtrl(this, ID_TREE_VIEW, wxPoint(4, 2), wxSize(200, 180), wxTR_DEFAULT_STYLE | wxSUNKEN_BORDER); new wxStaticText(this, 0, _T("Information"), wxPoint(210, 2), wxSize(60, 20)); m_pViewSel = new wxComboBox(this, ID_VIEW_SEL, _T(""), wxPoint(280, 2), wxSize(120, 24), 0, NULL, wxCB_READONLY); m_pViewSel->Append(wxT("General")); m_pViewSel->Append(wxT("Streams")); m_pViewSel->Append(wxT("Playback")); m_pViewSel->Append(wxT("Network")); m_pViewSel->SetSelection(0); m_pViewInfo = new wxTextCtrl(this, -1, wxT(""), wxPoint(210, 30), wxSize(320, 200), wxTE_MULTILINE | wxTE_READONLY | wxHSCROLL | wxSUNKEN_BORDER);#ifdef WIN32 m_pViewInfo->SetBackgroundColour(wxColour(wxT("LIGHT GREY")));#endif m_pViewWI = new wxButton(this, ID_VIEW_WI, wxT("View World Info"), wxPoint(4, 174), wxSize(200, 40)); m_pViewSG = new wxButton(this, ID_VIEW_SG, wxT("View Scene Graph"), wxPoint(4, 220), wxSize(200, 40)); wxString str = m_pApp->m_pPlayList->GetDisplayName(); str += wxT(" Properties"); SetTitle(str); m_pTimer = new wxTimer(); m_pTimer->SetOwner(this, ID_OD_TIMER); m_pTimer->Start(500, 0); RewriteODTree();}wxFileProps::~wxFileProps(){ m_pTimer->Stop(); delete m_pTimer;}BEGIN_EVENT_TABLE(wxFileProps, wxDialog) EVT_TREE_ITEM_ACTIVATED(ID_TREE_VIEW, wxFileProps::OnSetSelection) EVT_TREE_SEL_CHANGED(ID_TREE_VIEW, wxFileProps::OnSetSelection) EVT_TREE_ITEM_EXPANDED(ID_TREE_VIEW, wxFileProps::OnSetSelection) EVT_TREE_ITEM_COLLAPSED(ID_TREE_VIEW, wxFileProps::OnSetSelection) EVT_TIMER(ID_OD_TIMER, wxFileProps::OnTimer) EVT_BUTTON(ID_VIEW_SG, wxFileProps::OnViewSG) EVT_BUTTON(ID_VIEW_WI, wxFileProps::OnViewWorld) EVT_COMBOBOX(ID_VIEW_SEL, wxFileProps::OnSelectInfo)END_EVENT_TABLE()void wxFileProps::RewriteODTree(){ GF_ObjectManager *root_odm = gf_term_get_root_object(m_pApp->m_term); if (!root_odm) return; m_pTreeView->DeleteAllItems(); ODTreeData *root = new ODTreeData(root_odm); m_pTreeView->AddRoot(wxT("Root OD"), -1, -1, root); wxTreeItemId rootId = m_pTreeView->GetRootItem(); WriteInlineTree(root); SetInfo(root_odm);}void wxFileProps::WriteInlineTree(ODTreeData *root){ /*browse all ODs*/ u32 count = gf_term_get_object_count(m_pApp->m_term, root->m_pODMan); for (u32 i=0; i<count; i++) { GF_ObjectManager *odm = gf_term_get_object(m_pApp->m_term, root->m_pODMan, i); if (!odm) return; ODTreeData *odd = new ODTreeData(odm); m_pTreeView->AppendItem(root->GetId(), wxT("Object Descriptor"), -1, -1, odd); /*if inline propagate*/ switch (gf_term_object_subscene_type(m_pApp->m_term, odm)) { case 1: m_pTreeView->SetItemText(odd->GetId(), wxT("Root Scene")); WriteInlineTree(odd); break; case 2: m_pTreeView->SetItemText(odd->GetId(), wxT("Inline Scene")); WriteInlineTree(odd); break; case 3: m_pTreeView->SetItemText(odd->GetId(), wxT("Extern Proto Lib")); break; default: break; } }}void wxFileProps::OnSetSelection(wxTreeEvent& event){ ODTreeData *odd = (ODTreeData *) m_pTreeView->GetItemData(event.GetItem()); SetInfo(odd->m_pODMan);}void wxFileProps::SetInfo(GF_ObjectManager *odm){ m_current_odm = odm; switch (m_pViewSel->GetSelection()) { case 3: SetNetworkInfo(); break; case 2: SetDecoderInfo(); break; case 1: SetStreamsInfo(); break; default: SetGeneralInfo(); break; }}void wxFileProps::OnTimer(wxTimerEvent& WXUNUSED(event)){ switch (m_pViewSel->GetSelection()) { case 2: SetDecoderInfo(); break; }}void wxFileProps::OnSelectInfo(wxCommandEvent & WXUNUSED(event) ){ SetInfo(m_current_odm);}void wxFileProps::SetGeneralInfo(){ wxString info; ODInfo odi; u32 h, m, s; u32 i, j; info = wxT(""); m_pViewInfo->Clear(); m_pViewInfo->AppendText(info); if (!m_current_odm || gf_term_get_object_info(m_pApp->m_term, m_current_odm, &odi) != GF_OK) return; if (odi.has_profiles) info += wxT("Initial "); info += wxString::Format(wxT("Object Descriptor ID %d\n"), odi.od->objectDescriptorID); if (odi.duration) { h = (u32) (odi.duration / 3600); m = (u32) (odi.duration / 60) - h*60; s = (u32) (odi.duration) - h*3600 - m*60; info += wxString::Format(wxT("Duration %02d:%02d:%02d\n"), h, m, s); } else { info += wxT("Unknown duration\n"); } if (odi.owns_service) { info += wxT("Service Handler: ") + wxString(odi.service_handler, wxConvUTF8) + wxT("\n"); info += wxT("Service URL: ") + wxString(odi.service_url, wxConvUTF8) + wxT("\n"); } if (odi.od->URLString) { info += wxT("Remote OD - URL: ") + wxString(odi.od->URLString, wxConvUTF8) + wxT("\n"); } if (odi.codec_name) { switch (odi.od_type) { case GF_STREAM_VISUAL: info += wxString::Format(wxT("Video Object: Width %d - Height %d\n"), odi.width, odi.height); info += wxT("Media Codec ") + wxString(odi.codec_name, wxConvUTF8) + wxT("\n"); break; case GF_STREAM_AUDIO: info += wxString::Format(wxT("Audio Object: Sample Rate %d - %d channels\n"), odi.sample_rate, odi.num_channels); info += wxT("Media Codec ") + wxString(odi.codec_name, wxConvUTF8) + wxT("\n"); break; case GF_STREAM_PRIVATE_SCENE: case GF_STREAM_SCENE: if (odi.width && odi.height) { info += wxString::Format(wxT("Scene Description: Width %d - Height %d\n"), odi.width, odi.height); } else { info += wxT("Scene Description: No size specified\n"); } info += wxT("Scene Codec ") + wxString(odi.codec_name, wxConvUTF8) + wxT("\n"); break; case GF_STREAM_TEXT: if (odi.width && odi.height) { info += wxString::Format(wxT("Text Object: Width %d - Height %d\n"), odi.width, odi.height); } else { info += wxString::Format(wxT("Text Object: No size specified\n")); } info += wxT("Text Codec ") + wxString(odi.codec_name, wxConvUTF8) + wxT("\n"); break; } } if (odi.protection==2) info += wxT("Encrypted Media NOT UNLOCKED"); else if (odi.protection==1) info += wxT("Encrypted Media"); if (!gf_list_count(odi.od->OCIDescriptors)) { m_pViewInfo->Clear(); m_pViewInfo->AppendText(info); return; } info += wxT("\nObject Content Information:\n"); /*check OCI (not everything interests us) - FIXME: support for unicode*/ for (i=0; i<gf_list_count(odi.od->OCIDescriptors); i++) { GF_Descriptor *desc = (GF_Descriptor *) gf_list_get(odi.od->OCIDescriptors, i); switch (desc->tag) { case GF_ODF_SEGMENT_TAG: { GF_Segment *sd = (GF_Segment *) desc; info += wxT("\nSegment Descriptor:\nName: ") + wxString((char *) sd->SegmentName, wxConvUTF8); info += wxString::Format(wxT(" - start time %g sec - duration %g sec\n"), sd->startTime, sd->Duration); } break; case GF_ODF_CC_NAME_TAG: { GF_CC_Name *ccn = (GF_CC_Name *)desc; info += wxT("\nContent Creators:\n"); for (j=0; j<gf_list_count(ccn->ContentCreators); j++) { GF_ContentCreatorInfo *ci = (GF_ContentCreatorInfo *) gf_list_get(ccn->ContentCreators, j); if (!ci->isUTF8) continue; info += wxT("\t") + wxString(ci->contentCreatorName, wxConvUTF8) + wxT("\n"); } } break; case GF_ODF_SHORT_TEXT_TAG: { GF_ShortTextual *std = (GF_ShortTextual *)desc; info += wxT("\n") + wxString(std->eventName, wxConvUTF8) + wxT(": ") + wxString(std->eventText, wxConvUTF8) + wxT("\n"); } break; /*todo*/ case GF_ODF_CC_DATE_TAG: break; default: break; } } m_pViewInfo->Clear(); m_pViewInfo->AppendText(info);}void wxFileProps::SetStreamsInfo(){ u32 i, count; wxString info; ODInfo odi; char code[5]; info = wxT(""); m_pViewInfo->Clear(); m_pViewInfo->AppendText(info); if (!m_current_odm || gf_term_get_object_info(m_pApp->m_term, m_current_odm, &odi) != GF_OK) return; if (odi.has_profiles) { info += wxString::Format(wxT("\tOD Profile@Level %d\n"), odi.OD_pl); info += wxString::Format(wxT("\tScene Profile@Level %d\n"), odi.scene_pl); info += wxString::Format(wxT("\tGraphics Profile@Level %d\n"), odi.graphics_pl); info += wxString::Format(wxT("\tAudio Profile@Level %d\n"), odi.audio_pl); info += wxString::Format(wxT("\tVisual Profile@Level %d\n"), odi.scene_pl); if (odi.inline_pl) info += wxT("\tInline Content use same profiles\n"); info += wxT("\n"); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -