00001 00032 #include "llmediaimplfactory.h" 00033 00034 #include <iostream> 00035 00036 LLMediaImplFactory* LLMediaImplFactory::sInstance = NULL; 00037 00039 // static 00040 LLMediaImplFactory* LLMediaImplFactory::getInstance() 00041 { 00042 if ( ! sInstance ) 00043 sInstance = new LLMediaImplFactory(); 00044 00045 return sInstance; 00046 } 00047 00049 // 00050 void LLMediaImplFactory::registerImpl( const std::string& impl_name, LLMediaImplMakerBase* impl_maker ) 00051 { 00052 mNameImplMakerContainer.insert( name_impl_maker_container_t::value_type( impl_name, impl_maker ) ); 00053 } 00054 00056 // 00057 LLMediaImplMakerBase* LLMediaImplFactory::getImplMaker( const std::string& scheme, const std::string& type ) 00058 { 00059 name_impl_maker_container_t::const_iterator iter; 00060 name_impl_maker_container_t::const_iterator begin = mNameImplMakerContainer.begin(); 00061 name_impl_maker_container_t::const_iterator end = mNameImplMakerContainer.end(); 00062 00063 for(iter = begin; iter != end; ++iter) 00064 { 00065 if(( *iter->second ).supportsScheme(scheme)) 00066 { 00067 return ( iter->second ); 00068 } 00069 } 00070 00071 for(iter = begin; iter != end; ++iter) 00072 { 00073 if(( *iter->second ).supportsMimeType(type)) 00074 { 00075 return ( iter->second ); 00076 } 00077 } 00078 int idx1 = type.find("/"); 00079 int len = (idx1 == std::string::npos) ? 0 : idx1; 00080 std::string category = type.substr(0,len); 00081 for(iter = begin; iter != end; ++iter) 00082 { 00083 if(( *iter->second ).supportsMimeTypeCategory(category)) 00084 { 00085 return ( iter->second ); 00086 } 00087 } 00088 00089 return NULL; 00090 }; 00091 00093 // 00094 LLMediaImplMakerBase* LLMediaImplFactory::getImplMaker( const std::string& impl_name ) 00095 { 00096 name_impl_maker_container_t::const_iterator found = mNameImplMakerContainer.find( impl_name ); 00097 00098 if ( found == mNameImplMakerContainer.end() ) 00099 { 00100 return NULL; 00101 }; 00102 00103 return found->second; 00104 }