BMediaRoster

Derived from: BLooper

Declared in: be/media/MediaRoster.h

Library: libmedia.so

Allocation: Constructor only

[method summary]

The BMediaRoster class comprises the functionality that applications that use the Media Kit can access.

An application can only have a single instance of the BMediaRoster class, which is accessed by calling the static member function BMediaRoster::Roster(), which creates the media roster, establishes the connection to the Media Server, then returns a pointer to the roster.

The creation of the roster object is thread protected, so you can safely call BMediaRoster::Roster() from multiple threads without synchronization, and both threads will safely get the same instance. The cost of this synchronization is low enough that there's no need to cache the returned pointer, but it's perfectly safe to do so if you wish:

   BMediaRoster *gMediaRoster;
   
   int main(void) {
      status_t err;
   
      BApplication app("application/x-vnd.me-myself");
      gMediaRoster = BMediaRoster::Roster(&err);
   
      if (!gMediaRoster || (err != B_OK)) {
         /* the Media Server appears to be dead -- handle that here */
      }
   
      /* The Media Server connection is in place -- enjoy! */
   
      return 0;
   }

Because BMediaRoster is derived from BLooper, you should create your BApplication before calling BMediaRoster::Roster(), although the BApplication doesn't have to be running yet.

You should never delete the BMediaRoster returned to you by BMediaRoster::Roster(). Also, you can't derive a class from BMediaRoster.

If you want to receive notifications from the Media Server when specific changes occur, such as nodes coming online or going offline, for example, you can register to receive such notifications by calling StartWatching().


Playing Media from Disk

To play a media file from disk, you would follow the following steps:

Let's look at actual sample code that does this:

<<<insert sample code here>>>

If you want to play audio, you may find it much easier to use the BSound and BSoundPlayer classes to do so.


Constructor and Destructor


BMediaRoster()

      BMediaRoster() 

You never construct a BMediaRoster yourself. Instead, use the static Roster() function to obtain an instance of the BMediaRoster class that you can use.


~BMediaRoster

      ~BMediaRoster() 

You never delete a BMediaRoster yourself. Just let it go away automatically when your application shuts down.


Member Functions


Connect(), Disconnect()

      status_t Connect(const media_source &source,
         const media_destination &destination,
         media_format *ioFormat,
         media_output *outOutput,
         media_input *outInput)
      status_t Disconnect(media_node_id sourceNode,
         const media_source &source,
         media_node_id destinationNode,
         const media_destination &destination)

Connect() negotiates a connection from the source to the destination, using the media format specified in ioFormat as a basis for the negotiation; ioFormat is changed to the negotiated format before this call returns.

The actual connection is returned as an output and an input in outOutput and outInput. These two structures contain the data format as interpreted by the source and destination. There may be differences among these formats if wildcard fields were used in the original format.

The actual media_source and media_destination used for the connection may vary from those passed into Connect() if the source or the destination creates new sources or destinations for each connection request; the outOutput and outInput structures contain the actual media_source and media_destination values resulting from the call.

For more detailed information on the use of wildcards in format negotiation, see media_audio_format::wildcard and media_video_format::wildcard. A media_format with a type of B_MEDIA_UNKNOWN_TYPE matches any media class and format, although without specific knowledge of the source and destination, this will rarely result in a useful connection.

Disconnect() breaks the connection established between source and destination, which must belong to the nodes sourceNode and destinationNode, repectively.

The result of breaking a connection that's currently running is undefined, but is not permitted to crash.

RETURN CODES

B_OK. No error terminating the connection.

B_NAME_NOT_FOUND. The connection couldn't be made.


GetAudioInput(), GetVideoInput()

      status_t GetAudioInput(media_node *outNode)
      status_t GetVideoInput(media_node *outNode)

These functions return the nodes designated by the user as the preferred nodes for audio and video input. You can then query the returned node, hook into it, and manipulate it, using the reference returned in outNode.

RETURN CODES

B_OK. No error locating the default input node.

B_NAME_NOT_FOUND. The default node couldn't be identified.


