/*
    GDAM - Geoff & Dave's Audio Mixer
    Copyright (C) 1999    Dave Benson, Geoff Matters.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

    Contact:
        daveb@ffem.org <Dave Benson>
        geoff@ugcs.caltech.edu <Geoff Matters>
*/
#ifndef __GDAM_PRODUCER_H_
#define __GDAM_PRODUCER_H_

#include "gdammodel.h"


GtkType gdam_producer_get_type();
#define GDAM_TYPE_PRODUCER              (gdam_producer_get_type ())
#define GDAM_PRODUCER(obj)              (GTK_CHECK_CAST ((obj), GDAM_TYPE_PRODUCER, GdamProducer))
#define GDAM_PRODUCER_CLASS(klass)      (GTK_CHECK_CLASS_CAST ((klass), GDAM_TYPE_PRODUCER, GdamProducerClass))
#define GDAM_IS_PRODUCER(obj)           (GTK_CHECK_TYPE ((obj), GDAM_TYPE_PRODUCER))
#define GDAM_IS_PRODUCER_CLASS(klass)   (GTK_CHECK_CLASS_TYPE ((klass), GDAM_TYPE_PRODUCER))


typedef struct _GdamProducerClass GdamProducerClass;
typedef struct _GdamProducer GdamProducer;

struct _GdamProducerClass {
	GdamModelClass		base;


	int            (*play_request)    (GdamProducer*	producer,
					   GdamPlayInfo*	play_info,
					   int                  subsource_id,
					   GdamRequestBuilder*  builder);
	void           (*stop_request)    (GdamProducer*	producer,
					   GdamRequestBuilder*  builder);
	/*void         (*play)            (GdamProducer*	producer,
					   GdamPlayInfo*	play_info);
	void           (*stop)            (GdamProducer*);*/
	void           (*stopped)         (GdamProducer*        producer,
	                                   gdouble              stopped_pos);
	void           (*seek)     (GdamProducer* 	producer,
	                                   gdouble       	time,
					   int           	whence);
	void	       (*set_position)
					  (GdamProducer* 	producer,
					   gdouble	 	new_pos);
	void	       (*update_length) 
					  (GdamProducer* 	producer,
					   gdouble	 	new_length);
	void	       (*source_ended) 
					  (GdamProducer* 	producer,
					   gdouble	 	end_position);
};

struct _GdamProducer {
	GdamModel		model;

	/* Used to indicate the position when there is no active
	 * subsource (in that case it is a moving target that you
	 * must query with  */
	gdouble                 stopped_position;
	gboolean		making_stop_request;
	guint 			eof_sub_id;
	/* Optional: if the source which should be tracked for position
	 * is not model->source_id, set this */
	int			position_source_id;

};

void       gdam_producer_play         (GdamProducer*       producer,
				       GdamPlayInfo*       play_info);


/* Uses stopped position. */
void       gdam_producer_play_now     (GdamProducer*       producer);

void       gdam_producer_stop         (GdamProducer*       producer);

int        gdam_producer_play_request (GdamProducer*       producer,
				       GdamPlayInfo*       play_info,
				       int                 subsource_id,
				       GdamRequestBuilder* builder);
void       gdam_producer_stop_request (GdamProducer*       producer,
				       GdamRequestBuilder* builder);

void       gdam_producer_seek         (GdamProducer*       producer,
	                               gdouble             time,
				       int                 whence);
void       gdam_producer_set_position (GdamProducer*       producer,
	                               gdouble             position);
void       gdam_producer_source_ended (GdamProducer*       producer,
	                               gdouble             position);
void       gdam_producer_update_length(GdamProducer*       producer,
	                               gdouble             length);
#endif
