2007-09-02 18:48:22 +02:00
|
|
|
/*
|
|
|
|
|
Struct(Asset) - key abstraction: structural asset
|
|
|
|
|
|
|
|
|
|
Copyright (C) CinelerraCV
|
2007-11-27 03:19:35 +01:00
|
|
|
2007, Hermann Vosseler <Ichthyostega@web.de>
|
2007-09-02 18:48:22 +02:00
|
|
|
|
|
|
|
|
This program 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; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program 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 this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
* *****************************************************/
|
|
|
|
|
|
|
|
|
|
|
2007-09-16 03:02:05 +02:00
|
|
|
#include "proc/assetmanager.hpp"
|
2007-09-02 18:48:22 +02:00
|
|
|
#include "proc/asset/struct.hpp"
|
2008-01-14 01:01:11 +01:00
|
|
|
#include "proc/asset/procpatt.hpp"
|
|
|
|
|
#include "proc/asset/track.hpp"
|
2008-01-27 23:40:45 +01:00
|
|
|
#include "proc/asset/port.hpp"
|
2008-01-14 01:01:11 +01:00
|
|
|
#include "proc/mobject/session.hpp"
|
2008-01-07 18:16:03 +01:00
|
|
|
|
2008-01-18 16:43:53 +01:00
|
|
|
#include "common/query.hpp"
|
2007-09-16 03:02:05 +02:00
|
|
|
#include "common/util.hpp"
|
|
|
|
|
#include "nobugcfg.h"
|
2007-09-02 18:48:22 +02:00
|
|
|
|
2008-01-14 01:01:11 +01:00
|
|
|
using mobject::Session;
|
2008-01-18 16:43:53 +01:00
|
|
|
using cinelerra::query::normalizeID;
|
2008-01-14 01:01:11 +01:00
|
|
|
|
2007-09-02 18:48:22 +02:00
|
|
|
namespace asset
|
|
|
|
|
{
|
2007-09-16 03:02:05 +02:00
|
|
|
|
2008-01-27 23:40:45 +01:00
|
|
|
/****** NOTE: not implemented yet. What follows is a hack to build simple tests *******/
|
|
|
|
|
|
|
|
|
|
|
2008-01-12 18:19:37 +01:00
|
|
|
namespace // common Struct Asset implementation details
|
|
|
|
|
{
|
|
|
|
|
/** @internal derive a sensible asset ident tuple when creating
|
|
|
|
|
* a track asset based on a query
|
|
|
|
|
* @todo define the actual naming scheme of struct assets
|
|
|
|
|
*/
|
|
|
|
|
const Asset::Ident
|
2008-01-14 01:01:11 +01:00
|
|
|
createTrackIdent (const Query<Track>& query)
|
2008-01-12 18:19:37 +01:00
|
|
|
{
|
|
|
|
|
string name ("track-" + query); // TODO something sensible here; append number, sanitize etc.
|
|
|
|
|
TODO ("track naming scheme??");
|
|
|
|
|
Category category (STRUCT,"tracks");
|
|
|
|
|
return Asset::Ident (name, category );
|
|
|
|
|
}
|
2008-01-27 23:40:45 +01:00
|
|
|
|
|
|
|
|
typedef std::pair<string,string> PortIDs;
|
|
|
|
|
|
|
|
|
|
PortIDs
|
|
|
|
|
createPortIdent (const Query<Port>& query)
|
|
|
|
|
{
|
|
|
|
|
string name ("port-" + query); // TODO get some more sensible dummy values
|
|
|
|
|
TODO ("port naming scheme??");
|
|
|
|
|
return PortIDs (name, "mpeg"); // dummy stream type
|
|
|
|
|
}
|
2008-01-12 18:19:37 +01:00
|
|
|
}
|
2007-09-16 03:02:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StructFactory Struct::create; ///< storage for the static StructFactory instance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Factory method for Structural Asset instances. ....
|
2008-01-07 18:16:03 +01:00
|
|
|
* @todo work out the struct asset naming scheme!
|
2007-09-16 03:02:05 +02:00
|
|
|
* @return an Struct smart ptr linked to the internally registered smart ptr
|
|
|
|
|
* created as a side effect of calling the concrete Struct subclass ctor.
|
|
|
|
|
*/
|
2008-01-07 18:16:03 +01:00
|
|
|
template<>
|
|
|
|
|
shared_ptr<Track>
|
2008-01-14 01:01:11 +01:00
|
|
|
StructFactory::operator() (const Query<Track>& query)
|
2007-09-16 03:02:05 +02:00
|
|
|
{
|
2008-01-07 18:16:03 +01:00
|
|
|
TODO ("actually evaluate the query...");
|
|
|
|
|
Track* pT = new Track (createTrackIdent (query));
|
2008-01-14 01:01:11 +01:00
|
|
|
return AssetManager::instance().wrap (*pT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-01-27 23:40:45 +01:00
|
|
|
/** Similar instance for Port Query....
|
|
|
|
|
* @todo better a generic implementation utilizing ConfigQuery....
|
|
|
|
|
*/
|
|
|
|
|
template<>
|
|
|
|
|
shared_ptr<Port>
|
|
|
|
|
StructFactory::operator() (const Query<Port>& query)
|
|
|
|
|
{
|
|
|
|
|
TODO ("actually evaluate the query...");
|
|
|
|
|
PortIDs ids (createPortIdent (query));
|
|
|
|
|
return operator() (ids.first, ids.second);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-01-14 01:01:11 +01:00
|
|
|
/** Factory method for creating Ports explicitly.
|
|
|
|
|
* Normalizes port- and streamID, then retrieves the
|
|
|
|
|
* default processing pattern (ProcPatt) for this streamID.
|
|
|
|
|
* The Port ctor will fill out the shortDesc and longDesc
|
|
|
|
|
* automatically, based on portID and streamID (and they
|
|
|
|
|
* are editable anyways)
|
|
|
|
|
* @see ProcPatt
|
|
|
|
|
* @see DefaultsManager
|
|
|
|
|
*/
|
|
|
|
|
shared_ptr<Port>
|
|
|
|
|
StructFactory::operator() (string portID, string streamID)
|
|
|
|
|
{
|
2008-01-18 16:43:53 +01:00
|
|
|
normalizeID (portID);
|
|
|
|
|
normalizeID (streamID);
|
2008-01-14 01:01:11 +01:00
|
|
|
PProcPatt processingPattern = Session::current->defaults (Query<ProcPatt>("stream("+streamID+")"));
|
|
|
|
|
Port* pP = new Port (processingPattern, portID);
|
|
|
|
|
return AssetManager::instance().wrap (*pP);
|
2007-09-16 03:02:05 +02:00
|
|
|
}
|
2007-09-02 18:48:22 +02:00
|
|
|
|
|
|
|
|
|
2008-01-14 01:01:11 +01:00
|
|
|
|
2007-09-02 18:48:22 +02:00
|
|
|
} // namespace asset
|