📄 fileprops.cpp
字号:
// FileProps.cpp : implementation file//#include "stdafx.h"#include "osmo4.h"#include "FileProps.h"#include "MainFrm.h"/*ISO 639 languages*/#include <gpac/iso639.h>#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CFileProps dialogCFileProps::CFileProps(CWnd* pParent /*=NULL*/) : CDialog(CFileProps::IDD, pParent){ //{{AFX_DATA_INIT(CFileProps) //}}AFX_DATA_INIT}void CFileProps::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CFileProps) DDX_Control(pDX, IDC_VIEWSEL, m_ViewSel); DDX_Control(pDX, IDC_ODINFO, m_ODInfo); DDX_Control(pDX, IDC_ODTREE, m_ODTree); //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CFileProps, CDialog) //{{AFX_MSG_MAP(CFileProps) ON_NOTIFY(TVN_SELCHANGED, IDC_ODTREE, OnSelchangedOdtree) ON_BN_CLICKED(IDC_WORLD, OnWorld) ON_BN_CLICKED(IDC_VIEWSG, OnViewsg) ON_WM_TIMER() ON_WM_CLOSE() ON_WM_DESTROY() ON_NOTIFY(TCN_SELCHANGE, IDC_VIEWSEL, OnSelchangeViewsel) //}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CFileProps message handlers#define FP_TIMER_ID 20BOOL CFileProps::OnInitDialog() { CDialog::OnInitDialog(); char sText[5000]; sprintf(sText, "%s Properties", ((CMainFrame*)GetApp()->m_pMainWnd)->m_pPlayList->GetDisplayName()); SetWindowText(sText); current_odm = NULL; m_ViewSel.InsertItem(0, "General"); m_ViewSel.InsertItem(1, "Streams"); m_ViewSel.InsertItem(2, "Playback"); m_ViewSel.InsertItem(3, "Network"); m_ODTree.SetIndent(0); RewriteODTree(); SetTimer(FP_TIMER_ID, 500, NULL); return TRUE;}void CFileProps::WriteInlineTree(GF_ObjectManager *root_od, HTREEITEM parent){ WinGPAC *gpac = GetApp(); /*browse all ODs*/ u32 count = gf_term_get_object_count(gpac->m_term, root_od); for (u32 i=0; i<count; i++) { GF_ObjectManager *odm = gf_term_get_object(gpac->m_term, root_od, i); if (!odm) return; HTREEITEM item = m_ODTree.InsertItem("Object Descriptor", 0, 0, parent); m_ODTree.SetItemData(item, (DWORD) odm); /*if inline propagate*/ switch (gf_term_object_subscene_type(gpac->m_term, odm)) { case 1: m_ODTree.SetItemText(item, "Root Scene"); WriteInlineTree(odm, item); break; case 2: m_ODTree.SetItemText(item, "Inline Scene"); WriteInlineTree(odm, item); break; case 3: m_ODTree.SetItemText(item, "Extern Proto Lib"); WriteInlineTree(odm, item); break; default: break; } }}void CFileProps::RewriteODTree(){ WinGPAC *gpac = GetApp(); m_ODTree.DeleteAllItems(); GF_ObjectManager *root_odm = gf_term_get_root_object(gpac->m_term); if (!root_odm) return; HTREEITEM root = m_ODTree.InsertItem("Root OD", 0, 0); m_ODTree.SetItemData(root, (DWORD) root_odm); m_ODTree.SetItemText(root, "Root Scene"); WriteInlineTree(root_odm, root);}void CFileProps::OnSelchangedOdtree(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; *pResult = 0; HTREEITEM item = m_ODTree.GetSelectedItem(); GF_ObjectManager *odm = (GF_ObjectManager *) m_ODTree.GetItemData(item); if (!odm) return; SetInfo(odm);}void CFileProps::OnClose() { KillTimer(FP_TIMER_ID); DestroyWindow();}void CFileProps::OnDestroy() { CDialog::OnDestroy(); delete this; ((CMainFrame *)GetApp()->m_pMainWnd)->m_pProps = NULL;}void CFileProps::OnSelchangeViewsel(NMHDR* pNMHDR, LRESULT* pResult) { SetInfo(current_odm); *pResult = 0;}void CFileProps::SetInfo(GF_ObjectManager *odm){ current_odm = odm; switch (m_ViewSel.GetCurSel()) { case 3: SetNetworkInfo(); break; case 2: SetDecoderInfo(); break; case 1: SetStreamsInfo(); break; default: SetGeneralInfo(); break; }}void CFileProps::OnTimer(UINT nIDEvent) { if (nIDEvent == FP_TIMER_ID) { switch (m_ViewSel.GetCurSel()) { case 3: SetNetworkInfo(); break; case 2: SetDecoderInfo(); break; } } CDialog::OnTimer(nIDEvent);}void CFileProps::SetGeneralInfo(){ char info[10000]; char buf[1000]; ODInfo odi; GF_ObjectManager *odm; u32 h, m, s, i, j; WinGPAC *gpac = GetApp(); odm = current_odm; strcpy(info, ""); if (!odm || gf_term_get_object_info(gpac->m_term, odm, &odi) != GF_OK) return; if (!odi.od) { strcat(info, odi.service_url); m_ODInfo.SetWindowText(info); return; } sprintf(buf, "%sObject Descriptor ID %d\r\n", (odi.has_profiles) ? "Initial " : "", odi.od->objectDescriptorID); strcat(info, buf); if (odi.duration) { h = (u32) (odi.duration / 3600); m = (u32) (odi.duration / 60) - h*60; s = (u32) (odi.duration) - h*3600 - m*60; sprintf(buf, "Duration %02d:%02d:%02d\r\n", h, m, s); strcat(info, buf); } else { strcat(info, "Unknown duration\r\n"); } if (odi.owns_service) { strcat(info, "Service Handler: "); strcat(info, odi.service_handler); strcat(info, "\r\n"); strcat(info, "Service URL: "); strcat(info, odi.service_url); strcat(info, "\r\n"); } if (odi.od->URLString) { strcat(info, "Remote OD - URL: "); strcat(info, odi.od->URLString); strcat(info, "\r\n"); } /*get OD content info*/ if (odi.codec_name) { switch (odi.od_type) { case GF_STREAM_VISUAL: sprintf(buf, "Video Object: Width %d - Height %d\r\n", odi.width, odi.height); strcat(info, buf); strcat(info, "Media Codec "); strcat(info, odi.codec_name); strcat(info, "\r\n"); if (odi.par) { sprintf(buf, "Pixel Aspect Ratio: %d:%d\r\n", (odi.par>>16)&0xFF, (odi.par)&0xFF); strcat(info, buf); } break; case GF_STREAM_AUDIO: sprintf(buf, "Audio Object: Sample Rate %d - %d channels\r\n", odi.sample_rate, odi.num_channels); strcat(info, buf); strcat(info, "Media Codec "); strcat(info, odi.codec_name); strcat(info, "\r\n"); break; case GF_STREAM_PRIVATE_SCENE: case GF_STREAM_SCENE: if (odi.width && odi.height) { sprintf(buf, "Scene Description: Width %d - Height %d\r\n", odi.width, odi.height); } else { sprintf(buf, "Scene Description: No size specified\r\n"); } strcat(info, buf); strcat(info, "Scene Codec "); strcat(info, odi.codec_name); strcat(info, "\r\n"); break; case GF_STREAM_TEXT: if (odi.width && odi.height) { sprintf(buf, "Text Object: Width %d - Height %d\r\n", odi.width, odi.height); } else { sprintf(buf, "Text Object: No size specified\r\n"); } strcat(info, buf); strcat(info, "Text Codec "); strcat(info, odi.codec_name); strcat(info, "\r\n"); break; } } if (odi.protection) { strcat(info, "Encrypted Media"); if (odi.protection==2) strcat(info, " NOT UNLOCKED"); strcat(info, "\r\n"); } if (!gf_list_count(odi.od->OCIDescriptors)) { m_ODInfo.SetWindowText(info); return; } strcat(info, "\r\nObject Content Information:\r\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; strcat(info, "\r\nSegment Descriptor:\r\n"); sprintf(buf, "Name: %s - start time %g sec - duration %g sec\r\n", sd->SegmentName, sd->startTime, sd->Duration); strcat(info, buf); } break; case GF_ODF_CC_NAME_TAG: { GF_CC_Name *ccn = (GF_CC_Name *)desc; strcat(info, "\r\nContent Creators:\r\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; strcat(info, "\t"); strcat(info, ci->contentCreatorName); strcat(info, "\r\n"); } } break; case GF_ODF_SHORT_TEXT_TAG: { GF_ShortTextual *std = (GF_ShortTextual *)desc; strcat(info, "\r\n"); strcat(info, std->eventName); strcat(info, ": "); strcat(info, std->eventText); strcat(info, "\r\n"); } break; /*todo*/ case GF_ODF_CC_DATE_TAG: break; default: break; } } m_ODInfo.SetWindowText(info);}void CFileProps::OnWorld() { CString wit; const char *str; GF_List *descs; WinGPAC *gpac = GetApp(); descs = gf_list_new(); str = gf_term_get_world_info(gpac->m_term, current_odm, descs); if (!str) { MessageBox("No World Info available", "Sorry!"); return; } wit = ""; for (u32 i=0; i<gf_list_count(descs); i++) { const char *d = (const char *) gf_list_get(descs, i); wit += d; wit += "\n"; } MessageBox(wit, str);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -