/*
 * Copyright (c) 2002, Peter Bentley
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 *   Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 *   Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 *   The name Peter Bentley may not be used to endorse or promote
 * products derived from this software without specific prior
 * written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * $Id: netmd_cmd.h,v 1.14 2003/04/08 19:14:47 pete Exp $
 *
 * ** netmd.h - send actual netmd commands to the unit 
 */


/*
 * Command buffer - subject to change 
 */
typedef struct {
    unsigned int	size;	/* Number of bytes allocated */
    unsigned int	used;	/* Number of bytes actually used */
    uint8		*buffer;
} netmd_cmd_buf_t;



/* Functions to allocate or free a buffer */
netmd_cmd_buf_t *netmd_alloc_buffer( unsigned int size );
int netmd_free_buffer( netmd_cmd_buf_t *buffer );

/* Build up a command buffer from arguments */
int netmd_build_command( netmd_cmd_buf_t *cmdbuf, const char *fmt, ... );

/* Send a command to the unit */
int netmd_send_command( omd_unit_t *unit, netmd_cmd_buf_t *sndbuf,
			netmd_cmd_buf_t *rcvbuf );

/* Command to get unit status - Buffer must be at least 7 bytes long */
int netmd_unit_status( omd_unit_t *unit, uint8 *buffer, int bufsize );

/* Command to get playback status A - Buffer must be at least 12 bytes long */
int netmd_playback_status_a( omd_unit_t *unit, uint8 *buffer, int bufsize );

/* Command to get playback status B - Buffer must be at least 6 bytes long */
int netmd_playback_status_b( omd_unit_t *unit, uint8 *buffer, int bufsize );

/* Command to get playback position - Buffer must be at least 11 bytes long */
int netmd_get_playback_position( omd_unit_t *unit, uint8 *buffer, int bufsize);

/* Set playback position etc */
int netmd_set_playback_track( omd_unit_t *unit, uint16 track );
int netmd_set_playback_position( omd_unit_t *unit, uint16 track, uint32 pos);


/* Unit playback controls */
int netmd_start_playback( omd_unit_t *unit );
int netmd_stop_playback( omd_unit_t *unit );
int netmd_pause_playback( omd_unit_t *unit );
int netmd_start_rewind( omd_unit_t *unit );
int netmd_start_fforward( omd_unit_t *unit );

/* Disc initialise */
int netmd_disc_init( omd_unit_t *unit );

/* TOC cache control (INCORRECT!) */
int netmd_toc_sync( omd_unit_t *unit );
int netmd_toc_cache( omd_unit_t *unit );

/* Disc info commands */
int netmd_disc_flags( omd_unit_t *unit, uint8 *flagbuf );
int netmd_track_count( omd_unit_t *unit, uint8 *countbuf, int bufsize );
int netmd_disc_capacity( omd_unit_t *unit, uint8 *countbuf, int bufsize );
int netmd_disc_get_title( omd_unit_t *unit, uint8 *buffer, int bufsize );

/* Track info functions */
int netmd_track_get_title( omd_unit_t *unit, int track,uint8 *buf,int bufsize);
int netmd_track_get_length( omd_unit_t *unit, int track, uint8 *buf, int size);
int netmd_track_get_bitrate( omd_unit_t *unit, int track, uint8 *buf,int size);
int netmd_track_get_flags( omd_unit_t *unit, int track, uint8 *buf);

/* Rename track */
int netmd_track_set_title( omd_unit_t *unit, int track, int oldlen,
			   const char *title );
/* Move track */
int netmd_track_move( omd_unit_t *unit, int src, int dst );

/* Delete track */
int netmd_track_delete( omd_unit_t *unit, int track );

/* set disk/group title string */
int netmd_disc_set_title( omd_unit_t *unit, int oldlen, const char *title );

/* Low level send */
netmd_cmd_buf_t *netmd_simple_command( omd_unit_t *unit, int max,
				       const char *fmt, ... );


