1*a0795c6fSMarcus Overhagen // ConnectionIO.cpp 2*a0795c6fSMarcus Overhagen 3*a0795c6fSMarcus Overhagen #include "ConnectionIO.h" 4*a0795c6fSMarcus Overhagen #include "LiveNodeIO.h" 5*a0795c6fSMarcus Overhagen #include "NodeManager.h" 6*a0795c6fSMarcus Overhagen #include "NodeSetIOContext.h" 7*a0795c6fSMarcus Overhagen 8*a0795c6fSMarcus Overhagen #include "MediaFormatIO.h" 9*a0795c6fSMarcus Overhagen #include "route_app_io.h" 10*a0795c6fSMarcus Overhagen 11*a0795c6fSMarcus Overhagen #include <vector> 12*a0795c6fSMarcus Overhagen #include <Debug.h> 13*a0795c6fSMarcus Overhagen 14*a0795c6fSMarcus Overhagen __USE_CORTEX_NAMESPACE 15*a0795c6fSMarcus Overhagen 16*a0795c6fSMarcus Overhagen // -------------------------------------------------------- // 17*a0795c6fSMarcus Overhagen // *** ctor/dtor 18*a0795c6fSMarcus Overhagen // -------------------------------------------------------- // 19*a0795c6fSMarcus Overhagen 20*a0795c6fSMarcus Overhagen ConnectionIO::~ConnectionIO() { 21*a0795c6fSMarcus Overhagen if(m_inputNodeIO) delete m_inputNodeIO; 22*a0795c6fSMarcus Overhagen if(m_outputNodeIO) delete m_outputNodeIO; 23*a0795c6fSMarcus Overhagen } 24*a0795c6fSMarcus Overhagen 25*a0795c6fSMarcus Overhagen // initialize for import 26*a0795c6fSMarcus Overhagen ConnectionIO::ConnectionIO() : 27*a0795c6fSMarcus Overhagen m_inputNodeIO(0), 28*a0795c6fSMarcus Overhagen m_outputNodeIO(0), 29*a0795c6fSMarcus Overhagen m_flags(0), 30*a0795c6fSMarcus Overhagen m_exportValid(false), 31*a0795c6fSMarcus Overhagen m_importState(IMPORT_NONE) { 32*a0795c6fSMarcus Overhagen 33*a0795c6fSMarcus Overhagen m_outputFormat.type = B_MEDIA_NO_TYPE; 34*a0795c6fSMarcus Overhagen m_inputFormat.type = B_MEDIA_NO_TYPE; 35*a0795c6fSMarcus Overhagen m_requestedFormat.type = B_MEDIA_NO_TYPE; 36*a0795c6fSMarcus Overhagen } 37*a0795c6fSMarcus Overhagen 38*a0795c6fSMarcus Overhagen // initialize for export 39*a0795c6fSMarcus Overhagen ConnectionIO::ConnectionIO( 40*a0795c6fSMarcus Overhagen const Connection* con, 41*a0795c6fSMarcus Overhagen const NodeManager* manager, 42*a0795c6fSMarcus Overhagen const NodeSetIOContext* context) : 43*a0795c6fSMarcus Overhagen 44*a0795c6fSMarcus Overhagen m_inputNodeIO(0), 45*a0795c6fSMarcus Overhagen m_outputNodeIO(0), 46*a0795c6fSMarcus Overhagen m_exportValid(false), 47*a0795c6fSMarcus Overhagen m_importState(IMPORT_NONE) { 48*a0795c6fSMarcus Overhagen 49*a0795c6fSMarcus Overhagen ASSERT(con); 50*a0795c6fSMarcus Overhagen ASSERT(manager); 51*a0795c6fSMarcus Overhagen ASSERT(context); 52*a0795c6fSMarcus Overhagen status_t err; 53*a0795c6fSMarcus Overhagen 54*a0795c6fSMarcus Overhagen if(!con->isValid()) { 55*a0795c6fSMarcus Overhagen PRINT(( 56*a0795c6fSMarcus Overhagen "!!! ConnectionIO(): invalid connection\n")); 57*a0795c6fSMarcus Overhagen return; 58*a0795c6fSMarcus Overhagen } 59*a0795c6fSMarcus Overhagen 60*a0795c6fSMarcus Overhagen m_outputNodeIO = new LiveNodeIO( 61*a0795c6fSMarcus Overhagen manager, 62*a0795c6fSMarcus Overhagen context, 63*a0795c6fSMarcus Overhagen con->sourceNode()); 64*a0795c6fSMarcus Overhagen 65*a0795c6fSMarcus Overhagen // fetch output (connection-point) description 66*a0795c6fSMarcus Overhagen const char* name; 67*a0795c6fSMarcus Overhagen if(con->getOutputHint( 68*a0795c6fSMarcus Overhagen &name, 69*a0795c6fSMarcus Overhagen &m_outputFormat) == B_OK) 70*a0795c6fSMarcus Overhagen m_outputName = name; 71*a0795c6fSMarcus Overhagen else { 72*a0795c6fSMarcus Overhagen m_outputName = con->outputName(); 73*a0795c6fSMarcus Overhagen } 74*a0795c6fSMarcus Overhagen 75*a0795c6fSMarcus Overhagen m_inputNodeIO = new LiveNodeIO( 76*a0795c6fSMarcus Overhagen manager, 77*a0795c6fSMarcus Overhagen context, 78*a0795c6fSMarcus Overhagen con->destinationNode()); 79*a0795c6fSMarcus Overhagen 80*a0795c6fSMarcus Overhagen // fetch input (connection-point) description 81*a0795c6fSMarcus Overhagen if(con->getInputHint( 82*a0795c6fSMarcus Overhagen &name, 83*a0795c6fSMarcus Overhagen &m_inputFormat) == B_OK) 84*a0795c6fSMarcus Overhagen m_inputName = name; 85*a0795c6fSMarcus Overhagen 86*a0795c6fSMarcus Overhagen else { 87*a0795c6fSMarcus Overhagen m_inputName = con->inputName(); 88*a0795c6fSMarcus Overhagen } 89*a0795c6fSMarcus Overhagen 90*a0795c6fSMarcus Overhagen m_requestedFormat = con->requestedFormat(); 91*a0795c6fSMarcus Overhagen m_flags = con->flags(); 92*a0795c6fSMarcus Overhagen 93*a0795c6fSMarcus Overhagen m_exportValid = true; 94*a0795c6fSMarcus Overhagen } 95*a0795c6fSMarcus Overhagen 96*a0795c6fSMarcus Overhagen // -------------------------------------------------------- // 97*a0795c6fSMarcus Overhagen // *** operations 98*a0795c6fSMarcus Overhagen // -------------------------------------------------------- // 99*a0795c6fSMarcus Overhagen 100*a0795c6fSMarcus Overhagen // call when object imported to create the described 101*a0795c6fSMarcus Overhagen // connection 102*a0795c6fSMarcus Overhagen 103*a0795c6fSMarcus Overhagen // +++++ to do 104*a0795c6fSMarcus Overhagen // smarter input/output matching -- if no name/format provided, 105*a0795c6fSMarcus Overhagen // pick the first available endpoint. otherwise, make two passes: 106*a0795c6fSMarcus Overhagen // 1) match all nodes w/ given name (pass wildcards through to roster) 107*a0795c6fSMarcus Overhagen // 2) filter by format 108*a0795c6fSMarcus Overhagen 109*a0795c6fSMarcus Overhagen status_t ConnectionIO::instantiate( 110*a0795c6fSMarcus Overhagen NodeManager* manager, 111*a0795c6fSMarcus Overhagen const NodeSetIOContext* context, 112*a0795c6fSMarcus Overhagen Connection* outCon) { 113*a0795c6fSMarcus Overhagen 114*a0795c6fSMarcus Overhagen // sanity checks 115*a0795c6fSMarcus Overhagen ASSERT(manager); 116*a0795c6fSMarcus Overhagen if(!m_inputNodeIO || !m_outputNodeIO) 117*a0795c6fSMarcus Overhagen return B_NOT_ALLOWED; 118*a0795c6fSMarcus Overhagen 119*a0795c6fSMarcus Overhagen status_t err; 120*a0795c6fSMarcus Overhagen media_node_id node; 121*a0795c6fSMarcus Overhagen 122*a0795c6fSMarcus Overhagen // find output node 123*a0795c6fSMarcus Overhagen NodeRef* outputRef; 124*a0795c6fSMarcus Overhagen err = m_outputNodeIO->getNode(manager, context, &node); 125*a0795c6fSMarcus Overhagen if(err < B_OK) 126*a0795c6fSMarcus Overhagen return err; 127*a0795c6fSMarcus Overhagen err = manager->getNodeRef( 128*a0795c6fSMarcus Overhagen node, 129*a0795c6fSMarcus Overhagen &outputRef); 130*a0795c6fSMarcus Overhagen if(err < B_OK) 131*a0795c6fSMarcus Overhagen return err; 132*a0795c6fSMarcus Overhagen 133*a0795c6fSMarcus Overhagen // find output +++++ currently matches by name only 134*a0795c6fSMarcus Overhagen const int32 outputBufferSize = 16; 135*a0795c6fSMarcus Overhagen media_output outputs[outputBufferSize]; 136*a0795c6fSMarcus Overhagen int32 count = outputBufferSize; 137*a0795c6fSMarcus Overhagen 138*a0795c6fSMarcus Overhagen //vector<media_output> outputs; 139*a0795c6fSMarcus Overhagen // err = outputRef->getFreeOutputs( 140*a0795c6fSMarcus Overhagen // outputs/*, 141*a0795c6fSMarcus Overhagen // m_outputFormat.type*/); 142*a0795c6fSMarcus Overhagen 143*a0795c6fSMarcus Overhagen err = outputRef->getFreeOutputs( 144*a0795c6fSMarcus Overhagen outputs, 145*a0795c6fSMarcus Overhagen outputBufferSize, 146*a0795c6fSMarcus Overhagen &count); 147*a0795c6fSMarcus Overhagen if(err < B_OK) 148*a0795c6fSMarcus Overhagen return err; 149*a0795c6fSMarcus Overhagen 150*a0795c6fSMarcus Overhagen media_output output; 151*a0795c6fSMarcus Overhagen bool found = false; 152*a0795c6fSMarcus Overhagen for(int n = 0; n < count; ++n) { 153*a0795c6fSMarcus Overhagen if(m_outputName == outputs[n].name) { 154*a0795c6fSMarcus Overhagen output = outputs[n]; 155*a0795c6fSMarcus Overhagen found = true; 156*a0795c6fSMarcus Overhagen break; 157*a0795c6fSMarcus Overhagen } 158*a0795c6fSMarcus Overhagen } 159*a0795c6fSMarcus Overhagen if(!found) { 160*a0795c6fSMarcus Overhagen PRINT(("!!! output '%s' of node '%s' not found\n", 161*a0795c6fSMarcus Overhagen m_outputName.String(), 162*a0795c6fSMarcus Overhagen outputRef->name())); 163*a0795c6fSMarcus Overhagen return B_NAME_NOT_FOUND; 164*a0795c6fSMarcus Overhagen } 165*a0795c6fSMarcus Overhagen 166*a0795c6fSMarcus Overhagen // find input node 167*a0795c6fSMarcus Overhagen NodeRef* inputRef; 168*a0795c6fSMarcus Overhagen err = m_inputNodeIO->getNode(manager, context, &node); 169*a0795c6fSMarcus Overhagen if(err < B_OK) 170*a0795c6fSMarcus Overhagen return err; 171*a0795c6fSMarcus Overhagen err = manager->getNodeRef( 172*a0795c6fSMarcus Overhagen node, 173*a0795c6fSMarcus Overhagen &inputRef); 174*a0795c6fSMarcus Overhagen if(err < B_OK) 175*a0795c6fSMarcus Overhagen return err; 176*a0795c6fSMarcus Overhagen 177*a0795c6fSMarcus Overhagen // find input +++++ currently matches by name only 178*a0795c6fSMarcus Overhagen vector<media_input> inputs; 179*a0795c6fSMarcus Overhagen err = inputRef->getFreeInputs( 180*a0795c6fSMarcus Overhagen inputs /*, 181*a0795c6fSMarcus Overhagen m_inputFormat.type*/); 182*a0795c6fSMarcus Overhagen if(err < B_OK) 183*a0795c6fSMarcus Overhagen return err; 184*a0795c6fSMarcus Overhagen 185*a0795c6fSMarcus Overhagen media_input input; 186*a0795c6fSMarcus Overhagen found = false; 187*a0795c6fSMarcus Overhagen for(unsigned int n = 0; n < inputs.size(); ++n) { 188*a0795c6fSMarcus Overhagen if(m_inputName == inputs[n].name) { 189*a0795c6fSMarcus Overhagen input = inputs[n]; 190*a0795c6fSMarcus Overhagen found = true; 191*a0795c6fSMarcus Overhagen break; 192*a0795c6fSMarcus Overhagen } 193*a0795c6fSMarcus Overhagen } 194*a0795c6fSMarcus Overhagen if(!found) { 195*a0795c6fSMarcus Overhagen PRINT(("!!! input '%s' of node '%s' not found\n", 196*a0795c6fSMarcus Overhagen m_inputName.String(), 197*a0795c6fSMarcus Overhagen inputRef->name())); 198*a0795c6fSMarcus Overhagen return B_NAME_NOT_FOUND; 199*a0795c6fSMarcus Overhagen } 200*a0795c6fSMarcus Overhagen 201*a0795c6fSMarcus Overhagen // connect 202*a0795c6fSMarcus Overhagen Connection con; 203*a0795c6fSMarcus Overhagen if(m_requestedFormat.type != B_MEDIA_NO_TYPE) 204*a0795c6fSMarcus Overhagen err = manager->connect( 205*a0795c6fSMarcus Overhagen output, 206*a0795c6fSMarcus Overhagen input, 207*a0795c6fSMarcus Overhagen m_requestedFormat, 208*a0795c6fSMarcus Overhagen &con); 209*a0795c6fSMarcus Overhagen else 210*a0795c6fSMarcus Overhagen err = manager->connect( 211*a0795c6fSMarcus Overhagen output, 212*a0795c6fSMarcus Overhagen input, 213*a0795c6fSMarcus Overhagen &con); 214*a0795c6fSMarcus Overhagen 215*a0795c6fSMarcus Overhagen if(err < B_OK) 216*a0795c6fSMarcus Overhagen return err; 217*a0795c6fSMarcus Overhagen 218*a0795c6fSMarcus Overhagen if(outCon) 219*a0795c6fSMarcus Overhagen *outCon = con; 220*a0795c6fSMarcus Overhagen return B_OK; 221*a0795c6fSMarcus Overhagen } 222*a0795c6fSMarcus Overhagen 223*a0795c6fSMarcus Overhagen // -------------------------------------------------------- // 224*a0795c6fSMarcus Overhagen // *** document-type setup 225*a0795c6fSMarcus Overhagen // -------------------------------------------------------- // 226*a0795c6fSMarcus Overhagen 227*a0795c6fSMarcus Overhagen /*static*/ 228*a0795c6fSMarcus Overhagen void ConnectionIO::AddTo( 229*a0795c6fSMarcus Overhagen XML::DocumentType* docType) { 230*a0795c6fSMarcus Overhagen 231*a0795c6fSMarcus Overhagen // map self 232*a0795c6fSMarcus Overhagen docType->addMapping(new Mapping<ConnectionIO>(_CONNECTION_ELEMENT)); 233*a0795c6fSMarcus Overhagen 234*a0795c6fSMarcus Overhagen // map simple (content-only) elements 235*a0795c6fSMarcus Overhagen // +++++ should these be added at a higher level, since they're 236*a0795c6fSMarcus Overhagen // shared? no harm is done if one is added more than once, 237*a0795c6fSMarcus Overhagen // since they'll always map to StringContent -- but it's way 238*a0795c6fSMarcus Overhagen // messy! 239*a0795c6fSMarcus Overhagen // +++++ 240*a0795c6fSMarcus Overhagen //docType->addMapping(new Mapping<StringContent>(_LIVE_NODE_ELEMENT)); 241*a0795c6fSMarcus Overhagen // docType->addMapping(new Mapping<StringContent>(_NAME_ELEMENT)); 242*a0795c6fSMarcus Overhagen // docType->addMapping(new Mapping<StringContent>(_KIND_ELEMENT)); 243*a0795c6fSMarcus Overhagen // docType->addMapping(new Mapping<StringContent>(_FLAG_ELEMENT)); 244*a0795c6fSMarcus Overhagen } 245*a0795c6fSMarcus Overhagen 246*a0795c6fSMarcus Overhagen // -------------------------------------------------------- // 247*a0795c6fSMarcus Overhagen // *** IPersistent 248*a0795c6fSMarcus Overhagen // -------------------------------------------------------- // 249*a0795c6fSMarcus Overhagen 250*a0795c6fSMarcus Overhagen // -------------------------------------------------------- // 251*a0795c6fSMarcus Overhagen // EXPORT: 252*a0795c6fSMarcus Overhagen // -------------------------------------------------------- // 253*a0795c6fSMarcus Overhagen 254*a0795c6fSMarcus Overhagen 255*a0795c6fSMarcus Overhagen // -------------------------------------------------------- // 256*a0795c6fSMarcus Overhagen void ConnectionIO::xmlExportBegin( 257*a0795c6fSMarcus Overhagen ExportContext& context) const { 258*a0795c6fSMarcus Overhagen 259*a0795c6fSMarcus Overhagen if(!m_exportValid) { 260*a0795c6fSMarcus Overhagen context.reportError( 261*a0795c6fSMarcus Overhagen "ConnectionIO::xmlExportBegin():\n" 262*a0795c6fSMarcus Overhagen "*** invalid ***\n"); 263*a0795c6fSMarcus Overhagen return; 264*a0795c6fSMarcus Overhagen } 265*a0795c6fSMarcus Overhagen 266*a0795c6fSMarcus Overhagen context.beginElement(_CONNECTION_ELEMENT); 267*a0795c6fSMarcus Overhagen } 268*a0795c6fSMarcus Overhagen 269*a0795c6fSMarcus Overhagen void ConnectionIO::xmlExportAttributes( 270*a0795c6fSMarcus Overhagen ExportContext& context) const { TOUCH(context); } 271*a0795c6fSMarcus Overhagen 272*a0795c6fSMarcus Overhagen void ConnectionIO::xmlExportContent( 273*a0795c6fSMarcus Overhagen ExportContext& context) const { 274*a0795c6fSMarcus Overhagen 275*a0795c6fSMarcus Overhagen context.beginContent(); 276*a0795c6fSMarcus Overhagen 277*a0795c6fSMarcus Overhagen // write output 278*a0795c6fSMarcus Overhagen { 279*a0795c6fSMarcus Overhagen context.beginElement(_OUTPUT_ELEMENT); 280*a0795c6fSMarcus Overhagen context.beginContent(); 281*a0795c6fSMarcus Overhagen 282*a0795c6fSMarcus Overhagen // describe the node 283*a0795c6fSMarcus Overhagen // LiveNodeIO nodeIO( 284*a0795c6fSMarcus Overhagen // m_manager, 285*a0795c6fSMarcus Overhagen // dynamic_cast<NodeSetIOContext*>(&context), 286*a0795c6fSMarcus Overhagen // m_outputNode); 287*a0795c6fSMarcus Overhagen context.writeObject(m_outputNodeIO); 288*a0795c6fSMarcus Overhagen 289*a0795c6fSMarcus Overhagen // context.beginElement(_LIVE_NODE_ELEMENT); 290*a0795c6fSMarcus Overhagen // if(m_outputNodeKey.Length()) { 291*a0795c6fSMarcus Overhagen // context.writeAttr("key", m_outputNodeKey); 292*a0795c6fSMarcus Overhagen // } 293*a0795c6fSMarcus Overhagen // else { 294*a0795c6fSMarcus Overhagen // _write_simple("name", m_outputNodeName.String(), context); 295*a0795c6fSMarcus Overhagen // _write_node_kinds(m_outputNodeKind, context); 296*a0795c6fSMarcus Overhagen // } 297*a0795c6fSMarcus Overhagen // context.endElement(); // _LIVE_NODE_ELEMENT 298*a0795c6fSMarcus Overhagen 299*a0795c6fSMarcus Overhagen // describe the output 300*a0795c6fSMarcus Overhagen 301*a0795c6fSMarcus Overhagen _write_simple("name", m_outputName.String(), context); 302*a0795c6fSMarcus Overhagen 303*a0795c6fSMarcus Overhagen if(m_outputFormat.type > B_MEDIA_UNKNOWN_TYPE) { 304*a0795c6fSMarcus Overhagen MediaFormatIO io(m_outputFormat); 305*a0795c6fSMarcus Overhagen context.writeObject(&io); 306*a0795c6fSMarcus Overhagen } 307*a0795c6fSMarcus Overhagen 308*a0795c6fSMarcus Overhagen context.endElement(); // _OUTPUT_ELEMENT 309*a0795c6fSMarcus Overhagen } 310*a0795c6fSMarcus Overhagen 311*a0795c6fSMarcus Overhagen // write input 312*a0795c6fSMarcus Overhagen { 313*a0795c6fSMarcus Overhagen context.beginElement(_INPUT_ELEMENT); 314*a0795c6fSMarcus Overhagen context.beginContent(); 315*a0795c6fSMarcus Overhagen 316*a0795c6fSMarcus Overhagen // describe the node 317*a0795c6fSMarcus Overhagen // LiveNodeIO nodeIO( 318*a0795c6fSMarcus Overhagen // m_manager, 319*a0795c6fSMarcus Overhagen // dynamic_cast<NodeSetIOContext*>(&context), 320*a0795c6fSMarcus Overhagen // m_inputNode); 321*a0795c6fSMarcus Overhagen context.writeObject(m_inputNodeIO); 322*a0795c6fSMarcus Overhagen 323*a0795c6fSMarcus Overhagen // context.beginElement(_LIVE_NODE_ELEMENT); 324*a0795c6fSMarcus Overhagen // if(m_inputNodeKey.Length()) { 325*a0795c6fSMarcus Overhagen // context.writeAttr("key", m_inputNodeKey); 326*a0795c6fSMarcus Overhagen // } 327*a0795c6fSMarcus Overhagen // else { 328*a0795c6fSMarcus Overhagen // _write_simple("name", m_inputNodeName.String(), context); 329*a0795c6fSMarcus Overhagen // _write_node_kinds(m_inputNodeKind, context); 330*a0795c6fSMarcus Overhagen // } 331*a0795c6fSMarcus Overhagen // context.endElement(); // _LIVE_NODE_ELEMENT 332*a0795c6fSMarcus Overhagen 333*a0795c6fSMarcus Overhagen // describe the input 334*a0795c6fSMarcus Overhagen 335*a0795c6fSMarcus Overhagen _write_simple("name", m_inputName.String(), context); 336*a0795c6fSMarcus Overhagen 337*a0795c6fSMarcus Overhagen if(m_inputFormat.type > B_MEDIA_UNKNOWN_TYPE) { 338*a0795c6fSMarcus Overhagen MediaFormatIO io(m_inputFormat); 339*a0795c6fSMarcus Overhagen context.writeObject(&io); 340*a0795c6fSMarcus Overhagen } 341*a0795c6fSMarcus Overhagen 342*a0795c6fSMarcus Overhagen context.endElement(); // _INPUT_ELEMENT 343*a0795c6fSMarcus Overhagen } 344*a0795c6fSMarcus Overhagen 345*a0795c6fSMarcus Overhagen // write requested format 346*a0795c6fSMarcus Overhagen if(m_requestedFormat.type > B_MEDIA_UNKNOWN_TYPE) { 347*a0795c6fSMarcus Overhagen MediaFormatIO io(m_requestedFormat); 348*a0795c6fSMarcus Overhagen BString comment = "\n"; 349*a0795c6fSMarcus Overhagen comment << context.indentString(); 350*a0795c6fSMarcus Overhagen comment << "<!-- initial requested format -->"; 351*a0795c6fSMarcus Overhagen context.writeString(comment); 352*a0795c6fSMarcus Overhagen context.writeObject(&io); 353*a0795c6fSMarcus Overhagen } 354*a0795c6fSMarcus Overhagen } 355*a0795c6fSMarcus Overhagen 356*a0795c6fSMarcus Overhagen void ConnectionIO::xmlExportEnd( 357*a0795c6fSMarcus Overhagen ExportContext& context) const { 358*a0795c6fSMarcus Overhagen 359*a0795c6fSMarcus Overhagen context.endElement(); // _CONNECTION_ELEMENT 360*a0795c6fSMarcus Overhagen } 361*a0795c6fSMarcus Overhagen 362*a0795c6fSMarcus Overhagen // -------------------------------------------------------- // 363*a0795c6fSMarcus Overhagen // IMPORT: 364*a0795c6fSMarcus Overhagen // -------------------------------------------------------- // 365*a0795c6fSMarcus Overhagen 366*a0795c6fSMarcus Overhagen void ConnectionIO::xmlImportBegin( 367*a0795c6fSMarcus Overhagen ImportContext& context) { TOUCH(context); } 368*a0795c6fSMarcus Overhagen 369*a0795c6fSMarcus Overhagen void ConnectionIO::xmlImportAttribute( 370*a0795c6fSMarcus Overhagen const char* key, 371*a0795c6fSMarcus Overhagen const char* value, 372*a0795c6fSMarcus Overhagen ImportContext& context) { TOUCH(key); TOUCH(value); TOUCH(context); } 373*a0795c6fSMarcus Overhagen 374*a0795c6fSMarcus Overhagen void ConnectionIO::xmlImportContent( 375*a0795c6fSMarcus Overhagen const char* data, 376*a0795c6fSMarcus Overhagen uint32 length, 377*a0795c6fSMarcus Overhagen ImportContext& context) { TOUCH(data); TOUCH(length); TOUCH(context); } 378*a0795c6fSMarcus Overhagen 379*a0795c6fSMarcus Overhagen void ConnectionIO::xmlImportChild( 380*a0795c6fSMarcus Overhagen IPersistent* child, 381*a0795c6fSMarcus Overhagen ImportContext& context) { 382*a0795c6fSMarcus Overhagen 383*a0795c6fSMarcus Overhagen status_t err; 384*a0795c6fSMarcus Overhagen 385*a0795c6fSMarcus Overhagen if(!strcmp(context.element(), _LIVE_NODE_ELEMENT)) { 386*a0795c6fSMarcus Overhagen LiveNodeIO* nodeIO = dynamic_cast<LiveNodeIO*>(child); 387*a0795c6fSMarcus Overhagen ASSERT(nodeIO); 388*a0795c6fSMarcus Overhagen 389*a0795c6fSMarcus Overhagen // store the LiveNodeIO for now; it will be used in 390*a0795c6fSMarcus Overhagen // instantiate() 391*a0795c6fSMarcus Overhagen 392*a0795c6fSMarcus Overhagen switch(m_importState) { 393*a0795c6fSMarcus Overhagen case IMPORT_OUTPUT: 394*a0795c6fSMarcus Overhagen m_outputNodeIO = nodeIO; 395*a0795c6fSMarcus Overhagen child = 0; // don't delete child object 396*a0795c6fSMarcus Overhagen break; 397*a0795c6fSMarcus Overhagen 398*a0795c6fSMarcus Overhagen case IMPORT_INPUT: 399*a0795c6fSMarcus Overhagen m_inputNodeIO = nodeIO; 400*a0795c6fSMarcus Overhagen child = 0; // don't delete child object 401*a0795c6fSMarcus Overhagen break; 402*a0795c6fSMarcus Overhagen 403*a0795c6fSMarcus Overhagen case IMPORT_NONE: 404*a0795c6fSMarcus Overhagen context.reportError("Unexpected node description.\n"); 405*a0795c6fSMarcus Overhagen delete child; 406*a0795c6fSMarcus Overhagen return; 407*a0795c6fSMarcus Overhagen } 408*a0795c6fSMarcus Overhagen } 409*a0795c6fSMarcus Overhagen else if(!strcmp(context.element(), _NAME_ELEMENT)) { 410*a0795c6fSMarcus Overhagen StringContent* c = dynamic_cast<StringContent*>(child); 411*a0795c6fSMarcus Overhagen ASSERT(c); 412*a0795c6fSMarcus Overhagen 413*a0795c6fSMarcus Overhagen switch(m_importState) { 414*a0795c6fSMarcus Overhagen case IMPORT_OUTPUT: 415*a0795c6fSMarcus Overhagen m_outputName = c->content; 416*a0795c6fSMarcus Overhagen break; 417*a0795c6fSMarcus Overhagen 418*a0795c6fSMarcus Overhagen case IMPORT_INPUT: 419*a0795c6fSMarcus Overhagen m_inputName = c->content; 420*a0795c6fSMarcus Overhagen break; 421*a0795c6fSMarcus Overhagen 422*a0795c6fSMarcus Overhagen case IMPORT_NONE: 423*a0795c6fSMarcus Overhagen context.reportError("Unexpected node name.\n"); 424*a0795c6fSMarcus Overhagen delete child; 425*a0795c6fSMarcus Overhagen return; 426*a0795c6fSMarcus Overhagen } 427*a0795c6fSMarcus Overhagen } 428*a0795c6fSMarcus Overhagen else { 429*a0795c6fSMarcus Overhagen MediaFormatIO* io = dynamic_cast<MediaFormatIO*>(child); 430*a0795c6fSMarcus Overhagen if(!io) { 431*a0795c6fSMarcus Overhagen context.reportError("Unexpected element.\n"); 432*a0795c6fSMarcus Overhagen delete child; 433*a0795c6fSMarcus Overhagen return; 434*a0795c6fSMarcus Overhagen } 435*a0795c6fSMarcus Overhagen 436*a0795c6fSMarcus Overhagen media_format f; 437*a0795c6fSMarcus Overhagen err = io->getFormat(f); 438*a0795c6fSMarcus Overhagen if(err < B_OK) { 439*a0795c6fSMarcus Overhagen context.reportError("Malformed format.\n"); 440*a0795c6fSMarcus Overhagen delete child; 441*a0795c6fSMarcus Overhagen return; 442*a0795c6fSMarcus Overhagen } 443*a0795c6fSMarcus Overhagen 444*a0795c6fSMarcus Overhagen switch(m_importState) { 445*a0795c6fSMarcus Overhagen case IMPORT_OUTPUT: 446*a0795c6fSMarcus Overhagen m_outputFormat = f; 447*a0795c6fSMarcus Overhagen break; 448*a0795c6fSMarcus Overhagen 449*a0795c6fSMarcus Overhagen case IMPORT_INPUT: 450*a0795c6fSMarcus Overhagen m_inputFormat = f; 451*a0795c6fSMarcus Overhagen break; 452*a0795c6fSMarcus Overhagen 453*a0795c6fSMarcus Overhagen case IMPORT_NONE: 454*a0795c6fSMarcus Overhagen m_requestedFormat = f; 455*a0795c6fSMarcus Overhagen break; 456*a0795c6fSMarcus Overhagen } 457*a0795c6fSMarcus Overhagen } 458*a0795c6fSMarcus Overhagen 459*a0795c6fSMarcus Overhagen if(child) 460*a0795c6fSMarcus Overhagen delete child; 461*a0795c6fSMarcus Overhagen } 462*a0795c6fSMarcus Overhagen 463*a0795c6fSMarcus Overhagen void ConnectionIO::xmlImportComplete( 464*a0795c6fSMarcus Overhagen ImportContext& context) { 465*a0795c6fSMarcus Overhagen 466*a0795c6fSMarcus Overhagen // +++++ 467*a0795c6fSMarcus Overhagen } 468*a0795c6fSMarcus Overhagen 469*a0795c6fSMarcus Overhagen void ConnectionIO::xmlImportChildBegin( 470*a0795c6fSMarcus Overhagen const char* name, 471*a0795c6fSMarcus Overhagen ImportContext& context) { 472*a0795c6fSMarcus Overhagen 473*a0795c6fSMarcus Overhagen if(!strcmp(name, "input")) { 474*a0795c6fSMarcus Overhagen if(m_importState != IMPORT_NONE) { 475*a0795c6fSMarcus Overhagen context.reportError("ConnectionIO: unexpected nested child element\n"); 476*a0795c6fSMarcus Overhagen return; 477*a0795c6fSMarcus Overhagen } 478*a0795c6fSMarcus Overhagen m_importState = IMPORT_INPUT; 479*a0795c6fSMarcus Overhagen } 480*a0795c6fSMarcus Overhagen else if(!strcmp(name, "output")) { 481*a0795c6fSMarcus Overhagen if(m_importState != IMPORT_NONE) { 482*a0795c6fSMarcus Overhagen context.reportError("ConnectionIO: unexpected nested child element\n"); 483*a0795c6fSMarcus Overhagen return; 484*a0795c6fSMarcus Overhagen } 485*a0795c6fSMarcus Overhagen m_importState = IMPORT_OUTPUT; 486*a0795c6fSMarcus Overhagen } 487*a0795c6fSMarcus Overhagen else 488*a0795c6fSMarcus Overhagen context.reportError("ConnectionIO: unexpected child element\n"); 489*a0795c6fSMarcus Overhagen } 490*a0795c6fSMarcus Overhagen 491*a0795c6fSMarcus Overhagen void ConnectionIO::xmlImportChildComplete( 492*a0795c6fSMarcus Overhagen const char* name, 493*a0795c6fSMarcus Overhagen ImportContext& context) { 494*a0795c6fSMarcus Overhagen TOUCH(name); TOUCH(context); 495*a0795c6fSMarcus Overhagen 496*a0795c6fSMarcus Overhagen m_importState = IMPORT_NONE; 497*a0795c6fSMarcus Overhagen } 498*a0795c6fSMarcus Overhagen 499*a0795c6fSMarcus Overhagen // END -- ConnectionIO.cpp --