GetAudioMixer() see GetAudioOutput()


GetAudioOutput(), GetVideoOutput(), GetAudioMixer()

      status_t GetAudioOutput(media_node *outNode)
      status_t GetVideoOutput(media_node *outNode)
      status_t GetAudioMixer(media_node *outNode)

These functions return the nodes designated by the user as the preferred nodes for audio and video output. You can then query the returned node, hook into it, and manipulate it, using the reference returned in outNode.

You should usually use GetAudioMixer() when getting a node for playing audio instead of using the GetAudioOutput() function. GetAudioOutput() returns the lower-level node for audio output, which you would typically only need access to if you wanted to do some form of processing on all audio data being played in the system (such as a level meter).

The GetAudioMixer() function returns a reference to the audio mixer, which will perform audio mixing, format conversion, and sample rate conversion for you, then pass along the audio to the output node.

In BeOS Release 4, the system audio mixer only supports stereo output. If you want to do multi-channel output, you can call GetAudioOutput() and ask the card if it supports multiple channels. However, be ware that it's inappropriate to Disconnect() the system mixer from the AudioOutput().

RETURN CODES

B_OK. No error locating the default input node.

B_NAME_NOT_FOUND. The default node couldn't be identified.


GetConnectedInputsFor(), GetFreeInputsFor()

      status_t GetConnectedInputsFor(const media_node &node,
         media_input *outActiveInputsList,
         int32 numListInputs
         int32 *outNumInputs)
      status_t GetFreeInputsFor(const media_node &node,
         media_input *outFreeInputsList,
         int32 numListInputs
         int32 *outNumInputs,
         media_type filterType = B_MEDIA_UNKNOWN_TYPE)

GetConnectedInputsFor() fills the array of media_input structures specified by outActiveInputsList with information about all inputs belonging to node that are currently connected to some output; the number of elements that outActiveInputsList can hold is passed in numListInputs.

Similarly, GetFreeInputsFor() fills the array outFreeInputsList with information about all inputs that are still available in the specified node. Specifying a filterType other than B_MEDIA_NO_TYPE lets you obtain a list of inputs for a specific media type (or for inputs that can handle any media type). This is especially useful if you're only interested in a list of accepted media types your application supports.

Even though a node may report that a specific number of free inputs are available, it is possible that a node might create more inputs on demand. There is no way to know if this might happen, so GetFreeInputsFor() may not tell you whether or not a node can accept all the connections you'd like to make.

Both functions return the number of elements actually returned in the buffer in outNumInputs. If this number is less than numListInputs, your buffer was too small to receive all the results of the query. In this case, you might want to resize your array and try again.

RETURN CODES

B_OK. No error cloning the node.

B_NAME_NOT_FOUND. The requested node couldn't be cloned.


GetConnectedOutputsFor(), GetFreeOutputsFor()

      status_t GetConnectedOutputsFor(const media_node &node,
         media_output *outActiveOutputsList,
         int32 numListOutputs
         int32 *outNumOutputs)
      status_t GetFreeOutputsFor(const media_node &node,
         media_output *outFreeOutputsList,
         int32 numListOutputs
         int32 *outNumOutputs,
         media_type filterType = B_MEDIA_UNKNOWN_TYPE)

GetConnectedOutputsFor() fills the array of media_output structures specified by outActiveOutputsList with information about all outputs belonging to node that are currently connected to some input; the number of elements that outActiveOutputsList can hold is passed in numListOutputs.

Similarly, GetFreeOutputsFor() fills the array outFreeOutputsList with information about all outputs that are still available in the specified node. Specifying a filterType other than B_MEDIA_UNKNOWN_TYPE lets you obtain a list of outputs for a specific media type (or for outputs that can handle any media type). This is especially useful if you're only interested in a list of accepted media types your application supports.

Even though a node may report that a specific number of free outputs are available, it is possible that a node might create more outputs on demand. There is no way to know if this might happen, so GetFreeOutputsFor() may not tell you whether or not a node can accept all the connections you'd like to make.

