/**
 * Tracker object for continuous streams
 * <p>Use this tracker if you have live streams.</p>
 * @ignore
 * @markdown
<p>Example:</p>
        // enable debug output
        econda.debug.setEnabled(true);
    
        // get tracker object and set some properties in constructor
        var tracker = new econda.media.StreamTracker({
            stream: {
                name: "SatTV Regional",
                type: "video"
            }
        });
        
        // initialize it
        tracker.init();
        
        // track "start playback"
        tracker.setState("playing");
        
        // send a custom event
        tracker.sendEvent({
            type: "buffering",
            value: "6"            // number of seconds the user had to wait
        });
        
        // user clicked "stop video" button
        tracker.setState("stopped");

 * @class econda.media.StreamTracker 
 * @param {Object/String/econda.media.StreamTracker} cfg
 */
econda.media.StreamTracker = function(cfg)
{
    var __p = {
        /**
         * @cfg {econda.media.Stream} stream
         * Stream information
         */
        stream: null,
        
        /**
         * @cfg {String} [state="uninitialized"]
         * Current state, one of "uninitialized", "initialized", "started", "paused", "stopped"
         */
        state: 'uninitialized',
        
        /**
         * @cfg {Number} bandwidth Bandwidth in kbit
         * Bandwidth we use
         */
        bandwidth: null,
        
        /**
         * @cfg {String} format
         * Technical format (mpg, h.264, ..)
         * There are no predefined values, it's free formed text 
         */
        format: null
    };
    
    /**
     * Initialize tracker. 
     * @method
     */
    this.init = function()
    {
        return this;
    };
    
    /**
     * Set info about current stream
     * @method
     * @param {econda.media.Stream} stream
     */
    this.setStream = function(stream)
    {
        __p["stream"] = new econda.media.Stream(stream);
        return this;
    };
    
    /**
     * Get current stream info
     * @method
     * @return {econda.media.Stream}
     */
    this.getStream = function()
    {
        return __p["stream"];
    };
    
    /**
     * Set current player state
     * @method
     * @param {String} state
     */
    this.setState = function(state)
    {
        econda.debug.log("Sending state changed event to tracking server. New state: " + state, this);

        // currently not supported by tracking server
        econda.debug.log("Request skipped, function currently not supported by tracking server.");
        return this;
    };
    
    /**
     * Get current state
     * @method
     * @return {String}
     */
    this.getState = function()
    {
        return __p["state"];
    };
    
    /**
     * Set user bandwidth
     * @method
     * @param {Number} kbit
     */
    this.setBandwidth = function(kbit)
    {
        __p["bandwidth"] = kbit;
        return this;
    };
    
    /**
     * Get current bandwidth as set in tracker
     * @method
     * @return {Number}
     */
    this.getBandwidth = function()
    {
        return __p["bandwidth"];
    };
    
    /**
     * Set technical video format
     * @method
     * @param {String} format
     */
    this.setFormat = function(format)
    {
        __p["format"] = format;
        return this;
    };
    
    /**
     * Get format identifier as set in tracker object
     * @method
     * @return {String}
     */
    this.getFormat = function()
    {
        return __p["format"];
    };
    
    /**
     * Sends an event to tracking server. Used e.g. to log problems during playback.
     * <p>Examples:</p>
     *     // event typas ar free form text - send event with type "crash"
     *     tracker.sendEvent("crash");
     *     
     *     // let's add some more info, e.g. number of seconds the user had to wait
     *     tracker.sendEvent({
     *         type: "buffering",
     *         value: "4"
     *     });
     * @method
     * @param {econda.media.Event/Object/String} event event data
     */
    this.sendEvent = function(event)
    {
        // currently not supported by tracking server
        return this;
    }
    
    return this.setup(cfg, __p);
};
econda.media.StreamTracker.prototype = new econda.base.Object();