2
* GPAC - Multimedia Framework C SDK
4
* Copyright (c) Jean Le Feuvre 2000-2005
7
* This file is part of GPAC / Osmo4 wxWidgets GUI
9
* GPAC is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU Lesser General Public License as published by
11
* the Free Software Foundation; either version 2, or (at your option)
14
* GPAC is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU Lesser General Public License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this library; see the file COPYING. If not, write to
21
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26
#include "fileprops.h"
29
#include <wx/filename.h>
30
#include <gpac/modules/codec.h>
31
#include <gpac/modules/service.h>
32
#include <gpac/constants.h>
34
#include <gpac/iso639.h>
37
wxFileProps::wxFileProps(wxWindow *parent)
38
: wxDialog(parent, -1, wxString(_T("File Properties")))
41
m_pApp = (wxOsmo4Frame *)parent;
43
assert(m_pApp->m_pPlayList);
45
m_pTreeView = new wxTreeCtrl(this, ID_TREE_VIEW, wxPoint(4, 2), wxSize(200, 180), wxTR_DEFAULT_STYLE | wxSUNKEN_BORDER);
47
new wxStaticText(this, 0, _T("Information"), wxPoint(210, 2), wxSize(60, 20));
48
m_pViewSel = new wxComboBox(this, ID_VIEW_SEL, _T(""), wxPoint(280, 2), wxSize(120, 24), 0, NULL, wxCB_READONLY);
49
m_pViewSel->Append(wxT("General"));
50
m_pViewSel->Append(wxT("Streams"));
51
m_pViewSel->Append(wxT("Playback"));
52
m_pViewSel->Append(wxT("Network"));
53
m_pViewSel->SetSelection(0);
55
m_pViewInfo = new wxTextCtrl(this, -1, wxT(""), wxPoint(210, 30), wxSize(320, 200), wxTE_MULTILINE | wxTE_READONLY | wxHSCROLL | wxSUNKEN_BORDER);
58
m_pViewInfo->SetBackgroundColour(wxColour(wxT("LIGHT GREY")));
61
m_pViewWI = new wxButton(this, ID_VIEW_WI, wxT("View World Info"), wxPoint(4, 174), wxSize(200, 40));
62
m_pViewSG = new wxButton(this, ID_VIEW_SG, wxT("View Scene Graph"), wxPoint(4, 220), wxSize(200, 40));
65
wxString str = m_pApp->m_pPlayList->GetDisplayName();
66
str += wxT(" Properties");
69
m_pTimer = new wxTimer();
70
m_pTimer->SetOwner(this, ID_OD_TIMER);
71
m_pTimer->Start(500, 0);
76
wxFileProps::~wxFileProps()
83
BEGIN_EVENT_TABLE(wxFileProps, wxDialog)
84
EVT_TREE_ITEM_ACTIVATED(ID_TREE_VIEW, wxFileProps::OnSetSelection)
85
EVT_TREE_SEL_CHANGED(ID_TREE_VIEW, wxFileProps::OnSetSelection)
86
EVT_TREE_ITEM_EXPANDED(ID_TREE_VIEW, wxFileProps::OnSetSelection)
87
EVT_TREE_ITEM_COLLAPSED(ID_TREE_VIEW, wxFileProps::OnSetSelection)
88
EVT_TIMER(ID_OD_TIMER, wxFileProps::OnTimer)
89
EVT_BUTTON(ID_VIEW_SG, wxFileProps::OnViewSG)
90
EVT_BUTTON(ID_VIEW_WI, wxFileProps::OnViewWorld)
91
EVT_COMBOBOX(ID_VIEW_SEL, wxFileProps::OnSelectInfo)
94
void wxFileProps::RewriteODTree()
96
GF_ObjectManager *root_odm = gf_term_get_root_object(m_pApp->m_term);
97
if (!root_odm) return;
99
m_pTreeView->DeleteAllItems();
100
ODTreeData *root = new ODTreeData(root_odm);
101
m_pTreeView->AddRoot(wxT("Root OD"), -1, -1, root);
102
wxTreeItemId rootId = m_pTreeView->GetRootItem();
104
WriteInlineTree(root);
108
void wxFileProps::WriteInlineTree(ODTreeData *root)
111
u32 count = gf_term_get_object_count(m_pApp->m_term, root->m_pODMan);
113
for (u32 i=0; i<count; i++) {
114
GF_ObjectManager *odm = gf_term_get_object(m_pApp->m_term, root->m_pODMan, i);
116
ODTreeData *odd = new ODTreeData(odm);
117
m_pTreeView->AppendItem(root->GetId(), wxT("Object Descriptor"), -1, -1, odd);
119
/*if inline propagate*/
120
switch (gf_term_object_subscene_type(m_pApp->m_term, odm)) {
122
m_pTreeView->SetItemText(odd->GetId(), wxT("Root Scene"));
123
WriteInlineTree(odd);
126
m_pTreeView->SetItemText(odd->GetId(), wxT("Inline Scene"));
127
WriteInlineTree(odd);
130
m_pTreeView->SetItemText(odd->GetId(), wxT("Extern Proto Lib"));
138
void wxFileProps::OnSetSelection(wxTreeEvent& event)
140
ODTreeData *odd = (ODTreeData *) m_pTreeView->GetItemData(event.GetItem());
141
SetInfo(odd->m_pODMan);
144
void wxFileProps::SetInfo(GF_ObjectManager *odm)
148
switch (m_pViewSel->GetSelection()) {
149
case 3: SetNetworkInfo(); break;
150
case 2: SetDecoderInfo(); break;
151
case 1: SetStreamsInfo(); break;
152
default: SetGeneralInfo(); break;
156
void wxFileProps::OnTimer(wxTimerEvent& WXUNUSED(event))
158
switch (m_pViewSel->GetSelection()) {
159
case 2: SetDecoderInfo(); break;
162
void wxFileProps::OnSelectInfo(wxCommandEvent & WXUNUSED(event) )
164
SetInfo(m_current_odm);
167
void wxFileProps::SetGeneralInfo()
175
m_pViewInfo->Clear();
176
m_pViewInfo->AppendText(info);
178
if (!m_current_odm || gf_term_get_object_info(m_pApp->m_term, m_current_odm, &odi) != GF_OK) return;
180
if (odi.has_profiles) info += wxT("Initial ");
181
info += wxString::Format(wxT("Object Descriptor ID %d\n"), odi.od->objectDescriptorID);
183
h = (u32) (odi.duration / 3600);
184
m = (u32) (odi.duration / 60) - h*60;
185
s = (u32) (odi.duration) - h*3600 - m*60;
186
info += wxString::Format(wxT("Duration %02d:%02d:%02d\n"), h, m, s);
188
info += wxT("Unknown duration\n");
191
if (odi.owns_service) {
192
info += wxT("Service Handler: ") + wxString(odi.service_handler, wxConvUTF8) + wxT("\n");
193
info += wxT("Service URL: ") + wxString(odi.service_url, wxConvUTF8) + wxT("\n");
196
if (odi.od->URLString) {
197
info += wxT("Remote OD - URL: ") + wxString(odi.od->URLString, wxConvUTF8) + wxT("\n");
200
if (odi.codec_name) {
201
switch (odi.od_type) {
202
case GF_STREAM_VISUAL:
203
info += wxString::Format(wxT("Video Object: Width %d - Height %d\n"), odi.width, odi.height);
204
info += wxT("Media Codec ") + wxString(odi.codec_name, wxConvUTF8) + wxT("\n");
206
case GF_STREAM_AUDIO:
207
info += wxString::Format(wxT("Audio Object: Sample Rate %d - %d channels\n"), odi.sample_rate, odi.num_channels);
208
info += wxT("Media Codec ") + wxString(odi.codec_name, wxConvUTF8) + wxT("\n");
210
case GF_STREAM_PRIVATE_SCENE:
211
case GF_STREAM_SCENE:
212
if (odi.width && odi.height) {
213
info += wxString::Format(wxT("Scene Description: Width %d - Height %d\n"), odi.width, odi.height);
215
info += wxT("Scene Description: No size specified\n");
217
info += wxT("Scene Codec ") + wxString(odi.codec_name, wxConvUTF8) + wxT("\n");
220
if (odi.width && odi.height) {
221
info += wxString::Format(wxT("Text Object: Width %d - Height %d\n"), odi.width, odi.height);
223
info += wxString::Format(wxT("Text Object: No size specified\n"));
225
info += wxT("Text Codec ") + wxString(odi.codec_name, wxConvUTF8) + wxT("\n");
229
if (odi.protection==2) info += wxT("Encrypted Media NOT UNLOCKED");
230
else if (odi.protection==1) info += wxT("Encrypted Media");
232
if (!gf_list_count(odi.od->OCIDescriptors)) {
233
m_pViewInfo->Clear();
234
m_pViewInfo->AppendText(info);
238
info += wxT("\nObject Content Information:\n");
240
/*check OCI (not everything interests us) - FIXME: support for unicode*/
241
for (i=0; i<gf_list_count(odi.od->OCIDescriptors); i++) {
242
GF_Descriptor *desc = (GF_Descriptor *) gf_list_get(odi.od->OCIDescriptors, i);
244
case GF_ODF_SEGMENT_TAG:
246
GF_Segment *sd = (GF_Segment *) desc;
247
info += wxT("\nSegment Descriptor:\nName: ") + wxString((char *) sd->SegmentName, wxConvUTF8);
248
info += wxString::Format(wxT(" - start time %g sec - duration %g sec\n"), sd->startTime, sd->Duration);
251
case GF_ODF_CC_NAME_TAG:
253
GF_CC_Name *ccn = (GF_CC_Name *)desc;
254
info += wxT("\nContent Creators:\n");
255
for (j=0; j<gf_list_count(ccn->ContentCreators); j++) {
256
GF_ContentCreatorInfo *ci = (GF_ContentCreatorInfo *) gf_list_get(ccn->ContentCreators, j);
257
if (!ci->isUTF8) continue;
258
info += wxT("\t") + wxString(ci->contentCreatorName, wxConvUTF8) + wxT("\n");
263
case GF_ODF_SHORT_TEXT_TAG:
265
GF_ShortTextual *std = (GF_ShortTextual *)desc;
266
info += wxT("\n") + wxString(std->eventName, wxConvUTF8) + wxT(": ") + wxString(std->eventText, wxConvUTF8) + wxT("\n");
270
case GF_ODF_CC_DATE_TAG:
278
m_pViewInfo->Clear();
279
m_pViewInfo->AppendText(info);
282
void wxFileProps::SetStreamsInfo()
290
m_pViewInfo->Clear();
291
m_pViewInfo->AppendText(info);
293
if (!m_current_odm || gf_term_get_object_info(m_pApp->m_term, m_current_odm, &odi) != GF_OK) return;
295
if (odi.has_profiles) {
296
info += wxString::Format(wxT("\tOD Profile@Level %d\n"), odi.OD_pl);
297
info += wxString::Format(wxT("\tScene Profile@Level %d\n"), odi.scene_pl);
298
info += wxString::Format(wxT("\tGraphics Profile@Level %d\n"), odi.graphics_pl);
299
info += wxString::Format(wxT("\tAudio Profile@Level %d\n"), odi.audio_pl);
300
info += wxString::Format(wxT("\tVisual Profile@Level %d\n"), odi.scene_pl);
301
if (odi.inline_pl) info += wxT("\tInline Content use same profiles\n");
305
count = gf_list_count(odi.od->ESDescriptors);
307
for (i=0; i<count; i++) {
308
GF_ESD *esd = (GF_ESD *) gf_list_get(odi.od->ESDescriptors, i);
310
info += wxString::Format(wxT("Stream ID %d - Clock ID %d\n"), esd->ESID, esd->OCRESID);
311
if (esd->dependsOnESID) {
312
info += wxString::Format(wxT("\tDepends on Stream ID %d for decoding\n"), esd->dependsOnESID);
314
switch (esd->decoderConfig->streamType) {
316
info += wxString::Format(wxT("\tOD Stream - version %d\n"), esd->decoderConfig->objectTypeIndication);
319
info += wxT("\tObject Clock Reference Stream\n");
321
case GF_STREAM_SCENE:
322
info += wxString::Format(wxT("\tScene Description Stream - version %d\n"), esd->decoderConfig->objectTypeIndication);
324
case GF_STREAM_PRIVATE_SCENE:
325
info += wxString::Format(wxT("\tGPAC Private Scene Description Stream\n"));
327
case GF_STREAM_VISUAL:
328
info += wxT("\tVisual Stream - media type: ");
329
switch (esd->decoderConfig->objectTypeIndication) {
330
case GPAC_OTI_VIDEO_MPEG4_PART2: info += wxT("MPEG-4\n"); break;
331
case GPAC_OTI_VIDEO_MPEG2_SIMPLE: info += wxT("MPEG-2 Simple Profile\n"); break;
332
case GPAC_OTI_VIDEO_MPEG2_MAIN: info += wxT("MPEG-2 Main Profile\n"); break;
333
case GPAC_OTI_VIDEO_MPEG2_SNR: info += wxT("MPEG-2 SNR Profile\n"); break;
334
case GPAC_OTI_VIDEO_MPEG2_SPATIAL: info += wxT("MPEG-2 Spatial Profile\n"); break;
335
case GPAC_OTI_VIDEO_MPEG2_HIGH: info += wxT("MPEG-2 High Profile\n"); break;
336
case GPAC_OTI_VIDEO_MPEG2_422: info += wxT("MPEG-2 422 Profile\n"); break;
337
case GPAC_OTI_VIDEO_MPEG1: info += wxT("MPEG-1\n"); break;
338
case GPAC_OTI_IMAGE_JPEG: info += wxT("JPEG\n"); break;
339
case GPAC_OTI_IMAGE_PNG: info += wxT("PNG\n"); break;
340
case GPAC_OTI_IMAGE_JPEG_2000: info += wxT("JPEG2000\n"); break;
342
memcpy(code, esd->decoderConfig->decoderSpecificInfo->data, 4);
344
info += wxT("GPAC Intern (") + wxString(code, wxConvUTF8) + wxT(")\n");
347
info += wxString::Format(wxT("Private/Unknown Type (0x%x)\n"), esd->decoderConfig->objectTypeIndication);
352
case GF_STREAM_AUDIO:
353
info += wxT("\tAudio Stream - media type: ");
354
switch (esd->decoderConfig->objectTypeIndication) {
355
case GPAC_OTI_AUDIO_AAC_MPEG4: info += wxT("MPEG-4\n"); break;
356
case GPAC_OTI_AUDIO_AAC_MPEG2_MP: info += wxT("MPEG-2 AAC Main Profile\n"); break;
357
case GPAC_OTI_AUDIO_AAC_MPEG2_LCP: info += wxT("MPEG-2 AAC LowComplexity Profile\n"); break;
358
case GPAC_OTI_AUDIO_AAC_MPEG2_SSRP: info += wxT("MPEG-2 AAC Scalable Sampling Rate Profile\n"); break;
359
case GPAC_OTI_AUDIO_MPEG2_PART3: info += wxT("MPEG-2 Audio\n"); break;
360
case GPAC_OTI_AUDIO_MPEG1: info += wxT("MPEG-1 Audio\n"); break;
361
case 0xA0: info += wxT("EVRC Audio\n"); break;
362
case 0xA1: info += wxT("SMV Audio\n"); break;
363
case 0xE1: info += wxT("QCELP Audio\n"); break;
365
memcpy(code, esd->decoderConfig->decoderSpecificInfo->data, 4);
367
info += wxT("GPAC Intern (") + wxString(code, wxConvUTF8) + wxT(")\n");
370
info += wxString::Format(wxT("Private/Unknown Type (0x%x)\n"), esd->decoderConfig->objectTypeIndication);
374
case GF_STREAM_MPEG7:
375
info += wxString::Format(wxT("\tMPEG-7 Stream - version %d\n"), esd->decoderConfig->objectTypeIndication);
378
info += wxString::Format(wxT("\tIPMP Stream - version %d\n"), esd->decoderConfig->objectTypeIndication);
381
info += wxString::Format(wxT("\tOCI Stream - version %d\n"), esd->decoderConfig->objectTypeIndication);
383
case GF_STREAM_MPEGJ:
384
info += wxString::Format(wxT("\tMPEGJ Stream - version %d\n"), esd->decoderConfig->objectTypeIndication);
386
case GF_STREAM_INTERACT:
387
info += wxString::Format(wxT("\tUser Interaction Stream - version %d\n"), esd->decoderConfig->objectTypeIndication);
390
info += wxT("Private/Unknown\n");
394
info += wxString::Format(wxT("\tBuffer Size %d\n\tAverage Bitrate %d bps\n\tMaximum Bitrate %d bps\n"), esd->decoderConfig->bufferSizeDB, esd->decoderConfig->avgBitrate, esd->decoderConfig->maxBitrate);
395
if (esd->slConfig->predefined==SLPredef_SkipSL) {
396
info += wxString::Format(wxT("\tNot using MPEG-4 Synchronization Layer\n"));
398
info += wxString::Format(wxT("\tStream Clock Resolution %d\n"), esd->slConfig->timestampResolution);
401
info += wxT("\tStream Location: ") + wxString(esd->URLString, wxConvUTF8) + wxT("\n");
406
char lan[4], *szLang;
407
lan[0] = esd->langDesc->langCode>>16;
408
lan[1] = (esd->langDesc->langCode>>8)&0xFF;
409
lan[2] = (esd->langDesc->langCode)&0xFF;
412
if ((lan[0]=='u') && (lan[1]=='n') && (lan[2]=='d')) szLang = (char*) "Undetermined";
415
while (GF_ISO639_Lang[i]) {
416
if (GF_ISO639_Lang[i+2][0] && strstr(GF_ISO639_Lang[i+1], lan)) {
417
szLang = (char*) GF_ISO639_Lang[i];
423
info += wxString::Format(wxT("\tStream Language: %s\n"), szLang);
427
m_pViewInfo->Clear();
428
m_pViewInfo->AppendText(info);
432
void wxFileProps::SetDecoderInfo()
438
if (!m_current_odm || gf_term_get_object_info(m_pApp->m_term, m_current_odm, &odi)) {
439
m_pViewInfo->Clear();
440
m_pViewInfo->AppendText(info);
444
info = wxT("Status: ");
445
switch (odi.status) {
449
h = (u32) (odi.current_time / 3600);
450
m = (u32) (odi.current_time / 60) - h*60;
451
s = (u32) (odi.current_time) - h*3600 - m*60;
452
if (odi.status==0) info += wxT("Stopped");
453
else if (odi.status==1) info += wxT("Playing");
454
else info += wxT("Paused");
455
info += wxString::Format(wxT("\nObject Time: %02d:%02d:%02d\n"), h, m, s);
458
info += wxT("Not Setup\n");
459
m_pViewInfo->Clear();
460
m_pViewInfo->AppendText(info);
463
info += wxT("Setup Failed\n");
464
m_pViewInfo->Clear();
465
m_pViewInfo->AppendText(info);
469
info += wxString::Format(wxT("Clock drift: %d ms\n"), odi.clock_drift);
471
if (odi.buffer>=0) info += wxString::Format(wxT("Buffering Time: %d ms\n"), odi.buffer);
472
else if (odi.buffer==-1) info += wxT("Not buffering\n");
473
else info += wxT("Not Playing\n");
475
/*get DB occupation*/
476
if (odi.buffer>=0) info += wxString::Format(wxT("Decoding Buffer: %d Access Units\n"), odi.db_unit_count);
477
/*get CB occupation*/
478
if (odi.cb_max_count)
479
info += wxString::Format(wxT("Composition Memory: %d/%d Units\n"), odi.cb_unit_count, odi.cb_max_count);
481
Float avg_dec_time = 0;
482
if (odi.nb_dec_frames) {
483
avg_dec_time = (Float) odi.total_dec_time;
484
avg_dec_time /= odi.nb_dec_frames;
486
info += wxString::Format(wxT("Average Bitrate %d kbps (%d max)\nAverage Decoding Time %.2f ms (%d max)\nTotal decoded frames %d - %d dropped\n"),
487
(u32) odi.avg_bitrate/1024, odi.max_bitrate/1024, avg_dec_time, odi.max_dec_time, odi.nb_dec_frames, odi.nb_droped);
489
m_pViewInfo->Clear();
490
m_pViewInfo->AppendText(info);
493
void wxFileProps::SetNetworkInfo()
503
m_pViewInfo->Clear();
504
m_pViewInfo->AppendText(wxT(""));
506
if (!m_current_odm || gf_term_get_object_info(m_pApp->m_term, m_current_odm, &odi) != GF_OK) return;
508
if (odi.owns_service) {
509
const char *url, *path;
510
u32 done, total, bps;
511
info = wxT("Current Downloads in service:\n");
513
while (gf_term_get_download_info(m_pApp->m_term, m_current_odm, &d_enum, &url, &path, &done, &total, &bps)) {
514
info += wxString(url, wxConvUTF8);
516
info += wxString::Format(wxT(": %d / %d bytes (%.2f %%) - %.2f kBps\n"), done, total, (100.0*done)/total, ((Double)bps)/1024);
518
info += wxString::Format(wxT(": %.2f kBps\n"), ((Double)bps)/1024);
521
if (!d_enum) info = wxT("No Downloads in service\n");
526
while (gf_term_get_channel_net_info(m_pApp->m_term, m_current_odm, &d_enum, &id, &com, &e)) {
528
if (!com.bw_down && !com.bw_up) continue;
530
info += wxString::Format(wxT("Stream ID %d statistics:\n"), id);
531
if (com.multiplex_port) {
532
info += wxString::Format(wxT("\tMultiplex Port %d - multiplex ID %d\n"), com.multiplex_port, com.port);
534
info += wxString::Format(wxT("\tPort %d\n"), com.port);
536
info += wxString::Format(wxT("\tPacket Loss Percentage: %.4f\n"), com.pck_loss_percentage);
537
info += wxString::Format(wxT("\tDown Bandwidth: %.3f bps\n"), ((Float)com.bw_down)/1024);
538
if (com.bw_up) info += wxString::Format(wxT("\tUp Bandwidth: %d bps\n"), com.bw_up);
540
if (com.multiplex_port) {
541
info += wxString::Format(wxT("\tControl Multiplex Port: %d - Control Multiplex ID %d\n"), com.multiplex_port, com.ctrl_port);
543
info += wxString::Format(wxT("\tControl Port: %d\n"), com.ctrl_port);
545
info += wxString::Format(wxT("\tControl Down Bandwidth: %d bps\n"), com.ctrl_bw_down);
546
info += wxString::Format(wxT("\tControl Up Bandwidth: %d bps\n"), com.ctrl_bw_up);
550
m_pViewInfo->Clear();
551
m_pViewInfo->AppendText(info);
555
void wxFileProps::OnViewWorld(wxCommandEvent &WXUNUSED(event))
560
descs = gf_list_new();
561
str = gf_term_get_world_info(m_pApp->m_term, m_current_odm, descs);
564
wxMessageDialog(this, wxT("No World Info available"), wxT("Sorry!"), wxOK).ShowModal();
569
for (u32 i=0; gf_list_count(descs); i++) {
570
const char *d = (const char *) gf_list_get(descs, i);
571
wit += wxString(d, wxConvUTF8);
574
wxMessageDialog(this, wit, wxString(str, wxConvUTF8), wxOK).ShowModal();
578
void wxFileProps::OnViewSG(wxCommandEvent &WXUNUSED(event))
583
char szOutFile[GF_MAX_PATH];
586
sOpt = gf_cfg_get_key(m_pApp->m_user.config, "General", "CacheDirectory");
587
out_file.AssignDir(wxString(sOpt, wxConvUTF8) );
589
sOpt = gf_cfg_get_key(m_pApp->m_user.config, "General", "ViewXMT");
590
out_file.SetFullName(wxT("scene_dump"));
591
if (sOpt && !stricmp(sOpt, "yes")) {
596
strcpy(szOutFile, out_file.GetFullName().mb_str(wxConvUTF8));
598
GF_Err e = gf_term_dump_scene(m_pApp->m_term, szOutFile, NULL, dump_xmt, 0, m_current_odm);
600
wxMessageDialog dlg(this, wxString(gf_error_to_string(e), wxConvUTF8), wxT("Error while dumping"), wxOK);
603
wxString cmd = get_pref_browser(m_pApp->m_user.config);
605
cmd += wxString(szOutFile, wxConvUTF8);