Both functions return the number of elements actually returned in the buffer in outNumOutputs. If this number is less than numListOutputs, your buffer was too small to receive all the results of the query. In this case, you might want to resize your array and try again.

RETURN CODES

B_OK. No error.

B_MEDIA_BAD_NODE. The node isn't a buffer producer.

Other errors. An error occurred communicating with the producer or with the Media Server.


GetDormantNodes()

      status_t GetDormantNodes(dormant_node_info *outDormantNodeList,
         int32 *inOutNumNodes,
         const media_format *hasInputFormat = NULL,
         const media_format *hasOutputFormat = NULL,
         char *name = NULL,
         uint64 requireKinds = 0,
         uint64 denyKinds = 0)

Queries dormant nodes (those nodes that live in add-ons, rather than in the application) and returns those who match the specified inputs. If hasInputFormat isn't NULL, the node has to be a BBufferConsumer and have an input format compatible with the format described in hasInputFormat. Likewise, if hasOutputFormat isn't NULL, the node has to be a BBufferProducer that's compatible with the format described in hasOutputFormat.

If name isn't NULL, the node has to have a name that equals name, or, if the last character of name is an asterisk ("*"), a name whose initial characters match name up to, but not including, the asterisk.

The requireKinds and denyKinds arguments specifiy, respectively, the kinds that must be supported, and the kinds that must not be supported by the returned nodes.

Matching nodes are returned in outDormantNodeList. You should pass the size of the outDormantNodeList array (the number of elements that the array can hold) in inOutNumNodes; when this function returns, the value in inOutNumNodes will be changed to the actual number of matching nodes found, unless an error occurs.

RETURN CODES

B_OK. No error cloning the node.

B_NAME_NOT_FOUND. The requested node couldn't be cloned.


GetFileFormatsFor()

      status_t GetFileFormatsFor(const media_node &fileInterface,
         media_file_format *outFormatList,
         int32 *inOutFormatCount)

Given a BFileInterface node in fileInterface, returns information about the file formats the file interface can deal with in the array outFormatList. On entry, inOutFormatCount points to the number of media_file_format structures that can fit in the array specified by outFormatList. Upon return, it will contain the actual number of formats returned, unless GetFileFormatsFor() returns an error.

RETURN CODES

B_OK. No error sending the set mode request.

B_NAME_NOT_FOUND. The requested node couldn't be cloned.


GetFreeInputsFor() see GetConnectedInputsFor()


GetFreeOutputsFor() see GetConnectedOutputsFor()


GetLatencyFor()

      status_t GetLatencyFor(const media_node &producer, bigtime_t *outLatency)

Reports in outLatency the maximum latency found downstream from the specified BBufferProducer, producer, given the current connections.

If an error occurs, the value in outLatency is unreliable.

RETURN CODES

B_OK. No errors.

Other errors. Unable to get the latency.


GetLiveNodes()

      status_t GetLiveNodes(live_node_info *outLiveNodeList, int32 *ioTotalCount,
         const media_format *hasInput = NULL,
         const media_format *hasOutput = NULL,
         const char *name = NULL,
         uint64 nodeKinds = 0)

