Protected Member Functions | List of all members
BFileInterface Class Referenceabstract

A node that can read and write data to a file on disk. More...

Inherits BMediaNode.

Protected Member Functions

 BFileInterface ()
 Constructor.
 
virtual ~BFileInterface ()
 Destructor.
 
virtual void DisposeFileFormatCookie (int32 cookie)=0
 Implement this method to dispose of a file format supported by your node indexed by cookie. More...
 
virtual status_t GetDuration (bigtime_t *_time)=0
 Implement this method to fill out the duration in microseconds of the media data contained in the currently referenced file in _time. More...
 
virtual status_t GetNextFileFormat (int32 *cookie, media_file_format *_format)=0
 Implement this method to fill out information about a file format indexed by cookie. More...
 
virtual status_t GetRef (entry_ref *_ref, char *_mimeType)=0
 Implement to set the entry_ref and the MIME type of the file referenced by the current node. More...
 
virtual status_t HandleMessage (int32 message, const void *data, size_t size)
 Dispatches a message to the appropriate BMediaNode hook method given a message received on the control port. Implement this method to handle messages that arrive on your control port. More...
 
virtual status_t SetRef (const entry_ref &file, bool create, bigtime_t *_time)=0
 Used when an application wants your node to use a specific file. More...
 
virtual status_t SniffRef (const entry_ref &file, char *_mimeType, float *_quality)=0
 Implement this method to allow the Media Roster to identify a file format associated with this node. More...
 

Detailed Description

A node that can read and write data to a file on disk.

You should derive your subclass from BFileInterface so that your application may specify the file that the node will reference. The Media Server will then call upon the node to try to identify and work with files that are hereunto unknown to it.

Your node must also derive from BBufferConsumer or BBufferProducer, in addition to BFileInterface.

Member Function Documentation

◆ DisposeFileFormatCookie()

void BFileInterface::DisposeFileFormatCookie ( int32  cookie)
protectedpure virtual

Implement this method to dispose of a file format supported by your node indexed by cookie.

You are responsible for freeing any data blocks associated with this cookie before returning.

Parameters
cookieIndex of the cookie you wish to dispose of.

◆ GetDuration()

status_t BFileInterface::GetDuration ( bigtime_t _time)
protectedpure virtual

Implement this method to fill out the duration in microseconds of the media data contained in the currently referenced file in _time.

Parameters
_timeThe duration parameter to fill out.
Returns
A status code, typically B_OK on success and B_ERROR or another error code on error.

◆ GetNextFileFormat()

status_t BFileInterface::GetNextFileFormat ( int32 *  cookie,
media_file_format *  _format 
)
protectedpure virtual

Implement this method to fill out information about a file format indexed by cookie.

The first time this method is called cookie will be set to 0. In your implementation you should set information about the first file format you support in _format and set cookie to some meaningful non-zero value to track your positing in the list of supported formats, then return B_OK.

On successive calls return successive file format information and update cookie to track your position in the list. Each time you return new information about a file format return B_OK.

Once you run out of formats return B_ERROR.

Parameters
cookieIndex of file format to fill out.
_formatPointer to a preallocated media_file_format object to fill out.
Returns
B_OK if a file format was filled out for cookie, B_ERROR or an appropriate error code otherwise.

◆ GetRef()

status_t BFileInterface::GetRef ( entry_ref _ref,
char *  _mimeType 
)
protectedpure virtual

Implement to set the entry_ref and the MIME type of the file referenced by the current node.

Parameters
_refSet to the entry_ref of the file.
_mimeTypeSet to the MIME type of the current file.
Returns
B_OK on success or an appropriate error code such as B_ERROR on error.

◆ HandleMessage()

status_t BFileInterface::HandleMessage ( int32  message,
const void *  data,
size_t  size 
)
protectedvirtual

Dispatches a message to the appropriate BMediaNode hook method given a message received on the control port. Implement this method to handle messages that arrive on your control port.

Parameters
messageThe message identifier.
dataThe message data.
sizeThe size of the message data in bytes.
Returns
A status code.
Return values
B_OKMessage was dispatched.
B_ERRORThere was an error dispatching the message, possibly because it doesn't correspond to a hook function.
See also
BMediaNode::HandleMessage() for details.

Reimplemented from BMediaNode.

◆ SetRef()

status_t BFileInterface::SetRef ( const entry_ref file,
bool  create,
bigtime_t _time 
)
protectedpure virtual

Used when an application wants your node to use a specific file.

The file specified by file may or may not exist.

If create is false you should try to open the existing file, and if successful you should write the running time of the file into _time. If you the file does not exist you should return B_ENTRY_NOT_FOUND.

If create is true you should create a new file, initialize the file for writing, and store 0 in _time. You should overwrite the file if it already exists.

Returns
B_OK on success or an appropriate error code such as B_ERROR or B_ENTRY_NOT_FOUND on error.

◆ SniffRef()

status_t BFileInterface::SniffRef ( const entry_ref file,
char *  _mimeType,
float *  _quality 
)
protectedpure virtual

Implement this method to allow the Media Roster to identify a file format associated with this node.

If you can handle the format, set _mimeType to the MIME type of the file format and set _quality to indicate how well you can process the file.

A _quality of 0.0 means that you can't handle the file format at all and an _quality of 1.0 means you have total control over the file format.

Parameters
fileThe file being sniffed.
_mimeTypeFill this out with the appropriate MIME type.
_qualityHow well you are able to handle the file format from 0.0 to 1.0.
Returns
B_OK if you can identify the file's contents, otherwise return an appropriate error code. If you can't handle the file format at all, you should return B_MEDIA_NO_HANDLER.