1/* 2 * Copyright (c) 1999-2000, Eric Moon. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions, and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions, and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * 3. The name of the author may not be used to endorse or promote products 17 * derived from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 32// LiveNodeInfoView.cpp 33 34#include "LiveNodeInfoView.h" 35// InfoView 36#include "InfoWindowManager.h" 37// NodeManager 38#include "NodeGroup.h" 39#include "NodeRef.h" 40// Support 41#include "MediaIcon.h" 42#include "MediaString.h" 43 44// Media Kit 45#include <MediaNode.h> 46 47// Interface Kit 48#include <Window.h> 49 50__USE_CORTEX_NAMESPACE 51 52#include <Debug.h> 53#define D_METHOD(x) //PRINT (x) 54#define D_MESSAGE(x) //PRINT (x) 55 56// -------------------------------------------------------- // 57// *** ctor/dtor (public) 58// -------------------------------------------------------- // 59 60LiveNodeInfoView::LiveNodeInfoView( 61 const NodeRef *ref) 62 : InfoView(ref->name(), "Live Media Node", 63 new MediaIcon(ref->nodeInfo(), B_LARGE_ICON)), 64 m_nodeID(ref->id()) 65{ 66 D_METHOD(("LiveNodeInfoView::LiveNodeInfoView()\n")); 67 68 // adjust view properties 69 setSideBarWidth(be_plain_font->StringWidth(" Run Mode ") + 2 * InfoView::M_H_MARGIN); 70 71 // add "Node ID" field 72 BString s; 73 s << ref->id(); 74 addField("Node ID", s); 75 76 // add "Port" field 77 s = ""; 78 s << ref->node().port; 79 port_info portInfo; 80 if (get_port_info(ref->node().port, &portInfo) == B_OK) 81 { 82 s << " (" << portInfo.name << ")"; 83 } 84 addField("Port", s); 85 86 // add separator field 87 addField("", ""); 88 89 // add "Kinds" field 90 addField("Kinds", MediaString::getStringFor(static_cast<node_kind>(ref->kind()))); 91 92 // add "Run Mode" field 93 BMediaNode::run_mode runMode = static_cast<BMediaNode::run_mode>(ref->runMode()); 94 if (runMode < 1) 95 { 96 NodeGroup *group = ref->group(); 97 if (group) 98 { 99 runMode = group->runMode(); 100 } 101 } 102 addField("Run Mode", MediaString::getStringFor(runMode)); 103 104 // add "Latency" field 105 bigtime_t latency; 106 if (ref->totalLatency(&latency) == B_OK) 107 { 108 s = ""; 109 if (latency > 0) 110 { 111 s << static_cast<float>(latency) / 1000.0f << " ms"; 112 } 113 else 114 { 115 s = "?"; 116 } 117 addField("Latency", s); 118 } 119} 120 121LiveNodeInfoView::~LiveNodeInfoView() { 122 D_METHOD(("LiveNodeInfoView::~LiveNodeInfoView()\n")); 123 124} 125 126// -------------------------------------------------------- // 127// *** BView implementation (public) 128// -------------------------------------------------------- // 129 130void LiveNodeInfoView::DetachedFromWindow() { 131 D_METHOD(("LiveNodeInfoView::DetachedFromWindow()\n")); 132 133 InfoWindowManager *manager = InfoWindowManager::Instance(); 134 if (manager) { 135 BMessage message(InfoWindowManager::M_LIVE_NODE_WINDOW_CLOSED); 136 message.AddInt32("nodeID", m_nodeID); 137 manager->PostMessage(&message); 138 } 139} 140 141// END -- LiveNodeInfoView.cpp -- 142