Queries the Media Server for a list of all currently active nodes (whether they're running or not), and fills the array specified by outLiveNodeList with information about the nodes. The size of the array should be specified--in terms of how many elements it can contain--by the ioTotalCount argument; the actual number of entries in the returned list will be stored in ioTotalCount before the call returns.

You can obtain a more specific result list by specifying one or more of the hasInput, hasOutput, name, and nodeKinds arguments. hasInput and hasOutput let you restrict the resulting list to containing nodes that accept as input (or output) the specified format.

You should always specify 0 for nodeKinds; this parameter is currently not used.

RETURN CODES

B_OK. No errors.

Other errors. Unable to get the list of live nodes.


GetNodeFor()

      status_t GetNodeFor(media_node_id nodeID, media_node *clonedNode)

Given a node specified by node_id, GetNodeFor() returns in clonedNode a media_node reference to a clone of the node. You can then use the clonedNode to query the node for available inputs, outputs, and so forth.

This is the call you use to get a media_node to use for playing back and recording data.plication developer.

RETURN CODES

B_OK. No error cloning the node.

BMessage errors. The requested node couldn't be cloned.


GetParameterWebFor()

      status_t GetParameterWebFor(const media_node & node,
         BParameterWeb **outWeb)

Instantiates a BParameterWeb that describes the internal layout of a specific controllable node and stores a pointer to the BParameterWeb in outWeb. You can then walk the various BParameters within the web to figure out what there is to control, and to present a user interface to the node's parameters. Delete the web pointed to by outWeb when you're done with it.

RETURN CODES

B_OK. No error obtaining the BParameterWeb.

B_MEDIA_BAD_NODE. The requested node is invalid.


GetSystemTimeSource()

      status_t GetSystemTimeSource(media_node *clonedTimeSource)

This function returns, in clonedTimeSource, a reference to a clone of the system time source. The system time source is the fallback time source used when no other source is available; its time is derived from the system_time() real-time clock. As such, it's quite accurate, but has no relevant relationship to the timing of the hardware devices being used for media input and output. Thus it's not a good choice for a master clock--but it's there if nothing else is available.

RETURN CODES

B_OK. No error cloning the node.

B_NAME_NOT_FOUND. The time source couldn't be cloned.


GetTimeSource()

      status_t GetTimeSource(media_node *outNode)

Returns, in outNode, the preferred master clock to which other nodes are slaved. By slaving all nodes to a single master clock, good synchronization can be ensured.

Typically, the preferred master clock will be the same node as the default audio output (assuming that the audio output node is also a BTimeSource, which should be the case). The sound circuitry's DAC is then used as a timing reference. Although this may be less accurate than the system clock (as defined by the global system_time() function), glitch-free audio performance is best ensured by using the audio output to synchronize media operations.

The time source's reference count isn't incremented by this function. You should never call ReleaseNode() on a node returned by GetTimeSource().

RETURN CODES

B_OK. No error locating the default input node.

B_NAME_NOT_FOUND. The default node couldn't be identified.


GetVideoInput() see GetAudioInput()


GetVideoOutput() see GetAudioOutput()


InstantiateDormantNode()

      status_t InstantiateDormantNode(const dormant_node_info &inInfo,
         media_node *outNode)

Instantiates a node from an add-on, given the information specified in the dormant_node_info structure:

   struct dormant_node_info {
      dormant_node_info();
      ~dormant_node_info();
   
      media_addon_id addon;
      int32 flavor_id;
      char name[B_MEDIA_NAME_LENGTH];
   
   private:
      char reserved[128];
   };

The addon field should be filled out to contain the add-on ID of the add-on from which the node should be instantiated, and the flavor_id should be the flavor ID number the node should be instantiated to process. Typically you'll use a function such as GetDormantNodes() to find a dormant_node_info structure that describes a suitable node.

RETURN CODES

B_OK. No error instantiating the node.

B_NAME_NOT_FOUND. The requested node couldn't be instantiated.


MediaFlags()

      static ssize_t MediaFlags(media_flags flag, void *buffer, size_t bufferSize)

Asks the Media Server about its support for specific features and capabilities.

The specified buffer will be filled with the data indicating the value of the specified flag. If the buffer is too small (as indicated by bufferSize), only the first bufferSize bytes of the result data will be stored in the buffer, but no error will occur.

Constant Description
B_MEDIA_FLAGS_VERSION Returns the Media Kit version as an int32 value.

If the result is negative, an error occurred, or the Media Server isn't running.


PrerollNode()

      status_t PrerollNode(const media_node &node)

Calling PrerollNode() sends a preroll message to the specified node; the node's Preroll() hook function will be called. When that hook returns, PrerollNode() will also return. A node that's been prerolled should respond very quickly to a StartNode() call, because the time-consuming setup operations should have been done already by the Preroll() hook.

While it's not mandatory for an application to call PrerollNode() before calling StartNode(), it's recommended, because doing so may improve real-time performance once the node is started.

RETURN CODES

B_OK. No error sending the set mode request.

B_NAME_NOT_FOUND. The requested node couldn't be cloned.


RefFor() see SetRefFor()


RegisterNode(), UnregisterNode()

      status_t RegisterNode(BMediaNode *node)
      status_t UnregisterNode(BMediaNode *node)

RegisterNode() registers an object of a class derived from BMediaNode with the Media Server and assigns it a node_id. This function should be called once a BMediaNode-derived object is fully-constructed and before any attempt is made to connect the node to some other participant in the Media Server.

RegisterNode() is called automatically for nodes instantiated from add-ons, but your application will have to call it for any nodes it creates itself.

If you create your own subclass of BMediaNode, its constructor can call RegisterNode() itself just before returning (it must be the last thing the constructor does).

UnregisterNode() unregisters a node from the Media Server. It's called automatically by the BMediaNode destructor, but it might be convenient to call it sometime before you delete your node instance, depending on your implementation and circumstances.

These functions are generally only used if you're creating your own node class.

RETURN CODES

B_OK. No error sending the seek request.

B_BAD_VALUE. Invalid BMediaNode specified.


ReleaseNode()

      status_t ReleaseNode(const media_node &node)

Releases the specified node, which has previously been obtained by using the GetNodeFor() function.

RETURN CODES

B_OK. No error releasing the node.

BMessage errors. The node couldn't be released.


Roster()

      static BMediaRoster *Roster(status_t *outError = NULL)

Returns a pointer to the default BMediaRoster instance, or creates the BMediaRoster instance if it doesn't exist yet, then returns a pointer to it.

This static member function should be called by explicit scope, and never by dereference; this is how you get the BMediaRoster through which all other media roster functions are called. For example:

   BMediaRoster *r = BMediaRoster::Roster();
   status_t err = r->GetFreeOutputsFor(some_node, some_array, 3, &n);

On return, outError is set to B_OK if the default BMediaRoster was successfully returned, or a negative error code if something went wrong (for example, if the Media Server isn't running). If outError is NULL, no error code is returned.

In any case, Roster() returns NULL if an error occurs.


SeekNode()

      status_t SeekNode(const media_node &node, bigtime_t newTime,
         bigtime_t atTime = 0)

Sends the specified node a request that it change its playing location to the performance time newTime once the time atTime is reached.

If node refers to a BTimeSource, the performance time output by that BTimeSource will skip suddenly to the newTime (once atTime is reached), and all nodes slaved to that time source will receive TimeWarp messages so they can keep up with the change.

If the node isn't running, the seek request is processed immediately, and the atTime argument is ignored.

The error returned by this function only indicates whether or not the request was sent successfully; the node may later run into problems trying to perform the seek operation.

RETURN CODES

B_OK. No error sending the seek request.

B_NAME_NOT_FOUND. The requested node couldn't be cloned.


SetAudioInput(), SetVideoInput()

      status_t SetAudioInput(const media_node &defaultNode)
      status_t SetVideoInput(const media_node &defaultNode)

These functions set the preferred nodes for audio and video input. If the specified node isn't capable of being the system default, an error will be returned (for example, nodes defined by an application can't be the system default--only nodes defined by Media Kit add-ons can be system defaults).

In general, you shouldn't call these functions unless you're writing software that reimplements the functionality of the BeOS Media preference panels.

RETURN CODES

B_OK. No error setting the default input node.

B_NAME_NOT_FOUND. The default node couldn't be changed.


SetAudioOutput(), SetVideoOutput()

      status_t SetAudioOutput(const media_node &defaultNode)
      status_t SetVideoOutput(const media_node &defaultNode)

These functions set the preferred nodes for audio and video output. If the specified node isn't capable of being the system default, an error will be returned (for example, nodes defined by an application can't be the system default--only nodes defined by Media Kit add-ons can be system defaults).

