// +++++ broken? status_t NodeRef::getConnectedInputs( vector<media_input>& ioInputs, media_type filterType) const { BMediaRoster* r = BMediaRoster::Roster(); status_t err; int32 count; int32 bufferInc = 16; int32 inputBufferSize = 16; media_input* inputBuffer = new media_input[inputBufferSize]; while(true) { err = r->GetConnectedInputsFor( m_info.node, inputBuffer, inputBufferSize, &count); if(err < B_OK) return err; if(count == inputBufferSize) { // buffer too small; increase & try again inputBufferSize += bufferInc; delete [] inputBuffer; inputBuffer = new media_input[inputBufferSize]; continue; } if(count) // copy found inputs matching the given type into vector remove_copy_if(inputBuffer, inputBuffer + count, back_inserter(ioInputs), not1(match_endpoint_type<media_input>(filterType))); break; } // fix missing node info _fixInputs(ioInputs); delete [] inputBuffer; return B_OK; }
void MediaAddonServer::_DestroyInstantiatedFlavors(AddOnInfo& info) { printf("MediaAddonServer::_DestroyInstantiatedFlavors addon %ld\n", info.id); NodeVector::iterator iterator = info.active_flavors.begin(); for (; iterator != info.active_flavors.end(); iterator++) { media_node& node = *iterator; printf("node %ld\n", node.node); if ((node.kind & B_TIME_SOURCE) != 0 && (fMediaRoster->StopTimeSource(node, 0, true) != B_OK)) { printf("MediaAddonServer::_DestroyInstantiatedFlavors couldn't stop " "timesource\n"); continue; } if (fMediaRoster->StopNode(node, 0, true) != B_OK) { printf("MediaAddonServer::_DestroyInstantiatedFlavors couldn't stop " "node\n"); continue; } if ((node.kind & B_BUFFER_CONSUMER) != 0) { media_input inputs[16]; int32 count = 0; if (fMediaRoster->GetConnectedInputsFor(node, inputs, 16, &count) != B_OK) { printf("MediaAddonServer::_DestroyInstantiatedFlavors couldn't " "get connected inputs\n"); continue; } for (int32 i = 0; i < count; i++) { media_node_id sourceNode; if ((sourceNode = fMediaRoster->NodeIDFor( inputs[i].source.port)) < 0) { printf("MediaAddonServer::_DestroyInstantiatedFlavors " "couldn't get source node id\n"); continue; } if (fMediaRoster->Disconnect(sourceNode, inputs[i].source, node.node, inputs[i].destination) != B_OK) { printf("MediaAddonServer::_DestroyInstantiatedFlavors " "couldn't disconnect input\n"); continue; } } } if ((node.kind & B_BUFFER_PRODUCER) != 0) { media_output outputs[16]; int32 count = 0; if (fMediaRoster->GetConnectedOutputsFor(node, outputs, 16, &count) != B_OK) { printf("MediaAddonServer::_DestroyInstantiatedFlavors couldn't " "get connected outputs\n"); continue; } for (int32 i = 0; i < count; i++) { media_node_id destNode; if ((destNode = fMediaRoster->NodeIDFor( outputs[i].destination.port)) < 0) { printf("MediaAddonServer::_DestroyInstantiatedFlavors " "couldn't get destination node id\n"); continue; } if (fMediaRoster->Disconnect(node.node, outputs[i].source, destNode, outputs[i].destination) != B_OK) { printf("MediaAddonServer::_DestroyInstantiatedFlavors " "couldn't disconnect output\n"); continue; } } } MediaRosterEx(fMediaRoster)->ReleaseNodeAll(node); } info.active_flavors.clear(); }
void MediaIcon::_getMediaTypesFor(const live_node_info &nodeInfo, bool *audioIn, bool *audioOut, bool *videoIn, bool *videoOut) { D_INTERNAL(("MediaIcon::_getMediaTypeFor(live_node_info)\n")); // get the media_types supported by this node const int32 numberOfInputs = 4; int32 numberOfFreeInputs, numberOfConnectedInputs; media_input inputs[numberOfInputs]; const int32 numberOfOutputs = 4; int32 numberOfFreeOutputs, numberOfConnectedOutputs; media_output outputs[numberOfOutputs]; BMediaRoster *roster = BMediaRoster::CurrentRoster(); if (roster->GetFreeInputsFor(nodeInfo.node, inputs, numberOfInputs, &numberOfFreeInputs) == B_OK) { for (int32 i = 0; i < numberOfFreeInputs; i++) { if ((inputs[i].format.type == B_MEDIA_RAW_AUDIO) || (inputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) { *audioIn = true; continue; } if ((inputs[i].format.type == B_MEDIA_RAW_VIDEO) || (inputs[i].format.type == B_MEDIA_ENCODED_VIDEO)) { *videoIn = true; } } } if (roster->GetConnectedInputsFor(nodeInfo.node, inputs, numberOfInputs, &numberOfConnectedInputs) == B_OK) { for (int32 i = 0; i < numberOfConnectedInputs; i++) { if ((inputs[i].format.type == B_MEDIA_RAW_AUDIO) || (inputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) { *audioIn = true; continue; } if ((inputs[i].format.type == B_MEDIA_RAW_VIDEO) || (inputs[i].format.type == B_MEDIA_ENCODED_VIDEO)) { *videoIn = true; } } } if (roster->GetFreeOutputsFor(nodeInfo.node, outputs, numberOfOutputs, &numberOfFreeOutputs) == B_OK) { for (int32 i = 0; i < numberOfFreeOutputs; i++) { if ((outputs[i].format.type == B_MEDIA_RAW_AUDIO) || (outputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) { *audioOut = true; continue; } if ((outputs[i].format.type == B_MEDIA_RAW_VIDEO) || (outputs[i].format.type == B_MEDIA_ENCODED_VIDEO)) { *videoOut = true; } } } if (roster->GetConnectedOutputsFor(nodeInfo.node, outputs, numberOfOutputs, &numberOfConnectedOutputs) == B_OK) { for (int32 i = 0; i < numberOfConnectedOutputs; i++) { if ((outputs[i].format.type == B_MEDIA_RAW_AUDIO) || (outputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) { *audioOut = true; continue; } if ((outputs[i].format.type == B_MEDIA_RAW_VIDEO) || (outputs[i].format.type == B_MEDIA_ENCODED_VIDEO)) { *videoOut = true; } } } }