/*
 * (c) 2005 Research Group Dr. Fuhrmann, University of Karlsruhe, Germany
 * All rights reserved.
 *
 * Author:
 *         Stefan Denk <denk@ira.uka.de>
 *         Kendy Kutzner <kutzner@ira.uka.de>
 *
 * $Id: videosources.h,v 1.6 2006/01/05 10:31:45 denk Exp $
 *
 */

#ifndef _VIDEOSOURCES_H_
#define _VIDEOSOURCES_H_

#include <map>
using namespace std;
#include "aggr_dest.h"
#include "vtmsg.h"
#include "videosource.h"

/** All video sources we know.
 * Our data store of our own and foreign video blocks.
 */

class cvideosources {
	private:
		/** Defines the type of the internal representation.
		 * This definition makes iterating over all sources somewhat easier.
		 */
		typedef map<aggr_dest, sourcelist_t> hash_t;
		/// All video sources we know.
		hash_t _sources;
	public:
		/// A pointer to a string to a transport address. This address is set by our instanciator vtmain. Hopefully.
		string * _transport;
		/// Throw out all old sources.
		bool cleanup(time_t video_source_max_age);
		/// Create the list. Remember a pointer to our own tcp-address
		cvideosources(string * transport):_transport(transport){
		};
		/// Kill ourself
		~cvideosources();
		/// Add all video sources from a message.
		void add(vtmsg*m);
		/// Add all video sources from a vdrrecordings.
	///	void add(cvideosource &vs, aggr_dest &ag);
		// Add a specific block.
		void add(const aggr_dest & ad, const hashes_t & hashes);
		/// Retrieve the next piece of information which should be published.
		bool next2publish(aggr_dest *d, sourcelist_t *l);
		/// Check whether we have sources for this aggregation destination
		bool have (aggr_dest *);
		/// Retrieve a source
		sourcelist_t get(aggr_dest *d);
		/// list all video sources present
		void cvideosources::list();
};


#endif // _VIDEOSOURCES_H_