In general, you shouldn't call these functions unless you're writing software that reimplements the functionality of the BeOS Media preference panels.

RETURN CODES

B_OK. No error setting the default input node.

B_NAME_NOT_FOUND. The default node couldn't be changed.


SetOutputBuffersFor()

      status_t SetOutputBuffersFor(const media_source &output,
         BBufferGroup *group,
         bool willReclaim = false)

Tells the specified output node to use the buffers specified by group for all data sent through that output. If willReclaim is false, the Media Kit will dispose of the group for you; you can forget about it once this call returns. Otherwise, you're informing the Media Server that you want the group back, and that you'll delete it when you're done with it.

The ability to request that certain buffers be used by a particular output can save you from having to perform unnecessary copies; you might be able to use BBuffers that represent a graphics card frame buffer, for example, so that a video producer's output goes directly to video memory.

RETURN CODES

B_OK. No error.

BMessage errors. Unable to set the output buffers.


SetProducerRate()

      status_t SetProducerRate(const media_node &node,
         int32 numerator, int32 demominator)

This function is called to tell the producer to resample the data rate by the specified factor. Specifying a value of 1 (ie, numerator/denominator = 1) indicates that the data should be output at the same playback rate that it comes into the node at. The format of the data should be unchanged.

Nodes are not required to support this mechanism for controlling their data rate, so this call may have no effect.

