/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *  
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *  
 * This file is part of NMM. 
 * 
 * NMM is free software; you can redistribute it and/or modify it    
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; only version 2 of the License.      
 * 
 * NMM 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 General Public 
 * License for more details.  
 * 
 * You should have received a copy of the GNU General Public License 
 * along with NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#ifndef _NMM_PNGWRITENODE_HPP_
#define _NMM_PNGWRITENODE_HPP_ _NMM_PNGWRITENODE_HPP_

#include "nmm/nmm_prefix.hpp"

#include "nmm/multimedia/GenericSinkNode.hpp"
#include "nmm/plugins/file/interfaces/ISinkFileHandlerImpl.hpp"
#include "nmm/plugins/file/interfaces/IFileModeHandlerImpl.hpp"
#include "IPNGWriteImpl.hpp"
#include "nmm/utils/png/PNGUtils.hpp"

#include "visibility.hpp"
namespace NMM {

  class DLLEXPORT PNGWriteNode : public GenericSinkNode,
		       public ISinkFileHandlerImpl,
		       public IFileModeHandlerImpl,
		       public IPNGWriteImpl{

  private:
    PNGUtils png_utils;
    unsigned int image_width;  ///< width of the image in the input stream
    unsigned int image_height; ///< height of the image in the input stream
    unsigned int buf_count;
    string filename;
    string workdir;
    string fileext;
    const string deffileext; ///< Default file extension
    IFileModeHandler::FilenameMode filename_mode;
    Timestamp last_buf_timestamp;
    string last_filename;
    bool discardImages;
    
  protected:
    Result doInit();
    Result doActivate();
    Message* processBuffer(Buffer *);
    
    // IPNGWriteNode interface
    virtual void setDiscardImages(const nmm_bool&);

    // IFileHandler interface
    virtual void setFilename(const string&);

    // ISinkFileHandler interface
    virtual void setWorkingDirectory(const string& dir);
    virtual string getWorkingDirectory();
    virtual void setFileExtension(const string& ext);
    virtual string getFileExtension();
    
    // IFileModeHandler interface
    virtual void setMode(const IFileModeHandler::FileMode& mode);
    virtual IFileModeHandler::FileMode getMode();
    virtual void setFormat(const IFileModeHandler::FileFormat& format);
    virtual IFileModeHandler::FileFormat getFormat();
    virtual void setFilenameMode(const IFileModeHandler::FilenameMode& mode);
    virtual IFileModeHandler::FilenameMode getFilenameMode();
    virtual void setLoop(const nmm_bool& d);
    
  public:

    PNGWriteNode(const char *name = "PNGWriteNode",
		StreamQueue::Mode = StreamQueue::MODE_SUSPEND,
		int = StreamQueue::DEFAULT_SIZE);
    ~PNGWriteNode();

  };

}

#include "nmm/nmm_suffix.hpp"

#endif //_NMM_PNGWRITENODE_HPP_
