1 // LiveNodeInfoView.cpp 2 3 #include "LiveNodeInfoView.h" 4 // InfoView 5 #include "InfoWindowManager.h" 6 // NodeManager 7 #include "NodeGroup.h" 8 #include "NodeRef.h" 9 // Support 10 #include "MediaIcon.h" 11 #include "MediaString.h" 12 13 // Media Kit 14 #include <MediaNode.h> 15 16 // Interface Kit 17 #include <Window.h> 18 19 __USE_CORTEX_NAMESPACE 20 21 #include <Debug.h> 22 #define D_METHOD(x) //PRINT (x) 23 #define D_MESSAGE(x) //PRINT (x) 24 25 // -------------------------------------------------------- // 26 // *** ctor/dtor (public) 27 // -------------------------------------------------------- // 28 29 LiveNodeInfoView::LiveNodeInfoView( 30 const NodeRef *ref) 31 : InfoView(ref->name(), "Live Media Node", 32 new MediaIcon(ref->nodeInfo(), B_LARGE_ICON)), 33 m_nodeID(ref->id()) 34 { 35 D_METHOD(("LiveNodeInfoView::LiveNodeInfoView()\n")); 36 37 // adjust view properties 38 setSideBarWidth(be_plain_font->StringWidth(" Run Mode ") + 2 * InfoView::M_H_MARGIN); 39 40 // add "Node ID" field 41 BString s; 42 s << ref->id(); 43 addField("Node ID", s); 44 45 // add "Port" field 46 s = ""; 47 s << ref->node().port; 48 port_info portInfo; 49 if (get_port_info(ref->node().port, &portInfo) == B_OK) 50 { 51 s << " (" << portInfo.name << ")"; 52 } 53 addField("Port", s); 54 55 // add separator field 56 addField("", ""); 57 58 // add "Kinds" field 59 addField("Kinds", MediaString::getStringFor(static_cast<node_kind>(ref->kind()))); 60 61 // add "Run Mode" field 62 BMediaNode::run_mode runMode = static_cast<BMediaNode::run_mode>(ref->runMode()); 63 if (runMode < 1) 64 { 65 NodeGroup *group = ref->group(); 66 if (group) 67 { 68 runMode = group->runMode(); 69 } 70 } 71 addField("Run Mode", MediaString::getStringFor(runMode)); 72 73 // add "Latency" field 74 bigtime_t latency; 75 if (ref->totalLatency(&latency) == B_OK) 76 { 77 s = ""; 78 if (latency > 0) 79 { 80 s << static_cast<float>(latency) / 1000.0f << " ms"; 81 } 82 else 83 { 84 s = "?"; 85 } 86 addField("Latency", s); 87 } 88 } 89 90 LiveNodeInfoView::~LiveNodeInfoView() { 91 D_METHOD(("LiveNodeInfoView::~LiveNodeInfoView()\n")); 92 93 } 94 95 // -------------------------------------------------------- // 96 // *** BView implementation (public) 97 // -------------------------------------------------------- // 98 99 void LiveNodeInfoView::DetachedFromWindow() { 100 D_METHOD(("LiveNodeInfoView::DetachedFromWindow()\n")); 101 102 InfoWindowManager *manager = InfoWindowManager::Instance(); 103 if (manager) { 104 BMessage message(InfoWindowManager::M_LIVE_NODE_WINDOW_CLOSED); 105 message.AddInt32("nodeID", m_nodeID); 106 manager->PostMessage(&message); 107 } 108 } 109 110 // END -- LiveNodeInfoView.cpp -- 111