RETURN CODES

B_OK. No error.

Other errors. Returned by BBufferProducer::SetPlayRate().

See also: BBufferProducer::SetPlayRate()


SetRefFor(), RefFor()

      status_t SetRefFor(const media_node &fileInterface,
         entry_ref &file,
         bool createAndTruncate,
         bigtime_t *outDuration)
      status_t RefFor(const media_node &fileInterface,
         entry_ref *outFile,
         BMimeType *outMimeType = NULL)

SetRefFor() tells the BFileInterface fileInterface to work on the file whose entry_ref is specified by file. If createAndTruncate is true, any previous file with that reference is deleted and the file will be prepared for new output. If createAndTruncate is false, outDuration will, on return, contain the duration of the performance data found in the file.

RefFor() fills out the specified entry_ref, outFile, to reference the file with which the specified fileInterface node is working. If outMimeType isn't NULL, it'll contain a BMimeType object describing the file's type, unless an error occurs.

RETURN CODES

B_OK. No error.

B_MEDIA_BAD_NODE. The specified node doesn't exist, or isn't a file interface.


SetRunModeNode()

      status_t SetRunModeNode(const media_node &node,
         BMediaNode::run_mode newMode)

Sends the specified node a request that it change its policy for handling situations where it falls behind during real-time processing.

The error returned by this function only indicates whether or not the request was sent successfully.

RETURN CODES

B_OK. No error sending the set mode request.

B_BAD_NODE. The specified node is invalid.


SetTimeSourceFor()

      status_t SetTimeSourceFor(media_node_id node,
         media_node_id timeSource)

Tells the specified node to slave its timing to timeSource. Once this is done, the node will receive its notion of the passage of time from timeSource. As such, it will pause whenever timeSource is stopped, and so forth.

By default, nodes are slaved to the system time source, so you only need to call this function if you need to slave a node to a different time source.

The node will take whatever precautions are necessary to remain faithful to the notion of time presented by timeSource without causing glitches in the presentation of its media. For example, if a sound card node has a DAC that drifts from timeSource, it might try to fix the problem by varying the sampling rate slightly, or by dropping or doubling buffers occasionally. This is why you should usually use the default time source as your master time source--because this will usually be derived directly from the DAC being used to produce the media output.

RETURN CODES

B_OK. No error.

BMessage errors. Unable to set the time source.


SetVideoInput() see SetAudioInput()


SetVideoOutput() see SetAudioOutput()


SniffRef(), SniffRefFor()

      status_t SniffRef(const entry_ref &file,
         uint64 requireNodeKinds,
         dormant_node_info *outNode,
         BMimeType outMimeType = NULL)
      status_t SniffRefFor(const media_node &fileInterface,
         const entry_ref &file,
         BMimeType outMimeType,
         float *outCapability)

SniffRef() asks all BMediaAddOn instances that satisfy the requireNodeKinds restraint to identify the file. The requireNodeKinds argument should contain flags composited from the node_kind constants.

The node that returns the greatest outCapability value will be chosen, and a reference to it put in outNode. The MIME type of the file will be put into outMimeType.

In simpler terms: SniffRef() returns the node that can best handle the media data in the specified file.

SniffRefFor(), on the other hand, asks the specified fileInterface node to examine the file. If the node recognizes the file, the MIME type of the file is stored in the buffer outMimeType, and the node's capability to handle the file is returned in outCapability.

If the node doesn't recognize the file, an error is returned. If the node recognizes the file format but finds no recognizable data within the file, outCapability is set to 0.0 and no error is returned.

In either case, the higher the outCapability value returned, the more appropriate the node is for handling the media data in the file.

RETURN CODES

B_OK. No error sending the set mode request.

B_MEDIA_BAD_NODE. The specified node is invalid, or isn't a file interface.


SniffRefFor() see SniffRef()


StartControlPanel()

      status_t StartControlPanel(const media_node node,
         BMessenger *outMessenger = NULL)

Tells the specified node to start its custom control panel, which is started outside your application. There's no way to tell when the user has closed the control panel, other than by indirectly detecting possible changes to the node, such as a renegotiation of the format of data being output by the node.

If a BMessenger is provided as input to StartControlPanel(), the function returns in outMessenger a BMessneger that can be used to communicate with the control panel.

RETURN CODES

B_OK. No error starting the control panel.

B_MEDIA_BAD_NODE. The specified node is invalid.


StartNode(), StopNode()

      status_t StartNode(const media_node &node, bigtime_t atTime)
      status_t StopNode(const media_node &node, bigtime_t atTime)

StartNode() sends the specified node a request to start streaming data at the performance time specified by the startTime argument, according to that node's time source.

By default, nodes are in a stopped state upon creation, so you have to call StartNode() once you have a reference to it before anything will happen. Starting a node that's already running has no effect.

If node refers to a BTimeSource, that time source will unfreeze, and all nodes that have been started that are slaved to that time source will resume progressing.

StopNode() sends node a request to stop streaming data once the specified performance time stopTime is reached, according to that node's time source. Stopping a node that's already stopped has no effect.

In either case, the requested change will occur at the time specified by atTime.

If node refers to a BTimeSource, stopping it will freeze that time source, and all nodes slaved to it will stop progressing, even if they're not individually stopped. However, it may reduce processor overhead to also individually stop each node manually after stopping their time source.

BTimeSources count startTime and stopTime in BTimeSource::RealTime() units, not in performance time units.

The error returned by these functions only indicates whether or not the request was sent successfully; the node may later run into problems trying to start or stop its media and you won't know it based on the result of these functions.

RETURN CODES

B_OK. No error sending the start or stop request.

B_NAME_NOT_FOUND. The requested node couldn't be cloned.


StartWatching(), StopWatching()

      status_t StartWatching(const BMessenger &notifyHandler)
      status_t StopWatching(const BMessenger &notifyHandler)

StartWatching() registers the specified BHandler or BLooper as a recipient of notification messages from the Media Server. StopWatching() cancels this registration so that no further notifications will be sent.

Events are sent to registered BHandlers and BLoopers when certain events happen, such as nodes being created or deleted, or connections being made or broken.

See Notification Message "what" Codes for a list of the notifications you can receive.

Although the Media Server will automatically cancel notifications to BHandlers and BLoopers that go away without explicitly calling StopWatching(), this detection is expensive and may briefly interrupt the media system, so you should always call StopWatching() before allowing a BHandler or BLooper to go away.

RETURN CODES

B_OK. No error cloning the node.

B_NAME_NOT_FOUND. The requested node couldn't be cloned.


StopNode() see StartNode()


StopWatching() see StartWatching()






The Be Book, in lovely HTML, for BeOS Release 4.

Copyright © 1998 Be, Inc. All rights reserved.

Last modified December 11, 1998.